[antlr-interest] Java synpred fragment generating errors
Louis Burroughs
louis.burroughs at gmail.com
Fri Oct 14 07:10:06 PDT 2011
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_EsqlGrammar2008);
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_EsqlGrammar2014);
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
More information about the antlr-interest
mailing list