Boost logo

Boost :

From: scleary_at_[hidden]
Date: 2001-04-09 07:49:53


> I don't know how to setup flex/bison to make it possible to create two
> parser instances without having multiply defined symbols. If anyone knows
> how to do this, I'm all ears.

Note that the following information is from a book, "Lex and Yacc", by
Levine et. al., 1990/1992 (1995 printing). I've never actually used these
techniques:

Multiple parsers: bison supports the "-p" flag, which changes the prefixes,
and causes other variables used internally by the parser to be either
renamed or made static/auto. Also with bison, you can put %pure_parser in
the definition section -- this will create a reentrant parser (no global
vars), but the interface to yylex(), etc. is different -- see the docs.

Multiple lexers: I'd check to see if flex supports something like Bison
does, above. It did *not* as of the writing of this book, but this book is
old :). The authors recommend either a sed script for changing the names
(called from the makefile), or a bunch of preprocessor #define's at the
beginning of the grammar:
%{
  #define yylex xyzlex
  ...
%}
(This book also lists all variables that need to be renamed for flex 2.3.7)

Hope this helps...

        -Steve


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk