Skip to content

fix: preserve macro adjacency with the C 2 scanner - #65

Merged
exKAZUu merged 7 commits into
mainfrom
fix/c-macro-adjacency
Oct 6, 2026
Merged

exKAZUu merged 7 commits into
mainfrom
fix/c-macro-adjacency

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Why

Comments between a macro name and ( make the macro object-like, while a line splice alone preserves function-like adjacency. C++ inherits the grammar from C and must adopt the C 2.0.0 scanner contract to distinguish these cases. This is the corresponding C++ repair for WillBooster/tree-sitter-c#40.

Requirements

  • required: Improve all resolvable issues across the requested grammar repositories, checking existing PRs to prevent duplicates and creating a separate PR for each repair worth addressing.
  • required: For each PR, run review-booster, then complete-pr, then release.
  • required: Preserve public C++ node names, fields, parameter ranges, ordinary expression parsing and configured query captures.
  • chosen: Adopt the released C 2.0.0 grammar and its shared scanner helper rather than duplicate adjacency recognition. Port both macro-name recognition and splice-aware parameter scanning because the macro-name token ends before its lookahead splices.
  • chosen: Exercise all four inherited newline splice forms, Unicode and universal-character macro names, pragma extras, recovery outside macro definitions and incremental edits. Keep node types unchanged.
  • chosen: Retain inherited unreachable C single-statement rules in the generated grammar description. The C++ switch override remains compound-only as before this macro repair, and the generator omits all 15 inherited single-statement rules from parser.c and node-types.json. Removing them or enabling unbraced C++ switches is not required for macro adjacency; the latter needs a separate statement/query compatibility repair.

Customer Summary

Comments and whitespace keep C++ macros object-like. Line splices alone preserve function-like parameters, including when an editor adds or removes the separating text.

Technical Summary

Pin C 2.0.0, copy its shared preprocessor headers and wire the inherited macro-name external token into the C++ scanner. Consume splice-only separation before the opening parameter parenthesis. Regenerate the parser while retaining the node schema and C++ scanner features.

Testing

Parser generation, Wasm build and bun run verify pass. The macro-adjacency, corpus, inherited-C and query suites pass; the latest main integration also passes all nine macro-adjacency and typeof tests. Regression coverage includes actual configured C/C++ highlight queries. All checks on c2062c4 pass, including platform, examples, performance and robustness coverage.

exKAZUu and others added 2 commits October 6, 2026 12:19
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
@exKAZUu exKAZUu self-assigned this Oct 6, 2026
exKAZUu and others added 5 commits October 6, 2026 16:08
Integrate current main and regenerate the parser with its conversion fixes.

Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
Use the shared newline scanner for pack-index whitespace and integrate the
fixture-isolated typeof checks from main.

Co-authored-by: WillBooster (Codex CLI) <agent@willbooster.com>
@exKAZUu
exKAZUu merged commit 5bca2e4 into main Oct 6, 2026
10 checks passed
@exKAZUu
exKAZUu deleted the fix/c-macro-adjacency branch October 6, 2026 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant