]> git.draconx.ca Git - cdecl99.git/commit
libcdecl: Replace yytname array in the Bison parser.
authorNick Bowler <nbowler@draconx.ca>
Fri, 7 Jul 2023 02:46:20 +0000 (22:46 -0400)
committerNick Bowler <nbowler@draconx.ca>
Fri, 7 Jul 2023 04:18:57 +0000 (00:18 -0400)
commitaf1f874c4c58d0bd8becd52c892d0b358d08736e
tree59903b8b10d8e4f199a3ce28d51af0111cb0a937
parenta0629a04f4fc6093900c9e4703e440d6b0ba24ad
libcdecl: Replace yytname array in the Bison parser.

Bison generates a list of symbol names as a static array of char pointers
initialized with string literals, which is simply horrible.  These pointers
are two to four times larger than necessary, but with position-independent
code this also forces them into an unshareable, writeable segment since
they are not compile-time constants and must be initialized by the dynamic
loader at runtime.

Furthermore, the names of nonterminal symbols are always included but they
are not always needed; they should only be output by tracing code which
is disabled by default at compile time.

Fix this by adding a new build script which postprocesses the output,
replacing the yytname array with a function implementing the same lookup
with truly constant tables.  Inclusion of nonterminals is now conditional
on YYDEBUG.

This is a big win, reducing the overall library size about 5 to 10 percent
(64-bit hosts see the most improvement).
Makefile.am
src/fix-yytname.awk [new file with mode: 0755]