From 57cbee2f3377e079efa5b5652f6e9ea30720fa15 Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Sun, 23 Dec 2012 17:09:28 +0200 Subject: [PATCH] Detect strings and end-of-lines. --- builder.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/builder.py b/builder.py index 923b381a9..e415456f9 100755 --- a/builder.py +++ b/builder.py @@ -24,7 +24,10 @@ tokens = ['LPAREN', 'EQUALS', 'COMMA', 'DOT', - 'STRING'] + 'STRING', + 'EOL_CONTINUE', + 'EOL', + ] t_EQUALS = '=' t_LPAREN = '\(' @@ -34,8 +37,10 @@ t_COMMENT = '\#[^\n]*' t_COMMA = ',' t_DOT = '\.' t_STRING = "'[^']*'" +t_EOL_CONTINUE = r'\\\n' +t_EOL = r'\n' -t_ignore = ' \t\n' +t_ignore = ' \t' def t_error(t): print("Illegal character '%s'" % t.value[0]) @@ -44,7 +49,8 @@ def t_error(t): def test_lexer(): s = """hello = (something) # this = (that) function(h) - obj.method(lll, 'string') + obj.method(lll, \\ + 'string') """ lexer = lex.lex() lexer.input(s)