Mercurial > hg > expressionparser
diff expr.py @ 15:6f0c032b65f5 default tip
add a not token, i hope!
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Fri, 03 Jun 2011 13:01:22 -0700 |
parents | ec0e83ec329f |
children |
line wrap: on
line diff
--- a/expr.py Fri Jun 03 12:42:57 2011 -0700 +++ b/expr.py Fri Jun 03 13:01:22 2011 -0700 @@ -57,6 +57,11 @@ def led(self, parser, left): return left != parser.expression(self.lbp) +class not_op_token(object): + "!" + def nud(self, parser): + return not parser.expression() + class and_op_token(object): "&&" def led(self, parser, left): @@ -134,6 +139,7 @@ def lparen(scanner, t): return lparen_token() def rparen(scanner, t): return rparen_token() def string_(scanner, t): return string_token(t) + def not_(scanner, t): return not_op_token() scanner = re.Scanner([ (r"true|false", bool_), @@ -143,6 +149,7 @@ (r"==", eq), (r"!=", neq), (r"\|\|", or_), + (r"!", not_), (r"&&", and_), (r"\(", lparen), (r"\)", rparen),