blob: 6bdb3c597f5bbd1f39bd588685ae97372f6964e1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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");
}
|