[antlr-interest] small question

Terence Parr parrt at cs.usfca.edu
Sat Dec 11 13:33:09 PST 2004



On Dec 10, 2004, at 1:33 PM, DVLeonid wrote:

>
> Dear antlr-interest,
>
>   I'm confused while reading ANTLR meta-lang spec.
>
> At "Fixed depth lookahead and syntactic predicates" part there is
> sample:
>
> class parse extends Parser;
> a       :       (A (P)*) => A (P)*
>         |       A
>         ;
>
> I cannot understand how ANTLR recognize
>
> AB

Hi.

You mean AP?  Well, antlr first tries to match A following by 0 or more 
Ps.  If it succeeds, it does it again (because there might have been 
actions it didn't execute during the first pass).  If it does not find 
a P as in your AB example, it rewinds the input and tries to match A.

Ter

>
> as:      A(P)*, where amount of Ps is zero, is followed by B
> or as:   A is followed by B
>
> In common sense it should be recognized as ... I can't understand : (
> ambiguity penerated in my mind...
>
> -- 
> Best regards,
>  DVLeonid                          mailto:dvleonid at land.ru
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>
--
CS Professor & Grad Director, University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Cofounder, http://www.jguru.com
Cofounder, http://www.knowspam.net enjoy email again!





 
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