From 4db49a13f56e7e7c2faa5e4d51f6b022b2af6e3e Mon Sep 17 00:00:00 2001 From: mhoffm Date: Fri, 11 Jun 2021 23:41:02 +0200 Subject: [PATCH] add function name --- grammar.js | 7 ++++++- src/grammar.json | 8 ++++++-- src/node-types.json | 21 ++++++++++++++------- src/parser.c | 8 ++++---- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/grammar.js b/grammar.js index 414d90e..fbffc00 100644 --- a/grammar.js +++ b/grammar.js @@ -154,7 +154,12 @@ module.exports = grammar({ variable_expr: $ => $.identifier, - function_call: $ => seq($.identifier, '(', optional($.function_arguments), ')'), + function_call: $ => seq( + field('name', $.identifier), + '(', + optional($.function_arguments), + ')' + ), function_arguments: $ => seq( $.expression, diff --git a/src/grammar.json b/src/grammar.json index b6df5c8..4f04c52 100644 --- a/src/grammar.json +++ b/src/grammar.json @@ -694,8 +694,12 @@ "type": "SEQ", "members": [ { - "type": "SYMBOL", - "name": "identifier" + "type": "FIELD", + "name": "name", + "content": { + "type": "SYMBOL", + "name": "identifier" + } }, { "type": "STRING", diff --git a/src/node-types.json b/src/node-types.json index 219377c..6af1dfc 100644 --- a/src/node-types.json +++ b/src/node-types.json @@ -334,18 +334,25 @@ { "type": "function_call", "named": true, - "fields": {}, + "fields": { + "name": { + "multiple": false, + "required": true, + "types": [ + { + "type": "identifier", + "named": true + } + ] + } + }, "children": { - "multiple": true, - "required": true, + "multiple": false, + "required": false, "types": [ { "type": "function_arguments", "named": true - }, - { - "type": "identifier", - "named": true } ] } diff --git a/src/parser.c b/src/parser.c index 9e44d67..8e54f2e 100644 --- a/src/parser.c +++ b/src/parser.c @@ -5497,8 +5497,8 @@ static const TSParseActionEntry ts_parse_actions[] = { [148] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_object, 2), [150] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_for_object_expr, 8), [152] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_for_object_expr, 8), - [154] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_call, 4), - [156] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_call, 4), + [154] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_call, 4, .production_id = 1), + [156] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_call, 4, .production_id = 1), [158] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_for_object_expr, 7), [160] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_for_object_expr, 7), [162] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_bool_lit, 1), @@ -5528,8 +5528,8 @@ static const TSParseActionEntry ts_parse_actions[] = { [210] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_for_tuple_expr, 4), [212] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_tuple, 3), [214] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_tuple, 3), - [216] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_call, 3), - [218] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_call, 3), + [216] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_function_call, 3, .production_id = 1), + [218] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_function_call, 3, .production_id = 1), [220] = {.entry = {.count = 1, .reusable = true}}, REDUCE(sym_expr_term, 3), [222] = {.entry = {.count = 1, .reusable = false}}, REDUCE(sym_expr_term, 3), [224] = {.entry = {.count = 1, .reusable = true}}, SHIFT(9),