pmacs3/test2.py

19 lines
343 B
Python
Raw Normal View History

2007-03-27 22:52:47 -04:00
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)