diff --git a/example-file b/example-file.jrpc similarity index 100% rename from example-file rename to example-file.jrpc diff --git a/grammar.js b/grammar.js index ec04996..9e6e79d 100644 --- a/grammar.js +++ b/grammar.js @@ -84,7 +84,12 @@ module.exports = grammar({ ), ")", ), - function_argument: ($) => seq($.identifier, ":", $.type), + function_argument: ($) => + seq( + field("argument_identifier", $.identifier), + ":", + field("argument_type", $.type), + ), pair: ($) => seq( diff --git a/src/grammar.json b/src/grammar.json index 871aa0e..38d3806 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -510,16 +510,24 @@ "type": "SEQ", "members": [ { - "type": "SYMBOL", - "name": "identifier" + "type": "FIELD", + "name": "argument_identifier", + "content": { + "type": "SYMBOL", + "name": "identifier" + } }, { "type": "STRING", "value": ":" }, { - "type": "SYMBOL", - "name": "type" + "type": "FIELD", + "name": "argument_type", + "content": { + "type": "SYMBOL", + "name": "type" + } } ] }, diff --git a/src/node-types.json b/src/node-types.json index 13829cf..7c5e2ec 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -203,20 +203,27 @@ { "type": "function_argument", "named": true, - "fields": {}, - "children": { - "multiple": true, - "required": true, - "types": [ - { - "type": "identifier", - "named": true - }, - { - "type": "type", - "named": true - } - ] + "fields": { + "argument_identifier": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + }, + "argument_type": { + "multiple": false, + "required": true, + "types": [ + { + "type": "type", + "named": true + } + ] + } } }, { diff --git a/src/parser.c b/src/parser.c index c8fe4a2..ba8c7d4 100644 --- a/src/parser.c +++ b/src/parser.c @@ -11,9 +11,9 @@ #define ALIAS_COUNT 0 #define TOKEN_COUNT 28 #define EXTERNAL_TOKEN_COUNT 0 -#define FIELD_COUNT 5 +#define FIELD_COUNT 7 #define MAX_ALIAS_SEQUENCE_LENGTH 5 -#define PRODUCTION_ID_COUNT 5 +#define PRODUCTION_ID_COUNT 6 enum ts_symbol_identifiers { anon_sym_type = 1, @@ -468,15 +468,19 @@ static const TSSymbolMetadata ts_symbol_metadata[] = { }; enum ts_field_identifiers { - field_key = 1, - field_name = 2, - field_parameters = 3, - field_return_type = 4, - field_value = 5, + field_argument_identifier = 1, + field_argument_type = 2, + field_key = 3, + field_name = 4, + field_parameters = 5, + field_return_type = 6, + field_value = 7, }; static const char * const ts_field_names[] = { [0] = NULL, + [field_argument_identifier] = "argument_identifier", + [field_argument_type] = "argument_type", [field_key] = "key", [field_name] = "name", [field_parameters] = "parameters", @@ -488,7 +492,8 @@ static const TSFieldMapSlice ts_field_map_slices[PRODUCTION_ID_COUNT] = { [1] = {.index = 0, .length = 2}, [2] = {.index = 2, .length = 2}, [3] = {.index = 4, .length = 2}, - [4] = {.index = 6, .length = 3}, + [4] = {.index = 6, .length = 2}, + [5] = {.index = 8, .length = 3}, }; static const TSFieldMapEntry ts_field_map_entries[] = { @@ -502,6 +507,9 @@ static const TSFieldMapEntry ts_field_map_entries[] = { {field_name, 1}, {field_parameters, 2}, [6] = + {field_argument_identifier, 0}, + {field_argument_type, 2}, + [8] = {field_name, 0}, {field_parameters, 1}, {field_return_type, 3}, @@ -2363,8 +2371,8 @@ static const TSParseActionEntry ts_parse_actions[] = { [136] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_array_type, 2, 0, 0), [138] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_service_notification, 4, 0, 3), [140] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_service_notification, 4, 0, 3), - [142] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_service_function, 5, 0, 4), - [144] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_service_function, 5, 0, 4), + [142] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_service_function, 5, 0, 5), + [144] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_service_function, 5, 0, 5), [146] = {.entry = {.count = 1, .reusable = true}}, SHIFT(66), [148] = {.entry = {.count = 1, .reusable = true}}, SHIFT(83), [150] = {.entry = {.count = 1, .reusable = true}}, SHIFT(56), @@ -2406,7 +2414,7 @@ static const TSParseActionEntry ts_parse_actions[] = { [225] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_value_assignment, 3, 0, 0), [227] = {.entry = {.count = 1, .reusable = true}}, SHIFT(11), [229] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_enum_value, 1, 0, 0), - [231] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_argument, 3, 0, 0), + [231] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_argument, 3, 0, 4), [233] = {.entry = {.count = 1, .reusable = true}}, SHIFT(46), [235] = {.entry = {.count = 1, .reusable = true}}, SHIFT(54), [237] = {.entry = {.count = 1, .reusable = true}}, SHIFT(29),