[antlr-interest] Bug in Antlr - confusion on ANTLR grammar syntax???

John MccLain jmcclain at tcshealthcare.com
Thu Dec 9 13:35:07 PST 2004


Howdy,
Sebastian Kaliszewski replied to my post stating that the parser was waiting
for more input. He was correct - If I entered another NUM, the parser
processed it and continued to wait again. He also mentioned that my
startrule should have a check for EOF. I.E.:
Your start rule should have have EOF checking in it.
something like:

expression: simpleexp ((LE|GE|NE|EQ|LT|GT) simpleexp )? EOF

EOF checking is not implicit since many languages allow arbitrary
garbage afterthe program.

BUT, how do you check for EOF, and will this cause the parser to stop busy
waiting for input? That is what I want to do. Right now I am using standard
input (through the console in eclipse), but ultimately, I will be passing a
string into the parser for it to build a parse tree. How would I gracefully
exit the parser at the end of the input string ( or for now, standard in)

Here is my original post :



-----Original Message-----
From: Nigel Sheridan-Smith [mailto:nbsherid at secsme.org.au]
Sent: Thursday, December 09, 2004 1:16 PM
To: antlr-interest at yahoogroups.com
Subject: RE: [antlr-interest] Bug in Antlr - confusion on ANTLR grammar
syntax???





> -----Original Message-----
> From: Sebastian Kaliszewski [mailto:sk at z.pl]
> Sent: Friday, 10 December 2004 4:24 AM
> To: antlr-interest at yahoogroups.com
> Subject: Re: [antlr-interest] Bug in Antlr - confusion on ANTLR grammar
> syntax???
>
>
> John MccLain wrote:
> > I am not understanding this at all. I am building a grammar
> > to parse powerbuilder. Here is all of the parser grammar - I reduced it
> down
> > to localize
> > the confusion
> >
> > expression: simpleexp ((LE|GE|NE|EQ|LT|GT) simpleexp )?
> > ;
> >

Be careful of using 'LT' as it has significance for the parser/lexer. Try
changing this, or examine the generated code for that rule, and see if that
is what is causing it to hang.

Nigel

--
Nigel Sheridan-Smith
PhD research student

Faculty of Engineering
University of Technology, Sydney
Phone: 02 9514 7946
Fax: 02 9514 2435





Yahoo! Groups Links









 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 





More information about the antlr-interest mailing list