hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit cd18e31f80cb5d0d143e728905aac62c96d0ef4a
parent a41a1d8a4dd5e9381cee7f1aa81df61b930164cd
Author: Drew DeVault <sir@cmpwn.com>
Date:   Fri, 26 Mar 2021 20:01:16 -0400

hare::parse: fixes for expression-list

Diffstat:
Mhare/parse/expr.ha | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/hare/parse/expr.ha b/hare/parse/expr.ha @@ -37,7 +37,7 @@ export fn complex_expression(lexer: *lex::lexer) (ast::expr | error) = { fn expression_list(lexer: *lex::lexer) (ast::expr | error) = { let items: ast::list_expr = []; - for (true) { + for (let more = true; more) { let tok = match (lex::lex(lexer)?) { io::EOF => return syntaxerr(mkloc(lexer), "Unexpected EOF, expected scope or control expression"), @@ -49,7 +49,10 @@ fn expression_list(lexer: *lex::lexer) (ast::expr | error) = { btoken::RBRACE => break, btoken::BREAK, btoken::CONTINUE, - btoken::RETURN => control_statement(lexer)?, + btoken::RETURN => { + more = false; + control_statement(lexer)?; + }, * => scope_expression(lexer)?, }, * => scope_expression(lexer)?, @@ -58,6 +61,7 @@ fn expression_list(lexer: *lex::lexer) (ast::expr | error) = { want_btoken(lexer, btoken::SEMICOLON)?; }; + want_btoken(lexer, btoken::RBRACE)?; return items; };