diff options
Diffstat (limited to 'crates/rebel-parse')
-rw-r--r-- | crates/rebel-parse/examples/parse-string.rs | 4 | ||||
-rw-r--r-- | crates/rebel-parse/src/grammar/recipe.rs | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/crates/rebel-parse/examples/parse-string.rs b/crates/rebel-parse/examples/parse-string.rs index c023c46..9750a87 100644 --- a/crates/rebel-parse/examples/parse-string.rs +++ b/crates/rebel-parse/examples/parse-string.rs @@ -12,6 +12,8 @@ enum Rule { Block, BlockStmt, Expr, + Type, + Pat, } #[derive(Clone, Debug, Parser)] @@ -49,6 +51,8 @@ fn main() { Rule::Block => recipe::block(&tokens).map(as_debug), Rule::BlockStmt => recipe::block_stmt(&tokens).map(as_debug), Rule::Expr => recipe::expr(&tokens).map(as_debug), + Rule::Type => recipe::typ(&tokens).map(as_debug), + Rule::Pat => recipe::pat(&tokens).map(as_debug), }; if opts.rule != Rule::Tokenize { let dur = Instant::now().duration_since(start); diff --git a/crates/rebel-parse/src/grammar/recipe.rs b/crates/rebel-parse/src/grammar/recipe.rs index 50a0694..68429cb 100644 --- a/crates/rebel-parse/src/grammar/recipe.rs +++ b/crates/rebel-parse/src/grammar/recipe.rs @@ -62,7 +62,7 @@ peg::parser! { rule typed_pat() -> ast::TypedPat<'a> = pat:pat() typ:tagged(<p(':')>, <typ()>)? { ast::TypedPat { pat, typ } } - rule typ() -> Type<'a> + pub rule typ() -> Type<'a> = lit:typ_literal() { Type::Literal(lit) } / path:path() { Type::Path(path) } / p('(') t:typ() p(')') { Type::Paren(Box::new(t)) } @@ -79,7 +79,7 @@ peg::parser! { typ::Literal::Struct(entries) } - rule pat() -> Pat<'a> + pub rule pat() -> Pat<'a> = path:path() { Pat::Path(path) } rule struct_field_typ() -> typ::StructField<'a> |