views:

167

answers:

1

Hello, which is the best way to handle multiple flex/bison parsers inside a project? I wrote a parser and now I need a second one in the same project. So far in the third section of parser1.y I inserted the main(..) method and called yyparse from there.

What I want to obtain is having two different parsers (parser1.y and parser2.y) and be able to use them from an external function (let's assume main in main.cpp).

Which precautions should I use to export yyparse functions outside .y files and how should I handle two parsers?

PS. I'm using g++ to compile but not the c++ versions of flex and bison and I would like to keep this way (so avoiding encapsulating the parser inside an object).

Thanks in advance,

Jack

+1  A: 

Note that Bison provides the '-p zz' option to prefix symbols with 'zz' instead of 'yy'.

Similarly, Flex provides the '-P zz' option to prefix symbols with 'zz' instead of 'yy'. It uses '-p' for performance reporting. 'Tis a pity they are not consistent with each other.

Jonathan Leffler