EOF redefinition (3.5->3.6 error)

Egor Pugin <[email protected]>
Newsgroups gmane.comp.parsers.bison.bugs
Message-ID <CAHtU+mriS3=0QfawsJxyX5fX7+unDcdON26E9Ew=yGJF6gDh8w@mail.gmail.com>
The code:
https://github.com/egorpugin/primitives/blob/master/src/version/src/range.ll#L74

The user macro:
https://github.com/egorpugin/primitives/blob/master/src/templates/include/primitives/helper/bison.h#L342

The error:
/Users/egor/.sw/storage/pkg/d2/69/81cc/src/sdir/src/version/src/range.ll:75:8:
error: no member named 'yy_range' in 'yy_range::parser::token'; did
you mean simply 'yy_range'?

return MAKE(EOQ);

       ^

/Users/egor/.sw/storage/pkg/52/12/6ff0/src/sdir/src/templates/include/primitives/helper/bison.h:342:18:
note: expanded from macro 'MAKE'

#define MAKE(x) {THIS_PARSER2::token::x, {}}

                 ^


The reason:
At the end of bison generated header there is
#undef EOQ
#define EOQ yy_range::parser::token::EOQ

Possible solutions for me:
1) #undef EOQ in flex file again (after bison undef)
2) Rewrite line from return MAKE(EOQ); to return EOQ;

The problem is that I have bison 3.5 on some systems and 3.6 on others.

Another solution I see is to put solution #2 under condition (#ifdef)
for bison 3.5 and 3.6, but it seems we do not have bison version macro
- this would be really useful.

Example from protobuf:
https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/any.pb.h#L11

So, we might have something generated in generated header/source files like
#define BISON_VERSION 30500 // 3.5.0
or
#define BISON_VERSION 30601 // 3.6.1

-- 
Egor Pugin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.