From 2235f9c0a9d1bce9fa6e8ff684873079cea4bd9f Mon Sep 17 00:00:00 2001 From: Max Wash Date: Thu, 10 Apr 2025 13:04:12 +0100 Subject: [PATCH] lang: change symbols for properties and atoms to -> and $ respectively --- lang/ast/class.c | 9 +++++---- lang/ast/expr/expr.c | 1 + lang/ast/expr/expr.h | 2 ++ lang/lex.c | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lang/ast/class.c b/lang/ast/class.c index 32de36a..6d72d4f 100644 --- a/lang/ast/class.c +++ b/lang/ast/class.c @@ -15,7 +15,7 @@ struct class_parser_state { int s_prev_token; }; -static struct token_parse_result parse_dollar( +static struct token_parse_result parse_hyphen_right_angle( struct ivy_parser *ctx, struct ivy_token *tok) { struct class_parser_state *state @@ -146,8 +146,9 @@ static void to_string(struct ivy_ast_node *node, b_string *str) { struct ivy_ast_class_node *c = (struct ivy_ast_class_node *)node; - b_string_append_cstrf(str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type), - c->n_ident->t_str); + b_string_append_cstrf( + str, "%s (%s)", ivy_ast_node_type_to_string(node->n_type), + c->n_ident->t_str); } static void init_state(struct ivy_parser *ctx, struct parser_state *sp, uintptr_t arg) @@ -183,7 +184,7 @@ struct ast_node_type class_node_ops = { .n_state_size = sizeof(struct class_parser_state), .n_node_size = sizeof(struct ivy_ast_class_node), .n_symbol_parsers = { - SYM_PARSER(DOLLAR, parse_dollar), + SYM_PARSER(HYPHEN_RIGHT_ANGLE, parse_hyphen_right_angle), SYM_PARSER(HYPHEN, parse_hyphen), SYM_PARSER(PLUS, parse_plus), }, diff --git a/lang/ast/expr/expr.c b/lang/ast/expr/expr.c index 5234438..043a46f 100644 --- a/lang/ast/expr/expr.c +++ b/lang/ast/expr/expr.c @@ -90,6 +90,7 @@ struct ast_node_type expr_node_ops = { /* operator/block keywords */ KW_PARSER(IN, arith_parse_in), + KW_PARSER(IS, arith_parse_operator), KW_PARSER(DO, arith_parse_do), } }; diff --git a/lang/ast/expr/expr.h b/lang/ast/expr/expr.h index dfa6d7b..c8c725e 100644 --- a/lang/ast/expr/expr.h +++ b/lang/ast/expr/expr.h @@ -149,6 +149,8 @@ extern struct token_parse_result arith_parse_equal_right_angle( struct ivy_parser *ctx, struct ivy_token *tok); extern struct token_parse_result arith_parse_in( struct ivy_parser *ctx, struct ivy_token *tok); +extern struct token_parse_result arith_parse_is( + struct ivy_parser *ctx, struct ivy_token *tok); extern struct token_parse_result arith_parse_do( struct ivy_parser *ctx, struct ivy_token *tok); diff --git a/lang/lex.c b/lang/lex.c index dc94217..ebbb103 100644 --- a/lang/lex.c +++ b/lang/lex.c @@ -773,7 +773,7 @@ static enum ivy_status read_symbol(struct ivy_lexer *lex) return read_block_comment(lex); case IVY_SYM_DOUBLE_HYPHEN: return read_line_comment(lex); - case IVY_SYM_HASH: + case IVY_SYM_DOLLAR: return read_atom(lex); case IVY_SYM_LEFT_BRACE: push_symbol(lex, node->s_id);