diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-05-09 19:52:10 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-05-09 19:52:10 +0300 |
commit | 3f7f984a3910565887fcd530ed5c7323dd16708c (patch) | |
tree | 86ace362696e31b83a83a99d389ba324892f91f3 /mparser.py | |
parent | 8be84a4a7cb3ed81ef06c9d536ec7223150c9373 (diff) | |
download | meson-3f7f984a3910565887fcd530ed5c7323dd16708c.zip meson-3f7f984a3910565887fcd530ed5c7323dd16708c.tar.gz meson-3f7f984a3910565887fcd530ed5c7323dd16708c.tar.bz2 |
Handle then unary negation operator.
Diffstat (limited to 'mparser.py')
-rw-r--r-- | mparser.py | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -41,7 +41,7 @@ class Lexer: # Need to be sorted longest to shortest. ('ignore', re.compile(r'[ \t]')), ('id', re.compile('[_a-zA-Z][_0-9a-zA-Z]*')), - ('number', re.compile(r'-?\d+')), + ('number', re.compile(r'\d+')), ('eol_cont', re.compile(r'\\\n')), ('eol', re.compile(r'\n')), ('multiline_string', re.compile(r"'''(.|\n)*?'''", re.M)), @@ -114,6 +114,7 @@ class Lexer: else: value = match_text yield Token(tid, curline, col, value) + break if not matched: raise ParseException('lexer', lineno, col) @@ -245,6 +246,12 @@ class IfClauseNode(): self.ifs = [] self.elseblock = EmptyNode() +class UMinusNode(): + def __init__(self, lineno, colno, value): + self.lineno = lineno + self.colno = colno + self.value = value + class IfNode(): def __init__(self, lineno, colno, condition, block): self.lineno = lineno @@ -392,6 +399,8 @@ class Parser: def e6(self): if self.accept('not'): return NotNode(self.current.lineno, self.current.colno, self.e7()) + if self.accept('dash'): + return UMinusNode(self.current.lineno, self.current.colno, self.e7()) return self.e7() def e7(self): |