tree-sitter-sed 0.5.0 → 0.7.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/README.md +8 -0
- package/common/grammar.js +3 -3
- package/common/regex.js +10 -16
- package/common/scanner.h +1 -3
- package/package.json +4 -2
- package/queries/highlights.scm +30 -6
- package/sed_ere/queries/highlights.scm +30 -6
- package/sed_ere/src/grammar.json +166 -121
- package/sed_ere/src/node-types.json +37 -101
- package/sed_ere/src/parser.c +15605 -15421
- package/src/grammar.json +168 -123
- package/src/node-types.json +45 -109
- package/src/parser.c +15989 -15805
- package/tree-sitter.json +1 -1
package/CMakeLists.txt
CHANGED
package/Makefile
CHANGED
package/README.md
CHANGED
|
@@ -21,6 +21,14 @@ This repository contains the following two grammars.
|
|
|
21
21
|
| `sed` | BRE | `tree_sitter_sed()` |
|
|
22
22
|
| `sed_ere` | ERE | `tree_sitter_sed_ere()` |
|
|
23
23
|
|
|
24
|
+
## Development
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
npm install
|
|
28
|
+
npm run parse -- script.sed
|
|
29
|
+
npm run parse:ere -- script.sed
|
|
30
|
+
```
|
|
31
|
+
|
|
24
32
|
## Specifications
|
|
25
33
|
|
|
26
34
|
- [POSIX.1-2024 `sed`](https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/sed.html)
|
package/common/grammar.js
CHANGED
|
@@ -1276,19 +1276,19 @@ function issueDefinitions(mode) {
|
|
|
1276
1276
|
},
|
|
1277
1277
|
{
|
|
1278
1278
|
reason: "bre_subexpression_left_anchor",
|
|
1279
|
-
outcome: "
|
|
1279
|
+
outcome: "invalid_syntax",
|
|
1280
1280
|
rule: ($) => $._regex_bre_subexpression_caret,
|
|
1281
1281
|
},
|
|
1282
1282
|
{
|
|
1283
1283
|
reason: "bre_subexpression_right_anchor",
|
|
1284
|
-
outcome: "
|
|
1284
|
+
outcome: "invalid_syntax",
|
|
1285
1285
|
rule: ($) => $._regex_bre_subexpression_dollar,
|
|
1286
1286
|
},
|
|
1287
1287
|
]
|
|
1288
1288
|
: []),
|
|
1289
1289
|
{
|
|
1290
1290
|
reason: "omitted_file_separator",
|
|
1291
|
-
outcome: "
|
|
1291
|
+
outcome: "invalid_syntax",
|
|
1292
1292
|
rule: missing("omitted_file_separator"),
|
|
1293
1293
|
},
|
|
1294
1294
|
{
|
package/common/regex.js
CHANGED
|
@@ -64,24 +64,21 @@ function intervalExpression($, openingName, closingName) {
|
|
|
64
64
|
function compoundBracketExpression(
|
|
65
65
|
$,
|
|
66
66
|
openingExternal,
|
|
67
|
-
|
|
67
|
+
marker,
|
|
68
68
|
contentField,
|
|
69
69
|
content,
|
|
70
70
|
closingExternal,
|
|
71
|
-
closingName,
|
|
72
71
|
) {
|
|
73
|
-
const closing =
|
|
72
|
+
const closing = seq(alias(closingExternal, marker), "]");
|
|
74
73
|
return seq(
|
|
75
|
-
|
|
74
|
+
alias(openingExternal, "["),
|
|
75
|
+
marker,
|
|
76
76
|
choice(
|
|
77
77
|
seq(
|
|
78
78
|
field(contentField, content),
|
|
79
79
|
choice(
|
|
80
|
-
|
|
81
|
-
seq(
|
|
82
|
-
issueField($, "malformed_bracket_term"),
|
|
83
|
-
optional(field("closing", closing)),
|
|
84
|
-
),
|
|
80
|
+
closing,
|
|
81
|
+
seq(issueField($, "malformed_bracket_term"), optional(closing)),
|
|
85
82
|
issueField($, "incomplete_bracket_term"),
|
|
86
83
|
),
|
|
87
84
|
),
|
|
@@ -90,7 +87,7 @@ function compoundBracketExpression(
|
|
|
90
87
|
issueField($, "malformed_bracket_term"),
|
|
91
88
|
issueField($, "incomplete_bracket_term"),
|
|
92
89
|
),
|
|
93
|
-
optional(
|
|
90
|
+
optional(closing),
|
|
94
91
|
),
|
|
95
92
|
),
|
|
96
93
|
);
|
|
@@ -255,7 +252,7 @@ function bracketRules() {
|
|
|
255
252
|
compoundBracketExpression(
|
|
256
253
|
$,
|
|
257
254
|
$._regex_open_dot,
|
|
258
|
-
"
|
|
255
|
+
".",
|
|
259
256
|
"element",
|
|
260
257
|
choice(
|
|
261
258
|
namedExternal($, $._regex_coll_elem_single, "coll_elem_single"),
|
|
@@ -263,32 +260,29 @@ function bracketRules() {
|
|
|
263
260
|
namedExternal($, $._regex_meta_char, "meta_char"),
|
|
264
261
|
),
|
|
265
262
|
$._regex_dot_close,
|
|
266
|
-
"dot_close",
|
|
267
263
|
),
|
|
268
264
|
|
|
269
265
|
equivalence_class: ($) =>
|
|
270
266
|
compoundBracketExpression(
|
|
271
267
|
$,
|
|
272
268
|
$._regex_open_equal,
|
|
273
|
-
"
|
|
269
|
+
"=",
|
|
274
270
|
"element",
|
|
275
271
|
choice(
|
|
276
272
|
namedExternal($, $._regex_coll_elem_single, "coll_elem_single"),
|
|
277
273
|
namedExternal($, $._regex_coll_elem_multi, "coll_elem_multi"),
|
|
278
274
|
),
|
|
279
275
|
$._regex_equal_close,
|
|
280
|
-
"equal_close",
|
|
281
276
|
),
|
|
282
277
|
|
|
283
278
|
character_class: ($) =>
|
|
284
279
|
compoundBracketExpression(
|
|
285
280
|
$,
|
|
286
281
|
$._regex_open_colon,
|
|
287
|
-
"
|
|
282
|
+
":",
|
|
288
283
|
"name",
|
|
289
284
|
namedExternal($, $._regex_class_name, "class_name"),
|
|
290
285
|
$._regex_colon_close,
|
|
291
|
-
"colon_close",
|
|
292
286
|
),
|
|
293
287
|
};
|
|
294
288
|
}
|
package/common/scanner.h
CHANGED
|
@@ -1234,7 +1234,6 @@ static bool scan_regex_bracket_opener(
|
|
|
1234
1234
|
if (!valid_symbols[candidate]) {
|
|
1235
1235
|
return false;
|
|
1236
1236
|
}
|
|
1237
|
-
consume(lexer);
|
|
1238
1237
|
begin_compound_bracket_element(state);
|
|
1239
1238
|
finish_first_bracket_element(state);
|
|
1240
1239
|
state->regex_bracket_term_state = term_state;
|
|
@@ -1386,11 +1385,10 @@ static bool scan_regex_bracket_term_close(
|
|
|
1386
1385
|
return false;
|
|
1387
1386
|
}
|
|
1388
1387
|
|
|
1389
|
-
|
|
1388
|
+
consume(lexer);
|
|
1390
1389
|
if (lexer->lookahead != ']') {
|
|
1391
1390
|
return false;
|
|
1392
1391
|
}
|
|
1393
|
-
consume(lexer);
|
|
1394
1392
|
state->regex_bracket_term_state = REGEX_BRACKET_TERM_NONE;
|
|
1395
1393
|
finish_compound_bracket_element(state);
|
|
1396
1394
|
return emit_symbol(valid_symbols, candidate, symbol);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tree-sitter-sed",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Tree-sitter grammars for POSIX sed.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "git+https://github.com/konomanoasa/tree-sitter-sed.git",
|
|
@@ -27,13 +27,15 @@
|
|
|
27
27
|
"check": "biome check . && node scripts/check-c.js && node scripts/check-generated.js && npm test",
|
|
28
28
|
"format": "biome check --write . && node scripts/check-c.js --write",
|
|
29
29
|
"generate": "npm run tree-sitter -- generate-all",
|
|
30
|
+
"parse": "npm run tree-sitter -- parse --scope source.sed",
|
|
31
|
+
"parse:ere": "npm run tree-sitter -- parse --scope source.sed.ere",
|
|
30
32
|
"test": "npm run tree-sitter -- test-corpus --rebuild && node --test",
|
|
31
33
|
"test:fuzz": "npm run tree-sitter -- fuzz-all --iterations 100 --edits 5",
|
|
32
34
|
"tree-sitter": "node scripts/tree-sitter.js"
|
|
33
35
|
},
|
|
34
36
|
"devDependencies": {
|
|
35
37
|
"@biomejs/biome": "2.5.11",
|
|
36
|
-
"tree-sitter-cli": "0.
|
|
38
|
+
"tree-sitter-cli": "0.27.0"
|
|
37
39
|
},
|
|
38
40
|
"allowScripts": {
|
|
39
41
|
"tree-sitter-cli": true
|
package/queries/highlights.scm
CHANGED
|
@@ -65,11 +65,39 @@
|
|
|
65
65
|
(back_open_parenthesis)
|
|
66
66
|
(close_bracket_token)
|
|
67
67
|
(closing_brace_token)
|
|
68
|
-
(colon_close)
|
|
69
68
|
(open_bracket)
|
|
70
|
-
(open_colon)
|
|
71
69
|
] @punctuation.bracket
|
|
72
70
|
|
|
71
|
+
(character_class
|
|
72
|
+
"[" @punctuation.bracket
|
|
73
|
+
.
|
|
74
|
+
":" @punctuation.delimiter)
|
|
75
|
+
|
|
76
|
+
(character_class
|
|
77
|
+
":" @punctuation.delimiter
|
|
78
|
+
.
|
|
79
|
+
"]" @punctuation.bracket)
|
|
80
|
+
|
|
81
|
+
(collating_symbol
|
|
82
|
+
"[" @punctuation.bracket
|
|
83
|
+
.
|
|
84
|
+
"." @punctuation.delimiter)
|
|
85
|
+
|
|
86
|
+
(collating_symbol
|
|
87
|
+
"." @punctuation.delimiter
|
|
88
|
+
.
|
|
89
|
+
"]" @punctuation.bracket)
|
|
90
|
+
|
|
91
|
+
(equivalence_class
|
|
92
|
+
"[" @punctuation.bracket
|
|
93
|
+
.
|
|
94
|
+
"=" @punctuation.delimiter)
|
|
95
|
+
|
|
96
|
+
(equivalence_class
|
|
97
|
+
"=" @punctuation.delimiter
|
|
98
|
+
.
|
|
99
|
+
"]" @punctuation.bracket)
|
|
100
|
+
|
|
73
101
|
[
|
|
74
102
|
(nonmatching_list_operator)
|
|
75
103
|
(range_operator)
|
|
@@ -85,11 +113,7 @@
|
|
|
85
113
|
(coll_elem_multi)
|
|
86
114
|
(coll_elem_single)
|
|
87
115
|
(collating_element_token)
|
|
88
|
-
(dot_close)
|
|
89
|
-
(equal_close)
|
|
90
116
|
(meta_char)
|
|
91
|
-
(open_dot)
|
|
92
|
-
(open_equal)
|
|
93
117
|
(period_token)
|
|
94
118
|
] @character.special
|
|
95
119
|
|
|
@@ -63,13 +63,41 @@
|
|
|
63
63
|
(close_bracket_token)
|
|
64
64
|
(close_parenthesis_token)
|
|
65
65
|
(closing_brace_token)
|
|
66
|
-
(colon_close)
|
|
67
66
|
(open_brace)
|
|
68
67
|
(open_bracket)
|
|
69
|
-
(open_colon)
|
|
70
68
|
(open_parenthesis)
|
|
71
69
|
] @punctuation.bracket
|
|
72
70
|
|
|
71
|
+
(character_class
|
|
72
|
+
"[" @punctuation.bracket
|
|
73
|
+
.
|
|
74
|
+
":" @punctuation.delimiter)
|
|
75
|
+
|
|
76
|
+
(character_class
|
|
77
|
+
":" @punctuation.delimiter
|
|
78
|
+
.
|
|
79
|
+
"]" @punctuation.bracket)
|
|
80
|
+
|
|
81
|
+
(collating_symbol
|
|
82
|
+
"[" @punctuation.bracket
|
|
83
|
+
.
|
|
84
|
+
"." @punctuation.delimiter)
|
|
85
|
+
|
|
86
|
+
(collating_symbol
|
|
87
|
+
"." @punctuation.delimiter
|
|
88
|
+
.
|
|
89
|
+
"]" @punctuation.bracket)
|
|
90
|
+
|
|
91
|
+
(equivalence_class
|
|
92
|
+
"[" @punctuation.bracket
|
|
93
|
+
.
|
|
94
|
+
"=" @punctuation.delimiter)
|
|
95
|
+
|
|
96
|
+
(equivalence_class
|
|
97
|
+
"=" @punctuation.delimiter
|
|
98
|
+
.
|
|
99
|
+
"]" @punctuation.bracket)
|
|
100
|
+
|
|
73
101
|
[
|
|
74
102
|
(nonmatching_list_operator)
|
|
75
103
|
(range_operator)
|
|
@@ -85,11 +113,7 @@
|
|
|
85
113
|
(coll_elem_multi)
|
|
86
114
|
(coll_elem_single)
|
|
87
115
|
(collating_element_token)
|
|
88
|
-
(dot_close)
|
|
89
|
-
(equal_close)
|
|
90
116
|
(meta_char)
|
|
91
|
-
(open_dot)
|
|
92
|
-
(open_equal)
|
|
93
117
|
(period_token)
|
|
94
118
|
] @character.special
|
|
95
119
|
|