Skip to content

Add BAML grammar source and snapshots - #3843

Merged
codeshaunted merged 4 commits into
canaryfrom
avery/grammar
Jun 26, 2026
Merged

codeshaunted merged 4 commits into
canaryfrom
avery/grammar

Conversation

@codeshaunted

@codeshaunted codeshaunted commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add typed source generation for BAML/Jinja TextMate grammars
  • add BAML grammar snapshot fixtures/tests and preview UI
  • add CI coverage for pkg-grammar snapshot tests
  • sync generated grammars into the VS Code extension mirror

Testing

  • pnpm --filter @b/pkg-grammar test

Summary by CodeRabbit

  • New Features
    • Added an in-browser BAML grammar snapshot preview tool with fixture browsing, current-vs-saved comparison, and one-click snapshot acceptance.
  • Bug Fixes
    • Updated the VS Code extension and CI syncing to ship only the main BAML grammar (removed Jinja grammar contributions and drift detection).
    • Added dedicated grammar snapshot tests that run only when relevant changes occur.
  • Documentation
    • Updated grammar authoring docs to be TypeScript-first, clarifying the new build/sync flow and generated artifacts.

@vercel

vercel Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
app-website-waronslop Error Error Jun 26, 2026 6:56pm
beps Ready Ready Preview, Comment Jun 26, 2026 6:56pm
promptfiddle Ready Ready Preview, Comment Jun 26, 2026 6:56pm
promptfiddle2 Ready Ready Preview, Comment Jun 26, 2026 6:56pm

Request Review

@coderabbitai

coderabbitai Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR adds TypeScript-based grammar generation, a browser preview for grammar snapshots, fixture-driven snapshot tests, updated BAML examples, and CI gating that runs grammar tests when grammar-related paths change.

Changes

Grammar authoring, preview, and validation

Layer / File(s) Summary
CI and package wiring
.github/workflows/ci.yaml, typescript2/pkg-grammar/package.json, typescript2/pkg-grammar/tsconfig.json, typescript2/pkg-grammar/scripts/sync.mjs, typescript2/pkg-grammar/README.md, typescript2/app-vscode-ext/package.json, typescript2/pkg-editor/src/MonacoEditor.tsx
Adds grammar change detection, a conditional grammar-tests job, package scripts and TypeScript config for the grammar package, and removes Jinja grammar wiring from the extension and editor setup.
Grammar source and generation
typescript2/pkg-grammar/src/baml.ts, typescript2/pkg-grammar/scripts/build.ts
Adds the TypeScript-authored BAML TextMate grammar and the build script that emits the generated grammar JSON.
Snapshot preview UI
typescript2/pkg-grammar/preview/index.html, typescript2/pkg-grammar/preview/main.ts, typescript2/pkg-grammar/vite.config.ts, typescript2/pkg-grammar/vitest.config.ts, typescript2/pkg-grammar/preview/sample.baml
Adds the browser preview page, token diff rendering, snapshot acceptance flow, Vite endpoints, Vitest configuration, and the sample BAML file used by the preview.
Grammar fixtures and snapshots I
typescript2/pkg-grammar/tests/fixtures/ns_*, typescript2/pkg-grammar/tests/snapshots/ns_*, typescript2/pkg-grammar/tests/fixtures/generators.baml, typescript2/pkg-grammar/tests/snapshots/generators.baml.scope.txt
Adds agent, ANSI, build, demo, game, image, sentiment, and server fixtures plus their scope snapshots and the generator example.
Grammar fixtures and snapshots II
typescript2/pkg-grammar/tests/grammar-snapshots.test.ts, typescript2/pkg-grammar/tests/fixtures/baml_tests__*, typescript2/pkg-grammar/tests/snapshots/baml_tests__*, typescript2/pkg-grammar/tests/fixtures/lsp_*
Adds the grammar snapshot test harness and the large set of parser, pattern, iterator, semantic, LSP, and optional-chaining fixtures plus their stored scope snapshots.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

  • BoundaryML/baml#3463: This PR also updates the BAML TextMate grammar and related syntax coverage.
  • BoundaryML/baml#3496: This PR also changes CI change-detection and job gating in .github/workflows/ci.yaml.
  • BoundaryML/baml#3797: This PR also touches the grammar assets and snapshot-based syntax coverage for BAML backtick interpolation.

Suggested reviewers

  • imalsogreg

Poem

🐇 I hopped through scopes by lantern-light,
And snapshot panes danced left and right.
The grammar seeds grew neat and green,
While CI watched the whole scene.
A tidy build! A carrot-bright delight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding BAML grammar sources and snapshots.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch avery/grammar

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.23.0)
typescript2/app-vscode-ext/syntaxes/baml.tmLanguage.json

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

[00.13][ERROR]: unable to find a config; path .coderabbit-opengrep-fallback.yml does not exist

typescript2/pkg-grammar/baml.tmLanguage.json

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

[00.12][ERROR]: unable to find a config; path .coderabbit-opengrep-fallback.yml does not exist

typescript2/pkg-grammar/src/baml.ts

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

[00.17][ERROR]: unable to find a config; path .coderabbit-opengrep-fallback.yml does not exist


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 June 25, 2026 03:41 Inactive
@github-actions

Copy link
Copy Markdown

No description provided.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 14

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/ci.yaml:
- Around line 214-224: The grammar change detector in the check_grammar step is
missing the shared setup action path used by grammar-tests, so changes to that
action can bypass the grammar gate. Update the git diff paths in the
check_grammar logic to include .github/actions/setup-node2 (or make that action
part of the same condition) so grammar tests are marked when the shared setup
changes.
- Around line 496-499: The Checkout Branch step in the workflow uses the mutable
useblacksmith/checkout@v1 tag, which should be pinned to an immutable commit
SHA. Update the action reference in the grammar-tests job to a specific commit
for useblacksmith/checkout while keeping the existing with settings unchanged,
so the workflow remains stable if the tag is retargeted.

In `@typescript2/pkg-grammar/preview/main.ts`:
- Around line 753-765: Require a modifier key before triggering snapshot
acceptance in the global keydown handler. In window.addEventListener("keydown")
inside main.ts, update the acceptCurrentSnapshot shortcut so plain Enter and
Space no longer submit from most elements; gate the action behind a modifier
like Ctrl/Cmd (and keep the existing exclusions for HTMLButtonElement,
HTMLAnchorElement, and HTMLSelectElement). Ensure the isAcceptKey logic in the
keydown callback only calls preventDefault() and acceptCurrentSnapshot() when
the modifier is held.
- Around line 589-613: The loadFixture flow can apply an out-of-date
getFixture(name) result after the user has already switched fixtures, which can
overwrite source, savedSnapshot, and savedTokens for the wrong selection. In
loadFixture, capture the requested fixture name and, after awaiting getFixture,
verify it still matches selectedFixture before mutating state or calling
renderCurrentGrammar, renderPanes, updateInspect, or scroll syncing. If the
request is stale, return early so only the latest fixture selection updates the
UI and snapshot state.

In `@typescript2/pkg-grammar/src/baml.ts`:
- Around line 221-243: The prompt string path still treats backtick bodies as
plain string content instead of using the Jinja sub-grammar, so wire the prompt
template handling to include the Jinja scope. Update the backtick string rule
setup in backtickStringRules/backtickStringLiteral and the prompt value routing
that currently goes through expression so that prompt templates resolve to
source.baml-jinja, matching the grammar registered in jinja.ts and
preview/main.ts.

In `@typescript2/pkg-grammar/src/jinja.ts`:
- Around line 9-14: The jinja Grammar is currently being emitted as an empty
no-op stub, which removes standalone source.baml-jinja tokenization and breaks
the generated tmLanguage outputs. Restore the real Jinja grammar in the jinja
constant by keeping the existing patterns and rules instead of patterns: [] so
that both jinja.tmLanguage.json artifacts preserve the previous highlighting
behavior.

In `@typescript2/pkg-grammar/tests/fixtures/ns_agent__agent.baml`:
- Around line 281-291: The cancel/interrupt path in interrupt_turn and the
run_turn flow is discarding tool steps that were already applied, so the
returned Turn can be out of sync with the workspace. Update the cancellation
handling so it preserves any already-recorded [THOUGHT]/[ACTION]/[RESULT]
entries from the spawned future instead of rebuilding solely from the original
history, and make sure the final transcript returned by run_turn reflects
successful tool calls like write_file, edit_file, and run_bash before
cancellation.
- Around line 104-114: The `tool_edit_file` helper currently accepts an empty
`old_str`, which allows malformed edit requests to pass through and can corrupt
the target file. Add an explicit guard in `tool_edit_file` to reject empty or
missing `old_str` before calling `baml.fs.read`/`replace`, and return the same
style of error used for invalid inputs. Also update `execute()` where
`step.old_str` is normalized so it does not silently convert a missing value to
an empty string for `tool_edit_file`, and apply the same validation to the
related edit flow referenced by the other affected block.

In `@typescript2/pkg-grammar/tests/fixtures/ns_demo__demo.baml`:
- Around line 55-60: The retry helper currently exits on the first successful
fn() call but does not handle thrown failures, so it never actually retries.
Update the retry<T> function to catch exceptions inside the loop, continue to
the next attempt on failure, and only return after a successful fn() result; if
all attempts fail, keep the existing throw at the end. Use the retry function
and demo() in ns_demo__demo.baml as the main locations to adjust the control
flow.

In `@typescript2/pkg-grammar/tests/fixtures/ns_sentiment__eval.baml`:
- Around line 91-96: The case name helper still passes a potentially non-copied
string into slug when c.text is 40 characters or shorter, so the dynamic test
discovery workaround is incomplete. Update case_name to force an actual copy of
c.text before slugging it, using the existing case_name helper logic and the
c.text substring path so short inputs do not reuse the original buffer.

In `@typescript2/pkg-grammar/tests/fixtures/ns_server__server.baml`:
- Around line 37-43: The read failure path in handle currently logs and leaves
raw null, but the code still reaches the summarize_request(raw.to_string()) call
afterward. Update the sock.read() catch_all arm in handle so it exits the
function immediately (or otherwise skips the remaining logic) after logging the
failure, using the existing raw/summarize_request flow to locate the fix.

In `@typescript2/pkg-grammar/tests/grammar-snapshots.test.ts`:
- Around line 20-21: The snapshot tests are building `snapshotsDir` but
`toMatchFileSnapshot()` is still given relative paths, so the written snapshots
may not land in the managed directory. Update the snapshot assertions in
`grammar-snapshots.test.ts` to use the existing `snapshotsDir` path when
constructing the snapshot file location, and apply the same change wherever
`toMatchFileSnapshot()` is called so all writes resolve consistently through
`snapshotsDir`.

In `@typescript2/pkg-grammar/tests/snapshots/ns_build__build.baml.scope.txt`:
- Around line 171-178: The snapshot is currently reflecting incorrect
tokenization of the comparison operator in the grammar. Update the BAML grammar
rule that handles operators so the `!=` sequence is matched as a single
comparison token instead of separate `!` and `=` tokens, using the relevant
operator/matching rule in the grammar that affects `res.exit_code != 0`, then
regenerate the affected snapshot.

In `@typescript2/pkg-grammar/vite.config.ts`:
- Around line 16-24: The regenerate-baml-grammar plugin’s build() helper
currently catches and swallows rebuild failures, which lets Vite continue
running with stale generated JSON. Update build() and the buildStart hook in
vite.config.ts so a failed run("pnpm exec tsx scripts/build.ts", …) is surfaced
by rethrowing or rejecting after logging, ensuring startup and watch-triggered
rebuilds stop instead of continuing silently.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 7d1df2c3-8077-465b-88a0-740e20b2697a

📥 Commits

Reviewing files that changed from the base of the PR and between 0d03bfa and f4ecca1.

⛔ Files ignored due to path filters (1)
  • typescript2/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (48)
  • .github/workflows/ci.yaml
  • typescript2/app-vscode-ext/package.json
  • typescript2/app-vscode-ext/syntaxes/baml.tmLanguage.json
  • typescript2/app-vscode-ext/syntaxes/jinja.tmLanguage.json
  • typescript2/pkg-grammar/README.md
  • typescript2/pkg-grammar/baml.tmLanguage.json
  • typescript2/pkg-grammar/jinja.tmLanguage.json
  • typescript2/pkg-grammar/package.json
  • typescript2/pkg-grammar/preview/index.html
  • typescript2/pkg-grammar/preview/main.ts
  • typescript2/pkg-grammar/preview/sample.baml
  • typescript2/pkg-grammar/scripts/build.ts
  • typescript2/pkg-grammar/src/baml.ts
  • typescript2/pkg-grammar/src/jinja.ts
  • typescript2/pkg-grammar/tests/fixtures/generators.baml
  • typescript2/pkg-grammar/tests/fixtures/match_patterns.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_agent__agent.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_agent__clients.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_agent__tests.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_ansi__ansi.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_build__build.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_demo__demo.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_game__clients.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_game__game.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_images__pipeline.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_sentiment__eval.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_sentiment__sentiment.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_sentiment__tests.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_server__server.baml
  • typescript2/pkg-grammar/tests/grammar-snapshots.test.ts
  • typescript2/pkg-grammar/tests/snapshots/generators.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/match_patterns.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_agent__agent.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_agent__clients.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_agent__tests.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_ansi__ansi.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_build__build.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_demo__demo.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_game__clients.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_game__game.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_images__pipeline.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_sentiment__eval.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_sentiment__sentiment.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_sentiment__tests.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_server__server.baml.scope.txt
  • typescript2/pkg-grammar/tsconfig.json
  • typescript2/pkg-grammar/vite.config.ts
  • typescript2/pkg-grammar/vitest.config.ts

Comment thread .github/workflows/ci.yaml Resolved
Comment thread .github/workflows/ci.yaml Resolved
Comment thread typescript2/pkg-grammar/preview/main.ts Resolved
Comment thread typescript2/pkg-grammar/preview/main.ts Resolved
Comment thread typescript2/pkg-grammar/src/baml.ts Resolved
Comment thread typescript2/pkg-grammar/vite.config.ts Resolved
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle June 25, 2026 03:52 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps June 25, 2026 04:48 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 June 25, 2026 04:54 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@typescript2/pkg-grammar/preview/main.ts`:
- Around line 727-747: Capture the currently selected fixture identity and
related state at the start of acceptCurrentSnapshot before the await, then use
that saved identity when updating savedSnapshot, fixtureCache, savedTokens,
renderPanes, updateComparison, updateInspect, and setFixtureSummary. The issue
is that selectedFixture, source, and currentSnapshot can change while
fetchJson("/__grammar/snapshot") is in flight, so the UI and cache may be
updated for the wrong fixture; fix it by basing the post-POST updates on the
snapshot/fixture that was originally accepted rather than the current globals.
- Around line 593-605: The fixture-switch path in main.ts updates saved state
but does not actually reset the UI scroll position after loading a new fixture.
In the flow around getFixture(), selectedFixture, and renderCurrentGrammar(),
apply the same top-of-file reset to the panes when !restoringState and the
fixture changes, so the rendered view matches the persisted scrollTop/scrollLeft
state. Make the reset happen in the fixture loading/rendering path, not just in
writeState.

In `@typescript2/pkg-grammar/vite.config.ts`:
- Around line 26-31: The watcher in configureServer currently rebuilds only on
"change" events, so new or deleted files under src are missed. Update the
server.watcher handler to also trigger build() on "add" and "unlink" for files
under srcDir, keeping the same srcDir prefix check so grammar regeneration stays
automatic when source files are created or removed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 55c0a1b1-9642-4a6d-9c43-f2c3aed67681

📥 Commits

Reviewing files that changed from the base of the PR and between f4ecca1 and eb94b3b.

⛔ Files ignored due to path filters (1)
  • typescript2/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (45)
  • .github/workflows/ci.yaml
  • typescript2/app-vscode-ext/package.json
  • typescript2/app-vscode-ext/syntaxes/baml.tmLanguage.json
  • typescript2/pkg-grammar/README.md
  • typescript2/pkg-grammar/baml.tmLanguage.json
  • typescript2/pkg-grammar/package.json
  • typescript2/pkg-grammar/preview/index.html
  • typescript2/pkg-grammar/preview/main.ts
  • typescript2/pkg-grammar/preview/sample.baml
  • typescript2/pkg-grammar/scripts/build.ts
  • typescript2/pkg-grammar/src/baml.ts
  • typescript2/pkg-grammar/tests/fixtures/generators.baml
  • typescript2/pkg-grammar/tests/fixtures/match_patterns.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_agent__agent.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_agent__clients.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_agent__tests.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_ansi__ansi.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_build__build.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_demo__demo.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_game__clients.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_game__game.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_images__pipeline.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_sentiment__eval.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_sentiment__sentiment.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_sentiment__tests.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_server__server.baml
  • typescript2/pkg-grammar/tests/grammar-snapshots.test.ts
  • typescript2/pkg-grammar/tests/snapshots/generators.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/match_patterns.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_agent__agent.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_agent__clients.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_agent__tests.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_ansi__ansi.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_build__build.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_demo__demo.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_game__clients.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_game__game.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_images__pipeline.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_sentiment__eval.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_sentiment__sentiment.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_sentiment__tests.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_server__server.baml.scope.txt
  • typescript2/pkg-grammar/tsconfig.json
  • typescript2/pkg-grammar/vite.config.ts
  • typescript2/pkg-grammar/vitest.config.ts
✅ Files skipped from review due to trivial changes (13)
  • typescript2/pkg-grammar/tsconfig.json
  • typescript2/pkg-grammar/vitest.config.ts
  • typescript2/pkg-grammar/tests/snapshots/ns_agent__clients.baml.scope.txt
  • typescript2/pkg-grammar/tests/fixtures/ns_agent__clients.baml
  • typescript2/pkg-grammar/preview/sample.baml
  • typescript2/pkg-grammar/tests/snapshots/generators.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_sentiment__sentiment.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_server__server.baml.scope.txt
  • typescript2/pkg-grammar/tests/fixtures/generators.baml
  • typescript2/pkg-grammar/tests/snapshots/ns_game__clients.baml.scope.txt
  • typescript2/pkg-grammar/README.md
  • typescript2/pkg-grammar/tests/snapshots/ns_images__pipeline.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_demo__demo.baml.scope.txt
🚧 Files skipped from review as they are similar to previous changes (17)
  • typescript2/app-vscode-ext/package.json
  • typescript2/pkg-grammar/tests/fixtures/ns_images__pipeline.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_sentiment__sentiment.baml
  • typescript2/pkg-grammar/package.json
  • typescript2/pkg-grammar/preview/index.html
  • typescript2/pkg-grammar/tests/fixtures/ns_server__server.baml
  • typescript2/pkg-grammar/tests/grammar-snapshots.test.ts
  • typescript2/pkg-grammar/tests/fixtures/ns_sentiment__tests.baml
  • typescript2/pkg-grammar/tests/fixtures/match_patterns.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_game__clients.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_sentiment__eval.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_ansi__ansi.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_build__build.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_agent__agent.baml
  • typescript2/pkg-grammar/src/baml.ts
  • typescript2/pkg-grammar/tests/fixtures/ns_game__game.baml
  • typescript2/pkg-grammar/tests/fixtures/ns_agent__tests.baml

Comment thread typescript2/pkg-grammar/preview/main.ts Resolved
Comment thread typescript2/pkg-grammar/preview/main.ts Resolved
Comment thread typescript2/pkg-grammar/vite.config.ts Resolved
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle June 25, 2026 05:05 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps June 25, 2026 23:51 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 June 25, 2026 23:57 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
typescript2/pkg-grammar/src/baml.ts (2)

1479-1495: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Tokenize the assigned expression in if let/while let headers.

The generated snapshot still leaves the RHS plain in if const narrowed: int = value and while const loop_value: int = value. The header grammar is claiming the binding part but not handing the post-= segment to conditionExpression, so identifiers/operators on that side lose their normal scopes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@typescript2/pkg-grammar/src/baml.ts` around lines 1479 - 1495, The
`ifExpression.patterns` handling for `if let`/`while let` headers only scopes
the binding and assignment operator, so the RHS after `=` is not tokenized.
Update the grammar in `baml.ts` so the post-`=` segment is delegated to
`conditionExpression` (or the existing header expression rule used by
`ifConditionPattern`) for the `if-let-pattern` case, ensuring identifiers and
operators in the assigned expression get normal scopes in both `if const
narrowed: int = value` and `while const loop_value: int = value`.

1396-1433: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Treat bare array-destructure elements as bindings, not type references.

const [first] = xs; is still emitted as entity.name.type.baml in baml_tests__const_let_else_defer.baml.scope.txt, so the array-pattern body is letting a plain identifier fall through to typeExpression instead of claiming it as a binding. That makes ordinary destructures look like type annotations.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@typescript2/pkg-grammar/src/baml.ts` around lines 1396 - 1433, The array
destructuring pattern in baml.ts is letting bare identifiers inside the array
body fall through to typeExpression, so plain elements like first are being
scoped as type references instead of bindings. Update arrayDestructurePattern
and its nested patterns so a bare element is matched as a binding token before
typeExpression applies, using the existing binding patterns (such as
bareBindingPattern / wildcardBindingPattern) to claim identifiers inside the
array-destructure body.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@typescript2/pkg-grammar/scripts/sync.mjs`:
- Line 24: The GRAMMARS list in sync.mjs was narrowed to only BAML, which
removes the generated Jinja grammar from the sync/validation flow. Update the
sync set in GRAMMARS to include the Jinja grammar alongside baml.tmLanguage.json
so the sync/check logic in sync.mjs continues to refresh and validate both
package mirrors and keeps app-vscode-ext aligned with pkg-grammar.

In `@typescript2/pkg-grammar/src/baml.ts`:
- Around line 2774-2780: The interface body grammar is missing
`interfaceFieldLink`, so linked fields like `foo as bar` are not parsed inside
`interface { ... }` even though the symbol is already defined. Update the
`patterns` list in the interface body rule to include `interfaceFieldLink`
alongside `comments`, `interfaceMethodSignature`, `functionItem`,
`associatedTypeItem`, `field`, and `semicolon`, mirroring how the construct is
handled in `implements` blocks.

In
`@typescript2/pkg-grammar/tests/snapshots/baml_tests__generic_field_chain.baml.scope.txt`:
- Around line 49-54: The nested generic delimiters in the snapshot are using the
wrong token scopes, causing asymmetric highlighting for `Box<Box<User>>`. Update
the expected scopes in the `baml_tests__generic_field_chain.baml.scope.txt`
snapshot so the inner generic’s angle brackets use the same
`punctuation.definition.type-arguments.begin.baml` and
`punctuation.definition.type-arguments.end.baml` scopes as the outer `Box<...>`
instead of falling back to `punctuation.definition.type.baml`.

---

Outside diff comments:
In `@typescript2/pkg-grammar/src/baml.ts`:
- Around line 1479-1495: The `ifExpression.patterns` handling for `if
let`/`while let` headers only scopes the binding and assignment operator, so the
RHS after `=` is not tokenized. Update the grammar in `baml.ts` so the post-`=`
segment is delegated to `conditionExpression` (or the existing header expression
rule used by `ifConditionPattern`) for the `if-let-pattern` case, ensuring
identifiers and operators in the assigned expression get normal scopes in both
`if const narrowed: int = value` and `while const loop_value: int = value`.
- Around line 1396-1433: The array destructuring pattern in baml.ts is letting
bare identifiers inside the array body fall through to typeExpression, so plain
elements like first are being scoped as type references instead of bindings.
Update arrayDestructurePattern and its nested patterns so a bare element is
matched as a binding token before typeExpression applies, using the existing
binding patterns (such as bareBindingPattern / wildcardBindingPattern) to claim
identifiers inside the array-destructure body.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e0e4324c-581c-4928-8cee-bd3f112fe4ab

📥 Commits

Reviewing files that changed from the base of the PR and between eb94b3b and 8a48238.

📒 Files selected for processing (84)
  • typescript2/app-vscode-ext/package.json
  • typescript2/app-vscode-ext/syntaxes/baml.tmLanguage.json
  • typescript2/app-vscode-ext/syntaxes/jinja.tmLanguage.json
  • typescript2/pkg-editor/src/MonacoEditor.tsx
  • typescript2/pkg-grammar/README.md
  • typescript2/pkg-grammar/baml.tmLanguage.json
  • typescript2/pkg-grammar/jinja.tmLanguage.json
  • typescript2/pkg-grammar/package.json
  • typescript2/pkg-grammar/preview/main.ts
  • typescript2/pkg-grammar/scripts/sync.mjs
  • typescript2/pkg-grammar/src/baml.ts
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__backtick_strings.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__byte_string_literals.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__cancel_token.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__catch_all_keyword.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__catch_throw.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__class_decls.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__config_dictionary.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__const_let_else_defer.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__deep_method_call.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__enum_decls.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__generic_field_chain.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__interfaces_inferred_generic_type_args.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__interfaces_iter_core.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__interfaces_sort_comparable.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__is_operator.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__json_map_literal.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__json_parse_stringify_intrinsics.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__lambda_advanced.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__method_explicit_type_args.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__parser_for_loops.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__parser_while_loop.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__patterns_new.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__postfix_optional_chains.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__retry_policy_valid_retry.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__stream_llm_inferred_typeargs.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__task_group.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__template_string_decls.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__test_expr_throwing_body.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__testset_vibes_nested.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__watch_let.baml
  • typescript2/pkg-grammar/tests/grammar-snapshots.test.ts
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__backtick_strings.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__byte_string_literals.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__cancel_token.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__catch_all_keyword.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__catch_throw.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__class_decls.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__config_dictionary.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__const_let_else_defer.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__deep_method_call.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__enum_decls.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__generic_field_chain.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__interfaces_inferred_generic_type_args.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__interfaces_iter_core.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__interfaces_sort_comparable.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__is_operator.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__json_map_literal.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__json_parse_stringify_intrinsics.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__lambda_advanced.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__method_explicit_type_args.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__parser_for_loops.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__parser_while_loop.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__patterns_new.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__postfix_optional_chains.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__retry_policy_valid_retry.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__stream_llm_inferred_typeargs.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__task_group.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__template_string_decls.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__test_expr_throwing_body.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__testset_vibes_nested.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__watch_let.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/match_patterns.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_agent__agent.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_agent__tests.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_build__build.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_demo__demo.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_game__clients.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_game__game.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_images__pipeline.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_sentiment__eval.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_sentiment__sentiment.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_sentiment__tests.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/ns_server__server.baml.scope.txt
💤 Files with no reviewable changes (4)
  • typescript2/app-vscode-ext/syntaxes/jinja.tmLanguage.json
  • typescript2/pkg-grammar/jinja.tmLanguage.json
  • typescript2/pkg-grammar/package.json
  • typescript2/pkg-editor/src/MonacoEditor.tsx
✅ Files skipped from review due to trivial changes (23)
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__retry_policy_valid_retry.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__test_expr_throwing_body.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__deep_method_call.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__parser_while_loop.baml
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__template_string_decls.baml
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__parser_while_loop.baml.scope.txt
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__enum_decls.baml
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__method_explicit_type_args.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__test_expr_throwing_body.baml.scope.txt
  • typescript2/pkg-grammar/README.md
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__byte_string_literals.baml
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__json_parse_stringify_intrinsics.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__byte_string_literals.baml.scope.txt
  • typescript2/pkg-grammar/tests/fixtures/baml_tests__watch_let.baml
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__is_operator.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__catch_all_keyword.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__parser_for_loops.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__config_dictionary.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__testset_vibes_nested.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__watch_let.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__cancel_token.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__backtick_strings.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/baml_tests__enum_decls.baml.scope.txt

Comment thread typescript2/pkg-grammar/src/baml.ts Resolved
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle June 26, 2026 00:18 Inactive
Remove duplication in src/baml.ts while preserving emitted output:
- shared leaf rules (comma, =, ., :, identifier) replacing ~40 inline copies
- caps0() for the single-key begin/endCaptures shape (~80 sites)
- braceBlock() for all 11 brace-delimited blocks
- shared callArguments (4 identical arg lists -> 1)
- returnTypeRule / typeTargetClause / bindingPatternRule factories
- hoisted forIn rules, named end-pattern consts, DOTTED_REF/DOTTED_PATH,
  attributeNameCaptures, generalized ifConditionPattern
- collapsed test/testset wrapper indirection

src/baml.ts 2862->2415 lines; emitted repository 296->251 entries. All 237
regexes and 270 scopes preserved exactly; 45/45 grammar snapshots byte-identical.
Fixtures: 34 cases from the baml_language lsp syntax/semantic-token corpus,
covering features the existing set missed -- implements-for, interface
extends/field-link/requires, literal & map types, type aliases (jinja /
recursive), block & @stream attributes, throws clauses, jinja prompts,
client http/fallback/remap config, dynamic type_builder, config-form test
blocks, and the semantic-token highlighting set.

Grammar fixes:
- highlight top-level let/const bindings (not valid BAML, but friendlier
  than leaving them bare)
- suppress class-destructure after `is` in if/while condition position so
  `if r is Empty { }` reads `{` as the block, mirroring the parser's
  NO_STRUCT_LITERAL restriction (parens/arrays still destructure)
- end statements at `}` so an inline `{ return x }` doesn't swallow the
  block close (fixes a cascading misparse of later implements blocks)
- add `.as<Interface>` upcast/projection as a dedicated expression form
  (`as` = keyword, `<T>` = type), matching the language's UPCAST_EXPR
@vercel
vercel Bot temporarily deployed to Preview – app-website-waronslop June 26, 2026 18:37 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps June 26, 2026 18:38 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 June 26, 2026 18:43 Inactive

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@typescript2/pkg-grammar/tests/snapshots/lsp_syntax_headers__jinja_comment_in_prompt.baml.scope.txt`:
- Line 46: The prompt text in the snapshot contains a typo: “setnences” should
be corrected to “sentences” so the rendered preview/output is accurate. Update
the prompt string associated with the debugging workflow text in the relevant
grammar/snapshot content, keeping the rest of the wording unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8ad9345f-e5f1-4311-ae6d-f3b666699154

📥 Commits

Reviewing files that changed from the base of the PR and between 8a48238 and b847925.

📒 Files selected for processing (71)
  • typescript2/app-vscode-ext/syntaxes/baml.tmLanguage.json
  • typescript2/pkg-grammar/baml.tmLanguage.json
  • typescript2/pkg-grammar/src/baml.ts
  • typescript2/pkg-grammar/tests/fixtures/lsp_semantic__break_continue.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_semantic__const_keyword_ident.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_semantic__enum_member_access.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_semantic__if_expression.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_semantic__match_literal_types.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_semantic__test_block.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_class__block_attributes.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_class__literal_types.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_class__map_literal_keys.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_class__type_aliases_jinja.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_client__http_config.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_client__remap_role.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_expr__constructor_spread.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_expr__index_access.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_expr__top_level_binding.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_functions__jinja_control_prompt.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_functions__signature_variety.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_headers__header_comments.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_headers__jinja_comment_in_prompt.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_if_let__chained.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_interface__extends_chain.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_interface__field_alias.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_interface__implements_for.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_interface__requires_clause.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_interface__self_qualified_call.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_iterator__named_type_args.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_let_else__array_pattern.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_maps__map_type_and_methods.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_match__exhaustive.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_misc__dynamic_type_builder.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_streaming__stream_attrs.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_template_string__calls.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_throw__throws_clause.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_throw__throws_enum_union.baml
  • typescript2/pkg-grammar/tests/snapshots/lsp_semantic__break_continue.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_semantic__const_keyword_ident.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_semantic__enum_member_access.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_semantic__if_expression.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_semantic__match_literal_types.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_semantic__test_block.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_class__block_attributes.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_class__literal_types.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_class__map_literal_keys.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_class__type_aliases_jinja.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_client__http_config.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_client__remap_role.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_expr__constructor_spread.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_expr__index_access.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_expr__top_level_binding.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_functions__jinja_control_prompt.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_functions__signature_variety.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_headers__header_comments.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_headers__jinja_comment_in_prompt.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_if_let__chained.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_interface__extends_chain.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_interface__field_alias.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_interface__implements_for.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_interface__requires_clause.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_interface__self_qualified_call.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_iterator__named_type_args.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_let_else__array_pattern.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_maps__map_type_and_methods.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_match__exhaustive.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_misc__dynamic_type_builder.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_streaming__stream_attrs.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_template_string__calls.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_throw__throws_clause.baml.scope.txt
  • typescript2/pkg-grammar/tests/snapshots/lsp_syntax_throw__throws_enum_union.baml.scope.txt
✅ Files skipped from review due to trivial changes (9)
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_interface__extends_chain.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_expr__top_level_binding.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_class__block_attributes.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_headers__header_comments.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_semantic__if_expression.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_client__remap_role.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_client__http_config.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_maps__map_type_and_methods.baml
  • typescript2/pkg-grammar/tests/fixtures/lsp_syntax_if_let__chained.baml
🚧 Files skipped from review as they are similar to previous changes (1)
  • typescript2/pkg-grammar/src/baml.ts

@vercel
vercel Bot temporarily deployed to Preview – promptfiddle June 26, 2026 18:56 Inactive
@codeshaunted
codeshaunted added this pull request to the merge queue Jun 26, 2026
Merged via the queue into canary with commit 19907d2 Jun 26, 2026
53 of 54 checks passed
@codeshaunted
codeshaunted deleted the avery/grammar branch June 26, 2026 19:20
meefs pushed a commit to meefs/baml that referenced this pull request Jun 26, 2026
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). Only `src/baml.ts`
differs.

**What changed** (all in `src/baml.ts`):
- `CALL_ARGS_LOOKAHEAD` const for the `(?=\s*(?:<…>\s*)?\()` 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 (they 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
- deleted the dead `block` const (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 BoundaryML#3843 is merged).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Improved syntax highlighting consistency for function calls, field
access, pattern matching, and control-flow keywords.
* Better handling of optional chaining, postfix calls, and backtick
interpolation markers.
* **Refactor**
* Simplified the grammar by sharing common matching logic across related
language forms.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

This branch was previously deployed

4 inactive deployments
Preview – promptfiddle — b8479258 Deployed Jun 26, 2026 by vercel[bot]
Preview – promptfiddle2 — b8479258 Deployed Jun 26, 2026 by vercel[bot]
Preview – beps — b8479258 Deployed Jun 26, 2026 by vercel[bot]
Preview – app-website-waronslop — b8479258 Deployed Jun 26, 2026 by vercel[bot]
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