]> thyrsus.com Git - mad.git/commitdiff
Full argument parsing.
authorEric S. Raymond <esr@thyrsus,com>
Tue, 20 Jan 2004 18:46:52 +0000 (18:46 +0000)
committerEric S. Raymond <esr@thyrsus,com>
Tue, 20 Jan 2004 18:46:52 +0000 (18:46 +0000)
mad

diff --git a/mad b/mad
index d3cce88ca766ed6db1937c7bab96db9fd0aa33e5..50d1f11311964ea69b3be4e15c7b1148840a6fb5 100755 (executable)
--- a/mad
+++ b/mad
@@ -492,16 +492,27 @@ if __name__ == '__main__':
     import getopt
     mad_debug = 0
     (options, arguments) = getopt.getopt(sys.argv[1:], "d:")
-    print options
     for (opt, val) in options:
         if opt == '-d':
             mad_debug = int(val)
 
-    source = sys.stdin.read()
-    # Grotty hack to add end-of-statement delimiters
-    source = re.sub('\n([A-Z]|\t)', ' ;\n\\1', source).rstrip() + ' ;\n'
-    # Parse
-    yacc.parse(source, debug=mad_debug)
+    if len(arguments) == 0:
+        arguments = ['-']
+
+    for file in arguments:
+        if file == '-':
+            sourcefile = 'stdin'
+            source = sys.stdin.read()
+        else:
+            sourcefile = file
+            fp = open(file)
+            source = fp.read()
+            fp.close()
+        # Grotty hack to add end-of-statement delimiters
+        source = re.sub('\n([A-Z]|\t)', ' ;\n\\1', source).rstrip() + ' ;\n'
+        # Parse
+        yacc.parse(source, debug=mad_debug)
+
     # Perform global analysis
     analyze(deck)
     # Generate code