diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2012-12-25 19:12:33 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2012-12-25 19:12:33 +0200 |
commit | 5545518de1f511fff065469f5398b59e6e6f38e4 (patch) | |
tree | 0d2eb61bf4e75849bbc9c27f63845ae9f1ba917f /builder.py | |
parent | 6373bff4ff449b5810523c44d116578b2691512f (diff) | |
download | meson-5545518de1f511fff065469f5398b59e6e6f38e4.zip meson-5545518de1f511fff065469f5398b59e6e6f38e4.tar.gz meson-5545518de1f511fff065469f5398b59e6e6f38e4.tar.bz2 |
Parse slightly more.
Diffstat (limited to 'builder.py')
-rwxr-xr-x | builder.py | 18 |
1 files changed, 8 insertions, 10 deletions
@@ -80,12 +80,12 @@ def p_codeblock_last(t): def p_expression_atom(t): 'expression : ATOM' print('Atom: ' + t[1]) - pass + t[0] = t[1] def p_expression_string(t): 'expression : STRING' print('String: ' + t[1]) - pass + t[0] = t[1] def p_statement_assign(t): 'statement : expression EQUALS statement' @@ -93,13 +93,11 @@ def p_statement_assign(t): def p_statement_func_call(t): 'statement : expression LPAREN args RPAREN' - print('Function call: ' + str(t[1])) # t[1]) - pass + print('Function call: %s. Args: %s' % (str(t[1]), str(t[3]))) # t[1]) def p_statement_method_call(t): 'statement : expression DOT expression LPAREN args RPAREN' - print('Method call: ' + str(t[1])) - pass + print('Method call: %s %s. Args: %s' % (str(t[1]), str(t[3]), str(t[5]))) def p_statement_expression(t): 'statement : expression' @@ -108,11 +106,11 @@ def p_statement_expression(t): def p_args_multiple(t): 'args : statement COMMA args' - pass + t[0] = [t[1]] + t[3] def p_args_single(t): 'args : statement' - pass + t[0] = [t[1]] def p_args_none(t): 'args :' @@ -137,8 +135,8 @@ def test_lexer(): print(tok) def test_parser(): - code = """funccall('something') - method.call(abc) + code = """func_call('something', 'or else') + objectname.methodname(abc) """ lexer = lex.lex() parser = yacc.yacc() |