replace sed steps on generated parsers with api.prefix
Creating an issue to more accurately track a discussion stemming out of !1523 (merged)...
Several of the steps that generate lexers/parsers using Flex/Bison run a subsequent sed
step to find-and-replace "yy" with a custom prefix. The purpose of this is to avoid symbol clashes between different generated parsers.
These sed
steps are both fragile and over-eager (they end up replacing "yy" in comments etc), but they are also not necessary. At the time this code was written there was probably no other convenient way of accomplishing this. But today Flex provides %option prefix
and Bison provides %define api.prefix
for this purpose. Moving to these would make the build more robust, remove some unnecessary intermediate files, and take us one step towards dropping sed
as a build dependency.
Quoting my last comment from !1523 (merged):
I attempted this and it results in quite a nice clean up: https://gitlab.com/smattr/graphviz/-/commits/064bf64e-752b-45fc-8da7-e66050fbe8b5. However, the Windows builds fail CI:
Generating Code... Creating library C:/GitLab-Runner/builds/smattr/graphviz/build/lib/cdt/Debug/cdt.lib and object C:/GitLab-Runner/builds/smattr/graphviz/build/lib/cdt/Debug/cdt.exp cdt.vcxproj -> C:\GitLab-Runner\builds\smattr\graphviz\build\lib\cdt\Debug\cdt.dll [BISON][Grammar] Building parser with bison 2.7 grammar.y:14.20-24: error: syntax error, unexpected {...} C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(231,5): error MSB6006: "cmd.exe" exited with code 1. [C:\GitLab-Runner\builds\smattr\graphviz\build\lib\cgraph\cgraph.vcxproj]
This confuses me because this feature was introduced in Bison 2.6 and the version of Bison we're using there claims to be 2.7. The Bison docs indicate there have been no relevant changes to this feature since its introduction. @magjac do you have any guesses at what's going on here?