2007-03-06 10:05:38 -05:00
|
|
|
import lex2
|
|
|
|
|
|
|
|
lines = [
|
2007-03-27 22:52:47 -04:00
|
|
|
'this is the first line',
|
2007-03-06 10:05:38 -05:00
|
|
|
'<< EOF;'
|
|
|
|
' abracadra hocus pocus',
|
|
|
|
' EOF',
|
|
|
|
'EOF',
|
|
|
|
'"this is a double-quoted string" and this is not...',
|
|
|
|
"we're done",
|
|
|
|
]
|
2007-03-27 22:52:47 -04:00
|
|
|
g = lex2.TestGrammar()
|
|
|
|
l = lex2.Lexer('lexer', g)
|
2007-03-06 10:05:38 -05:00
|
|
|
l.lex(lines)
|
|
|
|
for t in l:
|
2007-03-27 22:52:47 -04:00
|
|
|
print '%-20r %r' % (t.name, t.string)
|