Re: Visual Studio - win_bison creates tab.h file exceeding compiler limits

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.bugs
Message-ID <[email protected]>
Hi!

> Le 9 nov. 2020 à 13:08, Jot Dot <[email protected]> a écrit :
> 
> bison generates the tab.h file using YY_ASSERT macros in many places. 
> bison is generating lines longer than the microsoft compiler allows, which causes a C2026 error. (Line exceeds 16380 bytes). 

Bummer.  My bad, I had not anticipated this.

> I am starting to write a SQL parser.

Sounds fun ;)


> bison is generating asserts to check for valid tokens but a couple lines are over 21700 bytes long. 
> Since the compiler truncates the line,

:facepalm:

> any YY_ASSERT() macro fails because the line is simply snipped. Thus it does not even encounter the trailing ')'. Naturally the compiler spits out gibberish at this point.

Always fun to workaround limitations.

> Although I've known about lex/yacc and flex/bison for years, this is my first real attempt to use it. This means I could be doing something "non-standard". 

Nope, AFAICT, you're on the right tracks.  Wrong compiler though.

> But my work so far was working with the standard C generation method. It is only now, converting it to C++, did I encounter this. 
> 
> It's easy enough to build, manually comment out the offending line, and then build again, but this is getting to be time consuming and highly annoying. 
> Any fix or ideas would be greatly appreciated.

I'll have to find something better than this long list, but it's going to take a bit of time.

Meanwhile, I recommend that you locate the file data/skeletons/variant.hh, and change:

      {
        YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);
      }

into

      {]b4_parse_assert_if([[
        YY_ASSERT (]m4_join([ || ], m4_map_sep([_b4_type_clause], [, ], [$@]))[);]])[
      }

twice.

That should eliminate the problem locally until we have something standard.

Could you please confirm it works as expected?  (don't use %define parse.assert).

Cheers!
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.