[antlr-interest] 2.7.2 problem with Tree Walker in cpp generation mode
Laat-de, Geert-Jan
Geert-Jan.Laat-de at dsm.com
Wed Aug 6 02:55:16 PDT 2003
Hi,
I've got the following code snippet in my tree walker source file:
[Start of code snippet]
expr
: id:ID
{
// Several actions....
}
| IntConst
| DoubleConst
| #( . expr expr)
;
[End of code snippet]
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 ?
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