Skip to content

Commit

Permalink
expression: Allow for paren'd expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
obiwac committed Sep 2, 2024
1 parent bb3fed1 commit 581c50a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion flamingo/grammar/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,16 @@ static int parse_expr(flamingo_t* flamingo, TSNode node, flamingo_val_t** val) {
return parse_identifier(flamingo, child, val);
}

// These expressions do have side-effects, so we need to parse them anyway.
// These expressions could have side-effects, so we need to parse them anyway.

if (strcmp(type, "call") == 0) {
return parse_call(flamingo, child, val);
}

if (strcmp(type, "parenthesized_expression") == 0) {
TSNode const grandchild = ts_node_child_by_field_name(child, "expression", 10);
return parse_expr(flamingo, grandchild, val);
}

return error(flamingo, "unknown expression type: %s", type);
}
4 changes: 2 additions & 2 deletions hello_world.fl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ fn do_nothing(a: str, b: str) {
do_nothing("test1", "test2")

fn no_args(x: str) {
print "b4"
return x # TODO return none
print("b4")
return(x) # TODO return none
print "a4"
}

Expand Down

0 comments on commit 581c50a

Please sign in to comment.