Skip to content

Commit

Permalink
Added newline detection to BARE_EXPRESSION symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
dekarrin committed May 4, 2018
1 parent f426017 commit 6eb5545
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions scrappy/parse/scp_lex.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,20 @@ def t_STRING(t):
return t

t_NUMBER = r"(?:(?:\+|-)\s*)?\d+(\.\d*)?"
t_PYTHON_BLOCK = r"\([Pp][Yy][Tt][Hh][Oo][Nn]\)\s*\{[^}\\]*(?:\\.[^}\\]*)*\}"

def t_PYTHON_BLOCK(t):
r"\([Pp][Yy][Tt][Hh][Oo][Nn]\)\s*\{[^}\\]*(?:\\.[^}\\]*)*\}"
num_linebreaks = len(t.value.splitlines()) - 1
t.lexer.lineno += num_linebreaks
return t

# master regex uses a capturing group, so group in this regex is really #2:
t_BARE_EXPRESSION = r"'[^'\\]*(?:\\.[^'\\]*)*'"
def t_BARE_EXPRESSION(t):
r"'[^'\\]*(?:\\.[^'\\]*)*'"
num_linebreaks = len(t.value.splitlines()) - 1
t.lexer.lineno += num_linebreaks
return t

t_COMMENT = r"\#.*"

t_ANY_ignore = ' \t'
Expand Down

0 comments on commit 6eb5545

Please sign in to comment.