aboutsummaryrefslogtreecommitdiff
path: root/mparser.py
diff options
context:
space:
mode:
authorJussi Pakkanen <jpakkane@gmail.com>2013-07-27 17:06:37 +0300
committerJussi Pakkanen <jpakkane@gmail.com>2013-07-27 17:06:37 +0300
commit6a5a9a384842870f9a54ffeb3a828e57eafdec08 (patch)
tree3c6347502cad39283048a11fe54419465f7da196 /mparser.py
parente990291c34aa976c12c88e3b26b45e7ac07b0ef2 (diff)
downloadmeson-6a5a9a384842870f9a54ffeb3a828e57eafdec08.zip
meson-6a5a9a384842870f9a54ffeb3a828e57eafdec08.tar.gz
meson-6a5a9a384842870f9a54ffeb3a828e57eafdec08.tar.bz2
Can do logical and.
Diffstat (limited to 'mparser.py')
-rw-r--r--mparser.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/mparser.py b/mparser.py
index 0b5ed30..5a28ccc 100644
--- a/mparser.py
+++ b/mparser.py
@@ -27,6 +27,9 @@ reserved = {'true' : 'TRUE',
'if' : 'IF',
'endif' : 'ENDIF',
'else' : 'ELSE',
+ 'and' : 'AND',
+ 'or' : 'OR',
+ 'not' : 'NOT',
}
tokens = ['LPAREN',
@@ -62,6 +65,16 @@ t_COLON = ':'
t_ignore = ' \t'
+precedence = (
+('left', 'COMMA'),
+('left', 'ASSIGN'),
+('nonassoc', 'EQUALS', 'NEQUALS'),
+('left', 'OR'),
+('left', 'AND'),
+('nonassoc', 'COLON')
+('left', 'DOT'),
+)
+
def t_ATOM(t):
'[a-zA-Z][_0-9a-zA-Z]*'
t.type = reserved.get(t.value, 'ATOM')
@@ -175,6 +188,14 @@ def p_statement_if(t):
'statement : IF statement EOL codeblock elseblock ENDIF'
t[0] = nodes.IfStatement(t[2], t[4], t[5], t.lineno(1))
+def p_statement_parentheses(t):
+ 'statement : LPAREN statement RPAREN'
+ t[0] = t[2]
+
+def p_statement_and(t):
+ 'statement : statement AND statement'
+ t[0] = nodes.AndStatement(t[1], t[3])
+
def p_empty_else(t):
'elseblock : '
return None