# HG changeset patch # User Jeff Hammel # Date 1307115415 25200 # Node ID 421e26c0299fe31af97b0d686f18b6746893b4b2 # Parent 9b2bf000aeed69b8e63bd5efe957d6c64ba901fb add a string token diff -r 9b2bf000aeed -r 421e26c0299f expr.py --- 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_),