Skip to content

Commit

Permalink
Support python-style comments as well as C-style comments
Browse files Browse the repository at this point in the history
  • Loading branch information
desplesda committed Aug 2, 2019
1 parent d3dff79 commit 453469d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tagged_document.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ def parse_lines(self, data):

assert isinstance(data, str)

begin_re = re.compile(r"\s*\/\/\s*BEGIN\s+([^\s]+)")
end_re = re.compile(r"\s*\/\/\s*END\s+([^\s]+)")
# begin_re = re.compile(r"\s*(\/\/|#)\s*BEGIN\s+([^\s]+)")
# end_re = re.compile(r"\s*(\/\/|#)\s*END\s+([^\s]+)")

begin_re = re.compile(r"\s*(\/\/|\#)\s*BEGIN\s+([^\s]+)")
end_re = re.compile(r"\s*(\/\/|\#)\s*END\s+([^\s]+)")


current_tags = []

Expand All @@ -178,7 +182,7 @@ def parse_lines(self, data):

# If we entered a tag, add it to the list
elif begin_re.search(line_text):
tag = begin_re.search(line_text).group(1)
tag = begin_re.search(line_text).group(2)

if tag in current_tags:
logging.warn("{0}:{1}: \"{2}\" was entered twice without exiting it".format(self.path, line_number, tag))
Expand All @@ -188,7 +192,7 @@ def parse_lines(self, data):

# If we left a tag, remove it
elif end_re.search(line_text):
tag = end_re.search(line_text).group(1)
tag = end_re.search(line_text).group(2)

if tag not in current_tags:
logging.warn("{0}:{1}: \"{2}\" was exited, but had not yet been entered".format(self.path, line_number, tag))
Expand Down

0 comments on commit 453469d

Please sign in to comment.