lang: ast: implement parsing of lambdas

This commit is contained in:
2024-12-06 22:26:06 +00:00
parent 68ad0655aa
commit dba4f123d6
6 changed files with 218 additions and 14 deletions

View File

@@ -30,6 +30,7 @@ extern struct ast_node_type while_loop_node_ops;
extern struct ast_node_type for_loop_node_ops;
extern struct ast_node_type return_node_ops;
extern struct ast_node_type property_node_ops;
extern struct ast_node_type lambda_node_ops;
extern struct ast_node_type discard_node_ops;
static const struct ast_node_type *node_ops[] = {
@@ -57,6 +58,7 @@ static const struct ast_node_type *node_ops[] = {
[IVY_AST_FOR_LOOP] = &for_loop_node_ops,
[IVY_AST_RETURN] = &return_node_ops,
[IVY_AST_PROPERTY] = &property_node_ops,
[IVY_AST_LAMBDA] = &lambda_node_ops,
[IVY_AST_DISCARD] = &discard_node_ops,
};
static const size_t nr_node_ops = sizeof node_ops / sizeof node_ops[0];
@@ -85,6 +87,8 @@ enum token_expr_type get_token_expr_type(struct ivy_token *tok)
case IVY_TOK_SYMBOL:
switch (tok->t_symbol) {
case IVY_SYM_LEFT_PAREN:
case IVY_SYM_LEFT_BRACKET:
case IVY_SYM_LEFT_BRACE:
case IVY_SYM_CARET:
return TOK_EXPR_BEGIN;
case IVY_SYM_COMMA: