Skip to content

Commit

Permalink
Accept 1- and 2-digit octal sequences in string literals.
Browse files Browse the repository at this point in the history
Fixes #9.
trotterdylan authored and whitequark committed Jan 25, 2017
1 parent a82d05d commit fb7a1f8
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pythonparser/lexer.py
Original file line number Diff line number Diff line change
@@ -187,7 +187,7 @@ def __init__(self, source_buffer, version, diagnostic_engine, interactive=False)
_lex_escape_re = re.compile(r"""
\\(?:
([\n\\'"abfnrtv]) # 1 single-char
| ([0-7]{3}) # 2 oct
| ([0-7]{1,3}) # 2 oct
| x([0-9A-Fa-f]{2}) # 3 hex
)
""", re.VERBOSE)
5 changes: 5 additions & 0 deletions pythonparser/test/test_lexer.py
Original file line number Diff line number Diff line change
@@ -184,6 +184,11 @@ def test_string_literal(self):
"strdata", "\n",
"strend", None)

self.assertLexes(r"'\0 \10 \010'",
"strbegin", "",
"strdata", "\x00 \x08 \x08",
"strend", None)

self.assertDiagnoses(
"'",
[("fatal", "unterminated string", (0, 1))])

0 comments on commit fb7a1f8

Please sign in to comment.