import sys import lex2 paths = sys.argv[1:] for path in paths: f = open(path, 'r') data = f.read() f.close() lines = data.split('\n') grammar = lex2.PerlGrammar() lexer = lex2.Lexer('lexer', grammar) lexer.lex(lines) print path for token in lexer: print '%-20s| %s' % (token.name, token.string)