From 2186eed80b26e77419d70b4985f10249bf2d7062 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 13 Jun 2015 22:15:05 -0400 Subject: [PATCH] Code blocks need a `=>` --- src/parser/mod.rs | 7 +++++-- src/parser/test.rs | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/parser/mod.rs b/src/parser/mod.rs index f06d792..7ddba65 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -55,6 +55,9 @@ rusty_peg! { action: a }; + ACTION: String = + ("=>", ) => c; + // Symbol items SYMBOL_ARG: SymbolArg = @@ -177,9 +180,9 @@ rusty_peg! { // Custom symbols. -struct ACTION; +struct CODE_BLOCK; -impl<'input> rusty_peg::Symbol<'input,Parser<'input>> for ACTION { +impl<'input> rusty_peg::Symbol<'input,Parser<'input>> for CODE_BLOCK { type Output = String; fn pretty_print(&self) -> String { diff --git a/src/parser/test.rs b/src/parser/test.rs index 8ec0c1a..ec925e1 100644 --- a/src/parser/test.rs +++ b/src/parser/test.rs @@ -46,3 +46,8 @@ fn token_expr() { assert!(parse_grammar(r#"grammar Foo { token Expr where { "foo" => "bar"; } }"#).is_ok()); } +#[test] +fn map() { + assert!(parse_grammar(r#"grammar Foo { Expr = => { { foo } }; }"#).is_ok()); +} +