pmacs3/test2.py

19 lines
359 B
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 '%-28s| %s' % (token.name, token.string)