NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io
crates.io, #1782 most downloaded on crates.io
Runtime support for rust-peg grammars. To use rust-peg, see the `peg` crate.
Latest stable
0.8.6
Last release 6 months ago
04 May 2026
Ships fairly regularly
a new release about every 9 months
Nearly every release is documented
notes for 11 of 11 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
11 releases · first in 2019
Drag across the ruler to compare, or tap a release to open it.
Add grammar-wide injected variables for more easily building syntax trees with spans
= expr at macro expansion time so that rust-analyzer can suggest a return type. (https://github.com/kevinmehall/rust-peg/pull/410)#[cache] (https://github.com/kevinmehall/rust-peg/pull/398)Minimum Rust version is increased to 1.82.
@kevinmehall @A4-Tacks @csnover @luohewuyang
Your coding agent can read these notes before it upgrades. Set up the MCP server →
The never-documented ##method() syntax is deprecated because the ## token is not allowed by Rust edition 2024. It will be removed in rust-peg v0.9. ##…
#{|input, pos| ... } custom expr (https://github.com/kevinmehall/rust-peg/pull/395)Box<dyn Operand + 'input>) in rule return types (https://github.com/kevinmehall/rust-peg/pull/385)my_rule::<u32>()) when calling a rule. (https://github.com/kevinmehall/rust-peg/issues/396)The never-documented ##method() syntax is deprecated because the ## token is not allowed by Rust edition 2024. It will be removed in rust-peg v0.9. ##method() can be replaced with #{|input, pos| input.method(pos) }.
@kevinmehall @brasswood
Full Changelog: https://github.com/kevinmehall/rust-peg/compare/0.8.4...0.8.5
Fix error with [x..] range pattern
[x..] range pattern (1b2da451)where clauses on rules by @A4-Tacks (#371)crate visibility modifier, which was dropped from rustc nightly in 2022Allow expected!() to accept a &'static str expression, not just a literal.
expected!() to accept a &'static str expression, not just a literal. (#361)BTreeSet in ExpectedSet for deterministic ordering. (#336)std feature that can be disabled to build on no-std + alloc (#336)impl Trait return types (#319)@stevefan1999-personal @Flamenco @tchajed @kevinmehall
Fix type inference for generic argument in rule's return position
&'a mut T in type grammar (#304)LineCol Copy (#298)@kevinmehall @plaflamme @zsol @Kile-Asmussen @kw217
Return matched token/character from [ ] pattern expression
#[cache_left_rec] annotation to allow left recursion (#266)[ ] pattern expression (#234)trace feature when using infix!{} (#277)#[cache] with grammar lifetime parametersclippy::redundant_closure_call lint in generated grammar (#258)Most users will not require changes to upgrade from 0.7 to 0.8; these only affect advanced use cases.
'input lifetime parameter to ParseElem trait so implementations can return tokens by reference. (#268)Copy on ParseElem::Element to better represent the expectation that they are cheap to copy/move.Contributors: @kevinmehall @zsol @neunenak @fgasperij
Significantly improved compile-time error messages for invalid grammars
[MyToken(x)] syntax for capturing variables from pattern expressions (#245)[^ ] inverted pattern syntax#[no_eof] pub rule() = ... syntax to allow matching a prefix of the input rather than reporting a parse error if the rule does not reach end-of-file (#233)rule _ = without parentheses when defining special underscore rule (#243)PartialEq, PartialOrd, Eq, Ord, Debug, Hash for RuleResult (#217)precedence!() (#238)return and ? behave as expected (#246)is_eof() method to Parse trait (#252)mixed_site hygiene prevents action code from accessing internal parser state variables such as __input, __pos, etc.@kevinmehall @dario23 @bgw @adrianwn
Contributors: @dario23 @kevinmehall
Contributors: @dario23 @kevinmehall
Derive PartialEq, PartialOrd, Eq, Ord, Debug, Hash for RuleResult
PartialEq, PartialOrd, Eq, Ord, Debug, Hash for RuleResult (#217)Contributors: @dario23 @kevinmehall
Use fully qualified Result path to avoid problems if Result is shadowed
Result path to avoid problems if Result is shadowed (#214)
peg name is shadowedpub rule#[cache] on rules with argumentsContributors: @dario23 @kevinmehall
Replaced build script integration and nightly-only syntax extension with a procedural macro that works on stable Rust. This means that errors both in
str input by implementing traits. It comes with an implementation for [T] (including [u8]), but you can define the traits for your own types. In fact, the rust-peg grammar is parsed with rust-peg via an implementation for token trees from proc-macro2.precedence!{} block for adding a precedence-climbing expression parser integrated with the surrounding PEG source.template syntax.peg = "0.5" from [build_dependencies] in Cargo.toml, and add peg = "0.6" under [dependencies].build.rs, delete it and remove build = "build.rs" from Cargo.tomlextern crate peg; to your crate root..rustpeg file into a Rust source file. Remove the
mod somename { include!(...) } and replace it with:peg::parser!{grammar somename() for str {
// grammar goes here
}}
rule keyword and parentheses to rule declarations.
foo = ... becomes rule foo() = ...pub bar -> X = ... becomes pub rule bar() -> X = ....name:ident becomes name:ident().[a-zA-Z] becomes ['a'..='z' | 'A'..='Z'].[^X] becomes (!['X'][_]) -- the inverted character set syntax was removed, but can be substituted with a negative lookahead followed by [_] to match and consume the character.. with [_].#position with position!()#quiet<e> with quiet!{e}#expected("foo") with expected!("foo").One column per quarter.