Skip to content

Commit f06a83a

Browse files
committed
Better error for literal with bad escaping (Issue #287)
1 parent 5697820 commit f06a83a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lark/load_grammar.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,10 @@ def _fix_escaping(s):
351351
for n in i:
352352
w += n
353353
if n == '\\':
354-
n2 = next(i)
354+
try:
355+
n2 = next(i)
356+
except StopIteration:
357+
raise ValueError("Literal ended unexpectedly (bad escaping): `%r`" % s)
355358
if n2 == '\\':
356359
w += '\\\\'
357360
elif n2 not in 'uxnftr':

0 commit comments

Comments
 (0)