peg
A simple Parsing Expression Grammar (PEG) parser generator.
0.8.6
32M downloads/mo
#1618 most downloaded on crates.io
kevinmehall/rust-peg
What this package is like to depend on
Last release 3 months ago
04 May 2026
Ships fairly regularly
a new release about every 7 months
Rarely documented
notes for 10 of 52 stable releases
Nothing withdrawn
no release was ever pulled
12 years old
52 releases · first in 2014
1 release in the last 12 months
see the full history below
Release timeline
52 releases · Nov 2014 to May 2026Releases
latest 52-
0.8.604 May 2026Release notes
Open source →New features
- Add grammar-wide injected variables for more easily building syntax trees with spans (#421)
- Support use-tree syntax (#408)
- Support use-bound on return position impl trait (#409)
- Allow rules without
= exprat macro expansion time so that rust-analyzer can suggest a return type. (#410)
Fixes
- Fix for no-std (#406)
- Fix for trace feature with
#[cache](#398) - Fix span on closing brace in meta-grammar (#411)
Minimum Rust version is increased to 1.82.
Contributors
-
0.8.502 Mar 2025Release notes
Open source →New features
- Add
#{|input, pos| ... }custom expr (#395) - Allow type bounds (e.g.
Box<dyn Operand + 'input>) in rule return types (#385) - Allow specifying generic arguments (e.g.
my_rule::<u32>()) when calling a rule. (#396)
Deprecations
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) }.Contributors
Full Changelog: 0.8.4...0.8.5
- Add
-
0.8.421 Jul 2024Release notes
Open source →Fixes
- Fix macro panic for parse error at end of
peg::parser!{ }specification (#376) by @kevinmehall - Fix handling of
r#raw idents (#378) by @A4-Tacks in #379
Full Changelog: 0.8.3...0.8.4
- Fix macro panic for parse error at end of
-
0.8.327 Apr 2024Release notes
Open source →Fixes
- Fix error with
[x..]range pattern (1b2da45)
Improvements
- Allow inlining standard Parse trait impls by @neocturne (#374)
- Support
whereclauses on rules by @A4-Tacks (#371) - Support trailing commas in type parameter lists by @A4-Tacks (#371)
- Improve compatibility with Rust qualified path syntax in type grammar by @A4-Tacks (#371)
Other
- Remove support for
cratevisibility modifier, which was dropped from rustc nightly in 2022
- Fix error with
-
0.8.211 Oct 2023Release notes
Open source →- Allow
expected!()to accept a&'static strexpression, not just a literal. (#361) - Use
BTreeSetinExpectedSetfor deterministic ordering. (#336) - Add enabled-by-default
stdfeature that can be disabled to build on no-std + alloc (#336) - Fix regression with
impl Traitreturn types (#319)
Contributors
- Allow
-
0.8.126 Sep 2022Release notes
Open source →Fixes
- Fix type inference for generic argument in rule's return position (#317)
- Fix parsing of
&'a mut Tin type grammar (#304)
Improvements
- Made
LineColCopy (#298)
Contributors
-
0.8.004 Jan 2022Release notes
Open source →New Features
#[cache_left_rec]annotation to allow left recursion (#266)- Return matched token/character from
[ ]pattern expression (#234)
Fixes
- Fix Rust grammar for arguments (#261) and type bounds (#279)
- Fix
tracefeature when usinginfix!{}(#277) - Fix
#[cache]with grammar lifetime parameters - Allow
clippy::redundant_closure_calllint in generated grammar (#258)
Breaking changes
Most users will not require changes to upgrade from 0.7 to 0.8; these only affect advanced use cases.
- Allow only lifetime, not type, parameters at the grammar level. (type parameters were never properly supported)
- Add
'inputlifetime parameter toParseElemtrait so implementations can return tokens by reference. (#268) - Require
CopyonParseElem::Elementto better represent the expectation that they are cheap to copy/move.
Contributors: @kevinmehall @zsol @neunenak @fgasperij
-
0.7.010 Apr 2021Release notes
Open source →New features
- Significantly improved compile-time error messages for invalid grammars
- Support
[MyToken(x)]syntax for capturing variables from pattern expressions (#245) - Restore support for
[^ ]inverted pattern syntax - Add
#[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) - Allow
rule _ =without parentheses when defining special underscore rule (#243) - Add grammar-level type and lifetime parameters (#254)
- Compile-time check for repeat expressions that infinite-loop without consuming input (#210)
- Implement
PartialEq, PartialOrd, Eq, Ord, Debug, HashforRuleResult(#217)
Fixes
- Extend detection of infinite-loop left recursion to check inside
precedence!()(#238) - Wrap user-supplied code in immediately-invoked closure so that
returnand?behave as expected (#246) - Remove overzealous error checks to allow passing rule closure arguments as parameters to another call (#226)
Breaking changes
- Add required
is_eof()method toParsetrait (#252) - Certain patterns that would infinite-loop or stack overflow if executed are now a compile-time error
mixed_sitehygiene prevents action code from accessing internal parser state variables such as__input,__pos, etc.
Contributors
-
0.6.322 Jul 2020Release notes
Open source →- Fix multiline doc-comments (#232)
- Documentation improvements
Contributors: @dario23 @kevinmehall
-
0.6.215 Feb 2020Release notes
Open source →- Derive
PartialEq, PartialOrd, Eq, Ord, Debug, Hashfor RuleResult (#217) - Documentation improvements
Contributors: @dario23 @kevinmehall
- Derive
-
0.6.118 Jan 2020Nothing published for this version
-
0.6.006 Oct 2019Nothing published for this version
-
0.5.706 Oct 2018Nothing published for this version
-
0.5.424 Jun 2017Nothing published for this version
-
0.5.309 May 2017Nothing published for this version
-
0.5.229 Apr 2017Nothing published for this version
-
0.5.129 Jan 2017Nothing published for this version
-
0.5.015 Jan 2017Nothing published for this version
-
0.4.021 Nov 2016Nothing published for this version
-
0.3.1803 Nov 2016Nothing published for this version
-
0.3.1722 Oct 2016Nothing published for this version
-
0.3.1617 Sep 2016Nothing published for this version
-
0.3.1501 Sep 2016Nothing published for this version
-
0.3.1403 Jul 2016Nothing published for this version
-
0.3.1322 Jun 2016Nothing published for this version
-
0.3.1211 Jun 2016Nothing published for this version
-
0.3.1126 Apr 2016Nothing published for this version
-
0.3.1018 Feb 2016Nothing published for this version
-
0.3.913 Feb 2016Nothing published for this version
-
0.3.812 Jan 2016Nothing published for this version
-
0.3.707 Jan 2016Nothing published for this version
-
0.3.606 Dec 2015Nothing published for this version
-
0.3.528 Nov 2015Nothing published for this version
-
0.3.407 Nov 2015Nothing published for this version
-
0.3.301 Sep 2015Nothing published for this version
-
0.3.226 Aug 2015Nothing published for this version
-
0.3.121 Jul 2015Nothing published for this version
-
0.3.019 May 2015Nothing published for this version
-
0.2.308 Apr 2015Nothing published for this version
-
0.2.229 Mar 2015Nothing published for this version
-
0.2.125 Mar 2015Nothing published for this version
-
0.2.013 Mar 2015Nothing published for this version
-
0.1.908 Mar 2015Nothing published for this version
-
0.1.801 Mar 2015Nothing published for this version
-
0.1.713 Feb 2015Nothing published for this version
-
0.1.611 Feb 2015Nothing published for this version
-
0.1.529 Jan 2015Nothing published for this version
-
0.1.424 Jan 2015Nothing published for this version
-
0.1.310 Jan 2015Nothing published for this version
-
0.1.224 Dec 2014Nothing published for this version
-
0.1.106 Dec 2014Nothing published for this version
-
0.1.023 Nov 2014Nothing published for this version