aboutsummaryrefslogtreecommitdiff
path: root/parser.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-01-25 21:25:52 +0200
committerJussi Pakkanen <jpakkane@gmail.com>2013-01-25 21:25:52 +0200
commit81fbb83f84cd7c1180d4c9d16f6e48eb8961c4ad (patch)
tree79f447dd18d636117d4b9b189ac12375472d622f /parser.py
parent88bd40ecf3f58414bbc2dd1ea924e90d3885116c (diff)
downloadmeson-81fbb83f84cd7c1180d4c9d16f6e48eb8961c4ad.zip
meson-81fbb83f84cd7c1180d4c9d16f6e48eb8961c4ad.tar.gz
meson-81fbb83f84cd7c1180d4c9d16f6e48eb8961c4ad.tar.bz2
Added else block support.
Diffstat (limited to 'parser.py')
-rwxr-xr-xparser.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/parser.py b/parser.py
index ac6c8e5..1c00ab8 100755
--- a/parser.py
+++ b/parser.py
@@ -21,7 +21,9 @@ import nodes
reserved = {'true' : 'TRUE',
'false' : 'FALSE',
'if' : 'IF',
- 'endif' : 'ENDIF'}
+ 'endif' : 'ENDIF',
+ 'else' : 'ELSE',
+ }
tokens = ['LPAREN',
'RPAREN',
@@ -122,8 +124,16 @@ def p_statement_method_call(t):
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))
+ 'statement : IF LPAREN statement RPAREN EOL codeblock elseblock ENDIF'
+ t[0] = nodes.IfStatement(t[3], t[6], t[7], t.lineno(1))
+
+def p_empty_else(t):
+ 'elseblock : '
+ return None
+
+def p_else(t):
+ 'elseblock : ELSE EOL codeblock'
+ t[0] = t[3]
def p_statement_expression(t):
'statement : expression'