[antlr-interest] Backtracking and labels

Bart Kiers bkiers at gmail.com
Fri Mar 9 02:51:38 PST 2012


Aren't you missing the `^` right before the `(` in the rewrite rule?

rule
  : OPTION1
  | value=OPTION2 -> ^($value)
  ;

Regards,
Bart.


On Fri, Mar 9, 2012 at 11:30 AM, Kieran Simpson <kierans777 at gmail.com>wrote:

> For my rule:
>
> rule
>   : OPTION1
>   | value=OPTION2 -> ($value)
>   ;
>
> with backtracking on (and memoize not that I think that's relevant) the
> synpredicate code generated has errors, both for the Java and C targets
> where the variable name is missing in the declaration
>
> eg:
>
> public final void synpred9_grammar_fragment() throws RecognitionException {
>         Token =null;
>
> and
>
> static void synpred9_grammar_fragment(pCoreConfigurationParser ctx )
> {
>        pANTLR3_COMMON_TOKEN    ;
>
>               = NULL;
>
> Interestingly this grammar runs in debug mode when used with Antlrworks
> even though I'm using version 3.4 of Antlr with my project and 3.4 is
> included with Antlrworks (1.4.3).
>
> Just in case it's due to an out of date version, here are some md5sums
>
> 9638f9b7b1b823fcaba977f06f0dd761  ./antlr/3.4/antlrworks-1.4.3.jar
>
> 465472089d78cd80f926f5825a29ec7f  ./lib/antlr-3.4.jar
> 0e0318be407e51fdf7ba6777eabfdf73  ./lib/antlr-runtime-3.4.jar
>
> Is something out of date here or is this a bug with the backtracking
> generation?
>
> Cheers,
>
> 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