tree-sitter-sed 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +43 -0
- package/README.md +6 -4
- package/bindings/rust/build.rs +40 -0
- package/bindings/rust/lib.rs +70 -0
- package/common/grammar.js +213 -257
- package/common/regex.js +38 -92
- package/common/scanner.h +766 -1112
- package/package.json +7 -8
- package/queries/highlights.scm +2 -5
- package/sed_ere/queries/highlights.scm +2 -5
- package/sed_ere/src/grammar.json +724 -1282
- package/sed_ere/src/node-types.json +56 -58
- package/sed_ere/src/parser.c +28115 -37718
- package/src/grammar.json +655 -1101
- package/src/node-types.json +57 -49
- package/src/parser.c +31870 -41448
- package/tree-sitter.json +3 -3
- package/CMakeLists.txt +0 -121
- package/Makefile +0 -145
- package/bindings/c/tree-sitter-sed.pc.in +0 -10
- package/bindings/c/tree_sitter/tree-sitter-sed.h +0 -17
- package/test/binding.test.c +0 -9
package/common/regex.js
CHANGED
|
@@ -10,6 +10,10 @@ function subexpressionBody($, expression) {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
function intervalExpression($, openingName, closingName) {
|
|
13
|
+
const closing = field(
|
|
14
|
+
"closing",
|
|
15
|
+
namedExternal($, $._regex_interval_close, closingName),
|
|
16
|
+
);
|
|
13
17
|
return seq(
|
|
14
18
|
field("opening", namedExternal($, $._regex_interval_open, openingName)),
|
|
15
19
|
choice(
|
|
@@ -29,19 +33,8 @@ function intervalExpression($, openingName, closingName) {
|
|
|
29
33
|
),
|
|
30
34
|
),
|
|
31
35
|
choice(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
namedExternal($, $._regex_interval_close, closingName),
|
|
35
|
-
),
|
|
36
|
-
seq(
|
|
37
|
-
issueField($, "malformed_interval"),
|
|
38
|
-
optional(
|
|
39
|
-
field(
|
|
40
|
-
"closing",
|
|
41
|
-
namedExternal($, $._regex_interval_close, closingName),
|
|
42
|
-
),
|
|
43
|
-
),
|
|
44
|
-
),
|
|
36
|
+
closing,
|
|
37
|
+
seq(issueField($, "malformed_interval"), optional(closing)),
|
|
45
38
|
issueField($, "incomplete_interval"),
|
|
46
39
|
),
|
|
47
40
|
),
|
|
@@ -50,12 +43,7 @@ function intervalExpression($, openingName, closingName) {
|
|
|
50
43
|
issueField($, "malformed_interval"),
|
|
51
44
|
issueField($, "incomplete_interval"),
|
|
52
45
|
),
|
|
53
|
-
optional(
|
|
54
|
-
field(
|
|
55
|
-
"closing",
|
|
56
|
-
namedExternal($, $._regex_interval_close, closingName),
|
|
57
|
-
),
|
|
58
|
-
),
|
|
46
|
+
optional(closing),
|
|
59
47
|
),
|
|
60
48
|
),
|
|
61
49
|
);
|
|
@@ -93,6 +81,22 @@ function compoundBracketExpression(
|
|
|
93
81
|
);
|
|
94
82
|
}
|
|
95
83
|
|
|
84
|
+
function bracketListBody($) {
|
|
85
|
+
return choice(
|
|
86
|
+
field("elements", $.bracket_list),
|
|
87
|
+
issueField($, "missing_bracket_list"),
|
|
88
|
+
issueField($, "incomplete_missing_bracket_list"),
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function subexpressionClose($, tokenName) {
|
|
93
|
+
return choice(
|
|
94
|
+
namedExternal($, $._regex_group_close, tokenName),
|
|
95
|
+
issueField($, "unclosed_subexpression"),
|
|
96
|
+
issueField($, "incomplete_unclosed_subexpression"),
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
96
100
|
function bracketRules() {
|
|
97
101
|
return {
|
|
98
102
|
bracket_expression: ($) =>
|
|
@@ -113,12 +117,7 @@ function bracketRules() {
|
|
|
113
117
|
issueField($, "incomplete_unclosed_bracket_expression"),
|
|
114
118
|
),
|
|
115
119
|
|
|
116
|
-
matching_list:
|
|
117
|
-
choice(
|
|
118
|
-
field("elements", $.bracket_list),
|
|
119
|
-
issueField($, "missing_bracket_list"),
|
|
120
|
-
issueField($, "incomplete_missing_bracket_list"),
|
|
121
|
-
),
|
|
120
|
+
matching_list: bracketListBody,
|
|
122
121
|
|
|
123
122
|
nonmatching_list: ($) =>
|
|
124
123
|
seq(
|
|
@@ -130,11 +129,7 @@ function bracketRules() {
|
|
|
130
129
|
"nonmatching_list_operator",
|
|
131
130
|
),
|
|
132
131
|
),
|
|
133
|
-
|
|
134
|
-
field("elements", $.bracket_list),
|
|
135
|
-
issueField($, "missing_bracket_list"),
|
|
136
|
-
issueField($, "incomplete_missing_bracket_list"),
|
|
137
|
-
),
|
|
132
|
+
bracketListBody($),
|
|
138
133
|
),
|
|
139
134
|
|
|
140
135
|
bracket_list: ($) =>
|
|
@@ -335,11 +330,7 @@ function breDuplicationSymbol($) {
|
|
|
335
330
|
}
|
|
336
331
|
|
|
337
332
|
function misplacedBreDuplSymbol($, reason) {
|
|
338
|
-
return
|
|
339
|
-
seq(issueField($, reason), field("operator", $.bre_dupl_symbol)),
|
|
340
|
-
issueField($, "malformed_interval"),
|
|
341
|
-
issueField($, "incomplete_interval"),
|
|
342
|
-
);
|
|
333
|
+
return seq(issueField($, reason), field("operator", $.bre_dupl_symbol));
|
|
343
334
|
}
|
|
344
335
|
|
|
345
336
|
function breRules() {
|
|
@@ -458,11 +449,7 @@ function breRules() {
|
|
|
458
449
|
),
|
|
459
450
|
|
|
460
451
|
back_close_parenthesis: ($) =>
|
|
461
|
-
|
|
462
|
-
namedExternal($, $._regex_group_close, "back_close_parenthesis_token"),
|
|
463
|
-
issueField($, "unclosed_subexpression"),
|
|
464
|
-
issueField($, "incomplete_unclosed_subexpression"),
|
|
465
|
-
),
|
|
452
|
+
subexpressionClose($, "back_close_parenthesis_token"),
|
|
466
453
|
|
|
467
454
|
backreference: ($) =>
|
|
468
455
|
namedExternal($, $._regex_backreference, "backreference_token"),
|
|
@@ -503,42 +490,20 @@ function ereDuplicationSymbol($) {
|
|
|
503
490
|
|
|
504
491
|
function ereRules() {
|
|
505
492
|
return {
|
|
506
|
-
extended_reg_exp: ($) =>
|
|
507
|
-
|
|
493
|
+
extended_reg_exp: ($) => {
|
|
494
|
+
const emptyBranch = alias($._empty_ere_branch, $.ere_branch);
|
|
495
|
+
return choice(
|
|
508
496
|
$.ere_branch,
|
|
509
497
|
prec.left(
|
|
510
498
|
1,
|
|
511
499
|
seq(
|
|
512
|
-
field("left", $.extended_reg_exp),
|
|
500
|
+
field("left", choice($.extended_reg_exp, emptyBranch)),
|
|
513
501
|
field("operator", $.ere_alternation_operator),
|
|
514
|
-
field("right", $.ere_branch),
|
|
502
|
+
field("right", choice($.ere_branch, emptyBranch)),
|
|
515
503
|
),
|
|
516
504
|
),
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
seq(
|
|
520
|
-
field("left", alias($._empty_ere_branch, $.ere_branch)),
|
|
521
|
-
field("operator", $.ere_alternation_operator),
|
|
522
|
-
field("right", $.ere_branch),
|
|
523
|
-
),
|
|
524
|
-
),
|
|
525
|
-
prec.left(
|
|
526
|
-
1,
|
|
527
|
-
seq(
|
|
528
|
-
field("left", $.extended_reg_exp),
|
|
529
|
-
field("operator", $.ere_alternation_operator),
|
|
530
|
-
field("right", alias($._empty_ere_branch, $.ere_branch)),
|
|
531
|
-
),
|
|
532
|
-
),
|
|
533
|
-
prec.left(
|
|
534
|
-
1,
|
|
535
|
-
seq(
|
|
536
|
-
field("left", alias($._empty_ere_branch, $.ere_branch)),
|
|
537
|
-
field("operator", $.ere_alternation_operator),
|
|
538
|
-
field("right", alias($._empty_ere_branch, $.ere_branch)),
|
|
539
|
-
),
|
|
540
|
-
),
|
|
541
|
-
),
|
|
505
|
+
);
|
|
506
|
+
},
|
|
542
507
|
|
|
543
508
|
_empty_ere_branch: ($) =>
|
|
544
509
|
choice(
|
|
@@ -584,12 +549,7 @@ function ereRules() {
|
|
|
584
549
|
field("operator", $.leading_ere_dupl_symbol),
|
|
585
550
|
),
|
|
586
551
|
|
|
587
|
-
close_parenthesis: ($) =>
|
|
588
|
-
choice(
|
|
589
|
-
namedExternal($, $._regex_group_close, "close_parenthesis_token"),
|
|
590
|
-
issueField($, "unclosed_subexpression"),
|
|
591
|
-
issueField($, "incomplete_unclosed_subexpression"),
|
|
592
|
-
),
|
|
552
|
+
close_parenthesis: ($) => subexpressionClose($, "close_parenthesis_token"),
|
|
593
553
|
|
|
594
554
|
one_char_or_coll_elem_ere: ($) =>
|
|
595
555
|
choice(
|
|
@@ -609,8 +569,6 @@ function ereRules() {
|
|
|
609
569
|
issueField($, "adjacent_duplication_symbol"),
|
|
610
570
|
ereDuplicationSymbol($),
|
|
611
571
|
),
|
|
612
|
-
issueField($, "malformed_interval"),
|
|
613
|
-
issueField($, "incomplete_interval"),
|
|
614
572
|
),
|
|
615
573
|
optional(field("modifier", $.repetition_modifier)),
|
|
616
574
|
),
|
|
@@ -626,21 +584,9 @@ function ereRules() {
|
|
|
626
584
|
),
|
|
627
585
|
|
|
628
586
|
leading_ere_dupl_symbol: ($) =>
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
field(
|
|
633
|
-
"operator",
|
|
634
|
-
alias($._leading_ere_dupl_symbol, $.ere_dupl_symbol),
|
|
635
|
-
),
|
|
636
|
-
),
|
|
637
|
-
seq(
|
|
638
|
-
choice(
|
|
639
|
-
issueField($, "malformed_interval"),
|
|
640
|
-
issueField($, "incomplete_interval"),
|
|
641
|
-
),
|
|
642
|
-
optional(field("modifier", $.repetition_modifier)),
|
|
643
|
-
),
|
|
587
|
+
seq(
|
|
588
|
+
issueField($, "leading_duplication_symbol"),
|
|
589
|
+
field("operator", alias($._leading_ere_dupl_symbol, $.ere_dupl_symbol)),
|
|
644
590
|
),
|
|
645
591
|
};
|
|
646
592
|
}
|