]> thyrsus.com Git - mad.git/commitdiff
Before trying to eliminate keyword ambiguities.
authorEric S. Raymond <esr@thyrsus,com>
Tue, 10 Feb 2004 09:52:07 +0000 (09:52 +0000)
committerEric S. Raymond <esr@thyrsus,com>
Tue, 10 Feb 2004 09:52:07 +0000 (09:52 +0000)
mad

diff --git a/mad b/mad
index 342dc3b15fa12d615beb05be32ca416459a89acd..5fbab39575439f6f627b2876747f9306a839e573 100755 (executable)
--- a/mad
+++ b/mad
@@ -1,11 +1,11 @@
 #!/usr/bin/env python
 
-reserved = ('BOOLEAN', 'CONDITIONAL', 'CONTINUE', 'DIMENSION', 'END',
+reserved = ('BOOLEAN', 'CONDITIONAL', 'CONTINUE', 'DATA', 'DIMENSION', 'END',
             'ENTRY', 'EXECUTE', 'EXTERNAL', 'FOR', 'FORMAT',
-            'FUNCTION', 'INTEGER', 'INTERNAL', 'IS', 'MODE',
-            'NORMAL', 'OF', 'PAUSE', 'PRINT', 'PROGRAM', 'READ',
-            'RETURN', 'THROUGH', 'TO', 'TRANSFER', 'VALUES', 'VECTOR',
-            'WHENEVER',
+            'FUNCTION', 'INTEGER', 'INTERNAL', 'IS', 'LIST', 'MODE',
+            'NORMAL', 'OF', 'PAUSE', 'PRINT', 'PROGRAM', 'READ', 'RESTORE',
+            'RETURN', 'SAVE', 'SET', 'THROUGH', 'TO', 'TRANSFER',
+            'VALUES', 'VECTOR', 'WHENEVER',
             # This is a pseudo-keyword generated early in compilation.
             'COMMENT')
 
@@ -286,6 +286,26 @@ def p_varlist_continue(t):
     'varlist : varlist COMMA NAME'
     t[0] = t[1] + [t[3]]
 
+## RESTORE
+def p_restore_data(t):
+    'statement : RESTORE DATA varlist'
+    t[0] = ('restore', tuple(t[3]))
+def p_restore_return(t):
+    'statement : RESTORE RETURN'
+    t[0] = ('restore_return',)
+
+## SAVE
+def p_save_data(t):
+    'statement : SAVE DATA exprlist'
+    t[0] = ('save', tuple(t[3]))
+def p_save_return(t):
+    'statement : SAVE RETURN'
+    t[0] = ('save_return',)
+
+## SET LIST
+def p_set_list(t):
+    'statement : SET LIST TO NAME'
+    t[0] = ('set_list', t[3])
 
 ## THROUGH
 def p_through_for(t):
@@ -457,7 +477,7 @@ def analyze():
         for i in range(len(deck)):
             (file, line, label, statement) = deck[i]
             if statement[0] == 'end_function' and i < len(deck)-1 and deck[i+1][2][0] != 'extern':
-                deck.insert(i, (file, line, None, ('entry', 'main.', ())))
+                deck.insert(i+1, (file, line, None, ('entry', 'main.', ())))
                 hasmain = True
     # Mine the code for compile-time directives
     for (file, line, label, statement) in deck:
@@ -737,6 +757,8 @@ def print_statement(statement):
                         'external_function',
                         'integer',
                         'normal',
+                        'restore_return',
+                        'save_return',
                         'values'):
         pass
     elif statement[0] == 'continue':
@@ -819,6 +841,8 @@ def print_statement(statement):
             return "return %s;" % print_expr(statement[1])
     elif statement[0] == 'or':
         return 'else if (' + print_expr(statement[2]) + ') {'
+    elif statement[0] == 'set_list':
+        return normaltype + " *recursor = " + statement[2] + ";"
     elif statement[0] == 'substitution':
         return statement[1] + ' = ' + print_expr(statement[2]) + ';'
     elif statement[0] == 'whenever':