diff --git a/grammar.js b/grammar.js index 21d78b6..c6fa8f1 100644 --- a/grammar.js +++ b/grammar.js @@ -143,7 +143,7 @@ module.exports = grammar({ assignment: $ => seq(field("left", choice($.access, $.identifier)), "=", field("right", $.expression)), unary_operator: _ => choice("-", "!"), - unary_expression: $ => seq(field("operator", $.unary_operator), field("expression", $.expression)), + unary_expression: $ => seq(field("operator", $.unary_operator), field("operand", $.expression)), power_operator: _ => "**", multiplicative_operator: _ => choice("*", "/", "%"), diff --git a/src/grammar.json b/src/grammar.json index 8e93477..53273c0 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -1125,7 +1125,7 @@ }, { "type": "FIELD", - "name": "expression", + "name": "operand", "content": { "type": "SYMBOL", "name": "expression" diff --git a/src/node-types.json b/src/node-types.json index 9c8344f..2a1b5f0 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -845,7 +845,7 @@ "type": "unary_expression", "named": true, "fields": { - "expression": { + "operand": { "multiple": false, "required": true, "types": [ diff --git a/src/parser.c b/src/parser.c index f907da6..382c9ca 100644 --- a/src/parser.c +++ b/src/parser.c @@ -11,7 +11,7 @@ #define ALIAS_COUNT 0 #define TOKEN_COUNT 59 #define EXTERNAL_TOKEN_COUNT 0 -#define FIELD_COUNT 27 +#define FIELD_COUNT 28 #define MAX_ALIAS_SEQUENCE_LENGTH 9 #define PRODUCTION_ID_COUNT 51 @@ -776,19 +776,20 @@ enum ts_field_identifiers { field_left = 12, field_msg = 13, field_name = 14, - field_operator = 15, - field_params = 16, - field_path = 17, - field_qualifiers = 18, - field_relative = 19, - field_rest = 20, - field_ret_type = 21, - field_right = 22, - field_rv = 23, - field_slice_begin = 24, - field_slice_end = 25, - field_test = 26, - field_type = 27, + field_operand = 15, + field_operator = 16, + field_params = 17, + field_path = 18, + field_qualifiers = 19, + field_relative = 20, + field_rest = 21, + field_ret_type = 22, + field_right = 23, + field_rv = 24, + field_slice_begin = 25, + field_slice_end = 26, + field_test = 27, + field_type = 28, }; static const char * const ts_field_names[] = { @@ -807,6 +808,7 @@ static const char * const ts_field_names[] = { [field_left] = "left", [field_msg] = "msg", [field_name] = "name", + [field_operand] = "operand", [field_operator] = "operator", [field_params] = "params", [field_path] = "path", @@ -889,7 +891,7 @@ static const TSFieldMapEntry ts_field_map_entries[] = { [5] = {field_rv, 1}, [6] = - {field_expression, 1}, + {field_operand, 1}, {field_operator, 0}, [8] = {field_body, 1}, diff --git a/test/corpus/unary.txt b/test/corpus/unary.txt index 32c0753..f1a08aa 100644 --- a/test/corpus/unary.txt +++ b/test/corpus/unary.txt @@ -13,7 +13,7 @@ Unary operators (expression (unary_expression operator: (unary_operator) - expression: (expression + operand: (expression (literal (number) ) @@ -33,7 +33,7 @@ Unary operators right: (expression (unary_expression operator: (unary_operator) - expression: (expression + operand: (expression (literal (number) )