diff --git a/src/python/flowmetal/parser.py b/src/python/flowmetal/parser.py index 291d008..6c06661 100644 --- a/src/python/flowmetal/parser.py +++ b/src/python/flowmetal/parser.py @@ -369,8 +369,8 @@ class Parser(SexpParser): return "\014" # form feed elif ch == 't': return "\t" - elif ch == '""': - return '""' + elif ch == '"': + return '"' @classmethod def parse_str(cls, f: PosTrackingBufferedReader): @@ -382,10 +382,12 @@ class Parser(SexpParser): while True: if not rtb.peek(): raise + # Handle end of string elif rtb.peek() == '"': rtb.read() break + # Handle escape sequences elif rtb.peek() == '\\': rtb.read() # Discard the escape leader diff --git a/test/python/flowmetal/test_parser.py b/test/python/flowmetal/test_parser.py index 5de274f..e4ffd29 100644 --- a/test/python/flowmetal/test_parser.py +++ b/test/python/flowmetal/test_parser.py @@ -135,6 +135,7 @@ def test_ambiguous_floats(txt, tokenization): @pytest.mark.parametrize('txt,', [ + r'""', r'"foo"', r'"foo bar baz qux"', r'"foo\nbar\tbaz\lqux"', @@ -142,8 +143,8 @@ def test_ambiguous_floats(txt, tokenization): bar baz qux"''', - r'""', r'"\000 \x00"', + r'"\"\""', ]) def test_string(txt): """Some examples of strings, and of escape sequences."""