lang: ast: use fancy index manipulation to reduce the size of ast_node_type

This commit is contained in:
2024-11-28 10:56:43 +00:00
parent f04c858d9a
commit fc76fe6ad4
10 changed files with 80 additions and 64 deletions

View File

@@ -178,13 +178,13 @@ struct ast_node_type selector_node_ops = {
.n_state_size = sizeof(struct selector_parser_state),
.n_node_size = sizeof(struct ivy_ast_selector_node),
.n_token_parsers = {
[IVY_TOK_IDENT] = parse_ident,
[IVY_TOK_LABEL] = parse_label,
[IVY_TOK_NONE] = parse_other,
TOK_PARSER(IDENT, parse_ident),
TOK_PARSER(LABEL, parse_label),
TOK_PARSER_FALLBACK(parse_other),
},
.n_symbol_parsers = {
[IVY_SYM_LEFT_PAREN] = parse_left_paren,
[IVY_SYM_RIGHT_PAREN] = parse_right_paren,
[IVY_SYM_PIPE] = parse_pipe,
SYM_PARSER(LEFT_PAREN, parse_left_paren),
SYM_PARSER(RIGHT_PAREN, parse_right_paren),
SYM_PARSER(PIPE, parse_pipe),
},
};