Repository navigation
Simplify grammar by factoring duplicated rule shapes - #3858
Conversation
DRY cleanup of typescript2/pkg-grammar/src/baml.ts. The emitted grammar is byte-identical: baml.tmLanguage.json, its app-vscode-ext mirror, and all 79 snapshots are unchanged. - CALL_ARGS_LOOKAHEAD const for the call `(?=...<...>...\()` lookahead that was hand-copied at three call begins - memberCall / memberAccess factories for the four near-identical optional / postfix method-call and field-access rules (differ only by the `?.` vs `[.$]` accessor) - isPatternRule factory for the two `is`-expression variants - keywordStatement factory for return / break / continue / defer / watch - interpolationKeyword factory for the backtick else / endfor / endif controls - delete the dead `block` const (never referenced, never emitted) This removes repetition rather than lines (the grammar was already slimmed): a future change to e.g. the call lookahead now touches one site instead of three.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe BAML TextMate grammar consolidates repeated rule definitions into shared helpers for member calls and access, ChangesBAML grammar helper refactors
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
⏭️ Performance benchmarks were skippedPerf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to To run them on this PR, do any of the following, then push a commit (or re-run CI):
|
DRY cleanup of
typescript2/pkg-grammar/src/baml.ts— no behavior change.Byte-identical output.
baml.tmLanguage.json, its app-vscode-ext mirror, and all 79 grammar snapshots are unchanged. Verified: the distinct begin/end/match regex set and the scope set are identical, and the repository entry count is unchanged (255). Onlysrc/baml.tsdiffers.What changed (all in
src/baml.ts):CALL_ARGS_LOOKAHEADconst for the(?=\s*(?:<…>\s*)?\()call lookahead that was hand-copied at three call beginsmemberCall/memberAccessfactories for the four near-identical optional/postfix method-call and field-access rules (they differ only by the?.vs[.$]accessor)isPatternRulefactory for the twois-expression variantskeywordStatementfactory for return / break / continue / defer / watchinterpolationKeywordfactory for the backtick else / endfor / endif controlsblockconst (never referenced, never emitted)Note: this is a de-duplication refactor, not a line reduction — the grammar was already slimmed, so the factory definitions roughly offset the call-site savings (net +21 lines). The value is one-source-of-truth: a future change to e.g. the call lookahead now touches one site instead of three.
Based on canary (the grammar from #3843 is merged).
Summary by CodeRabbit