From ba71fbc84b0887e94462e6b92ca8861988aa88af Mon Sep 17 00:00:00 2001 From: Ella Dunbar Date: Sat, 18 Oct 2025 16:58:19 -0500 Subject: [PATCH] Update builtin function highlighting --- grammar.js | 4 ++-- queries/highlights.scm | 5 +++-- src/grammar.json | 8 ++++++-- src/node-types.json | 19 +++++++++++++------ src/parser.c | 9 ++++++--- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/grammar.js b/grammar.js index 43ab82f..14d6ac0 100644 --- a/grammar.js +++ b/grammar.js @@ -54,7 +54,7 @@ module.exports = grammar({ 'action', 'Action', ), - $.identifier, + field('name', $.identifier), $.block, choice( 'COMPLETE', @@ -133,7 +133,7 @@ module.exports = grammar({ ), function: $ => seq( - field("name", $.identifier), + field('name', $.identifier), '(', optional( repeat( diff --git a/queries/highlights.scm b/queries/highlights.scm index d54fbd0..034afac 100644 --- a/queries/highlights.scm +++ b/queries/highlights.scm @@ -62,7 +62,8 @@ (comment) @comment (variable) @variable (match) @constant.macro -(identifier) @constant.macro +(identifier) @constant (number) @number (string) @string -(function name: (identifier) @function) +(function name: (identifier) @function.call) +(action name: (identifier) @function) diff --git a/src/grammar.json b/src/grammar.json index ef8bafc..5525019 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -129,8 +129,12 @@ ] }, { - "type": "SYMBOL", - "name": "identifier" + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } }, { "type": "SYMBOL", diff --git a/src/node-types.json b/src/node-types.json index fbf5669..1bdcef4 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -2,18 +2,25 @@ { "type": "action", "named": true, - "fields": {}, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, "children": { - "multiple": true, + "multiple": false, "required": true, "types": [ { "type": "block", "named": true - }, - { - "type": "identifier", - "named": true } ] } diff --git a/src/parser.c b/src/parser.c index 70a6bae..9e9bd24 100644 --- a/src/parser.c +++ b/src/parser.c @@ -13,7 +13,7 @@ #define EXTERNAL_TOKEN_COUNT 0 #define FIELD_COUNT 1 #define MAX_ALIAS_SEQUENCE_LENGTH 6 -#define PRODUCTION_ID_COUNT 2 +#define PRODUCTION_ID_COUNT 3 enum ts_symbol_identifiers { sym_identifier = 1, @@ -513,11 +513,14 @@ static const char * const ts_field_names[] = { static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { [1] = {.index = 0, .length = 1}, + [2] = {.index = 1, .length = 1}, }; static const TSFieldMapEntry ts_field_map_entries[] = { [0] = {field_name, 0}, + [1] = + {field_name, 1}, }; static const TSSymbol ts_alias_sequences[PRODUCTION_ID_COUNT][MAX_ALIAS_SEQUENCE_LENGTH] = { @@ -2961,8 +2964,8 @@ static const TSParseActionEntry ts_parse_actions[] = { [114] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_loop, 4, 0, 0), [116] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_branch, 4, 0, 0), [118] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_branch, 4, 0, 0), - [120] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_action, 4, 0, 0), - [122] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_action, 4, 0, 0), + [120] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_action, 4, 0, 2), + [122] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_action, 4, 0, 2), [124] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function, 3, 0, 1), [126] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function, 3, 0, 1), [128] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_assignment, 3, 0, 0),