Jeremy Hylton | 0c3208a | 2000-03-06 19:13:21 +0000 | [diff] [blame] | 1 | import sys |
| 2 | import getopt |
| 3 | |
| 4 | from compiler import compile, visitor |
| 5 | |
| 6 | def main(): |
| 7 | VERBOSE = 0 |
| 8 | opts, args = getopt.getopt(sys.argv[1:], 'vq') |
| 9 | for k, v in opts: |
| 10 | if k == '-v': |
| 11 | VERBOSE = 1 |
| 12 | visitor.ASTVisitor.VERBOSE = visitor.ASTVisitor.VERBOSE + 1 |
| 13 | if k == '-q': |
Jeremy Hylton | 0a4f1ff | 2000-05-02 22:29:46 +0000 | [diff] [blame] | 14 | if sys.platform[:3]=="win": |
| 15 | f = open('nul', 'wb') # /dev/null fails on Windows... |
| 16 | else: |
| 17 | f = open('/dev/null', 'wb') |
Jeremy Hylton | 0c3208a | 2000-03-06 19:13:21 +0000 | [diff] [blame] | 18 | sys.stdout = f |
| 19 | if not args: |
| 20 | print "no files to compile" |
| 21 | else: |
| 22 | for filename in args: |
| 23 | if VERBOSE: |
| 24 | print filename |
| 25 | compile(filename) |
| 26 | |
| 27 | if __name__ == "__main__": |
| 28 | main() |