lang: ast: implement parsing of unnamed parameters
This commit is contained in:
@@ -40,6 +40,8 @@ struct ast_node_type expr_node_ops = {
|
||||
SYM_PARSER(SEMICOLON, arith_parse_semicolon),
|
||||
SYM_PARSER(UNDERSCORE, arith_parse_operand),
|
||||
SYM_PARSER(CARET, arith_parse_caret),
|
||||
/* treat colons as empty labels */
|
||||
SYM_PARSER(COLON, arith_parse_label),
|
||||
SYM_PARSER(COMMA, arith_parse_comma),
|
||||
SYM_PARSER(DOT, arith_parse_dot),
|
||||
SYM_PARSER(BANG, arith_parse_bang),
|
||||
|
||||
@@ -269,8 +269,10 @@ static void to_string(struct ivy_ast_node *node, b_string *str)
|
||||
label = b_unbox(struct ivy_token, label_it.entry, t_entry);
|
||||
name = b_unbox(struct ivy_token, name_it.entry, t_entry);
|
||||
|
||||
if (label) {
|
||||
if (label && label->t_type == IVY_TOK_LABEL) {
|
||||
b_string_append_cstrf(str, "%s:", label->t_str);
|
||||
} else {
|
||||
b_string_append_cstrf(str, "_:");
|
||||
}
|
||||
|
||||
if (name) {
|
||||
|
||||
Reference in New Issue
Block a user