From e6591b80d937e0618e647a847ea9d8b8a5f657e1 Mon Sep 17 00:00:00 2001 From: greg Date: Sat, 16 Jan 2016 17:00:54 -0800 Subject: [PATCH] Add paren test --- src/parser.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/parser.rs b/src/parser.rs index 3753955..95954fe 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -7,11 +7,12 @@ use tokenizer::{Token, Kw, Op}; declaraion := Fn prototype (statement)* End prototype := identifier LParen identlist RParen identlist := Ident (Comma Ident)* | e + exprlist := Expression (Comma Expression)* | e expression := primary_expression (op primary_expression)* primary_expression := Variable | Number | String | call_expr | paren_expr paren_expr := LParen expression RParen - call_expr := identifier LParen identlist RParen + call_expr := identifier LParen exprlist RParen op := '+', '-', etc. */ @@ -254,6 +255,7 @@ impl Parser { } fn call_expr(&mut self) -> ParseResult { + use tokenizer::Token::*; unimplemented!() } @@ -302,5 +304,8 @@ mod tests { parsetest!("a * b + c", [ExprNode(BinExp(ref plus, box BinExp(ref mul, box Variable(ref a), box Variable(ref b)), box Variable(ref c)))], plus == "+" && mul == "*" && a == "a" && b == "b" && c == "c"); + parsetest!("(a + b) * c", + [ExprNode(BinExp(ref mul, box BinExp(ref plus, box Variable(ref a), box Variable(ref b)), box Variable(ref c)))], + plus == "+" && mul == "*" && a == "a" && b == "b" && c == "c"); } }