[antlr-interest] Java synpred fragment generating errors

Jim Idle jimi at temporal-wave.com
Fri Oct 14 08:57:00 PDT 2011


((LEFT_BRACKET atom RIGHT_BRACKET)=>


Don't add a label in to the predicate.


Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Louis Burroughs
> Sent: Friday, October 14, 2011 7:10 AM
> To: antlr-interest at antlr.org
> Subject: [antlr-interest] Java synpred fragment generating errors
>
> antlr 3.4
> java 1.6
> os: windows xp
>
> Hello,
>
> When I try to use syntactic predicates in my grammar I am getting an
> error in the generated grammar parser file.  My variables are not
> initialized correctly.  I am new to antlr and syntactic predicates so I
> am not sure if the problem is in my grammar or in the template.  This
> also happens when I turn the backtracking option to true and remove the
> predicates from my grammar.
>
>
>
> // $ANTLR start synpred50_EsqlGrammar
>     public final void synpred50_EsqlGrammar_fragment() throws
> RecognitionException {
>   -->   *void  =null;*
>
>
>         //
> C:\\EsqlParser\\src\\com\\abc\\iaf\\plugin\\EsqlGrammar.g:393:23:
> ( LEFT_BRACKET var_atom1= atom RIGHT_BRACKET )
>         //
> C:\\EsqlParser\\src\\com\\abc\\iaf\\plugin\\EsqlGrammar.g:393:24:
> LEFT_BRACKET var_atom1= atom RIGHT_BRACKET
>         {
>
> match(input,LEFT_BRACKET,FOLLOW_LEFT_BRACKET_in_synpred50_EsqlGrammar20
> 08);
> if (state.failed) return ;
>
>         pushFollow(FOLLOW_atom_in_synpred50_EsqlGrammar2012);
>         var_atom1=atom();
>
>         state._fsp--;
>         if (state.failed) return ;
>
>
> match(input,RIGHT_BRACKET,FOLLOW_RIGHT_BRACKET_in_synpred50_EsqlGrammar
> 2014);
> if (state.failed) return ;
>
>         }
>
>     }
>
> Grammar Syntax:
>
> variable
>   :
>   var_id1=IDENTIFIER ((LEFT_BRACKET var_atom1=atom
> RIGHT_BRACKET)=>LEFT_BRACKET var_atom1=atom RIGHT_BRACKET)?
> (pe+=path_element)*
>     ->
>       ^(VARIABLE ^(BRACKET $var_atom1)$var_id1  $pe* )
>   ;
>
>
> This also happens with tokens:
>
> Token =null;
>
> Thanks in advance,
> Louis Burroughs
>
> 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