diff --git a/lang/ast/expr/expr.c b/lang/ast/expr/expr.c index 2b87cb0..960aed1 100644 --- a/lang/ast/expr/expr.c +++ b/lang/ast/expr/expr.c @@ -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), diff --git a/lang/ast/selector.c b/lang/ast/selector.c index 7c5fbbb..9a8dace 100644 --- a/lang/ast/selector.c +++ b/lang/ast/selector.c @@ -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) {