]> thyrsus.com Git - mad.git/commitdiff
Handle Boolean literals correctly.
authorEric S. Raymond <esr@thyrsus,com>
Mon, 9 Feb 2004 22:45:51 +0000 (22:45 +0000)
committerEric S. Raymond <esr@thyrsus,com>
Mon, 9 Feb 2004 22:45:51 +0000 (22:45 +0000)
mad

diff --git a/mad b/mad
index 7f4916adaed139fa6edc43f2263c39ec494f88d8..78ce5d05cd80c6ce0b2d6e4f635222d6db68f678 100755 (executable)
--- a/mad
+++ b/mad
@@ -47,7 +47,6 @@ t_EQUALS  = r'='
 t_LPAREN  = r'\('
 t_RPAREN  = r'\)'
 t_STRING  = r'\$[^$]*\$'
-t_BOOLNUM = r'[01]B'
 
 reserved_map = { }
 for r in reserved:
@@ -67,6 +66,11 @@ def t_FLOATNUM(t):
         t.value += "0"
     return t
 
+def t_BOOLNUM(t):
+    r'[01]B'
+    t.value = int(t.value[0])
+    return t
+
 def t_INTNUM(t):
     r'\d+'
     # Leading zeros flip us into octal in C, therefore strip them.
@@ -374,6 +378,10 @@ def p_expression_group(t):
     'expression : LPAREN expression RPAREN'
     t[0] = t[2]
 
+def p_expression_bool(t):
+    'expression : BOOLNUM'
+    t[0] = ('boolnum', t[1])
+
 def p_expression_integer(t):
     'expression : INTNUM'
     t[0] = ('intnum', t[1])
@@ -382,10 +390,6 @@ def p_expression_float(t):
     'expression : FLOATNUM'
     t[0] = ('floatnum', t[1])
 
-def p_expression_bool(t):
-    'expression : BOOLNUM'
-    t[0] = ('boolnum', t[1])
-
 def p_expression_subscript(t):
     'expression : NAME application'
     t[0] = ('variable', t[1], tuple(t[2]))