Add paren parsing

This commit is contained in:
greg 2015-07-26 01:54:55 -07:00
parent 9d6dc5a5f2
commit cdb47bb3b9
2 changed files with 7 additions and 0 deletions

View File

@ -11,6 +11,7 @@
<expr> := if <expr> then <statements> end
| if <expr> then <statements> else <statements> end
| while <expr> SEP <statements> end
| ( <expr> )
| <simple_expr>
<simple_expr> := <id>

View File

@ -130,6 +130,12 @@ fn expression(tokens: &mut Tokens) -> ParseResult {
Some(&Keyword(Kw::While)) => {
while_expression(tokens)
},
Some(&LParen) => {
tokens.next();
let expr = expression(tokens);
expect!(RParen, tokens);
expr
},
_ => simple_expression(tokens)
}
}