Skip to content

Commit b58765d

Browse files
committed
workaround for big strings
1 parent d12a372 commit b58765d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sly/lex.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
import re
3737
import copy
3838

39+
40+
_strings_pattern_re = re.compile('(?P<QUOTE_STRING>(\'(?:\\\\.|[^\'])*(?:\'\'(?:\\\\.|[^\'])*)*\'))|(?P<DQUOTE_STRING>("(?:\\\\.|[^"])*"))')
41+
42+
3943
class LexError(Exception):
4044
'''
4145
Exception raised if an invalid character is encountered and no default
@@ -406,7 +410,11 @@ def _reject():
406410
tok = Token()
407411
tok.lineno = lineno
408412
tok.index = index
409-
m = _master_re.match(text, index)
413+
414+
m = _master_re.match(text, index, index + 50)
415+
if m is None:
416+
m = _strings_pattern_re.match(text, index)
417+
410418
if m:
411419
tok.end = index = m.end()
412420
tok.value = m.group()

0 commit comments

Comments
 (0)