[antlr-interest] 2.7.2 problem with Tree Walker in cpp generation mode

Ric Klaren klaren at cs.utwente.nl
Wed Aug 6 03:25:33 PDT 2003


On Wed, Aug 06, 2003 at 11:55:16AM +0200, Laat-de, Geert-Jan wrote:
> Running this through antlr 2.7.2 the following code is generated:
> [Start of generated code]
> void BuilderWalker::expr(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
> 	ANTLR_USE_NAMESPACE(antlr)RefAST expr_AST_in = _t;
> 	ANTLR_USE_NAMESPACE(antlr)RefAST id =
> ANTLR_USE_NAMESPACE(antlr)nullAST;
> 	
> 	try {      // for error handling
> 		if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
> 			_t = ASTNULL;
> 		if ((_t->getType() == ID)) {
> 			id = _t;
> 			match(_t,ID);
> 			_t = _t->getNextSibling();
> 			
> // Several actions
> 				
> 		}
> 		else if ((_t->getType() == IntConst)) {
> 			ANTLR_USE_NAMESPACE(antlr)RefAST tmp2_AST_in = _t;
> 			match(_t,IntConst);
> 			_t = _t->getNextSibling();
> 		}
> 		else if ((_t->getType() == DoubleConst)) {
> 			ANTLR_USE_NAMESPACE(antlr)RefAST tmp3_AST_in = _t;
> 			match(_t,DoubleConst);
> 			_t = _t->getNextSibling();
> 		}
> 		else if (((_t->getType() >= Vocabulary && _t->getType() <=
> IntConst))) {
> 			ANTLR_USE_NAMESPACE(antlr)RefAST __t4 = _t;
> 			ANTLR_USE_NAMESPACE(antlr)RefAST tmp4_AST_in = _t;
> 			if ( _t == ASTNULL ) throw
> MismatchedTokenException(); // !!!! Error message !!!!
> 			_t = _t->getFirstChild();
> 			expr(_t);
> 			_t = _retTree;
> 			expr(_t);
> 			_t = _retTree;
> 			_t = __t4;
> 			_t = _t->getNextSibling();
> 		}
> 		else {
> 			throw
> ANTLR_USE_NAMESPACE(antlr)NoViableAltException(_t);
> 		}
> 		
> 	}
> 	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
> 		reportError(ex);
> 		if ( _t != ANTLR_USE_NAMESPACE(antlr)nullAST )
> 			_t = _t->getNextSibling();
> 	}
> 	_retTree = _t;
> }
> [End of generated code]
> 
> And on compilation the following error message is generated (on the line
> indicated above):
> [Start of error message]
> Call to undefined function 'MismatchedTokenException'
> [End of error message]
> 
> Could someone please tell me what's wrong with my code ?

I have a queer feeling something's wrong with our code ;)

Is the problem solved if you add ANTLR_USE_NAMESPACE(antlr) in front of the
MismatchedTokenException ?

Cheers,

Ric
--
-----+++++*****************************************************+++++++++-------
    ---- Ric Klaren ----- j.klaren at utwente.nl ----- +31 53 4893722  ----
-----+++++*****************************************************+++++++++-------
 Time what is time - I wish I knew how to tell You why - It hurts to know -
          Aren't we machines - Time what is time - Unlock the door
               - And see the truth - Then time is time again
                From: 'Time what is Time' by Blind Guardian


 

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




More information about the antlr-interest mailing list