ref(searchQueryBuilder): Share filter parser grammar#115557
Open
scttcper wants to merge 6 commits into
Open
Conversation
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>
Contributor
📊 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
allowedStartRulesdirective so build and test output match.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.