[antlr-interest] ANTLR 3.4: missing parameter in the method generated for a syntactic predicate for a rule with a parameter
Francis ANDRE
francis.andre.kampbell at orange.fr
Thu Aug 16 05:01:38 PDT 2012
Hi
The generation of the method for the syntactic predicate of a rule with a
parameter is missing the parameter in its signature, which leads to a compile
error. I did not find out a way to fix this problem in the code base of antlr.
I would appreciate that someone looks at it and eventually fix this problem
because I am stuck
Rgds
FA
Here the CMinus grammar modified with the variable rule having a parameter and
conditioned by a syntactic predicate:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
program
scope {
List globals;
List functions;
}
@init {
$program::globals = new ArrayList();
$program::functions = new ArrayList();
}
: _declaration[2]_+
-> program(globals={$program::globals},functions={$program::functions})
;
declaration[int i]
: _(variable[i])=>variable[i]_ {$program::globals.add($variable.st);}
| f=function {$program::functions.add($f.st);}
;
_variable[int i]_
: type declarator ';'
-> {$function.size()>0 && $function::name==null}?
globalVariable(type={$type.st},name={$declarator.st})
-> variable(type={$type.st},name={$declarator.st})
;
Here the generated code
---------------------------------
// $ANTLR start synpred1_CMinus
public final void synpred1_CMinus_fragment() throws RecognitionException {
//
C:\\Users\\FrancisANDRE\\workspace\\zAntlr3\\src\\cminus\\CMinus.g:39:9: (
variable[i] )
//
C:\\Users\\FrancisANDRE\\workspace\\zAntlr3\\src\\cminus\\CMinus.g:39:10:
variable[i]
{
pushFollow(FOLLOW_variable_in_synpred1_CMinus101);
variable(i); _// <== i cannot be resolved to a variable
CMinusParser.java /zAntlr3/src/cminus line 1744 Java Problem_
state._fsp--;
if (state.failed) return ;
}
}
// $ANTLR end synpred1_CMinus
_______________________________________________
antlr-dev mailing list
antlr-dev at antlr.org
http://www.antlr.org/mailman/listinfo/antlr-dev
More information about the antlr-interest
mailing list