# HG changeset patch # User Jeff Hammel # Date 1307115177 25200 # Node ID 9b2bf000aeed69b8e63bd5efe957d6c64ba901fb # Parent 325dccc383086d8cbcde5aa8663cd5aa3b1af68d add an int token diff -r 325dccc38308 -r 9b2bf000aeed expr.py --- a/expr.py Fri Jun 03 08:31:29 2011 -0700 +++ b/expr.py Fri Jun 03 08:32:57 2011 -0700 @@ -82,11 +82,17 @@ # lowest left binding power, always ends parsing lbp = 0 +### derived literal tokens + class bool_token(literal_token): def __init__(self, value): value = {'true':True, 'false':False}[value] literal_token.__init__(self, value) +class int_token(literal_token): + def __init__(self, value): + literal_token.__init__(self, int(value)) + precedence = [(end_token, rparen_token), (or_op_token,), (and_op_token,), @@ -113,7 +119,7 @@ # scanner callbacks def bool_(scanner, t): return bool_token(t) def identifier(scanner, t): return ident_token(t) - def integer(scanner, t): return literal_token(int(t)) + def integer(scanner, t): return int_token(t) def eq(scanner, t): return eq_op_token() def neq(scanner, t): return neq_op_token() def or_(scanner, t): return or_op_token()