[antlr-interest] unknown parameters
Corno Schraverus
antlr-interest at schraverus.com
Mon Nov 5 04:55:26 PST 2007
Hi all,
I ran into a problem with antlr 3, is there anybody that can help me with
that?
I have a rule with a paramater ('context') and within that rule I call
another rule with that parameter as an argument (The grammar is an adjusted
version of the java grammar).
The generated code (in C, see below) contains a function that is a fragment
of the rule, but lacks the parameter, and therefore gives a compile-error.
Is this an error in the code generation or am I doing something wrong?
TIA,
Corno
The rule:
---------------------------
classBodyDeclarations [Context * context]
:
( ';'
| ( modifier [context]
)*
( typeParameters [context]
( ( type [context]
| 'void'
)
methodDeclaratorRest [context]
| constructorDeclaratorRest [context]
)
| type [context]
methodDeclaratorRest [context]
| type [context]
variableDeclarators [context]
';'
)
)*
;
--------------------------
The generated code:
--------------------------
// $ANTLR start synpred11
static void synpred11_fragment(pJavaParser ctx ) //<------------- parameter
missing here
{
// Java.g:68:5: ( type[context] methodDeclaratorRest[context] )
// Java.g:68:5: type[context] methodDeclaratorRest[context]
{
FOLLOWPUSH(FOLLOW_type_in_synpred11207);
type(ctx, context); //<--------------
problem is here
FOLLOWPOP();
if (HASEXCEPTION())
{
goto rulesynpred11Ex;
}
if (HASFAILED())
{
return ;
}
FOLLOWPUSH(FOLLOW_methodDeclaratorRest_in_synpred11214);
methodDeclaratorRest(ctx, context);
FOLLOWPOP();
if (HASEXCEPTION())
{
goto rulesynpred11Ex;
}
if (HASFAILED())
{
return ;
}
}
.....
----------------------------
More information about the antlr-interest
mailing list