From 0d13b5e3bc6e360294400d94688e8e83006ee24d Mon Sep 17 00:00:00 2001 From: greg Date: Sun, 19 Aug 2018 21:25:07 -0700 Subject: [PATCH] Preliminary support for binops in if-discriminators The BNF grammar is a bit more liberal than any successfully-compiled schala program should be, in that it allows things like `if x < is pattern`. It's okay if that parses successfully and then is an error at typechecking. --- schala-lang/src/parsing.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/schala-lang/src/parsing.rs b/schala-lang/src/parsing.rs index a515651..505e530 100644 --- a/schala-lang/src/parsing.rs +++ b/schala-lang/src/parsing.rs @@ -653,12 +653,11 @@ impl Parser { parse_method!(discriminator(&mut self) -> ParseResult { let lhs = self.prefix_expr()?; - Ok(match self.peek() { - //TODO make this whole process nicer - Operator(_) | Period | Pipe | Slash => { - unimplemented!() - }, - _ => Discriminator::Simple(lhs) + let ref next = self.peek(); + Ok(if let Some(op) = BinOp::from_sigil_token(next) { + Discriminator::BinOp(lhs, op) + } else { + Discriminator::Simple(lhs) }) });