pmacs3/test2.py

19 lines
359 B
Python
Raw Normal View History

2007-03-27 22:52:47 -04:00
import sys
2007-03-28 01:09:04 -04:00
import lex2, lex2_perl
2007-03-27 22:52:47 -04:00
paths = sys.argv[1:]
for path in paths:
f = open(path, 'r')
data = f.read()
f.close()
lines = data.split('\n')
2007-03-28 01:09:04 -04:00
grammar = lex2_perl.PerlGrammar()
2007-03-27 22:52:47 -04:00
lexer = lex2.Lexer('lexer', grammar)
lexer.lex(lines)
print path
for token in lexer:
print '%-28s| %r' % (token.name, token.string)