diff options
author | Bryan Bishop <kanzure@gmail.com> | 2012-04-26 11:02:17 -0500 |
---|---|---|
committer | Bryan Bishop <kanzure@gmail.com> | 2012-04-26 11:02:17 -0500 |
commit | 6e083c9b3ae767d6a3c8eddef96faf3f68b0c578 (patch) | |
tree | 3a0d6ea7ceb92d120bb2173e3ea4b4dd6d065135 /textpre.py | |
parent | d358b39024588daba6e206578ccfd5f49475ded2 (diff) |
only strip comments when a semicolon appears on the line
Diffstat (limited to 'textpre.py')
-rw-r--r-- | textpre.py | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/textpre.py b/textpre.py index 58412d8ed..dc8312650 100644 --- a/textpre.py +++ b/textpre.py @@ -271,28 +271,32 @@ for l in sys.stdin: sys.stdout.write(l) continue - # strip comments asm = "" - comment = None - in_quotes = False - in_comment = False - for letter in l: - if in_comment: - comment += letter - elif in_quotes and letter != "\"": - asm += letter - elif in_quotes and letter == "\"": - in_quotes = False - asm += letter - elif not in_quotes and letter == "\"": - in_quotes = True - asm += letter - elif not in_quotes and letter != "\"": - if letter == ";": - in_comment = True - comment = ";" - else: + + # strip comments + comment = None + if ";" in l: + in_quotes = False + in_comment = False + for letter in l: + if in_comment: + comment += letter + elif in_quotes and letter != "\"": asm += letter + elif in_quotes and letter == "\"": + in_quotes = False + asm += letter + elif not in_quotes and letter == "\"": + in_quotes = True + asm += letter + elif not in_quotes and letter != "\"": + if letter == ";": + in_comment = True + comment = ";" + else: + asm += letter + else: + asm = l # skip asm with no quotes if "\"" not in asm: |