From d390a38b498497ab1f2fb17d25f58258032caaf3 Mon Sep 17 00:00:00 2001 From: Kamil Jakubus Date: Mon, 18 Nov 2024 05:20:32 +0100 Subject: [PATCH] parser: try to streamline function call argument Fixes #85 --- grammar.js | 48 ++++++++++++++++++++++--------------------- test/corpus/basic.txt | 2 +- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/grammar.js b/grammar.js index 0c14338..5cbeb1e 100644 --- a/grammar.js +++ b/grammar.js @@ -370,31 +370,33 @@ module.exports = grammar({ choice(kw("INPUT"), kw("OUTPUT"), kw("INPUT-OUTPUT"), kw("DATA-SOURCE")) ), - argument_pass_type: ($) => - choice(kw("BY-VALUE"), kw("BY-REFERENCE"), kw("BIND")), - _function_argument_with_mode: ($) => - seq( - $.argument_mode, - choice( - seq( - choice($.identifier, $.object_access, $.qualified_name), - optional($.type_tuning) - ), - seq( - choice( - kw("TABLE"), - kw("TABLE-HANDLE"), - kw("DATASET"), - kw("DATASET-HANDLE") + argument_tuning: ($) => + choice(kw("BY-VALUE"), kw("BY-REFERENCE"), kw("BIND"), kw("APPEND")), + function_call_argument: ($) => + prec.right( + 1, + seq( + optional($.argument_mode), + choice( + seq( + choice($.identifier, $.object_access, $.qualified_name), + optional($.type_tuning) ), - choice($.identifier, $.qualified_name) - ) - ), - optional(kw("APPEND")), - optional($.argument_pass_type) + seq( + optional( + choice( + kw("TABLE"), + kw("TABLE-HANDLE"), + kw("DATASET"), + kw("DATASET-HANDLE") + ) + ), + $._expression + ) + ), + optional($.argument_tuning) + ) ), - function_call_argument: ($) => - prec.right(1, choice($._function_argument_with_mode, $._expression)), function_arguments: ($) => seq( diff --git a/test/corpus/basic.txt b/test/corpus/basic.txt index ec9522e..03773d1 100644 --- a/test/corpus/basic.txt +++ b/test/corpus/basic.txt @@ -993,7 +993,7 @@ PersonData:GetById(id, output table ttPerson by-reference). (argument (argument_mode) (identifier) - (argument_pass_type)))))) + (argument_tuning)))))) ================================================================================ DO TRANSACTION statement