aboutsummaryrefslogtreecommitdiff
path: root/parser.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-01-25 21:06:08 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2013-01-25 21:06:08 +0200
commit88bd40ecf3f58414bbc2dd1ea924e90d3885116c (patch)
tree6ebac917be52975399cdce8909de8dc95fa9b42c /parser.py
parentbd6e542f1c5be82ce24eb9374423747fa7b27a29 (diff)
downloadmeson-88bd40ecf3f58414bbc2dd1ea924e90d3885116c.zip
meson-88bd40ecf3f58414bbc2dd1ea924e90d3885116c.tar.gz
meson-88bd40ecf3f58414bbc2dd1ea924e90d3885116c.tar.bz2
Added if clause.
Diffstat (limited to 'parser.py')
-rwxr-xr-xparser.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/parser.py b/parser.py
index a6af003..ac6c8e5 100755
--- a/parser.py
+++ b/parser.py
@@ -19,7 +19,9 @@ import ply.yacc as yacc
import nodes
reserved = {'true' : 'TRUE',
- 'false' : 'FALSE'}
+ 'false' : 'FALSE',
+ 'if' : 'IF',
+ 'endif' : 'ENDIF'}
tokens = ['LPAREN',
'RPAREN',
@@ -119,6 +121,10 @@ def p_statement_method_call(t):
'statement : expression DOT expression LPAREN args RPAREN'
t[0] = nodes.MethodCall(t[1], t[3], t[5], t.lineno(1))
+def p_statement_if(t):
+ 'statement : IF LPAREN statement RPAREN EOL codeblock ENDIF'
+ t[0] = nodes.IfStatement(t[3], t[6], t.lineno(1))
+
def p_statement_expression(t):
'statement : expression'
t[0] = nodes.statement_from_expression(t[1])