Add paren parsing
This commit is contained in:
parent
9d6dc5a5f2
commit
cdb47bb3b9
1
Grammar
1
Grammar
@ -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>
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user