]> thyrsus.com Git - mad.git/commitdiff
This version compiles the GCD code.
authorEric S. Raymond <esr@thyrsus,com>
Fri, 13 Feb 2004 22:09:04 +0000 (22:09 +0000)
committerEric S. Raymond <esr@thyrsus,com>
Fri, 13 Feb 2004 22:09:04 +0000 (22:09 +0000)
mad

diff --git a/mad b/mad
index 708194e294cbece933341af8be2f2dce3528f3db..06de6e2f83a1d9037a2fb0d3902a44bf2696dfb7 100755 (executable)
--- a/mad
+++ b/mad
@@ -3,7 +3,7 @@
 reserved = ('BOOLEAN', 'CONDITIONAL', 'CONTINUE', 'DATA', 'DIMENSION',
             'END', 'ENTRY', 'EXECUTE', 'EXTERNAL', 'FOR', 'FUNCTION',
             'INTEGER', 'INTERNAL', 'IS', 'MODE', 'NORMAL',
-            'OF', 'PAUSE', 'PRINT_FORMAT', 'PROGRAM', 'READ_FORMAT',
+            'OF', 'OR', 'PAUSE', 'PRINT_FORMAT', 'PROGRAM', 'READ_FORMAT',
             'RESTORE', 'RETURN', 'SAVE', 'SET_LIST_TO', 'THROUGH',
             'TO', 'TRANSFER', 'VALUES', 'VECTOR', 'WHENEVER',
             # COMMENT is a pseudo-keyword generated early in compilation.
@@ -14,7 +14,7 @@ tokens = reserved + (
     'NAME','INTNUM', 'DOUBLENUM', 'BOOLNUM', 'STRING', 'FUNCALL',
     'LPAREN','RPAREN',
     'PLUS','MINUS','TIMES','DIVIDE','EQUALS',
-    'NOT', 'OR', 'AND', 'THEN', 'EQV',
+    'NOT', 'AND', 'THEN', 'EQV',       # See above for OR
     'EQ', 'NE', 'LT', 'LE', 'GT', 'GE',
     'ABS', 'POW',
     )
@@ -827,7 +827,10 @@ def print_C_statement(statement):
     elif statement[0] == 'continue':
         return "/* continue */;"
     elif statement[0] in ('end_program', 'end_function', 'end_conditional'):
-        return "} /* %s */" % statement[0] 
+        rep = "}"
+        if mad_debug:
+            rep += " /* %s */" % statement[0]
+        return rep
     elif statement[0] == 'entry':
         currentfunc = statement[1]
         types = typedict[currentfunc]
@@ -891,7 +894,7 @@ def print_C_statement(statement):
         rep += "((%s [%d]){%s})[%s];" % (statement[3][0][0][:-3], count, ", ".join(map(lambda x: `x[1]`, statement[3])), dummy)
         return rep
     elif statement[0] == 'or':
-        return 'else if (' + print_C_expr(statement[2]) + ') {'
+        return '} else if (' + print_C_expr(statement[1]) + ') {'
     elif statement[0] == 'otherwise':
         return 'else {'
     elif statement[0] == 'pause':