Releases: kevinmehall/rust-peg
Releases · kevinmehall/rust-peg
0.8.4
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
0.8.3
Fixes
- Fix error with
[x..]
range pattern (1b2da45)
Improvements
- Allow inlining standard Parse trait impls by @neocturne (#374)
- Support
where
clauses 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
crate
visibility modifier, which was dropped from rustc nightly in 2022
0.8.2
- Allow
expected!()
to accept a&'static str
expression, not just a literal. (#361) - Use
BTreeSet`` in
ExpectedSet`` for deterministic ordering. (#336) - Add enabled-by-default
std
feature that can be disabled to build on no-std + alloc (#336) - Fix regression with
impl Trait
return types (#319)
Contributors
0.8.1
0.8.0
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
trace
feature when usinginfix!{}
(#277) - Fix
#[cache]
with grammar lifetime parameters - Allow
clippy::redundant_closure_call
lint 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
'input
lifetime parameter toParseElem
trait so implementations can return tokens by reference. (#268) - Require
Copy
onParseElem::Element
to better represent the expectation that they are cheap to copy/move.
Contributors: @kevinmehall @zsol @neunenak @fgasperij
0.7.0
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, Hash
forRuleResult
(#217)
Fixes
- Extend detection of infinite-loop left recursion to check inside
precedence!()
(#238) - Wrap user-supplied code in immediately-invoked closure so that
return
and?
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 toParse
trait (#252) - Certain patterns that would infinite-loop or stack overflow if executed are now a compile-time error
mixed_site
hygiene prevents action code from accessing internal parser state variables such as__input
,__pos
, etc.
Contributors
0.6.3
- Fix multiline doc-comments (#232)
- Documentation improvements
Contributors: @dario23 @kevinmehall
0.6.2
- Derive
PartialEq, PartialOrd, Eq, Ord, Debug, Hash
for RuleResult (#217) - Documentation improvements
Contributors: @dario23 @kevinmehall
0.6.1
- Use fully qualified
Result
path to avoid problems ifResult
is shadowed (#214) - Update to 2018 edition for more consistent behavior when the
peg
name is shadowed - Allow crate-relative imports in grammars (#213)
- Documentation improvements
- Fix rule arguments on
pub rule
- Forbid
#[cache]
on rules with arguments
Contributors: @dario23 @kevinmehall
0.6.0
Major improvements
- Replaced build script integration and nightly-only syntax extension with a procedural macro that works on stable Rust. This means that errors both in the PEG grammar and the Rust code embedded from it are reported with source position by rustc. It even works with RLS!
- Add the ability to parse non-
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 fromproc-macro2
. - Add
precedence!{}
block for adding a precedence-climbing expression parser integrated with the surrounding PEG source. - Report errors in left-recursive rules that would cause infinte loops.
- Allow rules to accept value and type parameters, including passing closures to replace the
template
syntax. - Significant performance improvement for input that parses successfully by deferring error handling until parsing has failed.
Upgrade from 0.5.x
- Remove
peg = "0.5"
from[build_dependencies]
inCargo.toml
, and addpeg = "0.6"
under[dependencies]
. - If nothing else is in
build.rs
, delete it and removebuild = "build.rs"
fromCargo.toml
- If using the 2015 edition of Rust, add
extern crate peg;
to your crate root. - Move your grammar from a separate
.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
}}
- Add the
rule
keyword and parentheses to rule declarations.foo = ...
becomesrule foo() = ...
pub bar -> X = ...
becomespub rule bar() -> X = ...
.
- Add parentheses to expressions that invoke another rule.
name:ident
becomesname:ident()
.
- Replace the character set syntax with the pattern matching syntax.
[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.
- If your grammar used templates, replace them with rule arguments.
- Replace
.
with[_]
.#position
withposition!()
#quiet<e>
withquiet!{e}
#expected("foo")
withexpected!("foo")
.