2
votes

I am writing a parser and I want it to be as portable as possible.

Right now I am using GNU bison to generate my parser but I am not sure if my code is relying on yacc extensions that are not fully portable.

So I would like to know features GNU bison has that the original yacc is missing.

The reason I get worried is because I noticed that my parser failed to compile on Windows using a bison port. I would sacrifice GNU bison features and stick with the original standardized yacc if it would make my parser easier to port between different platforms.

So what are the differences between GNU bison and the original standard yacc? What features should I avoid when using GNU bison if I want my program to be as portable as possible?

1
Didn't you ask this question recently? And get some comments?user207421
Yes but it was not exactly the same. I decided to delete the other question because it was very confusing and I did not know very well what I was talking about at that time. That other question was also asking for why a specific program failed to compile when what I really wanted to know what I could do to make it as portable as possible.wefwefa3

1 Answers

5
votes

Usually the way you distribute a bison-generated parser is to distribute the generated parser. That means that neither bison nor yacc even needs to be installed on the target machine, and allows you to freely chose the version of bison you are comfortable with and use its features. (The bison input file will also be in the distribution, of course; including the bison output files simply means that bison does not need to be run to compile the code.)

If you want to verify that your parser description is compatible with yacc, you could try using the --yacc flag when you generate the parser. That will make bison attempt to mimic yacc, although it doesn't prevent you from asking for features which are clearly well out of yacc's scope, like %glr-parser or Java/C++ output. But frankly, I think you would be better off with the strategy outlined in the first paragraph.

If you want to get a list of bison features which are not in yacc, you could start by searching for the word yacc in the bison manual. Or you could read the Posix yacc documentation.