Skip to content

Commit

Permalink
parser: initial support for run statement
Browse files Browse the repository at this point in the history
Fixes #65
  • Loading branch information
jkbz64 committed Sep 18, 2024
1 parent 82239ef commit c9395ba
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
25 changes: 25 additions & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,30 @@ module.exports = grammar({
$._terminator
),

run_tuning: ($) =>
choice(
kw("PERSISTENT"),
kw("SINGLE-RUN"),
kw("SINGLETON"),
kw("ASYNCHRONOUS"),
seq(kw("SET"), $.identifier),
seq(kw("ON"), kw("SERVER"), $.identifier),
seq(kw("IN"), choice(kw("THIS-PROCEDURE"), $.identifier)),
seq(kw("EVENT-PROCEDURE"), $.string_literal)
),
run_statement: ($) =>
seq(
kw("RUN"),
field(
"procedure",
choice($.identifier, $.qualified_name, $.function_call)
),
repeat($.run_tuning),
optional(alias($.function_arguments, $.arguments)),
optional(kw("NO-ERROR")),
$._terminator
),

// Supertypes
_expression: ($) =>
choice(
Expand Down Expand Up @@ -1398,6 +1422,7 @@ module.exports = grammar({
$.prompt_for_statement,
$.dataset_definition,
$.button_definition,
$.run_statement,
$.abl_statement,
prec.left(PREC.EXTRA, $.label)
)
Expand Down
61 changes: 61 additions & 0 deletions test/corpus/basic.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2334,3 +2334,64 @@ VAR INT[ ] x = [funct( ), a + b].
(additive_expression
(identifier)
(identifier)))))))

================================================================================
RUN statement
================================================================================

RUN getMyNumber.p(piFirstNum, piSecNum).
RUN VALUE(programs[INDEX("12345", selection)]).
RUN recall-query IN phand.

RUN server-error.p ON SERVER hServer
ASYNCHRONOUS SET hRequest EVENT-PROCEDURE "procDone" IN
THIS-PROCEDURE (OUTPUT numLines AS INTEGER).

--------------------------------------------------------------------------------

(source_code
(run_statement
(qualified_name
(identifier)
(identifier))
(arguments
(argument
(identifier))
(argument
(identifier))))
(run_statement
(function_call
(identifier)
(arguments
(argument
(array_access
(identifier)
(function_call
(identifier)
(arguments
(argument
(string_literal))
(argument
(identifier)))))))))
(run_statement
(identifier)
(run_tuning
(identifier)))
(run_statement
(qualified_name
(identifier)
(identifier))
(run_tuning
(identifier))
(run_tuning)
(run_tuning
(identifier))
(run_tuning
(string_literal))
(run_tuning)
(arguments
(argument
(argument_mode)
(identifier)
(type_tuning
(primitive_type))))))

0 comments on commit c9395ba

Please sign in to comment.