[antlr-interest] Expression grammar issues (typecasts,
method calls)
Nigel Sheridan-Smith
nbsherid at secsme.org.au
Sun Jul 24 21:16:02 PDT 2005
> -----Original Message-----
> From: Nigel Sheridan-Smith [mailto:nbsherid at secsme.org.au]
> Sent: Monday, 25 July 2005 1:52 PM
> To: 'antlr-interest at antlr.org'
> Subject: RE: [antlr-interest] Expression grammar issues (typecasts,method
> calls)
>
> It might be a problem that is common with StringReader, in that you need
> to force the end-of-file on your top-level rule.
>
> Add the following line:
>
> expressionToParse: primaryExpression EOF!
>
>
> Then, in your code:
>
> HippoParser parser = new HippoParser(new HippoLexer(new
> StringReader("foo")));
> parser.expressionToParse();
>
>
Yeap, that's definitely it, as 'expression' is not a top-level rule (see
'expressionList' and 'argList'). You don't need EOF, just a new top-level
rule.
http://www.jguru.com/faq/view.jsp?EID=422381
I modified your grammar, tested it, and it works fine.
Cheers,
Nigel
--
Nigel Sheridan-Smith
PhD research student
Faculty of Engineering
University of Technology, Sydney
Phone: 02 9514 7946
Fax: 02 9514 2435
More information about the antlr-interest
mailing list