Mark Lakata
Mark Lakata

Reputation: 20904

multiple parsers using C++ api in bison, conflicts with stack.hh

When you run bison, it creates a stack class for you in "stack.hh". The file name is fixed, but the contents are wrapped in a namespace of your choosing.

If you use bison to generate 2 separate grammars (ie 2 *.y files) and you use the C++ mode, the "stack.hh" files conflict and get overwritten.

A similar thing happens for the "location.hh" and "position.hh" classes that are autogenerated, but there is a work around in bison 2.7

%define api.location.type "foo::location"

that lets you reuse the foo grammar namespace in your bar grammar namespace.

But I can't find anyway of doing this exercise when dealing with the "stack.hh" file.

Upvotes: 1

Views: 414

Answers (1)

Chris Hayden
Chris Hayden

Reputation: 1144

The easiest way to deal with this is just to put the Bison files in two separate directories. Then when you generate the code the files will not conflict, assuming each set of files gets generated in the same location as the corresponding Bison file.

Upvotes: 2

Related Questions