flex c++ question

"Michael O'Leary" <moleary@primus.com>
22 May 1997 22:41:46 -0400

          From comp.compilers

Related articles
flex c++ question moleary@primus.com (Michael O'Leary) (1997-05-22)
Re: flex c++ question buecher@swt.ruhr-uni-bochum.de (Thomas Buecher) (1997-05-27)
| List of all articles for this month |

From: "Michael O'Leary" <moleary@primus.com>
Newsgroups: comp.compilers
Date: 22 May 1997 22:41:46 -0400
Organization: Alternate Access Inc.
Keywords: flex, C++, question

I would like to adapt a tokenizer that I created in flex using flex's
c++ features to be used as a front end for a yacc parser (I had been
using it as a standalone tokenizer). I am wondering if there is a way
to continue having the tokenizer be defined as a c++ class and enable
the yacc (actually bison) parser to access it without recourse to
global variables. The parser's yyparse function calls yylex, but a
c++-based flex tokenizer gets its input (as I understand it) from
MyClass::LexerInput. I could define yylex to call LexerInput, but it
looks like I would have to define a global variable of type MyClass
and use it within yylex to make the call to LexerInput for this to
work. Is this true, or have I perhaps misunderstood how the
integration of lex and yacc works? Otherwise, has any version of yacc
or any of its variants been provided with c++ features in the way that
flex has in a way that would enable them to work together without
recourse to such things as global variables? Thanks for any advice you
can provide.

Michael O'Leary

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.