Skip to content

Commit

Permalink
parser: add on-quit and on-stop phrases for do block
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbz64 committed Nov 26, 2023
1 parent d3d110e commit 3b660f0
Show file tree
Hide file tree
Showing 5 changed files with 25,609 additions and 23,054 deletions.
39 changes: 38 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ module.exports = grammar({
$.transaction_statement,
$._stream_statement,
$.case_statement,
$.do_block,
$.input_close_statement,
$.output_close_statement,
$.assign_statement,
Expand Down Expand Up @@ -566,7 +567,43 @@ module.exports = grammar({
$._terminator
),

do_block: ($) => seq(kw("DO"), ":", optional($.body), $._block_terminator),
on_stop_phrase: ($) =>
seq(
kw("ON"),
kw("STOP"),
kw("UNDO"),
field("label", optional($.identifier)),
",",
choice(
seq(kw("LEAVE"), field("label", optional($.identifier))),
seq(kw("NEXT"), field("label", optional($.identifier))),
seq(kw("RETRY"), field("label", optional($.identifier))),
seq(kw("RETURN"), choice(seq(kw("ERROR")), kw("NO-APPLY")))
)
),

on_quit_phrase: ($) =>
seq(
kw("ON"),
kw("QUIT"),
optional(seq(kw("UNDO"), optional($.identifier))),
",",
choice(
seq(kw("LEAVE"), field("label", optional($.identifier))),
seq(kw("NEXT"), field("label", optional($.identifier))),
seq(kw("RETRY"), field("label", optional($.identifier))),
seq(kw("RETURN"), choice(seq(kw("ERROR")), kw("NO-APPLY")))
)
),

do_block: ($) =>
seq(
kw("DO"),
optional(choice($.on_stop_phrase, $.on_quit_phrase)),
":",
optional($.body),
$._block_terminator
),

_case_terminator: ($) =>
choice($._block_terminator, seq(kw("END"), kw("CASE"), $._terminator)),
Expand Down
Loading

0 comments on commit 3b660f0

Please sign in to comment.