forked from pest-parser/pest
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
one-or-more rule fix based on pest-parser#397
the fix was feature-guarded with "grammar-extras" in order to keep the semver compatibility. plus a test was added. Closes pest-parser#396 Co-authored-by: Emanuel Joebstl <emanuel.joebstl@gmail.com>
- Loading branch information
Showing
14 changed files
with
107 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
WHITESPACE = _{ " " | "\r" | "\n" | "\t" } | ||
|
||
|
||
identifier = { (ASCII_ALPHA | "_")+ } | ||
assign = { identifier ~ "<-" ~ identifier } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#[cfg(feature = "grammar-extras")] | ||
use pest::Parser; | ||
use pest_derive::Parser; | ||
|
||
#[derive(Parser)] | ||
#[grammar = "../tests/oneormore.pest"] | ||
pub struct OneOrMoreParser; | ||
|
||
#[test] | ||
#[cfg(feature = "grammar-extras")] | ||
pub fn test_one_or_more() { | ||
let result = OneOrMoreParser::parse(Rule::assign, "k <- b\n"); | ||
assert!(result.is_ok()); | ||
let mut pairs = result.unwrap(); | ||
let pair = pairs.next().unwrap(); | ||
assert_eq!(pair.as_rule(), Rule::assign); | ||
let mut inner = pair.into_inner(); | ||
let lhs = inner.next().unwrap(); | ||
assert_eq!(lhs.as_rule(), Rule::identifier); | ||
assert_eq!(lhs.as_str(), "k"); | ||
let rhs = inner.next().unwrap(); | ||
assert_eq!(rhs.as_rule(), Rule::identifier); | ||
assert_eq!(rhs.as_str(), "b"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters