[antlr-interest] Re: Better support for tracing
lgcraymer
lgc at mail1.jpl.nasa.gov
Thu Apr 15 12:41:38 PDT 2004
Monty--
I've been meaning to add a flag to do conditional tracing for 2.8 to tune the ParseTreeDebug stuff, so I'll just add the #ifdefs to the C++
code generation as well.
--Loring
--- In antlr-interest at yahoogroups.com, Monty Zukowski <monty at c...> wrote:
> 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