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.
Merge pull request #1 from pest-parser/master
one-or-more rule fix based on pest-parser#397 (pest-parser#878)
- Loading branch information
Showing
14 changed files
with
112 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,29 @@ | ||
#![cfg_attr(not(feature = "std"), no_std)] | ||
extern crate alloc; | ||
#[cfg(not(feature = "std"))] | ||
use alloc::{format, vec::Vec}; | ||
|
||
#[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