]> thyrsus.com Git - mad.git/commitdiff
Now we compile the payroll example.
authorEric S. Raymond <esr@thyrsus,com>
Tue, 17 Feb 2004 21:31:25 +0000 (21:31 +0000)
committerEric S. Raymond <esr@thyrsus,com>
Tue, 17 Feb 2004 21:31:25 +0000 (21:31 +0000)
mad

diff --git a/mad b/mad
index 06f753d8f836f2a05f6e933865424e0ea31f7b2b..eccd0fc6b1842af763da08bd73cf5fa8f4ef0bfb 100755 (executable)
--- a/mad
+++ b/mad
@@ -72,9 +72,11 @@ def t_NAME(t):
     return t
 
 def t_DOUBLENUM(t):
-    r'\d+\.\d*'
+    r'(\d+\.\d*|\.\d+)'
     if t.value[-1] == '.':
         t.value += "0"
+    if t.value[0] == '.':
+        t.value = "0" + t.value
     return t
 
 def t_BOOLNUM(t):
@@ -532,6 +534,15 @@ def analyze():
             if statement[0] == 'end_function' and i < len(deck)-1 and deck[i+1][3][0] != 'extern':
                 deck.insert(i+1, (file, line, None, ('entry', 'main.', ())))
                 hasmain = True
+    # Sanity check -- all labels in through statements must hit targwts
+    labels = filter(lambda x: x, map(lambda x: x[2], deck))
+    for (file, line, label, statement) in deck:
+        if statement[0] == 'for':
+            target = statement[1]
+            if  not target in labels:
+                croak((file,line,label,statement),"no such label as "+`target`)
+                sys.exit(1)
+    # On to actual analysis
     try:
         # Mine the code for compile-time directives
         for (file, line, label, statement) in deck: