Skip to content

Commit

Permalink
parser: try to streamline function call argument
Browse files Browse the repository at this point in the history
Fixes #85
  • Loading branch information
jkbz64 committed Nov 18, 2024
1 parent aca3a5f commit d390a38
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
48 changes: 25 additions & 23 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion test/corpus/basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ PersonData:GetById(id, output table ttPerson by-reference).
(argument
(argument_mode)
(identifier)
(argument_pass_type))))))
(argument_tuning))))))

================================================================================
DO TRANSACTION statement
Expand Down

0 comments on commit d390a38

Please sign in to comment.