tree-sitter-sed 0.4.0 → 0.5.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/CMakeLists.txt +1 -1
- package/Makefile +1 -1
- package/common/grammar.js +16 -59
- package/common/regex.js +10 -16
- package/common/scanner.h +18 -8
- package/package.json +1 -1
- package/sed_ere/src/grammar.json +251 -536
- package/sed_ere/src/node-types.json +1 -45
- package/sed_ere/src/parser.c +26253 -26886
- package/src/grammar.json +251 -536
- package/src/node-types.json +1 -45
- package/src/parser.c +25237 -25870
- package/tree-sitter.json +1 -1
package/CMakeLists.txt
CHANGED
package/Makefile
CHANGED
package/common/grammar.js
CHANGED
|
@@ -551,29 +551,17 @@ function operandRules(mode) {
|
|
|
551
551
|
}
|
|
552
552
|
|
|
553
553
|
return {
|
|
554
|
-
|
|
554
|
+
_substitute_function: ($) =>
|
|
555
555
|
choice(
|
|
556
556
|
seq(
|
|
557
557
|
$._complete_substitute_function,
|
|
558
558
|
optional(
|
|
559
|
-
field(
|
|
560
|
-
"flags",
|
|
561
|
-
alias($._substitution_flags_without_write, $.substitution_flags),
|
|
562
|
-
),
|
|
559
|
+
field("flags", alias($._substitution_flags, $.substitution_flags)),
|
|
563
560
|
),
|
|
564
561
|
),
|
|
565
562
|
$._incomplete_substitute_function,
|
|
566
563
|
),
|
|
567
564
|
|
|
568
|
-
_substitute_function_with_write: ($) =>
|
|
569
|
-
seq(
|
|
570
|
-
$._complete_substitute_function,
|
|
571
|
-
field(
|
|
572
|
-
"flags",
|
|
573
|
-
alias($._substitution_flags_with_write, $.substitution_flags),
|
|
574
|
-
),
|
|
575
|
-
),
|
|
576
|
-
|
|
577
565
|
_complete_substitute_function: ($) =>
|
|
578
566
|
seq(
|
|
579
567
|
functionVerb($, "s"),
|
|
@@ -659,6 +647,12 @@ function operandRules(mode) {
|
|
|
659
647
|
escaped_newline: ($) =>
|
|
660
648
|
namedExternal($, $._replacement_escaped_newline, "escaped_newline_token"),
|
|
661
649
|
|
|
650
|
+
_substitution_flags: ($) =>
|
|
651
|
+
choice(
|
|
652
|
+
$._substitution_flags_without_write,
|
|
653
|
+
seq(optional($._substitution_flags_without_write), $.write_flag),
|
|
654
|
+
),
|
|
655
|
+
|
|
662
656
|
_substitution_flags_without_write: ($) =>
|
|
663
657
|
choice(
|
|
664
658
|
substitutionFlagChoice($),
|
|
@@ -667,9 +661,6 @@ function operandRules(mode) {
|
|
|
667
661
|
),
|
|
668
662
|
),
|
|
669
663
|
|
|
670
|
-
_substitution_flags_with_write: ($) =>
|
|
671
|
-
seq(optional($._substitution_flags_without_write), $.write_flag),
|
|
672
|
-
|
|
673
664
|
occurrence_flag: () => /[[:digit:]]+/,
|
|
674
665
|
|
|
675
666
|
global_flag: () => "g",
|
|
@@ -684,8 +675,7 @@ function operandRules(mode) {
|
|
|
684
675
|
choice(
|
|
685
676
|
seq(
|
|
686
677
|
$._flag_after_write_marker,
|
|
687
|
-
|
|
688
|
-
repeat(postWriteSubstitutionFlagChoice($)),
|
|
678
|
+
repeat1(postWriteSubstitutionFlagChoice($)),
|
|
689
679
|
$._blanks,
|
|
690
680
|
choice(
|
|
691
681
|
field("wfile", alias($._substitution_wfile, $.wfile)),
|
|
@@ -955,39 +945,19 @@ function editingCommandRules() {
|
|
|
955
945
|
|
|
956
946
|
_line_terminated_editing_command: ($) =>
|
|
957
947
|
seq(
|
|
958
|
-
|
|
959
|
-
$._line_terminated_regular_editing_command_body,
|
|
960
|
-
$._line_terminated_substitute_editing_command_body,
|
|
961
|
-
),
|
|
948
|
+
addressedForms($, lineTerminated, "line_terminated"),
|
|
962
949
|
optional(issueField($, "unexpected_command_text")),
|
|
963
950
|
),
|
|
964
951
|
|
|
965
952
|
_recovered_line_terminated_editing_command: ($) =>
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
issueField($, "forbidden_command_separator"),
|
|
972
|
-
optional($._blanks),
|
|
973
|
-
),
|
|
974
|
-
),
|
|
975
|
-
prec.right(
|
|
976
|
-
seq(
|
|
977
|
-
$._line_terminated_substitute_editing_command_body,
|
|
978
|
-
optional(issueField($, "unexpected_command_text")),
|
|
979
|
-
issueField($, "command_after_write_flag"),
|
|
980
|
-
optional($._blanks),
|
|
981
|
-
),
|
|
953
|
+
prec.right(
|
|
954
|
+
seq(
|
|
955
|
+
$._line_terminated_editing_command,
|
|
956
|
+
issueField($, "forbidden_command_separator"),
|
|
957
|
+
optional($._blanks),
|
|
982
958
|
),
|
|
983
959
|
),
|
|
984
960
|
|
|
985
|
-
_line_terminated_regular_editing_command_body: ($) =>
|
|
986
|
-
addressedForms($, lineTerminated, "line_terminated"),
|
|
987
|
-
|
|
988
|
-
_line_terminated_substitute_editing_command_body: ($) =>
|
|
989
|
-
addressedFunction($, $._line_terminated_substitute_function),
|
|
990
|
-
|
|
991
961
|
_recovered_editing_command: ($) =>
|
|
992
962
|
choice(
|
|
993
963
|
addressedFunction($, $._unknown_function),
|
|
@@ -1034,10 +1004,7 @@ function editingCommandRules() {
|
|
|
1034
1004
|
_missing_function: ($) => missingAtEndOrBoundary($, "missing_function"),
|
|
1035
1005
|
|
|
1036
1006
|
_chainable_substitute_function: ($) =>
|
|
1037
|
-
alias($.
|
|
1038
|
-
|
|
1039
|
-
_line_terminated_substitute_function: ($) =>
|
|
1040
|
-
alias($._substitute_function_with_write, $.substitute_function),
|
|
1007
|
+
alias($._substitute_function, $.substitute_function),
|
|
1041
1008
|
|
|
1042
1009
|
negation: ($) =>
|
|
1043
1010
|
seq(
|
|
@@ -1250,16 +1217,6 @@ function issueDefinitions(mode) {
|
|
|
1250
1217
|
outcome: "undefined_syntax",
|
|
1251
1218
|
rule: ($) => $._translate_nonportable_escape,
|
|
1252
1219
|
},
|
|
1253
|
-
{
|
|
1254
|
-
reason: "command_after_write_flag",
|
|
1255
|
-
outcome: "undefined_syntax",
|
|
1256
|
-
rule: () => token.immediate(";"),
|
|
1257
|
-
},
|
|
1258
|
-
{
|
|
1259
|
-
reason: "flag_after_write_flag",
|
|
1260
|
-
outcome: "undefined_syntax",
|
|
1261
|
-
rule: ($) => postWriteSubstitutionFlagChoice($),
|
|
1262
|
-
},
|
|
1263
1220
|
{
|
|
1264
1221
|
reason: "equivalence_class_range_start",
|
|
1265
1222
|
outcome: "unspecified_syntax",
|
package/common/regex.js
CHANGED
|
@@ -340,6 +340,14 @@ function breDuplicationSymbol($) {
|
|
|
340
340
|
);
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
+
function misplacedBreDuplSymbol($, reason) {
|
|
344
|
+
return choice(
|
|
345
|
+
seq(issueField($, reason), field("operator", $.bre_dupl_symbol)),
|
|
346
|
+
issueField($, "malformed_interval"),
|
|
347
|
+
issueField($, "incomplete_interval"),
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
|
|
343
351
|
function breRules() {
|
|
344
352
|
return {
|
|
345
353
|
bre_extension_escape: ($) =>
|
|
@@ -483,24 +491,10 @@ function breRules() {
|
|
|
483
491
|
intervalExpression($, "back_open_brace", "back_close_brace"),
|
|
484
492
|
|
|
485
493
|
leading_bre_dupl_symbol: ($) =>
|
|
486
|
-
|
|
487
|
-
seq(
|
|
488
|
-
issueField($, "leading_duplication_symbol"),
|
|
489
|
-
field("operator", $.bre_dupl_symbol),
|
|
490
|
-
),
|
|
491
|
-
issueField($, "malformed_interval"),
|
|
492
|
-
issueField($, "incomplete_interval"),
|
|
493
|
-
),
|
|
494
|
+
misplacedBreDuplSymbol($, "leading_duplication_symbol"),
|
|
494
495
|
|
|
495
496
|
adjacent_bre_dupl_symbol: ($) =>
|
|
496
|
-
|
|
497
|
-
seq(
|
|
498
|
-
issueField($, "adjacent_duplication_symbol"),
|
|
499
|
-
field("operator", $.bre_dupl_symbol),
|
|
500
|
-
),
|
|
501
|
-
issueField($, "malformed_interval"),
|
|
502
|
-
issueField($, "incomplete_interval"),
|
|
503
|
-
),
|
|
497
|
+
misplacedBreDuplSymbol($, "adjacent_duplication_symbol"),
|
|
504
498
|
};
|
|
505
499
|
}
|
|
506
500
|
|
package/common/scanner.h
CHANGED
|
@@ -2851,16 +2851,26 @@ static bool scan_command_token(
|
|
|
2851
2851
|
}
|
|
2852
2852
|
|
|
2853
2853
|
if (at_command_boundary(lexer)) {
|
|
2854
|
-
const TSSymbol
|
|
2855
|
-
|
|
2856
|
-
|
|
2854
|
+
static const TSSymbol boundary_markers[][2] = {
|
|
2855
|
+
{MISSING_FUNCTION_MARKER, NONCONFORMING_MISSING_FUNCTION_MARKER},
|
|
2856
|
+
{MISSING_LABEL_MARKER, NONCONFORMING_MISSING_LABEL_MARKER},
|
|
2857
|
+
{MISSING_RFILE_MARKER, NONCONFORMING_MISSING_RFILE_MARKER},
|
|
2858
|
+
{MISSING_WFILE_MARKER, NONCONFORMING_MISSING_WFILE_MARKER},
|
|
2859
|
+
};
|
|
2860
|
+
const unsigned variant = lexer->eof(lexer) ? 0 : 1;
|
|
2857
2861
|
for (
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2862
|
+
unsigned index = 0;
|
|
2863
|
+
index < sizeof(boundary_markers) / sizeof(boundary_markers[0]);
|
|
2864
|
+
index++
|
|
2861
2865
|
) {
|
|
2862
|
-
|
|
2863
|
-
|
|
2866
|
+
if (
|
|
2867
|
+
emit_missing_marker(
|
|
2868
|
+
lexer,
|
|
2869
|
+
valid_symbols,
|
|
2870
|
+
boundary_markers[index][variant],
|
|
2871
|
+
symbol
|
|
2872
|
+
)
|
|
2873
|
+
) {
|
|
2864
2874
|
return true;
|
|
2865
2875
|
}
|
|
2866
2876
|
}
|