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
|
<expr> := if <expr> then <statements> end
|
||||||
| if <expr> then <statements> else <statements> end
|
| if <expr> then <statements> else <statements> end
|
||||||
| while <expr> SEP <statements> end
|
| while <expr> SEP <statements> end
|
||||||
|
| ( <expr> )
|
||||||
| <simple_expr>
|
| <simple_expr>
|
||||||
|
|
||||||
<simple_expr> := <id>
|
<simple_expr> := <id>
|
||||||
|
@ -130,6 +130,12 @@ fn expression(tokens: &mut Tokens) -> ParseResult {
|
|||||||
Some(&Keyword(Kw::While)) => {
|
Some(&Keyword(Kw::While)) => {
|
||||||
while_expression(tokens)
|
while_expression(tokens)
|
||||||
},
|
},
|
||||||
|
Some(&LParen) => {
|
||||||
|
tokens.next();
|
||||||
|
let expr = expression(tokens);
|
||||||
|
expect!(RParen, tokens);
|
||||||
|
expr
|
||||||
|
},
|
||||||
_ => simple_expression(tokens)
|
_ => simple_expression(tokens)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user