Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break up keyword in some phrases #20

Merged
merged 1 commit into from
Sep 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -285,21 +285,24 @@ module.exports = grammar({
seq(
kw("IF"),
field("condition", $._expression),
kw("THEN DO"),
kw("THEN"),
kw("DO"),
":",
optional($.body),
$._block_terminator,
optional(repeat(choice($.else_do_statement, $.else_do_if_statement)))
),

else_do_statement: ($) =>
seq(kw("ELSE DO"), ":", optional($.body), $._block_terminator),
seq(kw("ELSE"), kw("DO"), ":", optional($.body), $._block_terminator),

else_do_if_statement: ($) =>
seq(
kw("ELSE IF"),
kw("ELSE"),
kw("IF"),
field("condition", $._expression),
kw("THEN DO"),
kw("THEN"),
kw("DO"),
":",
optional($.body),
$._block_terminator
Expand Down Expand Up @@ -337,7 +340,8 @@ module.exports = grammar({

do_while_statement: ($) =>
seq(
kw("DO WHILE"),
kw("DO"),
kw("WHILE"),
field("condition", $._expression),
":",
optional($.body),
Expand All @@ -356,15 +360,15 @@ module.exports = grammar({
),

/// Procedures
_procedure_terminator: ($) => kw("END PROCEDURE."),
_procedure_terminator: ($) => seq(kw("END"), kw("PROCEDURE"), "."),
procedure_statement: ($) =>
seq(
kw("PROCEDURE"),
$.identifier,
optional(kw("PRIVATE")),
":",
optional($.body),
$._procedure_terminator
choice($._block_terminator, $._procedure_terminator)
),

procedure_parameter_definition: ($) =>
Expand All @@ -381,7 +385,10 @@ module.exports = grammar({

/// Functions
_function_terminator: ($) =>
choice($._block_terminator, seq(kw("END FUNCTION"), ".")),
choice(
$._block_terminator,
seq(kw("END"), kw("FUNCTION"), $._terminator)
),
function_parameter_mode: ($) => choice(kw("INPUT"), kw("OUTPUT")),
function_parameter: ($) =>
seq($.function_parameter_mode, $.identifier, kw("AS"), $.primitive_type),
Expand Down Expand Up @@ -616,7 +623,13 @@ module.exports = grammar({

// DO TRANSACTION statement
transaction_statement: ($) =>
seq(kw("DO TRANSACTION"), ":", optional($.body), $._block_terminator),
seq(
kw("DO"),
kw("TRANSACTION"),
":",
optional($.body),
$._block_terminator
),

/// ABL statements
abl_statement: ($) =>
Expand Down Expand Up @@ -693,7 +706,7 @@ module.exports = grammar({
// Available
available_expression: ($) =>
seq(
choice(kw("AVAIL "), kw("AVAILABLE ")),
choice(kw("AVAIL"), kw("AVAILABLE")),
choice($.parenthesized_expression, $.identifier)
)
}
Expand Down
Loading