diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-07-27 17:06:37 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-07-27 17:06:37 +0300 |
commit | 6a5a9a384842870f9a54ffeb3a828e57eafdec08 (patch) | |
tree | 3c6347502cad39283048a11fe54419465f7da196 /mparser.py | |
parent | e990291c34aa976c12c88e3b26b45e7ac07b0ef2 (diff) | |
download | meson-6a5a9a384842870f9a54ffeb3a828e57eafdec08.zip meson-6a5a9a384842870f9a54ffeb3a828e57eafdec08.tar.gz meson-6a5a9a384842870f9a54ffeb3a828e57eafdec08.tar.bz2 |
Can do logical and.
Diffstat (limited to 'mparser.py')
-rw-r--r-- | mparser.py | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -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 |