[antlr-interest] antlr bug or grammar problem?

kozchris csnyder at alumni.ncsu.edu
Thu Sep 23 11:10:13 PDT 2004


I'm using antlr 2.7.4. 
I've run the grammar building both a cpp and java version with same
results.

You can see the grammar file here
http://www.synergyss.com/SCRExpression.g.
and the java output here
http://www.synergyss.com/SCRExpressionParser.java

The issue is showing up in the parser code generated for rule
eventExpr on line 279.
The line: 
  ( BECAME_TRUE | BECAME_FALSE | CHANGED ) => expr {printf("processing
simple event expr\n");}

is showing up as this in the generated parser.

<<<< begin code snip
		switch ( LA(1)) {
		case BOOLEAN:
		case DoubleDoubleConst:
		case FloatDoubleConst:
		case LongDoubleConst:
		case IntBinaryConst:
		case IntHexConst:
		case LongHexConst:
		case UnsignedHexConst:
		case IntOctalConst:
		case LongOctalConst:
		case UnsignedOctalConst:
		case IntIntConst:
		case LongIntConst:
		case UnsignedIntConst:
		case LPAREN:
		case PLUS:
		case MINUS:
		case LNOT:
		case BNOT:
		case BECAME_TRUE:
		case BECAME_FALSE:
		case CHANGED:
		case ID:
		{
			expr();
			astFactory.addASTChild(currentAST, returnAST);
			if ( inputState.guessing==0 ) {
				printf("processing simple event expr\n");
			}
			eventExpr_AST = (AST)currentAST.root;
			break;
		}
<<<< end code snip

What is strange is that if I change line 281 from:
  ( BECAME_TRUE | BECAME_FALSE | CHANGED ) => expr {printf("processing
simple event expr\n");}

to:

  ( BECAME_TRUE | BECAME_FALSE | CHANGED ) => simpleEventExpr
{printf("processing simple event expr\n");}

the code generated is correct.

<<<< begin code snip
		switch ( LA(1)) {
		case BECAME_TRUE:
		case BECAME_FALSE:
		case CHANGED:
		{
			simpleEventExpr();
			astFactory.addASTChild(currentAST, returnAST);
			if ( inputState.guessing==0 ) {
				printf("processing simple event expr\n");
			}
			eventExpr_AST = (AST)currentAST.root;
			break;
		}
<<<< end code snip

Any ideas on how to solve this problem?

Thanks for the help.
Chris





 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
    antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list