diff --git a/conditional.schala b/conditional.schala index 7aa4477..9499e5b 100644 --- a/conditional.schala +++ b/conditional.schala @@ -1,4 +1,5 @@ -if 20 then +if 20 +then a = 20 b = 30 c = 40 diff --git a/src/parser.rs b/src/parser.rs index 3debcb8..693faaa 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -341,7 +341,18 @@ impl Parser { use tokenizer::Token::*; use self::Expression::*; expect!(self, Keyword(Kw::If)); + let test = try!(self.expression()); + loop { + match self.peek() { + Some(ref t) if is_delimiter(t) => { + self.next(); + continue; + } + _ => break, + } + } + expect!(self, Keyword(Kw::Then)); let mut then_block = VecDeque::new(); loop { @@ -492,5 +503,12 @@ mod tests { [ExprNode(Conditional(box Null, box Block(_), Some(box Block(_))))] => (), _ => panic!(), } + + let t2 = "if null\nthen\n20\nelse\n40\nend"; + let tokens2 = tokenizer::tokenize(t2).unwrap(); + match parse(&tokens2, &[]).unwrap()[..] { + [ExprNode(Conditional(box Null, box Block(_), Some(box Block(_))))] => (), + _ => panic!(), + } } }