fixes for easier parsing, result modifier added

This commit is contained in:
ProgramSnail 2023-07-24 13:02:21 +03:00
parent b26c0544bf
commit 18d84f5f28
2 changed files with 110 additions and 37 deletions

View file

@ -59,7 +59,7 @@ module.exports = grammar({
optional($.annotation_identifier),
optional($._reference),
$.argument_name_identifier,
optional('?'),
optional($._optional_result),
)),
optional(seq(':', repeat1(seq(
optional($.annotation_identifier),
@ -149,7 +149,7 @@ module.exports = grammar({
reference_expression: $ => prec(-1, seq($._reference, $._scoped_expression)),
suffix_expression: $ => seq($._scoped_expression, choice('?', '!')),
suffix_expression: $ => seq($._scoped_expression, $._optional_result),
// --- other
@ -232,14 +232,16 @@ module.exports = grammar({
type: $ => seq(
optional('^'),
field('name', $._type_identifier),
optional('?'),
optional($._optional_result),
optional(seq('[', repeat1($.type), ']'))
),
// --- comments
definition_info: $ => repeat1(seq(': ', /[^\n]*/)),
annotation_info: $ => seq($.annotation_identifier, /[^\n]*/),
definition_info: $ => repeat1(seq(': ', $.info)),
annotation_info: $ => seq($.annotation_identifier, $.info),
info: $ => /[^\n]*/,
_exec_comment: $ => token(seq('#!', /[^\n]*/)),
_line_comment: $ => token(seq('//', /[^\n]*/)),
@ -249,6 +251,7 @@ module.exports = grammar({
_do: $ => choice('=>', 'do'),
_var_let: $ => choice(choice('%', 'let'), choice('$', 'var')),
_optional_result: $ => choice('?', '!'),
_reference: $ => choice(choice('->', 'out'), choice('<-', 'in'), choice('<>', 'ref')),
_name_identifier: $ => choice($.argument_name_identifier, $.simple_name_identifier),