[antlr-interest] Gated Semantic Predicates in v4

Terence Parr parrt at cs.usfca.edu
Thu Oct 11 11:09:45 PDT 2012


all predicates in v4 are considered gated by the old terminology. They are always evaluated, even when syntax alone is sufficient to make decisions.  Note that predicates and Alexa should go at the right hand side of the rules for efficiency.

TEXT : . ;

will probably do what you want if you put it last.  note that we also have lexical modes now.

Ter

On Oct 11, 2012, at 11:03 AM, Edgar Espina wrote:

> Hi,
> 
> Is there a way to match dynamic tokens in v4 and provide? (where token
> usually has more than one character)
> 
> This is what I did in v3:
> 
> @lexer:members {
>  private String open = "{{"; // This could change at any time
>  private String close = "}}"; // This could change at any time
> }
> 
> OPEN:
>  {ahead(open)}=> {match(open);}
> 
> CLOSE:
>  {ahead(close)}=> {match(close);}
> 
> ...
> TEXT:
>  {!ahead(open)} => {consume until we find "open"}
> 
> The open and close tokens might change at runtime, that is why there is
> call to: *match.* There is also a custom rule for TEXT which basically eat
> everysingle char/token until it find the open token.
> 
> My questions are:
> 1. How can I match dynamic tokens in v4?
> 2. How can I provide a match function (like TEXT) in v4?
> 
> Thanks in advance
> -- 
> edgar
> 
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-email-address



More information about the antlr-interest mailing list