preprocessor: minor optimization in separate_comment

This commit is contained in:
yenatch 2013-05-15 01:51:58 -04:00
parent a6fee3622a
commit ffd562351b
1 changed files with 8 additions and 15 deletions

View File

@ -314,25 +314,18 @@ def separate_comment(l):
asm = ""
comment = None
in_quotes = False
in_comment = False
# token either belongs to the line or to the comment
for token in l:
if in_comment:
if comment:
comment += token
elif in_quotes and token != "\"":
asm += token
elif in_quotes and token == "\"":
in_quotes = False
asm += token
elif not in_quotes and token == "\"":
in_quotes = True
asm += token
elif not in_quotes and token != "\"":
if token == ";":
in_comment = True
comment = ";"
else:
if not in_quotes:
if token == ";":
comment = ";"
continue
if token == "\"":
in_quotes = not in_quotes
asm += token
return asm, comment