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

Laat-de, Geert-Jan Geert-Jan.Laat-de at dsm.com
Wed Aug 6 03:43:35 PDT 2003


On Wed, Aug 06, 2003, Ric Klaren wrote:
> -----Original Message-----
> From: Ric Klaren [mailto:klaren at cs.utwente.nl]
> Sent: woensdag 6 augustus 2003 12:26
> To: antlr-interest at yahoogroups.com
> Subject: Re: [antlr-interest] 2.7.2 problem with Tree Walker in cpp
> generation mode
> 
> 
> 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 ?
> 

Yes, that solves the problem.

Best regards,

Geert-Jan

This e-mail is for the intended recipient only.
If you have received it by mistake please let us know by reply and then
delete it from your system; access, disclosure, copying, distribution or
reliance on any of it by anyone else is prohibited.
If you as intended recipient have received this e-mail incorrectly, please
notify the sender (via e-mail) immediately.

 

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




More information about the antlr-interest mailing list