Skip to content

feat: scaffolding for winnow parser - #974

Merged
reubeno merged 1 commit into
mainfrom
winnow-scaffolding
Feb 8, 2026
Merged

reubeno merged 1 commit into
mainfrom
winnow-scaffolding

Conversation

@reubeno

@reubeno reubeno commented Feb 1, 2026

Copy link
Copy Markdown
Owner

Scaffolding for the winnow parser without an implementation body (yet).

@lu-zero I took your latest changes, stripped out the actual parser implementation, leaving just the scaffolding. I also added a runtime command-line option all the way up through brush-shell and some new options that would allow us to run our full suite of compat tests against either implementation, e.g.:

$ # Run brush shell with the winnow parser
$ cargo run --features=experimental -- --experimental-parser

$ # Run all tests and enable the winnow parser for tests run through our YAML-based test harness
$ BRUSH_ARGS="--experimental-parser" cargo nextest run --features=experimental

What do you think about this?

What I'm looking for is to get enough of the scaffolding in first that we can immediately start with an implementation that is 0% compatible and incrementally improve it. With each improvement that's made, we can track progress. Ideally I'd like to update PR CI workflows to run tests with the winnow parser too, but not gate; we can include in the report which percentage of tests are succeeding vs. failing on the winnow parser to track its progress and ensure we're monotonically moving forward.

Once the parser is working well enough to use a lot more, but not still not ready to be the default we can individually opt into using it by default in an interactive shell via the --experimental-parser option (included when compiling with the right features).

@github-actions

github-actions Bot commented Feb 1, 2026 •

Copy link
Copy Markdown

Test Results

    3 files     32 suites   12m 46s ⏱️
1 895 tests 1 895 ✅ 0 💤 0 ❌
5 657 runs  5 657 ✅ 0 💤 0 ❌

Results for commit ad1d54b.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Feb 1, 2026 •

Copy link
Copy Markdown

Performance Benchmark Report

Benchmark name Baseline (μs) Test/PR (μs) Delta (μs) Delta %
clone_shell_object 17.29 μs 16.95 μs -0.34 μs 🟢 -1.97%
eval_arithmetic 0.15 μs 0.16 μs 0.01 μs ⚪ Unchanged
expand_one_string 1.69 μs 1.60 μs -0.09 μs ⚪ Unchanged
for_loop 23.14 μs 23.59 μs 0.45 μs ⚪ Unchanged
function_call 2.69 μs 2.39 μs -0.30 μs ⚪ Unchanged
instantiate_shell 53.55 μs 53.41 μs -0.14 μs ⚪ Unchanged
instantiate_shell_with_init_scripts 28898.05 μs 30593.11 μs 1695.06 μs 🟠 +5.87%
run_echo_builtin_command 15.56 μs 16.21 μs 0.64 μs ⚪ Unchanged
tokenize_sample_script 3.52 μs 3.50 μs -0.02 μs ⚪ Unchanged

Benchmarks removed:

  • parse_sample_script
  • parse_bash_completion

Benchmarks added:

  • parse_peg_complex
  • full_peg_for_loop
  • full_peg_complex
  • full_peg_simple
  • parse_peg_pipeline
  • full_peg_pipeline
  • parse_peg_bash_completion
  • parse_peg_simple
  • full_peg_nested_expansions
  • parse_peg_for_loop

Code Coverage Report: Only Changed Files listed

Package Base Coverage New Coverage Difference
brush-core/src/shell.rs 🟢 93.4% 🟢 93.46% 🟢 0.06%
brush-core/src/shell/builder.rs 🟢 79.59% 🟢 79.8% 🟢 0.21%
brush-parser/src/parser/mod.rs 🟠 69.64% 🟠 66.95% 🔴 -2.69%
brush-shell/src/entry.rs 🟢 86.62% 🟢 86.71% 🟢 0.09%
Overall Coverage 🟢 74.51% 🟢 74.5% 🔴 -0.01%

Minimum allowed coverage is 70%, this run produced 74.5%

Test Summary: bash-completion test suite

Outcome Count Percentage
✅ Pass 1558 73.87
❗️ Error 19 0.90
❌ Fail 178 8.44
⏩ Skip 339 16.07
❎ Expected Fail 13 0.62
✔️ Unexpected Pass 2 0.09
📊 Total 2109 100.00

@lu-zero

lu-zero commented Feb 1, 2026

Copy link
Copy Markdown
Contributor

We can do that this way, but the winnow parser itself should be on par with peg at least for the situations I tested.

@reubeno

reubeno commented Feb 1, 2026

Copy link
Copy Markdown
Owner Author

I'm fine to start bringing in the real implementation pieces shortly thereafter, but I'd like to see the plumbing set up first and for us to actually hook it up to the interpreter and have the capability to run scenario / end-to-end tests.

Do you have any feedback on the changes I've made outside of brush-parser? The brush-parser changes are taken directly from your PR.

@lu-zero

lu-zero commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

it does look fine to me :)

Copilot AI 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.

Pull request overview

Adds feature-gated scaffolding to support an experimental Winnow-based parser, including CLI/test-harness plumbing to opt into the new parser and run the existing test suites against it.

Changes:

  • Introduces a new (stub) winnow_str parser module and a ParserImpl selector to switch between PEG and Winnow implementations.
  • Plumbs an --experimental-parser flag (feature-gated) through brush-shell into brush-core shell construction.
  • Extends the test harness to pass through extra brush CLI args (via --brush-args / BRUSH_ARGS) and updates xtask build checking to include --workspace.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
xtask/src/check.rs Ensures cargo check runs for the whole workspace during xtask checks.
brush-test-harness/src/config.rs Adds --brush-args / BRUSH_ARGS to allow passing extra CLI args to the shell-under-test.
brush-shell/tests/integration_tests.rs Appends brush_args to default brush invocation for integration tests.
brush-shell/tests/compat_tests.rs Appends brush_args to default brush invocation for compat tests (bash/sh oracle).
brush-shell/src/entry.rs Selects ParserImpl based on CLI flag and passes it into the shell builder.
brush-shell/src/args.rs Adds feature-gated --experimental-parser CLI flag.
brush-shell/Cargo.toml Adds experimental-parser feature and includes it under the broader experimental feature.
brush-parser/src/parser/winnow_str.rs Adds Winnow parser module scaffold (currently stubbed).
brush-parser/src/parser/tests/mod.rs Adds harness support to include Winnow in parser test configs and normalize AST comparisons.
brush-parser/src/parser/mod.rs Adds ParserImpl::Winnow (feature-gated), routes parsing based on implementation, introduces SourceInfo.
brush-parser/src/lib.rs Re-exports ParserImpl/SourceInfo and conditionally re-exports the winnow parser module.
brush-parser/benches/parser.rs Extends benchmarks to compare PEG pipeline vs (feature-gated) Winnow string parsing.
brush-parser/Cargo.toml Adds optional winnow dependency behind winnow-parser feature; enables insta redactions.
brush-core/src/shell/parsing.rs Uses the shell’s configured parser implementation when constructing ParserOptions.
brush-core/src/shell/builder.rs Adds a builder option to select parser implementation.
brush-core/src/shell.rs Stores selected parser implementation on the shell and propagates it through cloning/creation.
brush-core/src/lib.rs Re-exports ParserImpl through brush-core::parser.
brush-core/Cargo.toml Adds experimental-parser feature to enable brush-parser/winnow-parser.
Cargo.lock Adds winnow (and its transitive deps) to the lockfile.

Comment thread brush-core/src/shell/builder.rs Resolved
Comment thread brush-shell/tests/compat_tests.rs Resolved
Comment thread brush-shell/tests/integration_tests.rs Resolved
_options: &ParserOptions,
_source_info: &SourceInfo,
) -> Result<ast::Program, PError> {
unimplemented!("winnow string parser is not yet implemented")

Copilot AI Feb 2, 2026

Copy link

Choose a reason for hiding this comment

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

parse_program currently calls unimplemented!, which will panic whenever the experimental Winnow parser is selected (e.g. via --experimental-parser) and prevents using the scaffolding to run/measure failing tests. Prefer returning a structured Err(...) (even a placeholder) so the shell/test harness can surface a normal parse error instead of crashing.

Suggested change
unimplemented!("winnow string parser is not yet implemented")
Err(winnow::error::ErrMode::Cut(ContextError::new()))

Copilot uses AI. Check for mistakes.
@reubeno
reubeno marked this pull request as ready for review February 5, 2026 02:15
@reubeno
reubeno force-pushed the winnow-scaffolding branch from b179df6 to ee8ffa7 Compare February 8, 2026 00:02
Co-authored-by: Luca Barbato <lu_zero@gentoo.org>
@reubeno
reubeno force-pushed the winnow-scaffolding branch from ee8ffa7 to ad1d54b Compare February 8, 2026 00:52
@reubeno
reubeno merged commit 2ebef42 into main Feb 8, 2026
44 checks passed
@reubeno
reubeno deleted the winnow-scaffolding branch February 8, 2026 04:58
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.

3 participants