update test file

This commit is contained in:
csh
2025-10-25 14:06:58 +08:00
parent 6be3662226
commit 117f8e878e
13 changed files with 171248 additions and 149577 deletions
+1 -41
View File
@@ -1,41 +1 @@
function MyFunc(a: string; b: array of string);
begin
end
function MyFunc(a: string; b: array of string);overload;
begin
end;
// type ImageDimensions = class
// property Width read width_;
// property Width : array of string index 2 read width_;
// end;
// <?tslx>
// <div class="element-data-container">
// <?tsl
// rpt_data_bar(data[i],canAudit);
// ?>
// <div class="diff-section <?= isDiffed?'diff-section-diffed':''?>" id="eid-<?=tempid?>">
// <div class="diff-left span5">
// <?tsl
// try
// rpt_show_data(other_data_i);
// except
// dolog("diffrepot_erData","数据解析展示出错:"$data[i]["NAME"]);
// dolog("diffrepot_erData",tostn(data[i]["DATA_ID"]));
// end;
// ?>
// </div>
// <div class="diff-right span5">
// <?tsl rpt_show_data(data[i]); ?>
// </div>
// <div class="span2">
// <?=class(IDS_LiveReport).rpt_data_comments(data[i]['comment'])?>
// </div>
// <div class="clear"></div>
// </div>
// </div><!--end element-data-container -->
// <?tsl
data := `r | data;
@@ -13,6 +13,9 @@ ROOT_DIRS=(
"/mnt/d/code/tinysoft/OfficeXml-dev/generator"
"/mnt/d/code/tinysoft/tsoffice/"
"/mnt/d/code/tinysoft/pdfconverter"
"/mnt/c/Programs/Tinysoft/TSLGen2/funcext/other"
"/mnt/c/Programs/Tinysoft/TSLGen2/funcext/tsword"
"/mnt/c/Programs/Tinysoft/TSLGen2/funcext/word2arr"
# "/mnt/d/code/tinysoft/PdfConverter"
# 可以添加更多目录
# "/path/to/third/directory"
+219 -215
View File
@@ -58,9 +58,10 @@ module.exports = grammar({
word: ($) => $.identifier,
conflicts: ($) => [
[$._left_hand_side, $.primary_expression],
[$.tssql_select_expression, $._table_or_subquery],
[$._left_hand_side, $._primary_expression],
[$._tssql_select_expression, $._table_or_subquery],
[$.tslx_close_tag, $.tslx_expression_tag],
[$._assignable_expression, $.array_element],
],
inline: ($) => [$._statement],
@@ -86,22 +87,22 @@ module.exports = grammar({
$.break_statement,
$.continue_statement,
$.return_statement,
$.inherited_statement,
// $.inherited_statement,
),
_compound_statement: ($) =>
choice(
$.if_statement,
$.for_statement,
$._for_statement,
$.while_statement,
$.repeat_statement,
$.case_statement,
$.try_statement,
$.anonymous_function_statement,
// $.function_declaration_statement,
$.function_declaration_statement,
$.function_definition_statement,
$.function_definition_statement_with_overload,
$.function_definition_with_overload_statement,
$.class_definition_statement,
$.external_method_statement,
@@ -109,11 +110,14 @@ module.exports = grammar({
$._tslx_template_statement,
),
var_statement: ($) => seq($.var_declaration, kSemicolon),
var_statement: ($) =>
seq(field("declaration", $.var_declaration), kSemicolon),
static_statement: ($) => seq($.static_declaration, kSemicolon),
static_statement: ($) =>
seq(field("declaration", $.static_declaration), kSemicolon),
global_statement: ($) => seq($.global_declaration, kSemicolon),
global_statement: ($) =>
seq(field("declaration", $.global_declaration), kSemicolon),
const_statement: ($) =>
seq(
@@ -126,13 +130,16 @@ module.exports = grammar({
),
var_declaration: ($) =>
seq(kw("var"), $._variable_declaration, optional($._type_clause)),
seq(kw("var"), $._variable_declaration, optional($._type_clause), optional($._initial_value)),
static_declaration: ($) =>
seq(kw("static"), $._variable_declaration, optional($._type_clause)),
seq(kw("static"), $._variable_declaration, optional($._type_clause), optional($._initial_value)),
global_declaration: ($) =>
seq(kw("global"), $._variable_declaration, optional($._type_clause)),
seq(kw("global"), $._variable_declaration, optional($._type_clause), optional($._initial_value)),
_initial_value: ($) =>
seq(":=", field("initial_value", $._right_hand_side)),
_variable_declaration: ($) => sep1(field("name", $.identifier), ","),
@@ -165,73 +172,43 @@ module.exports = grammar({
continue_statement: (_) => seq(kw("continue"), kSemicolon),
return_statement: ($) =>
seq(kw("return"), optional($.expression), kSemicolon),
seq(kw("return"), field("value", optional($.expression)), kSemicolon),
inherited_statement: ($) => seq($.inherited_expression, kSemicolon),
// inherited_statement: ($) => seq($._inherited_expression, kSemicolon),
_built_in_expression: ($) =>
choice($.echo_expression, $.raise_expression, $.new_expression),
choice($.echo_expression, $.raise_expression, $.new_expression, $.inherited_expression),
echo_expression: ($) =>
prec.left(1, seq(kw("echo"), sep1($.expression, ","))),
prec.left(1, seq(kw("echo"), sep1(field("argument", $.expression), ","))),
raise_expression: ($) => seq(kw("raise"), $.expression),
raise_expression: ($) => seq(kw("raise"), field("exception", $.expression)),
inherited_expression: ($) => seq(kw("inherited"), optional($.expression)),
inherited_expression: ($) => prec.left(0, seq(kw("inherited"), field("class", optional($.expression)))),
new_expression: ($) => seq(kw("new"), $.expression),
new_expression: ($) => seq(kw("new"), field("class", $.expression)),
expression_statement: ($) =>
seq(choice($.expression, $.tssql_dml_expression), kSemicolon),
seq(choice($.expression, $._tssql_dml_expression), kSemicolon),
expression: ($) =>
choice(
$.operator_expression,
$.tssql_select_expression,
$.primary_expression,
$._operator_expression,
$._tssql_select_expression,
$._primary_expression,
$._built_in_expression,
),
operator_expression: ($) =>
_operator_expression: ($) =>
choice(
$.expr_expression,
$.ternary_expression,
$.logical_or_expression,
$.logical_and_expression,
$.logical_not_expression,
$.comparison_expression,
$.bitwise_or_expression,
$.bitwise_and_expression,
$.bitwise_xor_expression,
$.bitwise_not_expression,
$.shift_expression,
$.addition_expression,
$.multiplication_expression,
$.power_expression,
$.logarithm_expression,
$.matrix_multiplication_expression,
$.matrix_power_expression,
$.matrix_concatenation_expression,
$.matrix_transpose_expression,
$.range_expression,
$.set_operation_expression,
$.concatenation_expression,
$.unary_plus_expression,
$.unary_minus_expression,
$.binary_expression,
$.unary_expression,
$.prefix_increment_expression,
$.prefix_decrement_expression,
$.postfix_increment_expression,
$.postfix_decrement_expression,
$.derivative_expression,
$.function_pointer_expression,
),
@@ -295,7 +272,7 @@ module.exports = grammar({
),
),
_with_assignment_expression: ($) =>
_assignable_expression: ($) =>
choice(
$.expression,
$.assignment_expression,
@@ -308,51 +285,45 @@ module.exports = grammar({
seq(
field("condition", $.expression),
"?",
optional(field("consequence", $._with_assignment_expression)),
optional(field("consequence", $._assignable_expression)),
":",
field("alternative", $._with_assignment_expression),
field("alternative", $._assignable_expression),
),
),
logical_or_expression: ($) =>
prec.left(
kPrec.kLogicalOr,
seq(
field("left", $.expression),
field("operator", choice(kw("or"), ".||", "||")),
field("right", $.expression),
),
binary_expression: ($) =>
choice(
$._logical_or_expression,
$._logical_and_expression,
$._bitwise_or_expression,
$._bitwise_and_expression,
$._bitwise_xor_expression,
$._shift_expression,
$._addition_expression,
$._multiplication_expression,
$._power_expression,
$._logarithm_expression,
$._matrix_multiplication_expression,
$._matrix_power_expression,
$._matrix_concatenation_expression,
$._range_expression,
$._comparison_expression,
$._set_operation_expression,
$._concatenation_expression,
),
logical_and_expression: ($) =>
prec.left(
kPrec.kLogicalAnd,
seq(
field("left", $.expression),
field("operator", choice(kw("and"), ".&&", "&&")),
field("right", $.expression),
),
),
logical_not_expression: ($) =>
prec.left(
kPrec.kLogicalNot,
seq(
field("operator", choice(kw("not"), ".!!")),
field("argument", $.expression),
),
),
comparison_expression: ($) =>
_comparison_expression: ($) =>
prec.left(
kPrec.kComparsion,
seq(
$.expression,
repeat1(
seq(
field(
"operators",
choice(
field("left", $.expression),
field("operator", choice(
"=",
"<>",
">",
@@ -370,13 +341,40 @@ module.exports = grammar({
kw("like"),
),
),
$.expression,
),
),
field("right", $.expression),
),
),
bitwise_or_expression: ($) =>
_logical_or_expression: ($) =>
prec.left(
kPrec.kLogicalOr,
seq(
field("left", $.expression),
field("operator", choice(kw("or"), ".||", "||")),
field("right", $.expression),
),
),
_logical_and_expression: ($) =>
prec.left(
kPrec.kLogicalAnd,
seq(
field("left", $.expression),
field("operator", choice(kw("and"), ".&&", "&&")),
field("right", $.expression),
),
),
_logical_not_expression: ($) =>
prec.left(
kPrec.kLogicalNot,
seq(
field("operator", choice(kw("not"), ".!!")),
field("argument", $.expression),
),
),
_bitwise_or_expression: ($) =>
prec.left(
kPrec.kBitwiseOr,
seq(
@@ -386,7 +384,7 @@ module.exports = grammar({
),
),
bitwise_and_expression: ($) =>
_bitwise_and_expression: ($) =>
prec.left(
kPrec.kBitwiseAnd,
seq(
@@ -396,7 +394,7 @@ module.exports = grammar({
),
),
bitwise_xor_expression: ($) =>
_bitwise_xor_expression: ($) =>
prec.left(
kPrec.kBitwiseXor,
seq(
@@ -406,13 +404,13 @@ module.exports = grammar({
),
),
bitwise_not_expression: ($) =>
_bitwise_not_expression: ($) =>
prec.left(
kPrec.kBitwiseNot,
seq(field("operator", ".!"), field("argument", $.expression)),
),
shift_expression: ($) =>
_shift_expression: ($) =>
prec.left(
kPrec.kShift,
seq(
@@ -422,7 +420,7 @@ module.exports = grammar({
),
),
addition_expression: ($) =>
_addition_expression: ($) =>
prec.left(
kPrec.kAddSub,
seq(
@@ -432,7 +430,7 @@ module.exports = grammar({
),
),
multiplication_expression: ($) =>
_multiplication_expression: ($) =>
prec.left(
kPrec.kTimes,
seq(
@@ -442,7 +440,7 @@ module.exports = grammar({
),
),
power_expression: ($) =>
_power_expression: ($) =>
prec.right(
kPrec.kPower,
seq(
@@ -452,7 +450,7 @@ module.exports = grammar({
),
),
logarithm_expression: ($) =>
_logarithm_expression: ($) =>
prec.left(
kPrec.kLogarithm,
seq(
@@ -462,7 +460,7 @@ module.exports = grammar({
),
),
matrix_multiplication_expression: ($) =>
_matrix_multiplication_expression: ($) =>
prec.left(
kPrec.kMatrixTimes,
seq(
@@ -472,7 +470,7 @@ module.exports = grammar({
),
),
matrix_power_expression: ($) =>
_matrix_power_expression: ($) =>
prec.right(
kPrec.kMatrixPower,
seq(
@@ -482,7 +480,7 @@ module.exports = grammar({
),
),
matrix_concatenation_expression: ($) =>
_matrix_concatenation_expression: ($) =>
prec.left(
kPrec.kMatrixConcat,
seq(
@@ -492,7 +490,7 @@ module.exports = grammar({
),
),
range_expression: ($) =>
_range_expression: ($) =>
prec.left(
kPrec.kRange,
seq(
@@ -502,13 +500,13 @@ module.exports = grammar({
),
),
matrix_transpose_expression: ($) =>
_matrix_transpose_expression: ($) =>
prec(
kPrec.kMatrixTranspose,
seq(field("operator", "`"), field("argument", $.expression)),
),
set_operation_expression: ($) =>
_set_operation_expression: ($) =>
prec.left(
kPrec.kSet,
seq(
@@ -527,7 +525,7 @@ module.exports = grammar({
),
),
concatenation_expression: ($) =>
_concatenation_expression: ($) =>
prec.left(
kPrec.kConcat,
seq(
@@ -537,18 +535,37 @@ module.exports = grammar({
),
),
unary_plus_expression: ($) =>
unary_expression: ($) =>
choice(
$._unary_plus_expression,
$._unary_minus_expression,
$._derivative_expression,
$._logical_not_expression,
$._bitwise_not_expression,
$._matrix_transpose_expression,
),
_unary_plus_expression: ($) =>
prec(
kPrec.kSigned,
seq(field("operator", "+"), field("argument", $.expression)),
),
unary_minus_expression: ($) =>
_unary_minus_expression: ($) =>
prec(
kPrec.kSigned,
seq(field("operator", "-"), field("argument", $.expression)),
),
_derivative_expression: ($) =>
prec.left(
kPrec.kDerivative,
seq(field("operator", "!"), field("argument", $.expression)),
),
prefix_increment_expression: ($) =>
prec.right(
kPrec.kPrefix,
@@ -573,12 +590,6 @@ module.exports = grammar({
seq(field("argument", $.expression), field("operator", "--")),
),
derivative_expression: ($) =>
prec.left(
kPrec.kDerivative,
seq(field("operator", "!"), field("argument", $.expression)),
),
function_pointer_expression: ($) =>
prec(
kPrec.kFunctionPointer,
@@ -591,7 +602,7 @@ module.exports = grammar({
$._parameter_signature,
field("return_type", optional($._type_clause)),
optional(kSemicolon),
field("body", $.block_statement),
field("body", $.block_suite),
),
unpack_pattern: ($) => prec.dynamic(1, seq("[", $._unpack_vars, "]")),
@@ -604,10 +615,7 @@ module.exports = grammar({
_left_hand_side: ($) =>
choice(
$._assignable_identifier,
$.var_declaration,
$.static_declaration,
$.global_declaration,
$._identifier_like,
$.attribute,
$.subscript,
$.unpack_pattern,
@@ -620,7 +628,7 @@ module.exports = grammar({
$.augmented_assignment_expression,
),
tssql_select_expression: ($) =>
_tssql_select_expression: ($) =>
choice(
$.select_expression,
$.sselect_expression,
@@ -628,7 +636,7 @@ module.exports = grammar({
$.mselect_expression,
),
tssql_dml_expression: ($) =>
_tssql_dml_expression: ($) =>
choice($.update_expression, $.delete_expression, $.insert_expression),
select_expression: ($) => seq(kw("select"), $._select_clause),
@@ -673,7 +681,7 @@ module.exports = grammar({
update_assignment: ($) =>
seq(
field("column", $.primary_expression),
field("column", $._primary_expression),
"=",
field("value", $.expression),
),
@@ -799,16 +807,16 @@ module.exports = grammar({
")",
),
primary_expression: ($) =>
_primary_expression: ($) =>
choice(
$.attribute,
$.subscript,
$.parenthesized_expression,
$.call,
$.array,
$._literal,
$._assignable_identifier,
$._reserved_keyword,
$.literal,
$.reserved_keyword,
$._parenthesized_expression,
$._identifier_like,
$.sql_field,
),
@@ -816,12 +824,12 @@ module.exports = grammar({
// identifier: _ => /[a-zA-Z_][a-zA-Z0-9_]*/,
identifier: (_) => token(prec(kPrec.kIdentifier, /[a-zA-Z_][a-zA-Z0-9_]*/)),
_literal: ($) =>
literal: ($) =>
choice($.number, $.string, $.boolean, $.nil, $.infinity, $.ellipsis),
_assignable_identifier: ($) => choice($.identifier, $.type, $.do),
_identifier_like: ($) => choice($.identifier, $.type, $.do),
_reserved_keyword: ($) => choice($.class, $.in),
reserved_keyword: ($) => choice($.class, $.in),
type: (_) => kw("type"),
class: (_) => kw("class"),
@@ -890,9 +898,9 @@ module.exports = grammar({
prec(
kPrec.kCall,
seq(
field("function", $.primary_expression),
field("function", $._primary_expression),
"(",
field("arguments", optional($.argument_list)),
optional(sep1(field("argument", $.argument), ",")),
")",
),
),
@@ -901,7 +909,7 @@ module.exports = grammar({
prec(
kPrec.kAttribute,
seq(
field("object", choice($.primary_expression)),
field("object", choice($._primary_expression)),
".",
field("attribute", $.identifier),
),
@@ -913,7 +921,7 @@ module.exports = grammar({
prec(
kPrec.kSubscript,
seq(
field("value", $.primary_expression),
field("value", $._primary_expression),
"[",
field("subscript", $._index_spec),
"]",
@@ -921,8 +929,7 @@ module.exports = grammar({
),
),
parenthesized_expression: ($) =>
seq("(", $._with_assignment_expression, ")"),
_parenthesized_expression: ($) => seq("(", optional($._assignable_expression), ")"),
array: ($) =>
prec(
@@ -930,15 +937,18 @@ module.exports = grammar({
seq(kw("array"), "(", optional($._array_elements), ")"),
),
argument_list: ($) => sep1($.argument, ","),
argument: ($) =>
choice(
$.expression,
seq(field("name", $.identifier), ":", field("value", $.expression)),
"*",
$.named_argument,
// $.spread_argument
),
named_argument: ($) =>
seq(field("name", $.identifier), ":", field("value", $.expression)),
// spread_argument: (_) => "*",
_index_spec: ($) => choice($._multi_index, $._single_index),
_multi_index: ($) => seq($._index_item, repeat1(seq(",", $._index_item))),
@@ -969,9 +979,9 @@ module.exports = grammar({
key_value_pair: ($) =>
seq(
field("key", $.expression),
field("key", choice($.expression)),
":",
field("value", choice($.expression, $.parenthesized_array)),
field("value", choice($.parenthesized_array, $.expression)),
),
parenthesized_array: ($) =>
@@ -979,12 +989,7 @@ module.exports = grammar({
1,
seq(
"(",
choice(
seq($.key_value_pair, ",", sep1($.key_value_pair, ",")),
$.key_value_pair,
seq($.expression, ",", sep1($.expression, ",")),
$.expression,
),
sep1($.array_element, ","),
optional(","),
")",
),
@@ -1001,15 +1006,15 @@ module.exports = grammar({
kPrec.kIf,
seq(
$.if_clause,
repeat(field("alternative", $.else_if_clause)),
optional(field("alternative", $.else_clause)),
repeat($.else_if_clause),
optional($.else_clause),
),
),
if_clause: ($) =>
seq(
kw("if"),
field("condition", $._with_assignment_expression),
field("condition", $._assignable_expression),
kw("then"),
field("consequence", $._statement_suite),
),
@@ -1020,7 +1025,7 @@ module.exports = grammar({
seq(
kw("else"),
kw("if"),
field("condition", $._with_assignment_expression),
field("condition", $._assignable_expression),
kw("then"),
field("consequence", $._statement_suite),
),
@@ -1030,13 +1035,13 @@ module.exports = grammar({
seq(kw("else"), field("consequence", $._statement_suite)),
_statement_suite: ($) =>
choice(seq($.block_statement, optional(kSemicolon)), $.single_suite),
choice(seq($.block_suite, optional(kSemicolon)), $.single_suite),
single_suite: ($) => $._statement,
block_statement: ($) => seq(kw("begin"), repeat($._statement), kw("end")),
block_suite: ($) => seq(kw("begin"), repeat($._statement), kw("end")),
for_statement: ($) => choice($.for_in_statement, $.for_to_statement),
_for_statement: ($) => choice($.for_in_statement, $.for_to_statement),
for_in_statement: ($) =>
seq(
@@ -1091,13 +1096,9 @@ module.exports = grammar({
),
case_branch: ($) =>
seq(
$.case_values,
":",
field("consequence", $._statement_suite),
),
seq($._case_values, ":", field("consequence", $._statement_suite)),
case_values: ($) => sep1(field("value", $.expression), ","),
_case_values: ($) => sep1(field("value", $.expression), ","),
case_else: ($) => seq(kw("else"), field("consequence", $._statement_suite)),
@@ -1114,14 +1115,14 @@ module.exports = grammar({
anonymous_function_statement: ($) =>
seq($.anonymous_function_expression, optional(kSemicolon)),
// function_declaration_statement: ($) =>
// seq(
// kw("function"),
// field("name", $.identifier),
// $._parameter_signature,
// optional(field("return_type", $._type_clause)),
// kSemicolon,
// ),
function_declaration_statement: ($) =>
seq(
kw("function"),
field("name", $.identifier),
$._parameter_signature,
optional(field("return_type", $._type_clause)),
kSemicolon,
),
function_definition_statement: ($) =>
seq(
@@ -1130,11 +1131,11 @@ module.exports = grammar({
$._parameter_signature,
field("return_type", optional($._type_clause)),
optional(kSemicolon),
field("body", $.block_statement),
field("body", $.block_suite),
optional(kSemicolon),
),
function_definition_statement_with_overload: ($) =>
function_definition_with_overload_statement: ($) =>
seq(
kw("function"),
field("name", $.identifier),
@@ -1143,20 +1144,20 @@ module.exports = grammar({
kSemicolon,
kw("overload"),
kSemicolon,
field("body", $.block_statement),
field("body", $.block_suite),
optional(kSemicolon),
),
_parameter_signature: ($) =>
seq("(", optional(field("parameters", $.parameter_list)), ")"),
seq("(", optional(field("parameters", $.parameters)), ")"),
parameter_list: ($) => sep1($.parameter, kSemicolon),
parameters: ($) => sep1(field("parameter", $.parameter), kSemicolon),
parameter: ($) =>
seq(
optional(choice(kw("var"), kw("out"))),
sep1(field("name", $.identifier), ","),
optional(field("type", $._type_clause)),
optional($._type_clause),
optional(seq("=", field("default", $.expression))),
),
@@ -1184,9 +1185,10 @@ module.exports = grammar({
class_member: ($) =>
choice(
field("access_modifier", $.access_modifier),
field("reference_modifier", $.reference_modifier),
choice(
$.variable_declaration,
$.method_declaration,
$._method_declaration,
$.property_declaration,
),
$.uses_statement,
@@ -1198,7 +1200,7 @@ module.exports = grammar({
variable_declaration: ($) =>
seq(
optional($._reference_tag),
field("variables", $.member_variable),
field("variable", $.member_variable),
kSemicolon,
),
@@ -1207,13 +1209,15 @@ module.exports = grammar({
reference_modifier: (_) => choice(kw("weakref"), kw("autoref")),
member_variable: ($) =>
choice($.static_declaration, $.nostatic_declaration),
member_variable: ($) => choice($.static_member_variable, $.field_member_variable),
nostatic_declaration: ($) =>
seq($._variable_declaration, optional($._type_clause)),
static_member_variable: ($) =>
seq(kw("static"), $._variable_declaration, optional($._type_clause), optional(seq("=", field("initial_value", $._right_hand_side)))),
method_declaration: ($) =>
field_member_variable: ($) =>
seq($._variable_declaration, optional($._type_clause), optional(seq("=", field("initial_value", $._right_hand_side)))),
_method_declaration: ($) =>
choice(
$.method_declaration_only,
$.method_with_modifier,
@@ -1239,7 +1243,7 @@ module.exports = grammar({
kSemicolon,
field("modifier", $.method_modifier),
kSemicolon,
optional(seq(field("body", $.block_statement), optional(kSemicolon))),
optional(seq(field("body", $.block_suite), optional(kSemicolon))),
),
method_with_implementation: ($) =>
@@ -1250,13 +1254,13 @@ module.exports = grammar({
$._parameter_signature,
optional(field("return_type", $._type_clause)),
optional(kSemicolon),
field("body", $.block_statement),
field("body", $.block_suite),
optional(kSemicolon),
),
method_name: ($) =>
choice(
$._assignable_identifier,
$._identifier_like,
// $.identifier,
$.operator_overload,
),
@@ -1279,35 +1283,35 @@ module.exports = grammar({
kSemicolon,
),
_property_index: ($) => seq(kw("index"), choice($.number, $.string)),
_property_index: ($) => seq(kw("index"), field("index", choice($.number, $.string))),
property_accessors: ($) =>
choice(
$.read_only_accessor,
$.write_only_accessor,
$.read_write_accessor,
$.write_read_accessor,
$._read_only_accessor,
$._write_only_accessor,
$._read_write_accessor,
$._write_read_accessor,
),
read_only_accessor: ($) => seq(kw("read"), $.identifier),
_read_only_accessor: ($) => seq(kw("read"), field("read", $.identifier)),
write_only_accessor: ($) => seq(kw("write"), $.identifier),
_write_only_accessor: ($) => seq(kw("write"), field("write", $.identifier)),
read_write_accessor: ($) =>
seq(kw("read"), $.identifier, kw("write"), $.identifier),
_read_write_accessor: ($) =>
seq(kw("read"), field("read", $.identifier), kw("write"), field("write", $.identifier)),
write_read_accessor: ($) =>
seq(kw("write"), $.identifier, kw("read"), $.identifier),
_write_read_accessor: ($) =>
seq(kw("write"), field("write", $.identifier), kw("read"), field("read", $.identifier)),
// 类外方法实现
external_method_statement: ($) =>
choice($.modifier_method, $.operator_method, $.normal_method),
choice($._modifier_method, $._operator_method, $._normal_method),
matrix_iteration_statement: ($) =>
seq(
field("target", $.expression),
"::",
field("body", $.block_statement),
field("body", $.block_suite),
optional(kSemicolon),
),
@@ -1364,7 +1368,7 @@ module.exports = grammar({
html_comment: (_) =>
token(seq("<!--", repeat(choice(/[^-]/, /-[^-]/, /--[^>]/)), "-->")),
modifier_method: ($) =>
_modifier_method: ($) =>
seq(
kw("function"),
$._qualified_method_name,
@@ -1373,14 +1377,14 @@ module.exports = grammar({
kSemicolon,
field("modifier", $.method_modifier),
kSemicolon,
field("body", $.block_statement),
field("body", $.block_suite),
optional(kSemicolon),
),
operator_method: ($) =>
_operator_method: ($) =>
choice($._operator_method, $._operator_method_with_modifier),
normal_method: ($) =>
_normal_method: ($) =>
seq(
optional($.class),
kw("function"),
@@ -1388,7 +1392,7 @@ module.exports = grammar({
$._parameter_signature,
optional(field("return_type", $._type_clause)),
optional(kSemicolon),
field("body", $.block_statement),
field("body", $.block_suite),
optional(kSemicolon),
),
@@ -1402,7 +1406,7 @@ module.exports = grammar({
$._parameter_signature,
optional(field("return_type", $._type_clause)),
optional(kSemicolon),
field("body", $.block_statement),
field("body", $.block_suite),
optional(kSemicolon),
),
@@ -1418,7 +1422,7 @@ module.exports = grammar({
kSemicolon,
field("modifier", $.method_modifier),
kSemicolon,
field("body", $.block_statement),
field("body", $.block_suite),
optional(kSemicolon),
),
@@ -1444,16 +1448,16 @@ module.exports = grammar({
),
interface_section: ($) =>
seq(kw("interface"), optional(repeat($._statement))),
seq(kw("interface"), repeat($._statement)),
implementation_section: ($) =>
seq(kw("implementation"), optional(repeat($._statement))),
seq(kw("implementation"), repeat($._statement)),
initialization_section: ($) =>
seq(kw("initialization"), optional(repeat($._statement))),
seq(kw("initialization"), repeat($._statement)),
finalization_section: ($) =>
seq(kw("finalization"), optional(repeat($._statement))),
seq(kw("finalization"), repeat($._statement)),
uses_statement: ($) =>
seq(kw("uses"), sep1(field("module", $.identifier), ","), kSemicolon),
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+166381 -146442
View File
File diff suppressed because it is too large Load Diff