[antlr-interest] newbiew question on parsar grammar
Sebastian Kaliszewski
sk at z.pl
Sun Dec 12 04:12:14 PST 2004
Dnia pią 10. grudzień 2004 17:44, John MccLain napisał:
> Howdy,
> Sebastian Kaliszewski replied to an earlier post of mine (See original
> post below) 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, what is the rule for EOF,
The rule (token) for EOF is EOF. Exactly as i wrote.
> and will this cause the parser to stop busy
> waiting for input?
It should
> 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
> an expression or function
> 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)
Just use that soecial EOF token. It's automatically generated byt the lexer
when input terminates.
rgds
--
Sebastian Kaliszewski
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