[antlr-interest] Better support for tracing
Monty Zukowski
monty at codetransform.com
Thu Apr 15 11:45:32 PDT 2004
Pardon me if this has been discussed before. Debugging my tree parser
I decided to override match() to help me see what is going on inside of
the rule. (See below for C++ code)
I think it would be handy to have a #define TRACE_TREE_PARSER generated
into my SqlTreeParser.hpp so I can avoid forgetting to remove the code
before delivery.
For Java we might have a final constant defined so we could gate print
statements.
Comments?
void SqlTreeParser::match(ANTLR_USE_NAMESPACE(antlr)RefAST t, int ttype)
{
traceIndent();
if (!t || t==ASTNULL || t->getType()!=ttype)
{
ANTLR_USE_NAMESPACE(std)cout << "mismatch(" << t->getType() << ", "<<
ttype <<")"<< ANTLR_USE_NAMESPACE(std)endl;
throw ANTLR_USE_NAMESPACE(antlr)MismatchedTokenException();
}
ANTLR_USE_NAMESPACE(std)cout << "match(" << ttype <<")"<<
ANTLR_USE_NAMESPACE(std)endl;
}
Monty
ANTLR consulting
www.codetransform.com
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