And fix \" escapes

This commit is contained in:
Reid 'arrdem' McKenzie 2020-07-18 15:37:49 -06:00
parent 7b47598b9f
commit 43d1040d76
2 changed files with 6 additions and 3 deletions

View file

@ -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

View file

@ -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."""