blob: 58fc3b2c6d6685b5940c53199dc54435645f0848 [file] [log] [blame]
Jeremy Hylton0c3208a2000-03-06 19:13:21 +00001import sys
2import getopt
3
4from compiler import compile, visitor
5
6def main():
7 VERBOSE = 0
Jeremy Hyltone7f710c2000-10-13 21:59:32 +00008 DISPLAY = 0
9 opts, args = getopt.getopt(sys.argv[1:], 'vqd')
Jeremy Hylton0c3208a2000-03-06 19:13:21 +000010 for k, v in opts:
11 if k == '-v':
12 VERBOSE = 1
13 visitor.ASTVisitor.VERBOSE = visitor.ASTVisitor.VERBOSE + 1
14 if k == '-q':
Jeremy Hylton0a4f1ff2000-05-02 22:29:46 +000015 if sys.platform[:3]=="win":
16 f = open('nul', 'wb') # /dev/null fails on Windows...
17 else:
18 f = open('/dev/null', 'wb')
Jeremy Hylton0c3208a2000-03-06 19:13:21 +000019 sys.stdout = f
Jeremy Hyltone7f710c2000-10-13 21:59:32 +000020 if k == '-d':
21 DISPLAY = 1
Jeremy Hylton0c3208a2000-03-06 19:13:21 +000022 if not args:
23 print "no files to compile"
24 else:
25 for filename in args:
26 if VERBOSE:
27 print filename
Jeremy Hyltone7f710c2000-10-13 21:59:32 +000028 compile(filename, DISPLAY)
Jeremy Hylton0c3208a2000-03-06 19:13:21 +000029
30if __name__ == "__main__":
31 main()