Skip to content

audit: bison review & fixes#36

Merged
theodevelop merged 4 commits intodevfrom
audit/bison-review
Apr 2, 2026
Merged

audit: bison review & fixes#36
theodevelop merged 4 commits intodevfrom
audit/bison-review

Conversation

@theodevelop
Copy link
Copy Markdown
Owner

Type of change

  • Bug fix

What does this PR do?

Two bugs found during a proactive audit of bisonParser.ts, analogous to the Flex audit in #35.

audit-E — uppercase-only regex in %left/%right/%nonassoc parsing
[A-Z_][A-Z0-9_]* in bisonParser.ts:169 silently dropped lowercase/mixed-case
tokens (e.g. kPLUS, kMINUS, tTOKEN) from doc.precedence. These tokens
were then falsely reported as bison/undeclared-token (or missed by the
shift/reduce heuristic). Fixed to [A-Za-z_][A-Za-z0-9_]*.

audit-F — [^}]* in extractDollarRefs misses $N after nested sub-blocks
/\{([^}]*)\}/g stops at the first }, so a $N reference appearing after
a nested { ... } block inside the same action (e.g.
{ if (cond) { log(); } $$ = $5; }) was not detected, producing a false
negative for bison/out-of-bounds. Rewrote extractDollarRefs with a
brace-depth scanner. Added removeBalancedBraces() helper and applied it to
extractSymbols, getFirstSymbol, and extractRuleReferences for consistency.

Related issue

No dedicated issue — found during internal audit.

How to test manually

  1. Open a .y file with %left kPLUS kMINUS (lowercase tokens) — no false
    bison/undeclared-token should appear for kPLUS/kMINUS.
  2. Write a rule with an action like A { if (1) { int x = 0; } $$ = $5; }
    $5 should be flagged as out-of-bounds (1 symbol + 1 action = 2 positions).

Checklist

  • npm run compile passes with no new errors
  • Tests added or updated — 2 new assertions in tests/test-diagnostic-codes.ts (196 total, 0 failed)
  • Manual test done in VS Code
  • CHANGELOG.md updated
  • No unintended files staged

@theodevelop theodevelop self-assigned this Apr 2, 2026
@theodevelop theodevelop added the bug Something isn't working label Apr 2, 2026
@theodevelop theodevelop merged commit 2cd1c07 into dev Apr 2, 2026
1 check passed
@theodevelop theodevelop deleted the audit/bison-review branch April 2, 2026 22:04
@theodevelop theodevelop mentioned this pull request Apr 2, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant