Menu

Commit [r13022]  Maximize  Restore  History

4glc: build the keyword state table from bison --xml, keep y.output as fallback

The per-state "which tokens can the parser accept here" table was scraped out
of bison's y.output, which is a human-readable report rather than an interface
- hence the %empty stripping, the dot-position scanning and the per-version
format workarounds, and hence a failure mode where a format change yields a
well-formed but wrong table and keywords silently become identifiers.

bison's --xml report carries exactly the same information, including the
<lookaheads> sets that are the whole reason y.output was needed in the first
place (the parser's own yypact/yycheck/yytable cannot supply them - see the
comment at the top of mk_states_c.in). It is one element per line, so it is
read with anchored patterns instead of prose parsing.

--xml is not in every bison and passing -x to one without it is fatal, so
configure now checks and sets BISON_XML_FLAG, which reaches the bison command
line as YACC_XML. mk_states_c uses the XML only if bison actually produced
one, and otherwise takes the original y.output route, which is preserved
unchanged. The two routes were run against each other on this grammar and
produce byte identical output, so the fallback is a real equivalent rather
than a degraded mode.

The script is now two small extractors - one for XML, one for y.output -
feeding a shared emitter over a flat "S <state> / T <token>" stream, so the
table building logic exists once.

Also made the group dedup deterministic. The key was built by "for (a in arr)",
whose order is unspecified, so the same set of tokens could produce different
key strings between runs: states that should have shared a group got separate
ones, and the generated file was not reproducible. Sorting the key first drops
the group count from 607 to 578 and makes repeated runs byte identical.

Verified: both routes produce the same mk_states.c, full build clean, and the
aubit4gltest run (-esqli -tui, all 21 ranges) is unchanged at 1098 run with
test 1413 still fixed. Test 706 shows up in this run and not the last, but it
passes on its own on both builds - it is flaky in batch, and the generated
table here is byte identical so parser behaviour cannot have changed.

mikeaubury 2026-08-31

changed /aubit4glsrc/trunk/compilers/4glc/mk_states_c.in
changed /aubit4glsrc/trunk/compilers/4glc/rules/Makefile.in
changed /aubit4glsrc/trunk/configure
changed /aubit4glsrc/trunk/incl/Makefile-common.in
changed /aubit4glsrc/trunk/m4/aubit_tools.m4
/aubit4glsrc/trunk/compilers/4glc/mk_states_c.in Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/compilers/4glc/rules/Makefile.in Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/configure Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/incl/Makefile-common.in Diff Switch to side-by-side view
Loading...
/aubit4glsrc/trunk/m4/aubit_tools.m4 Diff Switch to side-by-side view
Loading...