NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io
crates.io, #1773 most downloaded on crates.io
A simple Parsing Expression Grammar (PEG) parser generator.
Latest stable
0.8.6
Last release 6 months ago
04 May 2026
Ships fairly regularly
a new release about every 7 months
Some releases are documented
notes for 19 of 52 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
52 releases · first in 2014
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 macro panic for parse error at end of peg::parser!{ } specification (https://github.com/kevinmehall/rust-peg/issues/376) by @kevinmehall
peg::parser!{ } specification (https://github.com/kevinmehall/rust-peg/issues/376) by @kevinmehallr# raw idents (#378) by @A4-Tacks in https://github.com/kevinmehall/rust-peg/pull/379Full Changelog: https://github.com/kevinmehall/rust-peg/compare/0.8.3...0.8.4
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").Use ? instead of try!() for compatibility with Rust 2018.
? instead of try!() for compatibility with Rust 2018.dyn and impl in rule return typesFix operator capture in #infix parser
Fix infix parsers in grammars using context arguments
Context arguments for passing variables to all rules
Fix line comments after types in grammar source
Change #[pub] rule_name = ... syntax to pub rule_name = .... The old syntax is retained for backwards compatibility, but pub is now a reserved keyword
#[pub] rule_name = ... syntax to pub rule_name = .... The old syntax is retained for backwards compatibility, but pub is now a reserved keyword and cannot be used as an identifier.#infix syntax for parsing binary infix expressions by precedence climbing.**<n,m>.x*<{count}> syntax for a repeat bounded by a Rust expression.#quiet<e> and #expected("msg") expressions for improved error reporting.as in use statements to match Rust syntax.& and ! expressions.If you were using the syntax extension, replace peg = "0.3.0" with peg-syntax-ext = "0.4.0" in your Cargo.toml's [dependencies] section. The library n
peg = "0.3.0" with peg-syntax-ext = "0.4.0" in your Cargo.toml's [dependencies] section. The library name in #![plugin(peg_syntax_ext)] remains the same. Consider moving to the build script for compatibility with Rust stable.match_str variable has been removed in favor of the $(expr) syntax. Replace [0-9]+ { match_str.parse().unwrap() } with n:$([0-9]+) { n.parse().unwrap() }start_pos and pos variables have been removed. Use #position as an expression, which returns a usize offset into the source string. Replace foo:x { Span(start_pos, pos, foo) } with start:#position foo:x end:#position { Span(start, end, foo) }\u2029 unicode hex escape syntax has been removed, as it has long-since been removed from Rust. Use \u{2029} instead.foo{x,y} bounded-repeat syntax was replaced with foo*<x,y> to avoid a grammar ambiguity (#74).Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
Nothing published for this version
One column per quarter.