[antlr-interest] Syntactic predicate - simple case

Timothy Washington timothyjwashington at yahoo.ca
Wed Sep 6 08:37:44 PDT 2006


--- Loring Craymer <lgcraymer at yahoo.com> wrote:

> 1.) With ANTLR 2, STARTCHUNK should be a "protected"
> rule; with ANTLR 3, it should be a "fragment.
> 
> 2.)  synpreds distinguish alternatives--you need a
> rule that looks something like
> 
> CHUNK
>     :
>     ( STARTCHUNK (WS)? "/>" )=> ( STARTCHUNK(WS)?
> "/>" ) 
>         { $setType(EMTYTAG); }
>     |
>        ( STARTCHUNK (WS)? '>' ) 
>         { $setType(STARTTAG); }
>     ;
> 
> but it is still better to simply left factor:
> 
> LCHUNK
>     :
>     STARTCHUNK (WS)?
>     (    "/>"     { $setType(EMTYTAG); }
>         |
>             '>'     { $setType(STARTTAG); }
>     ;
> 
> --Loring

Yes yes, this works. The systactic predicate makes
more sense now. Thanks very much Loring. 

Tim



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the antlr-interest mailing list