Skip to content

yacc/bison: grammar rules with no C action block are dropped from the named function list (Mode B brace-slice fallthrough) #2351

Closed

Description

@squid-protocol

Summary

GitGalaxy's yacc/bison named-function extraction silently drops every grammar rule that has no { ... } C semantic action anywhere in its productions. The raw struct_func_start signal counts these rules correctly; they are lost between the raw signal and the named function_data list that reaches consumers.

Root cause

yacc has no ScopeParsingRegistry entry and its lexical_family is standard_block, so detector.py's mode dispatch (gitgalaxy/core/detector.py, ~line 1976) falls through to Mode_B_Braces (_slice_by_braces). A yacc grammar rule only contains a {/} pair when one of its productions carries a C action:

Many_specs:            /* no action anywhere -> Mode B cannot bound a body -> DROPPED */
	Many_specs Spec
	| /* lambda */
	;

System_id:
	Save_id { newopt(&mkopt, ns("KERNEL"), $1, 0, 0); };   /* has an action -> kept */

Rules with no action can't be brace-sliced, so they never make it into function_data.

This is the same bug class as #1899 (abap), #1975 (jcl/m4), and the dockerfile Mode-B fallthrough — a language with no brace-delimited bodies silently routed to Mode_B_Braces.

Reproduction

Corpus: language-crucible/data/yacc/freebsd/config.y (also cobol/gnucobol_internals/parser.y).

file ctags grammar rules GitGalaxy struct_func_start (raw) GitGalaxy function_count (named)
config.y 20 20 11
parser.y (gnucobol) 823 1148 781

The 9 missed rules in config.y are exactly the action-less ones: Configuration, Many_specs, System_parameter_list, Opt_list, NoOpt_list, Mkopt_list, Device_spec, Dev_list, NoDev_list.

Fix

Add "yacc" to the Mode_A_Labels branch in detector.py. Mode A's "greedy to the next func_start match" body heuristic is the correct boundary: grammar rules never nest, so each rule's body runs from its own Name: to the next rule's Name: (or the trailing %%) — exactly like COBOL's label-only paragraphs. .l/.ll/.lpp (lex/flex) share the yacc rule set and are fixed by the same change.

After the fix: config.y 20/20, parser.y 1148/1148 (100% precision — see companion finding on ctags for why 1148 > ctags' 823).

Surfaced by the tri-comparison-ledger-sweep skill validating yacc/function/existence/agree[gitgalaxy]_vs[ctags] (2026-08-27).

Known residual (accepted, not blocking)

Mode A's last matched rule per file greedily absorbs the trailing C epilogue as its "body" (inflated LOC/complexity on that one function), identical to how every other Mode A language behaves at end-of-segment. Existence/precision are unaffected.

Activity

  1. added
    bug
    core-engine
    on Aug 27, 2026
  2. added a commit that references this issue on Aug 29, 2026
  3. added this to the v2.4.9 milestone on Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcore-engine

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions