pmacs3/test2.py

22 lines
488 B
Python
Raw Normal View History

2007-04-09 19:21:43 -04:00
#!/usr/bin/python
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:
2007-04-09 19:21:43 -04:00
print '%-30s| %-6s | %r' % (token.name,
'(%d,%d)' % (token.x, token.y),
token.string)