changeset 9:421e26c0299f

add a string token
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 03 Jun 2011 08:36:55 -0700
parents 9b2bf000aeed
children 15fb1081784f
files expr.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/expr.py	Fri Jun 03 08:32:57 2011 -0700
+++ b/expr.py	Fri Jun 03 08:36:55 2011 -0700
@@ -93,6 +93,10 @@
     def __init__(self, value):
         literal_token.__init__(self, int(value))
 
+class string_token(literal_token):
+    def __init__(self, value):
+        literal_token.__init__(self, value[1:-1])
+
 precedence = [(end_token, rparen_token),
               (or_op_token,),
               (and_op_token,),
@@ -126,7 +130,7 @@
         def and_(scanner, t): return and_op_token()
         def lparen(scanner, t): return lparen_token()
         def rparen(scanner, t): return rparen_token()
-        def string_(scanner, t): return literal_token(t[1:-1])
+        def string_(scanner, t): return string_token(t)
 
         scanner = re.Scanner([
             (r"true|false", bool_),