diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-04-21 16:47:20 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-04-21 16:47:20 +0300 |
commit | 417abe105c3d7bfa2c4753306cf03a9ab89d1f54 (patch) | |
tree | 2a8df1c2948bbcaec9f073324546e8afeec57201 /mparser.py | |
parent | 7606b7af8c25e991c99784e7f6d95fe02bbc0d24 (diff) | |
download | meson-417abe105c3d7bfa2c4753306cf03a9ab89d1f54.zip meson-417abe105c3d7bfa2c4753306cf03a9ab89d1f54.tar.gz meson-417abe105c3d7bfa2c4753306cf03a9ab89d1f54.tar.bz2 |
Added multiline strings.
Diffstat (limited to 'mparser.py')
-rw-r--r-- | mparser.py | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -39,6 +39,7 @@ tokens = ['LPAREN', 'COMMA', 'DOT', 'STRING', + 'MULTILINE_STRING', 'INT', 'EOL_CONTINUE', 'EOL', @@ -66,6 +67,13 @@ def t_ATOM(t): t.type = reserved.get(t.value, 'ATOM') return t + +def t_MULTILINE_STRING(t): + r"'''(.|\n)*?'''" + t.value = t.value[3:-3] + t.lexer.lineno += t.value.count('\n') + return t + def t_STRING(t): "'[^']*'" t.value = t.value[1:-1] @@ -127,6 +135,10 @@ def p_expression_string(t): 'expression : STRING' t[0] = nodes.StringExpression(t[1], t.lineno(1)) +def p_expression_multiline_string(t): + 'expression : MULTILINE_STRING' + t[0] = nodes.StringExpression(t[1], t.lineno(1)) + def p_statement_assign(t): 'statement : expression ASSIGN statement' t[0] = nodes.Assignment(t[1], t[3], t[1].lineno()) |