[fine] Fix list variable binding

This commit is contained in:
John Doty 2024-02-08 06:34:02 -08:00
parent 09a85596d8
commit 13aaca36c8
3 changed files with 46 additions and 28 deletions

View file

@ -139,6 +139,7 @@ pub enum TreeKind {
Identifier,
IfStatement,
IsExpression,
IteratorVariable,
LetStatement,
ListConstructor,
ListConstructorElement,
@ -889,10 +890,7 @@ fn statement_for(p: &mut CParser) {
let m = p.start();
p.expect_start(TokenKind::For);
p.expect(
TokenKind::Identifier,
"expected an identifier for the loop variable",
);
iterator_variable(p);
p.expect(TokenKind::In, "expect an 'in' after the loop variable");
if p.at_any(EXPRESSION_FIRST) {
expression(p);
@ -904,6 +902,17 @@ fn statement_for(p: &mut CParser) {
p.end(m, TreeKind::ForStatement);
}
fn iterator_variable(p: &mut CParser) {
let m = p.start();
p.expect(
TokenKind::Identifier,
"expected an identifier for the iterator variable",
);
p.end(m, TreeKind::IteratorVariable);
}
fn statement_expression(p: &mut CParser) {
let m = p.start();