pmacs3/test2.py

22 lines
488 B
Python

#!/usr/bin/python
import sys
import lex2, lex2_perl
paths = sys.argv[1:]
for path in paths:
f = open(path, 'r')
data = f.read()
f.close()
lines = data.split('\n')
grammar = lex2_perl.PerlGrammar()
lexer = lex2.Lexer('lexer', grammar)
lexer.lex(lines)
print path
for token in lexer:
print '%-30s| %-6s | %r' % (token.name,
'(%d,%d)' % (token.x, token.y),
token.string)