[antlr-interest] [C++] How to init variables of MyParser ?
Ruslan Zasukhin
sunshine at public.kherson.ua
Mon Sep 1 12:41:09 PDT 2003
Hi guys,
Assume I do such parser
-------------------------------------------------
class VSQL_Parser extends Parser;
{
public:
std::ostream* mstream;
static bool print_error_to_console;
void reportError(const antlr::RecognitionException& ex)
{
if( mstream )
*mstream << ex.toString().c_str() << '\n';
if( print_error_to_console )
std::cout << ex.toString().c_str() << '\n';
}
}
-------------------------------------------------
Question is, how I can make ANTLR to generate C++ sources that will init
mstream on construction of parser instance ???
PROBLEM IS:
1) I cannot define own version of constructor in the above { } section.
2) because ANTLR produce the next constructors for parser:
-------------------------------------------------
VSQL_Parser::VSQL_Parser(antlr::TokenBuffer& tokenBuf, int k)
: antlr::LLkParser(tokenBuf,k)
{
}
VSQL_Parser::VSQL_Parser(antlr::TokenBuffer& tokenBuf)
: antlr::LLkParser(tokenBuf,2)
{
}
-------------------------------------------------
3) I think only way to resolve this problem is that ANTLR need generate
constructors that call some InitSelf() method. I can then define such
method.
Yes, this method cannot be virtual.
4) or anybody knows other trick?
--
Best regards,
Ruslan Zasukhin [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com
To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list