Skip to content

ref(searchQueryBuilder): Share filter parser grammar#115557

Open
scttcper wants to merge 6 commits into
masterfrom
scttcper/share-peggy-filter-grammar
Open

ref(searchQueryBuilder): Share filter parser grammar#115557
scttcper wants to merge 6 commits into
masterfrom
scttcper/share-peggy-filter-grammar

Conversation

@scttcper
Copy link
Copy Markdown
Member

@scttcper scttcper commented May 14, 2026

The search query builder had five tiny Peggy grammars for filter values, and each generated its own parser runtime. The grammars are small, but the generated parser scaffolding is not, so we were paying for the same Peggy machinery several times.

This folds the percentage, duration, size, string-list, and date filter parsers into one shared grammar with separate start rules. The wrapper APIs stay the same. The rspack loader and Jest transformer both read the same allowedStartRules directive so build and test output match.

State Raw Gzip
Five separate filter parsers 86.4 kB 17.9 kB
Shared filter parser 42.3 kB 5.9 kB
Delta -44.1 kB -11.9 kB

Also removes copied-over string-list rules Peggy was already pruning and simplifies unquoted list values into one rule, which trims a little more generated code while preserving behavior.

The search query builder had five tiny Peggy grammars, each generating its own parser runtime. That adds a decent amount of repeated code for simple filter value parsing.

Move those filter parsers into one grammar with separate start rules, then teach the rspack and Jest Peggy loaders to preserve those start rules.

Co-Authored-By: Codex GPT-5 <noreply@openai.com>
@github-actions github-actions Bot added the Scope: Frontend Automatically applied to PRs that change frontend components label May 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 14, 2026

📊 Type Coverage Diff

✅ No new type safety issues introduced. Coverage: 93.52%

These rules were copied over from the full search grammar but are not reachable from the shared filter value start rules. Peggy already pruned them from generated output, so this just keeps the smaller grammar easier to read.

Co-Authored-By: Codex GPT-5 <noreply@openai.com>
Make the allowed start rule directive parsing explicit in both the rspack loader and Jest transformer. Empty or missing directives now fall back to Peggy's default start rule behavior.

Co-Authored-By: Codex GPT-5 <noreply@openai.com>
Collapse the unquoted and empty text-list value branches into one zero-or-more character rule. This keeps parse behavior the same, trims generated Peggy output a bit, and makes the string-list path a little cheaper.

Co-Authored-By: Codex GPT-5 <noreply@openai.com>
Use a parser-specific type name for percentage filter values instead of carrying over the duration parser name.

Co-Authored-By: Codex GPT-5 <noreply@openai.com>
The filter value parsers now share one Peggy grammar with separate start rules. Add small parser-level tests for the date, duration, percentage, and size wrappers so each public parser has direct coverage like the string parser already did.

This mostly guards the shared grammar wiring, not the string-list size tweak.

Co-Authored-By: Codex GPT-5 <noreply@openai.com>
@scttcper scttcper marked this pull request as ready for review May 14, 2026 16:37
@scttcper scttcper requested review from a team as code owners May 14, 2026 16:37
@scttcper scttcper changed the title perf(search): Share filter parser grammar ref(searchQueryBuilder): Share filter parser grammar May 14, 2026
@scttcper scttcper requested a review from a team May 14, 2026 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant