changeset 8:9b2bf000aeed

add an int token
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 03 Jun 2011 08:32:57 -0700
parents 325dccc38308
children 421e26c0299f
files expr.py
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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()