Hi,
2006/5/23, Toly Kournik <[EMAIL PROTECTED]>:
I'm trying to integrate generated C++ Bison parser with generated C++
Flex scanner.
The goal is to do it without generated code intervention.
There are several questions:
1. How can I cause generated Parser::parse() method to call
Lexer::yylex() instead of yylex() ?
You could try the following (untestet). Write a global yylex-Function
that is called from bison. Use the bison directive %lex-param to pass
your Flexer:
%lex-param {MyFlexLexer* lexer}
Then call the lexer->yylex() method from this function:
int yylex(MyFlexLexer* lexer) {
return lexer->yylex();
}
When you have more arguments use more %lex-params and just pass them
through the global yylex-Function.
2. How can I tell Lexer::yylex() to receive parameters?
in your derived class from yyFlexLexer declare the yylex-Function as
you like it:
class MyFlexLexer : public yyFlexLexer {
// ...
public:
int yylex(int foo, std::string& bar);
// ...
}
then redefine YY_DECL to MyFlexLexer::yylex(int foo, std::string& bar);
Regards,
Michael
_______________________________________________
[email protected] http://lists.gnu.org/mailman/listinfo/help-bison