And fix \" escapes
This commit is contained in:
parent
7b47598b9f
commit
43d1040d76
2 changed files with 6 additions and 3 deletions
|
@ -369,8 +369,8 @@ class Parser(SexpParser):
|
||||||
return "\014" # form feed
|
return "\014" # form feed
|
||||||
elif ch == 't':
|
elif ch == 't':
|
||||||
return "\t"
|
return "\t"
|
||||||
elif ch == '""':
|
elif ch == '"':
|
||||||
return '""'
|
return '"'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def parse_str(cls, f: PosTrackingBufferedReader):
|
def parse_str(cls, f: PosTrackingBufferedReader):
|
||||||
|
@ -382,10 +382,12 @@ class Parser(SexpParser):
|
||||||
while True:
|
while True:
|
||||||
if not rtb.peek():
|
if not rtb.peek():
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# Handle end of string
|
# Handle end of string
|
||||||
elif rtb.peek() == '"':
|
elif rtb.peek() == '"':
|
||||||
rtb.read()
|
rtb.read()
|
||||||
break
|
break
|
||||||
|
|
||||||
# Handle escape sequences
|
# Handle escape sequences
|
||||||
elif rtb.peek() == '\\':
|
elif rtb.peek() == '\\':
|
||||||
rtb.read() # Discard the escape leader
|
rtb.read() # Discard the escape leader
|
||||||
|
|
|
@ -135,6 +135,7 @@ def test_ambiguous_floats(txt, tokenization):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('txt,', [
|
@pytest.mark.parametrize('txt,', [
|
||||||
|
r'""',
|
||||||
r'"foo"',
|
r'"foo"',
|
||||||
r'"foo bar baz qux"',
|
r'"foo bar baz qux"',
|
||||||
r'"foo\nbar\tbaz\lqux"',
|
r'"foo\nbar\tbaz\lqux"',
|
||||||
|
@ -142,8 +143,8 @@ def test_ambiguous_floats(txt, tokenization):
|
||||||
bar
|
bar
|
||||||
baz
|
baz
|
||||||
qux"''',
|
qux"''',
|
||||||
r'""',
|
|
||||||
r'"\000 \x00"',
|
r'"\000 \x00"',
|
||||||
|
r'"\"\""',
|
||||||
])
|
])
|
||||||
def test_string(txt):
|
def test_string(txt):
|
||||||
"""Some examples of strings, and of escape sequences."""
|
"""Some examples of strings, and of escape sequences."""
|
||||||
|
|
Loading…
Reference in a new issue