Skip to content

Releases: kevinmehall/rust-peg

0.6.0

06 Oct 18:17
Compare
Choose a tag to compare

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 from proc-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

  1. Remove peg = "0.5" from [build_dependencies] in Cargo.toml, and add peg = "0.6" under [dependencies].
  2. If nothing else is in build.rs, delete it and remove build = "build.rs" from Cargo.toml
  3. If using the 2015 edition of Rust, add extern crate peg; to your crate root.
  4. 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
}}
  1. Add the rule keyword and parentheses to rule declarations.
    • foo = ... becomes rule foo() = ...
    • pub bar -> X = ... becomes pub rule bar() -> X = ....
  2. Add parentheses to expressions that invoke another rule.
    • name:ident becomes name:ident().
  3. 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.
  4. If your grammar used templates, replace them with rule arguments.
  5. Replace
    • . with [_].
    • #position with position!()
    • #quiet<e> with quiet!{e}
    • #expected("foo") with expected!("foo").

0.5.7

06 Oct 18:42
Compare
Choose a tag to compare
  • Use ? instead of try!() for compatibility with Rust 2018.
  • Add support for dyn and impl in rule return types
  • Fix peg-syntax-ext for changes in Rust nightly (0.6 will replace peg-syntax-ext with a proc-macro for stable Rust)

0.5.6 (peg-syntax-ext)

21 Aug 04:36
Compare
Choose a tag to compare

Fix for libsyntax OneVector rename

0.5.5 (peg-syntax-ext)

16 Dec 22:44
Compare
Choose a tag to compare

Fix for FileName change in libsyntax API

0.5.4

24 Jun 19:41
Compare
Choose a tag to compare

Fixes

  • Fix operator capture in #infix parser (#165)

0.5.3

09 May 03:17
Compare
Choose a tag to compare

Fixes

  • Fix infix parsers in grammars using context arguments (#162)

0.5.2

29 Apr 15:22
Compare
Choose a tag to compare

New Features

Fixes

  • [peg-syntax-ext] Update for rust-nightly-2017-04-28

0.5.1

29 Jan 22:48
Compare
Choose a tag to compare

Fixes

  • Fix line comments after types in grammar source (#152)
  • Fix error position reporting for source with DOS-style newlines (#153)

0.5.0

15 Jan 20:11
Compare
Choose a tag to compare

Changes

  • Change #[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.

New features

  • Add rule templates
  • Add experimental #infix syntax for parsing binary infix expressions by precedence climbing.
  • Allow delimited-repeat with range bounds **<n,m>.
  • Add x*<{count}> syntax for a repeat bounded by a Rust expression.
  • Add #quiet<e> and #expected("msg") expressions for improved error reporting.
  • Allow as in use statements to match Rust syntax.

Fixes

  • Fix a bug in error reporting of & and ! expressions.
  • Avoid type errors if a rule returns a result, but the result is not used.
  • Error when using a nonexistent rule, rather than generating Rust code that doesn't compile.

0.4.0

20 Nov 22:37
Compare
Choose a tag to compare

Migrating from 0.3

  • 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 name in #![plugin(peg_syntax_ext)] remains the same. Consider moving to the build script for compatibility with Rust stable.
  • The 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) }
  • The \u2029 unicode hex escape syntax has been removed, as it has long-since been removed from Rust. Use \u{2029} instead.
  • The previously-undocumented foo{x,y} bounded-repeat syntax was replaced with foo*<x,y> to avoid a grammar ambiguity (#74).