improve tree-sitter
This commit is contained in:
parent
9385aaf2c1
commit
dbccd5b605
|
|
@ -2413,20 +2413,20 @@
|
||||||
"name": "_parameter_signature"
|
"name": "_parameter_signature"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
|
||||||
"name": "return_type",
|
|
||||||
"content": {
|
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "return_type",
|
||||||
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_type_clause"
|
"name": "_type_clause"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "BLANK"
|
"type": "BLANK"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
|
|
@ -5601,7 +5601,7 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"function_declaration_statement": {
|
"_function_header": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
|
|
@ -5640,6 +5640,15 @@
|
||||||
"type": "BLANK"
|
"type": "BLANK"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"function_declaration_statement": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_function_header"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
|
|
@ -5651,41 +5660,8 @@
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "ALIAS",
|
|
||||||
"content": {
|
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "(?i)function"
|
|
||||||
},
|
|
||||||
"named": false,
|
|
||||||
"value": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "name",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "identifier"
|
"name": "_function_header"
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_parameter_signature"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "return_type",
|
|
||||||
"content": {
|
|
||||||
"type": "CHOICE",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_type_clause"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "BLANK"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
|
|
@ -5725,41 +5701,8 @@
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "ALIAS",
|
|
||||||
"content": {
|
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "(?i)function"
|
|
||||||
},
|
|
||||||
"named": false,
|
|
||||||
"value": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "name",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "identifier"
|
"name": "_function_header"
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_parameter_signature"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "return_type",
|
|
||||||
"content": {
|
|
||||||
"type": "CHOICE",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_type_clause"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "BLANK"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
|
|
@ -6115,11 +6058,20 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"class_body": {
|
"class_body": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "uses_statement"
|
||||||
|
},
|
||||||
|
{
|
||||||
"type": "REPEAT1",
|
"type": "REPEAT1",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "class_member"
|
"name": "class_member"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"class_member": {
|
"class_member": {
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
|
|
@ -6156,10 +6108,6 @@
|
||||||
"name": "property_declaration"
|
"name": "property_declaration"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "uses_statement"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -7396,8 +7344,33 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_operator_method": {
|
"_operator_method": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_operator_overload_method"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_operator_method_with_modifier"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_normal_method": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "class"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "ALIAS",
|
"type": "ALIAS",
|
||||||
"content": {
|
"content": {
|
||||||
|
|
@ -7408,33 +7381,8 @@
|
||||||
"value": "function"
|
"value": "function"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "ALIAS",
|
|
||||||
"content": {
|
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "(?i)operator"
|
|
||||||
},
|
|
||||||
"named": false,
|
|
||||||
"value": "operator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "class_name",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "identifier"
|
"name": "_qualified_method_name"
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "operator",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_overloadable_operator"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
|
|
@ -7490,21 +7438,9 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_normal_method": {
|
"_operator_overload_method": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
|
||||||
"type": "CHOICE",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "class"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "BLANK"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "ALIAS",
|
"type": "ALIAS",
|
||||||
"content": {
|
"content": {
|
||||||
|
|
@ -7515,8 +7451,33 @@
|
||||||
"value": "function"
|
"value": "function"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "(?i)operator"
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "operator"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "class_name",
|
||||||
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_qualified_method_name"
|
"name": "identifier"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "operator",
|
||||||
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_overloadable_operator"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
|
|
|
||||||
|
|
@ -1127,6 +1127,10 @@
|
||||||
{
|
{
|
||||||
"type": "class_member",
|
"type": "class_member",
|
||||||
"named": true
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "uses_statement",
|
||||||
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -1230,10 +1234,6 @@
|
||||||
"type": "property_declaration",
|
"type": "property_declaration",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "uses_statement",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "variable_declaration",
|
"type": "variable_declaration",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
@ -1680,7 +1680,7 @@
|
||||||
"fields": {
|
"fields": {
|
||||||
"body": {
|
"body": {
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"required": true,
|
"required": false,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "block_suite",
|
"type": "block_suite",
|
||||||
|
|
@ -1690,7 +1690,7 @@
|
||||||
},
|
},
|
||||||
"class_name": {
|
"class_name": {
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"required": false,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "identifier",
|
"type": "identifier",
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,5 +1,2 @@
|
||||||
function abc();
|
type A = class(B.c)
|
||||||
begin
|
|
||||||
uses m1, m2;
|
|
||||||
data := `r | data;
|
|
||||||
end;
|
end;
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ ROOT_DIRS=(
|
||||||
"/mnt/c/Programs/Tinysoft/TSLGen2/funcext/other"
|
"/mnt/c/Programs/Tinysoft/TSLGen2/funcext/other"
|
||||||
"/mnt/c/Programs/Tinysoft/TSLGen2/funcext/tsword"
|
"/mnt/c/Programs/Tinysoft/TSLGen2/funcext/tsword"
|
||||||
"/mnt/c/Programs/Tinysoft/TSLGen2/funcext/word2arr"
|
"/mnt/c/Programs/Tinysoft/TSLGen2/funcext/word2arr"
|
||||||
|
"/mnt/c/Programs/Tinysoft/TSLGen2/funcext/tsoffice"
|
||||||
|
"/mnt/c/Programs/Tinysoft/TSLGen2/funcext/OfficeXml-dev"
|
||||||
# "/mnt/d/code/tinysoft/PdfConverter"
|
# "/mnt/d/code/tinysoft/PdfConverter"
|
||||||
# 可以添加更多目录
|
# 可以添加更多目录
|
||||||
# "/path/to/third/directory"
|
# "/path/to/third/directory"
|
||||||
|
|
|
||||||
|
|
@ -130,13 +130,28 @@ module.exports = grammar({
|
||||||
),
|
),
|
||||||
|
|
||||||
var_declaration: ($) =>
|
var_declaration: ($) =>
|
||||||
seq(kw("var"), $._variable_declaration, optional($._type_clause), optional($._initial_value)),
|
seq(
|
||||||
|
kw("var"),
|
||||||
|
$._variable_declaration,
|
||||||
|
optional($._type_clause),
|
||||||
|
optional($._initial_value),
|
||||||
|
),
|
||||||
|
|
||||||
static_declaration: ($) =>
|
static_declaration: ($) =>
|
||||||
seq(kw("static"), $._variable_declaration, optional($._type_clause), optional($._initial_value)),
|
seq(
|
||||||
|
kw("static"),
|
||||||
|
$._variable_declaration,
|
||||||
|
optional($._type_clause),
|
||||||
|
optional($._initial_value),
|
||||||
|
),
|
||||||
|
|
||||||
global_declaration: ($) =>
|
global_declaration: ($) =>
|
||||||
seq(kw("global"), $._variable_declaration, optional($._type_clause), optional($._initial_value)),
|
seq(
|
||||||
|
kw("global"),
|
||||||
|
$._variable_declaration,
|
||||||
|
optional($._type_clause),
|
||||||
|
optional($._initial_value),
|
||||||
|
),
|
||||||
|
|
||||||
_initial_value: ($) =>
|
_initial_value: ($) =>
|
||||||
seq(":=", field("initial_value", $._right_hand_side)),
|
seq(":=", field("initial_value", $._right_hand_side)),
|
||||||
|
|
@ -177,14 +192,23 @@ module.exports = grammar({
|
||||||
// inherited_statement: ($) => seq($._inherited_expression, kSemicolon),
|
// inherited_statement: ($) => seq($._inherited_expression, kSemicolon),
|
||||||
|
|
||||||
_built_in_expression: ($) =>
|
_built_in_expression: ($) =>
|
||||||
choice($.echo_expression, $.raise_expression, $.new_expression, $.inherited_expression),
|
choice(
|
||||||
|
$.echo_expression,
|
||||||
|
$.raise_expression,
|
||||||
|
$.new_expression,
|
||||||
|
$.inherited_expression,
|
||||||
|
),
|
||||||
|
|
||||||
echo_expression: ($) =>
|
echo_expression: ($) =>
|
||||||
prec.left(1, seq(kw("echo"), sep1(field("argument", $.expression), ","))),
|
prec.left(1, seq(kw("echo"), sep1(field("argument", $.expression), ","))),
|
||||||
|
|
||||||
raise_expression: ($) => seq(kw("raise"), field("exception", $.expression)),
|
raise_expression: ($) => seq(kw("raise"), field("exception", $.expression)),
|
||||||
|
|
||||||
inherited_expression: ($) => prec.left(0, seq(kw("inherited"), field("class", optional($.expression)))),
|
inherited_expression: ($) =>
|
||||||
|
prec.left(
|
||||||
|
0,
|
||||||
|
seq(kw("inherited"), field("class", optional($.expression))),
|
||||||
|
),
|
||||||
|
|
||||||
new_expression: ($) => seq(kw("new"), field("class", $.expression)),
|
new_expression: ($) => seq(kw("new"), field("class", $.expression)),
|
||||||
|
|
||||||
|
|
@ -323,7 +347,9 @@ module.exports = grammar({
|
||||||
kPrec.kComparsion,
|
kPrec.kComparsion,
|
||||||
seq(
|
seq(
|
||||||
field("left", $.expression),
|
field("left", $.expression),
|
||||||
field("operator", choice(
|
field(
|
||||||
|
"operator",
|
||||||
|
choice(
|
||||||
"=",
|
"=",
|
||||||
"<>",
|
"<>",
|
||||||
">",
|
">",
|
||||||
|
|
@ -600,7 +626,7 @@ module.exports = grammar({
|
||||||
seq(
|
seq(
|
||||||
kw("function"),
|
kw("function"),
|
||||||
$._parameter_signature,
|
$._parameter_signature,
|
||||||
field("return_type", optional($._type_clause)),
|
optional(field("return_type", $._type_clause)),
|
||||||
optional(kSemicolon),
|
optional(kSemicolon),
|
||||||
field("body", $.block_suite),
|
field("body", $.block_suite),
|
||||||
),
|
),
|
||||||
|
|
@ -614,12 +640,7 @@ module.exports = grammar({
|
||||||
),
|
),
|
||||||
|
|
||||||
_left_hand_side: ($) =>
|
_left_hand_side: ($) =>
|
||||||
choice(
|
choice($._identifier_like, $.attribute, $.subscript, $.unpack_pattern),
|
||||||
$._identifier_like,
|
|
||||||
$.attribute,
|
|
||||||
$.subscript,
|
|
||||||
$.unpack_pattern,
|
|
||||||
),
|
|
||||||
|
|
||||||
_right_hand_side: ($) =>
|
_right_hand_side: ($) =>
|
||||||
choice(
|
choice(
|
||||||
|
|
@ -929,7 +950,8 @@ module.exports = grammar({
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
||||||
_parenthesized_expression: ($) => seq("(", optional($._assignable_expression), ")"),
|
_parenthesized_expression: ($) =>
|
||||||
|
seq("(", optional($._assignable_expression), ")"),
|
||||||
|
|
||||||
array: ($) =>
|
array: ($) =>
|
||||||
prec(
|
prec(
|
||||||
|
|
@ -985,15 +1007,7 @@ module.exports = grammar({
|
||||||
),
|
),
|
||||||
|
|
||||||
parenthesized_array: ($) =>
|
parenthesized_array: ($) =>
|
||||||
prec(
|
prec(1, seq("(", sep1($.array_element, ","), optional(","), ")")),
|
||||||
1,
|
|
||||||
seq(
|
|
||||||
"(",
|
|
||||||
sep1($.array_element, ","),
|
|
||||||
optional(","),
|
|
||||||
")",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
|
|
||||||
line_comment: (_) => token(seq("//", /.*/)),
|
line_comment: (_) => token(seq("//", /.*/)),
|
||||||
|
|
||||||
|
|
@ -1004,11 +1018,7 @@ module.exports = grammar({
|
||||||
if_statement: ($) =>
|
if_statement: ($) =>
|
||||||
prec.right(
|
prec.right(
|
||||||
kPrec.kIf,
|
kPrec.kIf,
|
||||||
seq(
|
seq($.if_clause, repeat($.else_if_clause), optional($.else_clause)),
|
||||||
$.if_clause,
|
|
||||||
repeat($.else_if_clause),
|
|
||||||
optional($.else_clause),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
|
|
||||||
if_clause: ($) =>
|
if_clause: ($) =>
|
||||||
|
|
@ -1115,21 +1125,23 @@ module.exports = grammar({
|
||||||
anonymous_function_statement: ($) =>
|
anonymous_function_statement: ($) =>
|
||||||
seq($.anonymous_function_expression, optional(kSemicolon)),
|
seq($.anonymous_function_expression, optional(kSemicolon)),
|
||||||
|
|
||||||
function_declaration_statement: ($) =>
|
_function_header: ($) =>
|
||||||
seq(
|
seq(
|
||||||
kw("function"),
|
kw("function"),
|
||||||
field("name", $.identifier),
|
field("name", $.identifier),
|
||||||
$._parameter_signature,
|
$._parameter_signature,
|
||||||
optional(field("return_type", $._type_clause)),
|
optional(field("return_type", $._type_clause)),
|
||||||
|
),
|
||||||
|
|
||||||
|
function_declaration_statement: ($) =>
|
||||||
|
seq(
|
||||||
|
$._function_header,
|
||||||
kSemicolon,
|
kSemicolon,
|
||||||
),
|
),
|
||||||
|
|
||||||
function_definition_statement: ($) =>
|
function_definition_statement: ($) =>
|
||||||
seq(
|
seq(
|
||||||
kw("function"),
|
$._function_header,
|
||||||
field("name", $.identifier),
|
|
||||||
$._parameter_signature,
|
|
||||||
field("return_type", optional($._type_clause)),
|
|
||||||
optional(kSemicolon),
|
optional(kSemicolon),
|
||||||
field("body", $.block_suite),
|
field("body", $.block_suite),
|
||||||
optional(kSemicolon),
|
optional(kSemicolon),
|
||||||
|
|
@ -1137,10 +1149,7 @@ module.exports = grammar({
|
||||||
|
|
||||||
function_definition_with_overload_statement: ($) =>
|
function_definition_with_overload_statement: ($) =>
|
||||||
seq(
|
seq(
|
||||||
kw("function"),
|
$._function_header,
|
||||||
field("name", $.identifier),
|
|
||||||
$._parameter_signature,
|
|
||||||
field("return_type", optional($._type_clause)),
|
|
||||||
kSemicolon,
|
kSemicolon,
|
||||||
kw("overload"),
|
kw("overload"),
|
||||||
kSemicolon,
|
kSemicolon,
|
||||||
|
|
@ -1180,7 +1189,10 @@ module.exports = grammar({
|
||||||
")",
|
")",
|
||||||
),
|
),
|
||||||
|
|
||||||
class_body: ($) => repeat1($.class_member),
|
class_body: ($) => choice(
|
||||||
|
$.uses_statement,
|
||||||
|
repeat1($.class_member),
|
||||||
|
),
|
||||||
|
|
||||||
class_member: ($) =>
|
class_member: ($) =>
|
||||||
choice(
|
choice(
|
||||||
|
|
@ -1191,7 +1203,6 @@ module.exports = grammar({
|
||||||
$._method_declaration,
|
$._method_declaration,
|
||||||
$.property_declaration,
|
$.property_declaration,
|
||||||
),
|
),
|
||||||
$.uses_statement,
|
|
||||||
),
|
),
|
||||||
|
|
||||||
access_modifier: (_) =>
|
access_modifier: (_) =>
|
||||||
|
|
@ -1209,13 +1220,23 @@ module.exports = grammar({
|
||||||
|
|
||||||
reference_modifier: (_) => choice(kw("weakref"), kw("autoref")),
|
reference_modifier: (_) => choice(kw("weakref"), kw("autoref")),
|
||||||
|
|
||||||
member_variable: ($) => choice($.static_member_variable, $.field_member_variable),
|
member_variable: ($) =>
|
||||||
|
choice($.static_member_variable, $.field_member_variable),
|
||||||
|
|
||||||
static_member_variable: ($) =>
|
static_member_variable: ($) =>
|
||||||
seq(kw("static"), $._variable_declaration, optional($._type_clause), optional(seq("=", field("initial_value", $._right_hand_side)))),
|
seq(
|
||||||
|
kw("static"),
|
||||||
|
$._variable_declaration,
|
||||||
|
optional($._type_clause),
|
||||||
|
optional(seq("=", field("initial_value", $._right_hand_side))),
|
||||||
|
),
|
||||||
|
|
||||||
field_member_variable: ($) =>
|
field_member_variable: ($) =>
|
||||||
seq($._variable_declaration, optional($._type_clause), optional(seq("=", field("initial_value", $._right_hand_side)))),
|
seq(
|
||||||
|
$._variable_declaration,
|
||||||
|
optional($._type_clause),
|
||||||
|
optional(seq("=", field("initial_value", $._right_hand_side))),
|
||||||
|
),
|
||||||
|
|
||||||
_method_declaration: ($) =>
|
_method_declaration: ($) =>
|
||||||
choice(
|
choice(
|
||||||
|
|
@ -1283,7 +1304,8 @@ module.exports = grammar({
|
||||||
kSemicolon,
|
kSemicolon,
|
||||||
),
|
),
|
||||||
|
|
||||||
_property_index: ($) => seq(kw("index"), field("index", choice($.number, $.string))),
|
_property_index: ($) =>
|
||||||
|
seq(kw("index"), field("index", choice($.number, $.string))),
|
||||||
|
|
||||||
property_accessors: ($) =>
|
property_accessors: ($) =>
|
||||||
choice(
|
choice(
|
||||||
|
|
@ -1298,10 +1320,20 @@ module.exports = grammar({
|
||||||
_write_only_accessor: ($) => seq(kw("write"), field("write", $.identifier)),
|
_write_only_accessor: ($) => seq(kw("write"), field("write", $.identifier)),
|
||||||
|
|
||||||
_read_write_accessor: ($) =>
|
_read_write_accessor: ($) =>
|
||||||
seq(kw("read"), field("read", $.identifier), kw("write"), field("write", $.identifier)),
|
seq(
|
||||||
|
kw("read"),
|
||||||
|
field("read", $.identifier),
|
||||||
|
kw("write"),
|
||||||
|
field("write", $.identifier),
|
||||||
|
),
|
||||||
|
|
||||||
_write_read_accessor: ($) =>
|
_write_read_accessor: ($) =>
|
||||||
seq(kw("write"), field("write", $.identifier), kw("read"), field("read", $.identifier)),
|
seq(
|
||||||
|
kw("write"),
|
||||||
|
field("write", $.identifier),
|
||||||
|
kw("read"),
|
||||||
|
field("read", $.identifier),
|
||||||
|
),
|
||||||
|
|
||||||
// 类外方法实现
|
// 类外方法实现
|
||||||
external_method_statement: ($) =>
|
external_method_statement: ($) =>
|
||||||
|
|
@ -1382,7 +1414,7 @@ module.exports = grammar({
|
||||||
),
|
),
|
||||||
|
|
||||||
_operator_method: ($) =>
|
_operator_method: ($) =>
|
||||||
choice($._operator_method, $._operator_method_with_modifier),
|
choice($._operator_overload_method, $._operator_method_with_modifier),
|
||||||
|
|
||||||
_normal_method: ($) =>
|
_normal_method: ($) =>
|
||||||
seq(
|
seq(
|
||||||
|
|
@ -1396,7 +1428,7 @@ module.exports = grammar({
|
||||||
optional(kSemicolon),
|
optional(kSemicolon),
|
||||||
),
|
),
|
||||||
|
|
||||||
_operator_method: ($) =>
|
_operator_overload_method: ($) =>
|
||||||
seq(
|
seq(
|
||||||
kw("function"),
|
kw("function"),
|
||||||
kw("operator"),
|
kw("operator"),
|
||||||
|
|
@ -1447,8 +1479,7 @@ module.exports = grammar({
|
||||||
".",
|
".",
|
||||||
),
|
),
|
||||||
|
|
||||||
interface_section: ($) =>
|
interface_section: ($) => seq(kw("interface"), repeat($._statement)),
|
||||||
seq(kw("interface"), repeat($._statement)),
|
|
||||||
|
|
||||||
implementation_section: ($) =>
|
implementation_section: ($) =>
|
||||||
seq(kw("implementation"), repeat($._statement)),
|
seq(kw("implementation"), repeat($._statement)),
|
||||||
|
|
@ -1456,8 +1487,7 @@ module.exports = grammar({
|
||||||
initialization_section: ($) =>
|
initialization_section: ($) =>
|
||||||
seq(kw("initialization"), repeat($._statement)),
|
seq(kw("initialization"), repeat($._statement)),
|
||||||
|
|
||||||
finalization_section: ($) =>
|
finalization_section: ($) => seq(kw("finalization"), repeat($._statement)),
|
||||||
seq(kw("finalization"), repeat($._statement)),
|
|
||||||
|
|
||||||
uses_statement: ($) =>
|
uses_statement: ($) =>
|
||||||
seq(kw("uses"), sep1(field("unit", $.identifier), ","), kSemicolon),
|
seq(kw("uses"), sep1(field("unit", $.identifier), ","), kSemicolon),
|
||||||
|
|
|
||||||
|
|
@ -2413,20 +2413,20 @@
|
||||||
"name": "_parameter_signature"
|
"name": "_parameter_signature"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "FIELD",
|
|
||||||
"name": "return_type",
|
|
||||||
"content": {
|
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "return_type",
|
||||||
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_type_clause"
|
"name": "_type_clause"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "BLANK"
|
"type": "BLANK"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
|
|
@ -5601,7 +5601,7 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"function_declaration_statement": {
|
"_function_header": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
|
|
@ -5640,6 +5640,15 @@
|
||||||
"type": "BLANK"
|
"type": "BLANK"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"function_declaration_statement": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_function_header"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
|
|
@ -5651,41 +5660,8 @@
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "ALIAS",
|
|
||||||
"content": {
|
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "(?i)function"
|
|
||||||
},
|
|
||||||
"named": false,
|
|
||||||
"value": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "name",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "identifier"
|
"name": "_function_header"
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_parameter_signature"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "return_type",
|
|
||||||
"content": {
|
|
||||||
"type": "CHOICE",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_type_clause"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "BLANK"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
|
|
@ -5725,41 +5701,8 @@
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
{
|
||||||
"type": "ALIAS",
|
|
||||||
"content": {
|
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "(?i)function"
|
|
||||||
},
|
|
||||||
"named": false,
|
|
||||||
"value": "function"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "name",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "identifier"
|
"name": "_function_header"
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_parameter_signature"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "return_type",
|
|
||||||
"content": {
|
|
||||||
"type": "CHOICE",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_type_clause"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "BLANK"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "STRING",
|
"type": "STRING",
|
||||||
|
|
@ -6115,11 +6058,20 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"class_body": {
|
"class_body": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "uses_statement"
|
||||||
|
},
|
||||||
|
{
|
||||||
"type": "REPEAT1",
|
"type": "REPEAT1",
|
||||||
"content": {
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "class_member"
|
"name": "class_member"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"class_member": {
|
"class_member": {
|
||||||
"type": "CHOICE",
|
"type": "CHOICE",
|
||||||
|
|
@ -6156,10 +6108,6 @@
|
||||||
"name": "property_declaration"
|
"name": "property_declaration"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "uses_statement"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -7396,8 +7344,33 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_operator_method": {
|
"_operator_method": {
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_operator_overload_method"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_operator_method_with_modifier"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"_normal_method": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "CHOICE",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "class"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "BLANK"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "ALIAS",
|
"type": "ALIAS",
|
||||||
"content": {
|
"content": {
|
||||||
|
|
@ -7408,33 +7381,8 @@
|
||||||
"value": "function"
|
"value": "function"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "ALIAS",
|
|
||||||
"content": {
|
|
||||||
"type": "PATTERN",
|
|
||||||
"value": "(?i)operator"
|
|
||||||
},
|
|
||||||
"named": false,
|
|
||||||
"value": "operator"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "class_name",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "identifier"
|
"name": "_qualified_method_name"
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "STRING",
|
|
||||||
"value": "."
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "FIELD",
|
|
||||||
"name": "operator",
|
|
||||||
"content": {
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "_overloadable_operator"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
|
|
@ -7490,21 +7438,9 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"_normal_method": {
|
"_operator_overload_method": {
|
||||||
"type": "SEQ",
|
"type": "SEQ",
|
||||||
"members": [
|
"members": [
|
||||||
{
|
|
||||||
"type": "CHOICE",
|
|
||||||
"members": [
|
|
||||||
{
|
|
||||||
"type": "SYMBOL",
|
|
||||||
"name": "class"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "BLANK"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "ALIAS",
|
"type": "ALIAS",
|
||||||
"content": {
|
"content": {
|
||||||
|
|
@ -7515,8 +7451,33 @@
|
||||||
"value": "function"
|
"value": "function"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"type": "ALIAS",
|
||||||
|
"content": {
|
||||||
|
"type": "PATTERN",
|
||||||
|
"value": "(?i)operator"
|
||||||
|
},
|
||||||
|
"named": false,
|
||||||
|
"value": "operator"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "class_name",
|
||||||
|
"content": {
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "_qualified_method_name"
|
"name": "identifier"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "FIELD",
|
||||||
|
"name": "operator",
|
||||||
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "_overloadable_operator"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
|
|
|
||||||
|
|
@ -1127,6 +1127,10 @@
|
||||||
{
|
{
|
||||||
"type": "class_member",
|
"type": "class_member",
|
||||||
"named": true
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "uses_statement",
|
||||||
|
"named": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
@ -1230,10 +1234,6 @@
|
||||||
"type": "property_declaration",
|
"type": "property_declaration",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"type": "uses_statement",
|
|
||||||
"named": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "variable_declaration",
|
"type": "variable_declaration",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
@ -1680,7 +1680,7 @@
|
||||||
"fields": {
|
"fields": {
|
||||||
"body": {
|
"body": {
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"required": true,
|
"required": false,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "block_suite",
|
"type": "block_suite",
|
||||||
|
|
@ -1690,7 +1690,7 @@
|
||||||
},
|
},
|
||||||
"class_name": {
|
"class_name": {
|
||||||
"multiple": false,
|
"multiple": false,
|
||||||
"required": false,
|
"required": true,
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"type": "identifier",
|
"type": "identifier",
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue