[antlr-interest] - Python Target
Edward Hartley
ed.hartley at gmail.com
Sun Jul 15 13:25:26 PDT 2007
> I'm looking at the example grammar Expr.g from the book and when testing
> it with valid expressions like (3+4)*9 I get the output like the following
>>>> (3+4)*9
> line 0:-1 mismatched input '<EOF>' expecting NEWLINE
>
> Is this behaviour correct or is it due to my having missed something:
> I retained the skip() call in the NEWLINE rule.
> I don not get this behavior with the Java target and see the same as is
> described in the book.
I can't reproduce this. Are you sure that the input actually has a '\n' at
the end? How does your main script look like?
My Driver program looks like this:
import antlr3
from ExprLexer import ExprLexer
from ExprParser import ExprParser
while True:
expr = raw_input('>>> ')
if expr == "'':
break
cStream = antlr3.StringStream(expr)
lexer = ExprLexer(cStream)
tStream = antlr3.CommonTokenStream(lexer)
parser = ExprParser(tStream)
parser.prog()
I'm a bit mystified and expect I've missed something blindingly obvious.
TIA
Ed
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20070715/3913c5bb/attachment.html
More information about the antlr-interest
mailing list