From 482674b19a884214226f1e0e9297d8d827770a09 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 15 Aug 2018 09:34:00 -0700 Subject: [PATCH] Start on expr_or_block WIP doesn't work yet --- schala-lang/src/parsing.rs | 5 +++++ schala-lang/src/reduced_ast.rs | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/schala-lang/src/parsing.rs b/schala-lang/src/parsing.rs index 5355917..41c9fcb 100644 --- a/schala-lang/src/parsing.rs +++ b/schala-lang/src/parsing.rs @@ -240,6 +240,10 @@ record_pattern := IDENTIFIER '{' (record_pattern_entry, ',')* '}' record_pattern_entry := IDENTIFIER | IDENTIFIER ':' Pattern tuple_struct_pattern := IDENTIFIER '(' (pattern, ',')* ')' + +//TODO when this works bring it to guard_arm +expr_or_block := '{' (statement delimiter)* '}' | expr + /* Expression - If */ if_expr := 'if' discriminator ('then' condititional | 'is' simple_pattern_match | guard_block) discriminator := modified_precedence_expression @@ -694,6 +698,7 @@ impl Parser { parse_method!(guard_arm(&mut self) -> ParseResult { let guard = self.guard()?; expect!(self, Operator(ref c) if **c == "->"); + println!("WE HIIII? {:?}", self.peek()); let body = self.block()?; Ok(GuardArm { guard, body }) }); diff --git a/schala-lang/src/reduced_ast.rs b/schala-lang/src/reduced_ast.rs index 893e7b7..875ffc3 100644 --- a/schala-lang/src/reduced_ast.rs +++ b/schala-lang/src/reduced_ast.rs @@ -188,7 +188,12 @@ fn reduce_if_expression(discriminator: &Discriminator, body: &IfExpressionBody, alternatives, } }, - IfExpressionBody::GuardList(ref _guard_arms) => panic!(), + IfExpressionBody::GuardList(ref guard_arms) => { + for arm in guard_arms.iter() { + //TODO do stuff here!! + } + Expr::UnimplementedSigilValue + } } }