From b85725125c6b0479addd67ba1e06d117465f85a7 Mon Sep 17 00:00:00 2001 From: greg Date: Wed, 22 Aug 2018 16:41:31 -0700 Subject: [PATCH] Start using HalfExp --- schala-lang/src/parsing.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/schala-lang/src/parsing.rs b/schala-lang/src/parsing.rs index 3d7bbd2..083cf4d 100644 --- a/schala-lang/src/parsing.rs +++ b/schala-lang/src/parsing.rs @@ -695,7 +695,6 @@ 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.expr_or_block()?; Ok(GuardArm { guard, body }) }); @@ -707,7 +706,15 @@ impl Parser { let pat = self.pattern()?; Guard::Pat(pat) }, - e => return ParseError::new(&format!("{:?} not valid in pattern guard", e)), + ref tok if BinOp::from_sigil_token(tok).is_some() => { + let op = BinOp::from_sigil_token(&self.next()).unwrap(); + let Expression(expr, _) = self.expression()?; + Guard::HalfExpr(HalfExpr { op: Some(op), expr }) + }, + _ => { + let Expression(expr, _) = self.expression()?; + Guard::HalfExpr(HalfExpr { op: None, expr }) + } }) });