| 1 | extern crate peg; |
| 2 | |
| 3 | peg::parser!{ |
| 4 | pub grammar foo_parser() for str { |
| 5 | use crate::types::Foo; |
| 6 | |
| 7 | pub rule foo() -> Foo |
| 8 | = "foo" { Foo } |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | mod types { |
| 13 | #[derive(PartialEq, Debug)] |
| 14 | pub struct Foo; |
| 15 | } |
| 16 | |
| 17 | |
| 18 | fn main() { |
| 19 | assert_eq!(foo_parser::foo("foo"), Ok(crate::types::Foo)); |
| 20 | } |