From f5835d85e2ae098aacb3f585bc63bea5c9e7884f Mon Sep 17 00:00:00 2001 From: Jussi Pakkanen Date: Fri, 25 Jan 2013 21:59:53 +0200 Subject: Added comparison. --- parser.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'parser.py') diff --git a/parser.py b/parser.py index 96cf1f741..ad2e87f62 100755 --- a/parser.py +++ b/parser.py @@ -34,6 +34,8 @@ tokens = ['LPAREN', 'ATOM', 'COMMENT', 'ASSIGN', + 'EQUALS', + 'NEQUALS', 'COMMA', 'DOT', 'STRING', @@ -42,6 +44,8 @@ tokens = ['LPAREN', ] + list(reserved.values()) t_ASSIGN = '=' +t_EQUALS = '==' +t_NEQUALS = '\!=' t_LPAREN = '\(' t_RPAREN = '\)' t_LBRACKET = '\[' @@ -115,6 +119,11 @@ def p_statement_assign(t): 'statement : expression ASSIGN statement' t[0] = nodes.Assignment(t[1], t[3], t.lineno(1)) +def p_statement_equals(t): + '''statement : statement EQUALS statement + | statement NEQUALS statement''' + t[0] = nodes.Comparison(t[1], t[2], t[3], t.lineno(1)) + def p_statement_func_call(t): 'statement : expression LPAREN args RPAREN' t[0] = nodes.FunctionCall(t[1], t[3], t.lineno(1)) -- cgit v1.2.3