Add paren test

This commit is contained in:
greg 2016-01-16 17:00:54 -08:00
parent e099f713ad
commit e6591b80d9

View File

@ -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<Expression> {
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");
}
}