@konomanoasa/tree-sitter-posix-awk 0.13.0 → 0.15.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 +1 -1
- package/bindings/rust/build.rs +3 -2
- package/bindings/rust/lib.rs +497 -73
- package/grammar.js +392 -275
- package/package.json +1 -1
- package/queries/highlights.scm +1 -1
- package/src/grammar.json +1319 -570
- package/src/node-types.json +72 -94
- package/src/parser.c +143436 -58654
- package/src/scanner.c +395 -517
- package/tree-sitter.json +1 -1
package/grammar.js
CHANGED
|
@@ -8,7 +8,6 @@ const PRECEDENCE = {
|
|
|
8
8
|
concatenation: 14,
|
|
9
9
|
additive: 16,
|
|
10
10
|
multiplicative: 18,
|
|
11
|
-
postfixUpdate: 20,
|
|
12
11
|
field: 22,
|
|
13
12
|
};
|
|
14
13
|
|
|
@@ -32,13 +31,6 @@ const KEYWORDS = [
|
|
|
32
31
|
"while",
|
|
33
32
|
];
|
|
34
33
|
|
|
35
|
-
const keywordRules = Object.fromEntries(
|
|
36
|
-
KEYWORDS.map((keyword) => [
|
|
37
|
-
`${keyword}_keyword`,
|
|
38
|
-
($) => $[`_${keyword}_word`],
|
|
39
|
-
]),
|
|
40
|
-
);
|
|
41
|
-
|
|
42
34
|
const TWO_CHARACTER_TOKENS = [
|
|
43
35
|
"div_assign",
|
|
44
36
|
"add_assign",
|
|
@@ -58,6 +50,22 @@ const TWO_CHARACTER_TOKENS = [
|
|
|
58
50
|
"append",
|
|
59
51
|
];
|
|
60
52
|
|
|
53
|
+
const SINGLE_CHARACTER_OPERATORS = {
|
|
54
|
+
"+": "plus",
|
|
55
|
+
"-": "minus",
|
|
56
|
+
"*": "star",
|
|
57
|
+
"%": "percent",
|
|
58
|
+
"^": "caret",
|
|
59
|
+
"!": "bang",
|
|
60
|
+
"<": "less",
|
|
61
|
+
">": "greater",
|
|
62
|
+
"=": "equal",
|
|
63
|
+
"|": "pipe",
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const singleOperator = ($, character) =>
|
|
67
|
+
alias($[`_${SINGLE_CHARACTER_OPERATORS[character]}_operator`], character);
|
|
68
|
+
|
|
61
69
|
const twoCharacterTokenRules = Object.fromEntries(
|
|
62
70
|
TWO_CHARACTER_TOKENS.map((name) => [name, ($) => $[`_${name}_operator`]]),
|
|
63
71
|
);
|
|
@@ -68,9 +76,6 @@ const afterOptionalNewline = ($, member) => seq(newlineLayout($), member);
|
|
|
68
76
|
|
|
69
77
|
const functionBody = ($) => afterOptionalNewline($, field("body", $.action));
|
|
70
78
|
|
|
71
|
-
const ereEscapeWithCharacter = ($, character) =>
|
|
72
|
-
seq($._ere_escape_start, $._escape_introducer, character);
|
|
73
|
-
|
|
74
79
|
// A separate closing-hyphen token avoids competing with range separators.
|
|
75
80
|
const ereClosingHyphen = ($) => alias($._ere_closing_hyphen, "-");
|
|
76
81
|
|
|
@@ -109,14 +114,74 @@ const initialFollowListRules = (prefix, firstElement) => {
|
|
|
109
114
|
};
|
|
110
115
|
|
|
111
116
|
const ereCompoundOpening = ($, punctuation) =>
|
|
112
|
-
seq(
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
seq(alias($._ere_compound_opening, "["), token.immediate(punctuation));
|
|
118
|
+
|
|
119
|
+
const ereCompoundClosing = (closing, punctuation) =>
|
|
120
|
+
seq(alias(closing, punctuation), token.immediate("]"));
|
|
121
|
+
|
|
122
|
+
const ereExpressionRules = (insideGroup) => {
|
|
123
|
+
const name = (rule) => (insideGroup ? `group_${rule}` : rule);
|
|
124
|
+
const member = ($, rule) =>
|
|
125
|
+
insideGroup ? alias($[name(rule)], $[rule]) : $[rule];
|
|
126
|
+
return {
|
|
127
|
+
[name("extended_reg_exp")]: ($) =>
|
|
128
|
+
choice(
|
|
129
|
+
member($, "ere_branch"),
|
|
130
|
+
seq(
|
|
131
|
+
field("left", member($, "extended_reg_exp")),
|
|
132
|
+
field("operator", token.immediate("|")),
|
|
133
|
+
field("right", member($, "ere_branch")),
|
|
134
|
+
),
|
|
135
|
+
),
|
|
136
|
+
|
|
137
|
+
[name("ere_branch")]: ($) =>
|
|
138
|
+
choice(
|
|
139
|
+
member($, "ere_expression"),
|
|
140
|
+
seq(
|
|
141
|
+
field("left", member($, "ere_branch")),
|
|
142
|
+
field("right", member($, "ere_expression")),
|
|
143
|
+
),
|
|
144
|
+
),
|
|
117
145
|
|
|
118
|
-
|
|
119
|
-
|
|
146
|
+
[name("ere_expression")]: ($) =>
|
|
147
|
+
choice(
|
|
148
|
+
member($, "one_char_or_coll_elem_ere"),
|
|
149
|
+
$.left_anchor,
|
|
150
|
+
$.right_anchor,
|
|
151
|
+
seq(
|
|
152
|
+
field("opening", token.immediate("(")),
|
|
153
|
+
field(
|
|
154
|
+
"expression",
|
|
155
|
+
alias($.group_extended_reg_exp, $.extended_reg_exp),
|
|
156
|
+
),
|
|
157
|
+
field("closing", $._ere_close_parenthesis),
|
|
158
|
+
),
|
|
159
|
+
seq(
|
|
160
|
+
field("operand", member($, "ere_expression")),
|
|
161
|
+
field("operator", $.ere_dupl_symbol),
|
|
162
|
+
),
|
|
163
|
+
),
|
|
164
|
+
|
|
165
|
+
[name("one_char_or_coll_elem_ere")]: ($) =>
|
|
166
|
+
choice(
|
|
167
|
+
member($, "ordinary_character"),
|
|
168
|
+
$.quoted_character,
|
|
169
|
+
$.wildcard,
|
|
170
|
+
$.bracket_expression,
|
|
171
|
+
alias($.ere_octal_escape_sequence, $.escape_sequence),
|
|
172
|
+
alias($.ere_undefined_escape_sequence, $.escape_sequence),
|
|
173
|
+
),
|
|
174
|
+
|
|
175
|
+
[name("ordinary_character")]: ($) =>
|
|
176
|
+
choice(
|
|
177
|
+
alias($._ordinary_character, $.ordinary_character_content),
|
|
178
|
+
...(insideGroup ? [] : [$._ere_ordinary_close_parenthesis]),
|
|
179
|
+
$._ere_ordinary_close_brace,
|
|
180
|
+
$.escaped_delimiter,
|
|
181
|
+
alias($.ere_named_escape_sequence, $.escape_sequence),
|
|
182
|
+
),
|
|
183
|
+
};
|
|
184
|
+
};
|
|
120
185
|
|
|
121
186
|
const header = ($, keyword, rest) => seq(keyword, rest, newlineLayout($));
|
|
122
187
|
|
|
@@ -155,6 +220,25 @@ const callArguments = ($) => parenthesized(optional($.expr_list));
|
|
|
155
220
|
|
|
156
221
|
const subscript = (subscripts) => seq("[", subscripts, "]");
|
|
157
222
|
|
|
223
|
+
const lvalueWithFieldOperand = ($, operand) =>
|
|
224
|
+
choice(
|
|
225
|
+
$.name,
|
|
226
|
+
seq($.name, subscript($.expr_list)),
|
|
227
|
+
seq(field("operator", "$"), field("operand", operand)),
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
const directInputFunction = ($, get) =>
|
|
231
|
+
choice(
|
|
232
|
+
field("get", get),
|
|
233
|
+
prec.right(
|
|
234
|
+
PRECEDENCE.field,
|
|
235
|
+
seq(field("get", get), singleOperator($, "<"), field("source", $.expr)),
|
|
236
|
+
),
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
const getWithTarget = ($, target) =>
|
|
240
|
+
prec.dynamic(1, seq($.getline_keyword, field("target", target)));
|
|
241
|
+
|
|
158
242
|
const terminatedStatements = ($) => repeat1($.terminated_statement);
|
|
159
243
|
|
|
160
244
|
const statementListWithTail = ($, tail) =>
|
|
@@ -169,7 +253,12 @@ const EXPRESSION_CONTEXT = {
|
|
|
169
253
|
unaryExpression: "unary_expr",
|
|
170
254
|
nonUnaryExpression: "non_unary_expr",
|
|
171
255
|
comparison: true,
|
|
172
|
-
input:
|
|
256
|
+
input: ($) =>
|
|
257
|
+
choice(
|
|
258
|
+
$._direct_input_function,
|
|
259
|
+
alias($.piped_input_function, $.non_unary_input_function),
|
|
260
|
+
),
|
|
261
|
+
unaryInput: true,
|
|
173
262
|
},
|
|
174
263
|
print: {
|
|
175
264
|
prefix: "print",
|
|
@@ -177,7 +266,13 @@ const EXPRESSION_CONTEXT = {
|
|
|
177
266
|
unaryExpression: "unary_print_expr",
|
|
178
267
|
nonUnaryExpression: "non_unary_print_expr",
|
|
179
268
|
comparison: false,
|
|
180
|
-
|
|
269
|
+
},
|
|
270
|
+
field: {
|
|
271
|
+
prefix: "field",
|
|
272
|
+
expression: "expr",
|
|
273
|
+
unaryExpression: "unary_expr",
|
|
274
|
+
nonUnaryExpression: "non_unary_expr",
|
|
275
|
+
input: ($) => $._direct_input_function,
|
|
181
276
|
},
|
|
182
277
|
};
|
|
183
278
|
|
|
@@ -210,33 +305,112 @@ const CLASSIFICATIONS = ["unary", "non_unary"];
|
|
|
210
305
|
const aliasedAnyTier = ($, context, tier) =>
|
|
211
306
|
alias($[anyTierName(context, tier)], $[context.expression]);
|
|
212
307
|
|
|
213
|
-
const nonUnaryAtom = ($, context) => {
|
|
308
|
+
const nonUnaryAtom = ($, context, lvalue = $._lvalue) => {
|
|
214
309
|
const atoms = [
|
|
215
310
|
$._parenthesized_expression,
|
|
216
311
|
$.number,
|
|
217
312
|
$.string,
|
|
218
|
-
|
|
313
|
+
lvalue,
|
|
219
314
|
$._user_function_call,
|
|
220
315
|
$._builtin_function_call,
|
|
221
316
|
$.builtin_func_name,
|
|
222
317
|
$.ere,
|
|
223
318
|
];
|
|
224
319
|
if (context.input) {
|
|
225
|
-
atoms.push(
|
|
320
|
+
atoms.push(context.input($));
|
|
226
321
|
}
|
|
227
322
|
return choice(...atoms);
|
|
228
323
|
};
|
|
229
324
|
|
|
325
|
+
const classOperandRules = (context, classification, tier) => ({
|
|
326
|
+
[classOperandName(context, classification, tier)]: ($) =>
|
|
327
|
+
prec(1, classTier($, context, classification, tier)),
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
const anyTierRules = (context, tier) => ({
|
|
331
|
+
...classOperandRules(context, "unary", tier),
|
|
332
|
+
...classOperandRules(context, "non_unary", tier),
|
|
333
|
+
[anyTierName(context, tier)]: ($) =>
|
|
334
|
+
choice(
|
|
335
|
+
aliasedClassTier($, context, "unary", tier),
|
|
336
|
+
aliasedClassTier($, context, "non_unary", tier),
|
|
337
|
+
),
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
const unaryExpressionRules = (context) => {
|
|
341
|
+
const rules = anyTierRules(context, "unary");
|
|
342
|
+
const unary = (tier) => classTierName(context, "unary", tier);
|
|
343
|
+
const nonUnary = (tier) => classTierName(context, "non_unary", tier);
|
|
344
|
+
const not = `_${context.prefix}_not_expr`;
|
|
345
|
+
const addOperand = (classification, tier) =>
|
|
346
|
+
Object.assign(rules, classOperandRules(context, classification, tier));
|
|
347
|
+
rules[unary("unary")] = ($) =>
|
|
348
|
+
choice(
|
|
349
|
+
...(context.unaryInput
|
|
350
|
+
? [classTier($, context, "unary", "exponentiation")]
|
|
351
|
+
: []),
|
|
352
|
+
...["+", "-"].map((operator) =>
|
|
353
|
+
seq(
|
|
354
|
+
field("operator", singleOperator($, operator)),
|
|
355
|
+
field("operand", aliasedAnyTier($, context, "unary")),
|
|
356
|
+
),
|
|
357
|
+
),
|
|
358
|
+
);
|
|
359
|
+
rules[not] = ($) =>
|
|
360
|
+
seq(
|
|
361
|
+
field("operator", singleOperator($, "!")),
|
|
362
|
+
field("operand", aliasedAnyTier($, context, "unary")),
|
|
363
|
+
);
|
|
364
|
+
rules[nonUnary("unary")] = ($) =>
|
|
365
|
+
choice($[nonUnary("exponentiation")], $[not]);
|
|
366
|
+
|
|
367
|
+
const exponentiationTail = `_${context.prefix}_exponentiation_tail`;
|
|
368
|
+
rules[exponentiationTail] = ($) =>
|
|
369
|
+
seq(
|
|
370
|
+
$._exponentiation_operator,
|
|
371
|
+
field("right", aliasedAnyTier($, context, "unary")),
|
|
372
|
+
);
|
|
373
|
+
const exponentiationClassifications = context.unaryInput
|
|
374
|
+
? CLASSIFICATIONS
|
|
375
|
+
: ["non_unary"];
|
|
376
|
+
for (const classification of exponentiationClassifications) {
|
|
377
|
+
addOperand(classification, "update");
|
|
378
|
+
rules[classTierName(context, classification, "exponentiation")] = ($) =>
|
|
379
|
+
choice(
|
|
380
|
+
classTier($, context, classification, "update"),
|
|
381
|
+
seq(
|
|
382
|
+
field("left", aliasedClassTier($, context, classification, "update")),
|
|
383
|
+
$[exponentiationTail],
|
|
384
|
+
),
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
if (context.unaryInput) {
|
|
388
|
+
rules[unary("update")] = ($) => $.unary_input_function;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
rules[nonUnary("update")] = ($) =>
|
|
392
|
+
choice(
|
|
393
|
+
$[nonUnary("atom")],
|
|
394
|
+
$._prefix_update_expr,
|
|
395
|
+
seq(
|
|
396
|
+
field("operand", alias($.postfix_lvalue, $.lvalue)),
|
|
397
|
+
field("operator", choice($.incr, $.decr)),
|
|
398
|
+
),
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
// A postfix update must win over forwarding its lvalue as a complete atom.
|
|
402
|
+
rules[nonUnary("atom")] = ($) =>
|
|
403
|
+
nonUnaryAtom($, context, prec(-1, $._lvalue));
|
|
404
|
+
|
|
405
|
+
return rules;
|
|
406
|
+
};
|
|
407
|
+
|
|
230
408
|
const tieredExpressionRules = (context) => {
|
|
231
409
|
const rules = {};
|
|
232
410
|
const unary = (tier) => classTierName(context, "unary", tier);
|
|
233
411
|
const nonUnary = (tier) => classTierName(context, "non_unary", tier);
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
rules[classOperandName(context, classification, tier)] = ($) =>
|
|
237
|
-
prec(1, classTier($, context, classification, tier));
|
|
238
|
-
};
|
|
239
|
-
const not = `_${context.prefix}_not_expr`;
|
|
412
|
+
const addOperand = (classification, tier) =>
|
|
413
|
+
Object.assign(rules, classOperandRules(context, classification, tier));
|
|
240
414
|
const conditionalTail = `_${context.prefix}_conditional_tail`;
|
|
241
415
|
const expression = ($) => $[context.expression];
|
|
242
416
|
rules[conditionalTail] = ($) =>
|
|
@@ -247,16 +421,8 @@ const tieredExpressionRules = (context) => {
|
|
|
247
421
|
field("alternative", aliasedAnyTier($, context, "conditional")),
|
|
248
422
|
);
|
|
249
423
|
|
|
250
|
-
const addAnyTier = (tier) =>
|
|
251
|
-
|
|
252
|
-
addOperand(classification, tier);
|
|
253
|
-
}
|
|
254
|
-
rules[any(tier)] = ($) =>
|
|
255
|
-
choice(
|
|
256
|
-
aliasedClassTier($, context, "unary", tier),
|
|
257
|
-
aliasedClassTier($, context, "non_unary", tier),
|
|
258
|
-
);
|
|
259
|
-
};
|
|
424
|
+
const addAnyTier = (tier) =>
|
|
425
|
+
Object.assign(rules, anyTierRules(context, tier));
|
|
260
426
|
|
|
261
427
|
const addLeftAssociativeTier = (tier, nextTier, operator, precedence) => {
|
|
262
428
|
addAnyTier(nextTier);
|
|
@@ -310,7 +476,7 @@ const tieredExpressionRules = (context) => {
|
|
|
310
476
|
prec.right(
|
|
311
477
|
PRECEDENCE.assignment,
|
|
312
478
|
seq(
|
|
313
|
-
field("left", $.
|
|
479
|
+
field("left", $._lvalue),
|
|
314
480
|
field(
|
|
315
481
|
"operator",
|
|
316
482
|
choice(
|
|
@@ -320,7 +486,7 @@ const tieredExpressionRules = (context) => {
|
|
|
320
486
|
$.div_assign,
|
|
321
487
|
$.add_assign,
|
|
322
488
|
$.sub_assign,
|
|
323
|
-
"=",
|
|
489
|
+
singleOperator($, "="),
|
|
324
490
|
),
|
|
325
491
|
),
|
|
326
492
|
field("right", expression($)),
|
|
@@ -466,70 +632,12 @@ const tieredExpressionRules = (context) => {
|
|
|
466
632
|
PRECEDENCE.multiplicative,
|
|
467
633
|
);
|
|
468
634
|
|
|
469
|
-
rules
|
|
470
|
-
choice(
|
|
471
|
-
...(context.input
|
|
472
|
-
? [classTier($, context, "unary", "exponentiation")]
|
|
473
|
-
: []),
|
|
474
|
-
...["+", "-"].map((operator) =>
|
|
475
|
-
seq(
|
|
476
|
-
field("operator", operator),
|
|
477
|
-
field("operand", aliasedAnyTier($, context, "unary")),
|
|
478
|
-
),
|
|
479
|
-
),
|
|
480
|
-
);
|
|
481
|
-
rules[not] = ($) =>
|
|
482
|
-
seq(
|
|
483
|
-
field("operator", "!"),
|
|
484
|
-
field("operand", aliasedAnyTier($, context, "unary")),
|
|
485
|
-
);
|
|
486
|
-
rules[nonUnary("unary")] = ($) =>
|
|
487
|
-
choice($[nonUnary("exponentiation")], $[not]);
|
|
488
|
-
|
|
489
|
-
const exponentiationTail = `_${context.prefix}_exponentiation_tail`;
|
|
490
|
-
rules[exponentiationTail] = ($) =>
|
|
491
|
-
seq(
|
|
492
|
-
$._exponentiation_operator,
|
|
493
|
-
field("right", aliasedAnyTier($, context, "unary")),
|
|
494
|
-
);
|
|
495
|
-
const exponentiationClassifications = context.input
|
|
496
|
-
? CLASSIFICATIONS
|
|
497
|
-
: ["non_unary"];
|
|
498
|
-
for (const classification of exponentiationClassifications) {
|
|
499
|
-
addOperand(classification, "update");
|
|
500
|
-
rules[classTierName(context, classification, "exponentiation")] = ($) =>
|
|
501
|
-
choice(
|
|
502
|
-
classTier($, context, classification, "update"),
|
|
503
|
-
seq(
|
|
504
|
-
field("left", aliasedClassTier($, context, classification, "update")),
|
|
505
|
-
$[exponentiationTail],
|
|
506
|
-
),
|
|
507
|
-
);
|
|
508
|
-
}
|
|
509
|
-
if (context.input) {
|
|
510
|
-
rules[unary("update")] = ($) => $.unary_input_function;
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
rules[nonUnary("update")] = ($) =>
|
|
514
|
-
choice(
|
|
515
|
-
$[nonUnary("atom")],
|
|
516
|
-
$._prefix_update_expr,
|
|
517
|
-
prec.left(
|
|
518
|
-
PRECEDENCE.postfixUpdate,
|
|
519
|
-
seq(
|
|
520
|
-
field("operand", $.lvalue),
|
|
521
|
-
field("operator", choice($.incr, $.decr)),
|
|
522
|
-
),
|
|
523
|
-
),
|
|
524
|
-
);
|
|
525
|
-
|
|
526
|
-
rules[nonUnary("atom")] = ($) => nonUnaryAtom($, context);
|
|
527
|
-
|
|
528
|
-
return rules;
|
|
635
|
+
return { ...rules, ...unaryExpressionRules(context) };
|
|
529
636
|
};
|
|
530
637
|
|
|
531
638
|
const normalExpressionRules = tieredExpressionRules(EXPRESSION_CONTEXT.normal);
|
|
532
639
|
const printExpressionRules = tieredExpressionRules(EXPRESSION_CONTEXT.print);
|
|
640
|
+
const fieldExpressionRules = unaryExpressionRules(EXPRESSION_CONTEXT.field);
|
|
533
641
|
|
|
534
642
|
const listElementTail = ($, element) =>
|
|
535
643
|
seq(",", afterOptionalNewline($, element));
|
|
@@ -538,7 +646,7 @@ export default grammar({
|
|
|
538
646
|
name: "posix_awk",
|
|
539
647
|
|
|
540
648
|
externals: ($) => [
|
|
541
|
-
...KEYWORDS.map((keyword) => $[
|
|
649
|
+
...KEYWORDS.map((keyword) => $[`${keyword}_keyword`]),
|
|
542
650
|
$._name_word,
|
|
543
651
|
$._for_in_variable_word,
|
|
544
652
|
$._getline_word,
|
|
@@ -546,58 +654,100 @@ export default grammar({
|
|
|
546
654
|
$._builtin_func_name_word,
|
|
547
655
|
$._builtin_call_word,
|
|
548
656
|
$._func_name_word,
|
|
549
|
-
$.
|
|
550
|
-
$._number_fraction,
|
|
551
|
-
$._number_exponent,
|
|
657
|
+
$._number,
|
|
552
658
|
$._division_slash,
|
|
553
659
|
$._ere_opening_slash,
|
|
554
660
|
...TWO_CHARACTER_TOKENS.map((name) => $[`_${name}_operator`]),
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
$.
|
|
559
|
-
$.
|
|
560
|
-
$.
|
|
561
|
-
$.
|
|
562
|
-
$.
|
|
661
|
+
...Object.values(SINGLE_CHARACTER_OPERATORS).map(
|
|
662
|
+
(name) => $[`_${name}_operator`],
|
|
663
|
+
),
|
|
664
|
+
$._output_greater,
|
|
665
|
+
$._ere_compound_opening,
|
|
666
|
+
$._ere_dot_closing,
|
|
667
|
+
$._ere_equal_closing,
|
|
668
|
+
$._ere_colon_closing,
|
|
669
|
+
$._ere_bracket_literal_open,
|
|
670
|
+
$._ere_compound_content,
|
|
563
671
|
$._ere_closing_hyphen,
|
|
564
672
|
$._ere_closing,
|
|
565
673
|
$._string_opening,
|
|
566
|
-
$.
|
|
674
|
+
$._string_closing,
|
|
675
|
+
$._string_content,
|
|
676
|
+
$._string_escape,
|
|
677
|
+
$._ere_named_escape,
|
|
678
|
+
$._ere_quoted_escape,
|
|
679
|
+
$._ere_octal_escape,
|
|
680
|
+
$._ere_undefined_escape,
|
|
681
|
+
$._ere_escaped_delimiter,
|
|
682
|
+
$._ere_class_name,
|
|
683
|
+
$._ere_dup_count,
|
|
567
684
|
$.comment,
|
|
568
|
-
$.
|
|
685
|
+
$._continuation_backslash,
|
|
686
|
+
$._continuation_newline,
|
|
569
687
|
$._error_sentinel,
|
|
570
688
|
],
|
|
571
689
|
|
|
572
690
|
extras: ($) => [
|
|
573
691
|
token(repeat1(choice(" ", "\t"))),
|
|
574
692
|
$.comment,
|
|
575
|
-
$.
|
|
576
|
-
$.
|
|
693
|
+
$._continuation_marker,
|
|
694
|
+
$._continuation_newline,
|
|
577
695
|
],
|
|
578
696
|
|
|
579
697
|
inline: ($) => [
|
|
698
|
+
$._lvalue,
|
|
699
|
+
$._simple_get,
|
|
700
|
+
$._direct_input_function,
|
|
580
701
|
$._item,
|
|
702
|
+
// Unit-reduction merging must not inherit update fields through atom children.
|
|
703
|
+
$._normal_non_unary_update_expr,
|
|
704
|
+
$._print_non_unary_update_expr,
|
|
705
|
+
$._field_non_unary_update_expr,
|
|
581
706
|
$._normal_unary_assignment_expr,
|
|
582
707
|
$._normal_unary_update_expr,
|
|
583
708
|
$._print_unary_assignment_expr,
|
|
584
709
|
],
|
|
585
710
|
|
|
586
|
-
conflicts: ($) => [
|
|
711
|
+
conflicts: ($) => [
|
|
712
|
+
[$.postfix_simple_get],
|
|
713
|
+
[$.postfix_simple_get, $.nonpostfix_simple_get],
|
|
714
|
+
// The final item joins item_list only after its terminator is known.
|
|
715
|
+
[$.item_list, $._item_list],
|
|
716
|
+
],
|
|
587
717
|
|
|
588
718
|
rules: {
|
|
589
|
-
program: ($) =>
|
|
590
|
-
seq(optional(alias($._item_list, $.item_list)), optional($._item)),
|
|
719
|
+
program: ($) => seq(optional($.item_list), optional($._item)),
|
|
591
720
|
|
|
592
|
-
|
|
721
|
+
// A literal extra would let the generated lexer accept raw backslashes.
|
|
722
|
+
_continuation_marker: ($) => alias($._continuation_backslash, "\\"),
|
|
723
|
+
|
|
724
|
+
_additive_operator: ($) =>
|
|
725
|
+
field("operator", choice(singleOperator($, "+"), singleOperator($, "-"))),
|
|
593
726
|
|
|
594
727
|
_multiplicative_operator: ($) =>
|
|
595
|
-
field(
|
|
728
|
+
field(
|
|
729
|
+
"operator",
|
|
730
|
+
choice(
|
|
731
|
+
singleOperator($, "*"),
|
|
732
|
+
alias($._division_slash, "/"),
|
|
733
|
+
singleOperator($, "%"),
|
|
734
|
+
),
|
|
735
|
+
),
|
|
596
736
|
|
|
597
|
-
_exponentiation_operator: () => field("operator", "^"),
|
|
737
|
+
_exponentiation_operator: ($) => field("operator", singleOperator($, "^")),
|
|
598
738
|
|
|
599
739
|
_comparison_operator: ($) =>
|
|
600
|
-
field(
|
|
740
|
+
field(
|
|
741
|
+
"operator",
|
|
742
|
+
choice(
|
|
743
|
+
singleOperator($, "<"),
|
|
744
|
+
$.le,
|
|
745
|
+
$.ne,
|
|
746
|
+
$.eq,
|
|
747
|
+
singleOperator($, ">"),
|
|
748
|
+
$.ge,
|
|
749
|
+
),
|
|
750
|
+
),
|
|
601
751
|
|
|
602
752
|
_match_operator: ($) => field("operator", choice("~", $.no_match)),
|
|
603
753
|
|
|
@@ -607,7 +757,8 @@ export default grammar({
|
|
|
607
757
|
|
|
608
758
|
_logical_or_operator: ($) => field("operator", $.or),
|
|
609
759
|
|
|
610
|
-
|
|
760
|
+
item_list: ($) => $._item_list,
|
|
761
|
+
|
|
611
762
|
_item_list: ($) =>
|
|
612
763
|
choice(
|
|
613
764
|
field("leading", $.newline_opt),
|
|
@@ -616,14 +767,14 @@ export default grammar({
|
|
|
616
767
|
|
|
617
768
|
_item: ($) =>
|
|
618
769
|
choice(
|
|
619
|
-
alias($.
|
|
620
|
-
alias($.
|
|
770
|
+
alias($.closed_item, $.item),
|
|
771
|
+
alias($.normal_pattern_item, $.item),
|
|
621
772
|
),
|
|
622
773
|
|
|
623
774
|
_terminated_item: ($) =>
|
|
624
775
|
seq(field("item", $._item), field("terminator", $.terminator)),
|
|
625
776
|
|
|
626
|
-
|
|
777
|
+
closed_item: ($) =>
|
|
627
778
|
choice($._action_item, $._pattern_action_item, $._function_item),
|
|
628
779
|
|
|
629
780
|
_action_item: ($) => field("action", $.action),
|
|
@@ -631,7 +782,7 @@ export default grammar({
|
|
|
631
782
|
_pattern_action_item: ($) =>
|
|
632
783
|
seq(field("pattern", $.pattern), field("action", $.action)),
|
|
633
784
|
|
|
634
|
-
|
|
785
|
+
normal_pattern_item: ($) => field("pattern", $.normal_pattern),
|
|
635
786
|
|
|
636
787
|
_function_item: ($) => seq($._function_header, functionBody($)),
|
|
637
788
|
|
|
@@ -645,7 +796,8 @@ export default grammar({
|
|
|
645
796
|
")",
|
|
646
797
|
),
|
|
647
798
|
|
|
648
|
-
param_list: ($) =>
|
|
799
|
+
param_list: ($) =>
|
|
800
|
+
seq($.name, repeat(seq(",", afterOptionalNewline($, $.name)))),
|
|
649
801
|
|
|
650
802
|
pattern: ($) => choice($.normal_pattern, $.special_pattern),
|
|
651
803
|
|
|
@@ -661,8 +813,6 @@ export default grammar({
|
|
|
661
813
|
|
|
662
814
|
special_pattern: ($) => choice($.begin_keyword, $.end_keyword),
|
|
663
815
|
|
|
664
|
-
...keywordRules,
|
|
665
|
-
|
|
666
816
|
action: ($) =>
|
|
667
817
|
seq(
|
|
668
818
|
field("opening", "{"),
|
|
@@ -702,11 +852,13 @@ export default grammar({
|
|
|
702
852
|
|
|
703
853
|
_for_in_clause: ($) =>
|
|
704
854
|
seq(
|
|
705
|
-
field("variable", alias($.
|
|
855
|
+
field("variable", alias($.for_in_variable, $.name)),
|
|
706
856
|
$.in_keyword,
|
|
707
857
|
field("array", $.name),
|
|
708
858
|
),
|
|
709
859
|
|
|
860
|
+
for_in_variable: ($) => $._for_in_variable_word,
|
|
861
|
+
|
|
710
862
|
_for_header: ($) =>
|
|
711
863
|
header(
|
|
712
864
|
$,
|
|
@@ -775,7 +927,7 @@ export default grammar({
|
|
|
775
927
|
|
|
776
928
|
output_redirection: ($) =>
|
|
777
929
|
seq(
|
|
778
|
-
choice(
|
|
930
|
+
choice(alias($._output_greater, ">"), $.append, singleOperator($, "|")),
|
|
779
931
|
$.expr,
|
|
780
932
|
),
|
|
781
933
|
|
|
@@ -806,32 +958,33 @@ export default grammar({
|
|
|
806
958
|
_prefix_update_expr: ($) =>
|
|
807
959
|
seq(
|
|
808
960
|
field("operator", choice($.incr, $.decr)),
|
|
809
|
-
field("operand", $.
|
|
961
|
+
field("operand", $._lvalue),
|
|
810
962
|
),
|
|
811
963
|
|
|
812
964
|
...normalExpressionRules,
|
|
813
965
|
|
|
814
966
|
...printExpressionRules,
|
|
815
967
|
|
|
816
|
-
|
|
968
|
+
// A pending field operand cannot start a competing pipe source.
|
|
969
|
+
...fieldExpressionRules,
|
|
970
|
+
|
|
971
|
+
nonpostfix_field_expr: ($) =>
|
|
817
972
|
choice(
|
|
818
973
|
alias($.normal_unary_field_expr, $.unary_expr),
|
|
819
|
-
alias($.
|
|
974
|
+
alias($.nonpostfix_non_unary_field_expr, $.non_unary_expr),
|
|
820
975
|
),
|
|
821
976
|
|
|
822
977
|
normal_unary_field_expr: ($) =>
|
|
823
|
-
prec(PRECEDENCE.field, $.
|
|
824
|
-
|
|
825
|
-
_normal_non_unary_field_atom_expr: ($) =>
|
|
826
|
-
prec(PRECEDENCE.field, nonUnaryAtom($, EXPRESSION_CONTEXT.normal)),
|
|
978
|
+
prec(PRECEDENCE.field, $._field_unary_unary_expr),
|
|
827
979
|
|
|
828
|
-
|
|
980
|
+
nonpostfix_non_unary_field_expr: ($) =>
|
|
829
981
|
prec(
|
|
830
982
|
PRECEDENCE.field,
|
|
831
983
|
choice(
|
|
832
|
-
$.
|
|
833
|
-
$._normal_not_expr,
|
|
984
|
+
$._field_not_expr,
|
|
834
985
|
$._prefix_update_expr,
|
|
986
|
+
alias($.nonpostfix_lvalue, $.lvalue),
|
|
987
|
+
alias($.nonpostfix_direct_input_function, $.non_unary_input_function),
|
|
835
988
|
),
|
|
836
989
|
),
|
|
837
990
|
|
|
@@ -840,45 +993,90 @@ export default grammar({
|
|
|
840
993
|
_user_function_call: ($) => seq($.func_name, callArguments($)),
|
|
841
994
|
|
|
842
995
|
_builtin_function_call: ($) =>
|
|
843
|
-
seq(alias($.
|
|
996
|
+
seq(alias($.builtin_call_name, $.builtin_func_name), callArguments($)),
|
|
844
997
|
|
|
845
|
-
|
|
998
|
+
builtin_call_name: ($) => $._builtin_call_word,
|
|
999
|
+
|
|
1000
|
+
_lvalue: ($) =>
|
|
846
1001
|
choice(
|
|
847
|
-
$.
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
1002
|
+
alias($.postfix_lvalue, $.lvalue),
|
|
1003
|
+
alias($.nonpostfix_lvalue, $.lvalue),
|
|
1004
|
+
),
|
|
1005
|
+
|
|
1006
|
+
nonpostfix_lvalue: ($) =>
|
|
1007
|
+
seq(
|
|
1008
|
+
field("operator", "$"),
|
|
1009
|
+
field("operand", alias($.nonpostfix_field_expr, $.expr)),
|
|
1010
|
+
),
|
|
1011
|
+
|
|
1012
|
+
postfix_lvalue: ($) =>
|
|
1013
|
+
lvalueWithFieldOperand($, alias($.postfix_field_expr, $.expr)),
|
|
1014
|
+
|
|
1015
|
+
postfix_field_expr: ($) =>
|
|
1016
|
+
alias($.postfix_non_unary_field_expr, $.non_unary_expr),
|
|
1017
|
+
|
|
1018
|
+
postfix_non_unary_field_expr: ($) =>
|
|
1019
|
+
prec(
|
|
1020
|
+
PRECEDENCE.field,
|
|
1021
|
+
nonUnaryAtom(
|
|
1022
|
+
$,
|
|
1023
|
+
{
|
|
1024
|
+
...EXPRESSION_CONTEXT.field,
|
|
1025
|
+
input: ($) =>
|
|
1026
|
+
alias(
|
|
1027
|
+
$.postfix_direct_input_function,
|
|
1028
|
+
$.non_unary_input_function,
|
|
1029
|
+
),
|
|
1030
|
+
},
|
|
1031
|
+
alias($.postfix_lvalue, $.lvalue),
|
|
852
1032
|
),
|
|
853
1033
|
),
|
|
854
1034
|
|
|
855
|
-
|
|
1035
|
+
_direct_input_function: ($) =>
|
|
856
1036
|
choice(
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
1037
|
+
alias($.postfix_direct_input_function, $.non_unary_input_function),
|
|
1038
|
+
alias($.nonpostfix_direct_input_function, $.non_unary_input_function),
|
|
1039
|
+
),
|
|
1040
|
+
|
|
1041
|
+
nonpostfix_direct_input_function: ($) =>
|
|
1042
|
+
directInputFunction($, alias($.nonpostfix_simple_get, $.simple_get)),
|
|
1043
|
+
|
|
1044
|
+
postfix_direct_input_function: ($) =>
|
|
1045
|
+
directInputFunction($, alias($.postfix_simple_get, $.simple_get)),
|
|
1046
|
+
|
|
1047
|
+
piped_input_function: ($) =>
|
|
1048
|
+
prec.right(
|
|
1049
|
+
PRECEDENCE.field,
|
|
1050
|
+
seq(
|
|
1051
|
+
field("source", $.non_unary_expr),
|
|
1052
|
+
singleOperator($, "|"),
|
|
1053
|
+
field("get", $._simple_get),
|
|
869
1054
|
),
|
|
870
1055
|
),
|
|
871
1056
|
|
|
872
1057
|
unary_input_function: ($) =>
|
|
873
1058
|
prec.right(
|
|
874
1059
|
PRECEDENCE.field,
|
|
875
|
-
seq(
|
|
1060
|
+
seq(
|
|
1061
|
+
field("source", $.unary_expr),
|
|
1062
|
+
singleOperator($, "|"),
|
|
1063
|
+
field("get", $._simple_get),
|
|
1064
|
+
),
|
|
876
1065
|
),
|
|
877
1066
|
|
|
878
|
-
|
|
1067
|
+
_simple_get: ($) =>
|
|
1068
|
+
choice(
|
|
1069
|
+
alias($.postfix_simple_get, $.simple_get),
|
|
1070
|
+
alias($.nonpostfix_simple_get, $.simple_get),
|
|
1071
|
+
),
|
|
1072
|
+
|
|
1073
|
+
nonpostfix_simple_get: ($) =>
|
|
1074
|
+
getWithTarget($, alias($.nonpostfix_lvalue, $.lvalue)),
|
|
1075
|
+
|
|
1076
|
+
postfix_simple_get: ($) =>
|
|
879
1077
|
choice(
|
|
880
1078
|
$.getline_keyword,
|
|
881
|
-
|
|
1079
|
+
getWithTarget($, alias($.postfix_lvalue, $.lvalue)),
|
|
882
1080
|
),
|
|
883
1081
|
|
|
884
1082
|
getline_keyword: ($) => $._getline_word,
|
|
@@ -891,24 +1089,18 @@ export default grammar({
|
|
|
891
1089
|
|
|
892
1090
|
name: ($) => $._name_word,
|
|
893
1091
|
|
|
894
|
-
number: ($) =>
|
|
895
|
-
choice($._number_integer, $._number_fraction, $._number_exponent),
|
|
1092
|
+
number: ($) => $._number,
|
|
896
1093
|
|
|
897
1094
|
string: ($) =>
|
|
898
1095
|
seq(
|
|
899
1096
|
field("opening", alias($._string_opening, '"')),
|
|
900
1097
|
repeat(choice($.string_content, $.escape_sequence)),
|
|
901
|
-
$.
|
|
902
|
-
field("closing", token.immediate('"')),
|
|
1098
|
+
field("closing", alias($._string_closing, '"')),
|
|
903
1099
|
),
|
|
904
1100
|
|
|
905
|
-
string_content: () =>
|
|
1101
|
+
string_content: ($) => $._string_content,
|
|
906
1102
|
|
|
907
|
-
escape_sequence: ($) =>
|
|
908
|
-
seq(
|
|
909
|
-
$._escape_introducer,
|
|
910
|
-
choice($._escape_character, $._escape_octal_digits),
|
|
911
|
-
),
|
|
1103
|
+
escape_sequence: ($) => $._string_escape,
|
|
912
1104
|
|
|
913
1105
|
...twoCharacterTokenRules,
|
|
914
1106
|
|
|
@@ -919,59 +1111,11 @@ export default grammar({
|
|
|
919
1111
|
field("closing", alias($._ere_closing, "/")),
|
|
920
1112
|
),
|
|
921
1113
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
$.ere_branch,
|
|
925
|
-
seq(
|
|
926
|
-
field("left", $.extended_reg_exp),
|
|
927
|
-
field("operator", token.immediate("|")),
|
|
928
|
-
field("right", $.ere_branch),
|
|
929
|
-
),
|
|
930
|
-
),
|
|
931
|
-
|
|
932
|
-
ere_branch: ($) =>
|
|
933
|
-
choice(
|
|
934
|
-
$.ere_expression,
|
|
935
|
-
seq(field("left", $.ere_branch), field("right", $.ere_expression)),
|
|
936
|
-
),
|
|
937
|
-
|
|
938
|
-
ere_expression: ($) =>
|
|
939
|
-
choice(
|
|
940
|
-
$.one_char_or_coll_elem_ere,
|
|
941
|
-
$.left_anchor,
|
|
942
|
-
$.right_anchor,
|
|
943
|
-
seq(
|
|
944
|
-
field("opening", token.immediate("(")),
|
|
945
|
-
field("expression", $.extended_reg_exp),
|
|
946
|
-
field("closing", $._ere_close_parenthesis),
|
|
947
|
-
),
|
|
948
|
-
seq(
|
|
949
|
-
field("operand", $.ere_expression),
|
|
950
|
-
field("operator", $.ere_dupl_symbol),
|
|
951
|
-
),
|
|
952
|
-
),
|
|
953
|
-
|
|
954
|
-
one_char_or_coll_elem_ere: ($) =>
|
|
955
|
-
choice(
|
|
956
|
-
$.ordinary_character,
|
|
957
|
-
$.quoted_character,
|
|
958
|
-
$.wildcard,
|
|
959
|
-
$.bracket_expression,
|
|
960
|
-
alias($._ere_octal_escape_sequence, $.escape_sequence),
|
|
961
|
-
alias($._ere_undefined_escape_sequence, $.escape_sequence),
|
|
962
|
-
),
|
|
963
|
-
|
|
964
|
-
ordinary_character: ($) =>
|
|
965
|
-
choice(
|
|
966
|
-
alias($._ordinary_character, $.ordinary_character_content),
|
|
967
|
-
$._ere_ordinary_close_parenthesis,
|
|
968
|
-
$._ere_ordinary_close_brace,
|
|
969
|
-
$.escaped_delimiter,
|
|
970
|
-
alias($._ere_named_escape_sequence, $.escape_sequence),
|
|
971
|
-
),
|
|
1114
|
+
...ereExpressionRules(false),
|
|
1115
|
+
...ereExpressionRules(true),
|
|
972
1116
|
|
|
973
1117
|
quoted_character: ($) =>
|
|
974
|
-
alias($.
|
|
1118
|
+
alias($.ere_quoted_escape_sequence, $.escape_sequence),
|
|
975
1119
|
|
|
976
1120
|
wildcard: () => token.immediate("."),
|
|
977
1121
|
|
|
@@ -1002,7 +1146,7 @@ export default grammar({
|
|
|
1002
1146
|
$._ere_close_brace,
|
|
1003
1147
|
),
|
|
1004
1148
|
|
|
1005
|
-
dup_count: ($) => $.
|
|
1149
|
+
dup_count: ($) => $._ere_dup_count,
|
|
1006
1150
|
|
|
1007
1151
|
bracket_expression: ($) =>
|
|
1008
1152
|
seq(
|
|
@@ -1057,9 +1201,9 @@ export default grammar({
|
|
|
1057
1201
|
collating_element: ($) =>
|
|
1058
1202
|
choice(
|
|
1059
1203
|
alias($._ere_bracket_character, $.collating_element_content),
|
|
1060
|
-
alias(
|
|
1204
|
+
alias($._ere_bracket_literal_open, $.collating_element_content),
|
|
1061
1205
|
$.escaped_delimiter,
|
|
1062
|
-
alias($.
|
|
1206
|
+
alias($.ere_bracket_escape_sequence, $.escape_sequence),
|
|
1063
1207
|
),
|
|
1064
1208
|
|
|
1065
1209
|
collating_symbol: ($) =>
|
|
@@ -1082,7 +1226,7 @@ export default grammar({
|
|
|
1082
1226
|
character_class: ($) =>
|
|
1083
1227
|
seq($._ere_open_colon, $.class_name, $._ere_colon_close),
|
|
1084
1228
|
|
|
1085
|
-
class_name: ($) => $.
|
|
1229
|
+
class_name: ($) => $._ere_class_name,
|
|
1086
1230
|
|
|
1087
1231
|
meta_character: ($) => $._ere_compound_meta_character,
|
|
1088
1232
|
|
|
@@ -1105,47 +1249,39 @@ export default grammar({
|
|
|
1105
1249
|
_ere_compound_nonmeta_atom: ($) =>
|
|
1106
1250
|
choice(
|
|
1107
1251
|
alias($._ere_compound_nonmeta_character, $.collating_element_content),
|
|
1252
|
+
alias($._ere_compound_content, $.collating_element_content),
|
|
1108
1253
|
$.escaped_delimiter,
|
|
1109
|
-
alias($.
|
|
1254
|
+
alias($.ere_bracket_escape_sequence, $.escape_sequence),
|
|
1110
1255
|
),
|
|
1111
1256
|
|
|
1112
1257
|
_ere_open_dot: ($) => ereCompoundOpening($, "."),
|
|
1113
1258
|
|
|
1114
|
-
_ere_dot_close: ($) => ereCompoundClosing($.
|
|
1259
|
+
_ere_dot_close: ($) => ereCompoundClosing($._ere_dot_closing, "."),
|
|
1115
1260
|
|
|
1116
1261
|
_ere_open_equal: ($) => ereCompoundOpening($, "="),
|
|
1117
1262
|
|
|
1118
|
-
_ere_equal_close: ($) => ereCompoundClosing($.
|
|
1263
|
+
_ere_equal_close: ($) => ereCompoundClosing($._ere_equal_closing, "="),
|
|
1119
1264
|
|
|
1120
1265
|
_ere_open_colon: ($) => ereCompoundOpening($, ":"),
|
|
1121
1266
|
|
|
1122
|
-
_ere_colon_close: ($) => ereCompoundClosing($.
|
|
1267
|
+
_ere_colon_close: ($) => ereCompoundClosing($._ere_colon_closing, ":"),
|
|
1123
1268
|
|
|
1124
|
-
escaped_delimiter: ($) =>
|
|
1125
|
-
seq(
|
|
1126
|
-
$._ere_escaped_delimiter_start,
|
|
1127
|
-
$._escape_introducer,
|
|
1128
|
-
$._ere_escaped_delimiter_end,
|
|
1129
|
-
),
|
|
1269
|
+
escaped_delimiter: ($) => $._ere_escaped_delimiter,
|
|
1130
1270
|
|
|
1131
|
-
|
|
1132
|
-
ereEscapeWithCharacter($, $._ere_named_escape_character),
|
|
1271
|
+
ere_named_escape_sequence: ($) => $._ere_named_escape,
|
|
1133
1272
|
|
|
1134
|
-
|
|
1135
|
-
ereEscapeWithCharacter($, $._ere_quoted_escape_character),
|
|
1273
|
+
ere_quoted_escape_sequence: ($) => $._ere_quoted_escape,
|
|
1136
1274
|
|
|
1137
|
-
|
|
1138
|
-
ereEscapeWithCharacter($, $._escape_octal_digits),
|
|
1275
|
+
ere_octal_escape_sequence: ($) => $._ere_octal_escape,
|
|
1139
1276
|
|
|
1140
|
-
|
|
1141
|
-
ereEscapeWithCharacter($, $._ere_undefined_escape_character),
|
|
1277
|
+
ere_undefined_escape_sequence: ($) => $._ere_undefined_escape,
|
|
1142
1278
|
|
|
1143
|
-
|
|
1279
|
+
ere_bracket_escape_sequence: ($) =>
|
|
1144
1280
|
choice(
|
|
1145
|
-
$.
|
|
1146
|
-
$.
|
|
1147
|
-
$.
|
|
1148
|
-
$.
|
|
1281
|
+
$._ere_named_escape,
|
|
1282
|
+
$._ere_quoted_escape,
|
|
1283
|
+
$._ere_octal_escape,
|
|
1284
|
+
$._ere_undefined_escape,
|
|
1149
1285
|
),
|
|
1150
1286
|
|
|
1151
1287
|
// Tree-sitter rejects the POSIX bracket spelling for these delimiter
|
|
@@ -1167,33 +1303,14 @@ export default grammar({
|
|
|
1167
1303
|
_ere_bracket_character: () => token.immediate(/[^\x2D\x2F\x5B\x5C\x5D\n]/),
|
|
1168
1304
|
|
|
1169
1305
|
_ere_compound_nonmeta_character: () =>
|
|
1170
|
-
token.immediate(/[
|
|
1306
|
+
token.immediate(/[^.:=\x2D\x2F\x5C\x5D\n]/),
|
|
1171
1307
|
|
|
1172
1308
|
_ere_compound_meta_character: () => token.immediate(/[\x2D\x5D]/),
|
|
1173
1309
|
|
|
1174
|
-
_ere_class_name_spelling: () => token.immediate(/[A-Za-z][A-Za-z0-9]*/),
|
|
1175
|
-
|
|
1176
|
-
_ere_named_escape_character: () => token.immediate(prec(1, /[abfnrtv]/)),
|
|
1177
|
-
|
|
1178
|
-
_ere_quoted_escape_character: () =>
|
|
1179
|
-
token.immediate(prec(1, /[().*+?{}|^$\x5B\x5C\x5D]/)),
|
|
1180
|
-
|
|
1181
|
-
_ere_undefined_escape_character: () => token.immediate(/[^0-7\x2F\x5C\n]/),
|
|
1182
|
-
|
|
1183
1310
|
newline_opt: ($) => rawNewlines($),
|
|
1184
1311
|
|
|
1185
1312
|
terminator: ($) => choice(rawNewlines($), seq(";", repeat($.newline))),
|
|
1186
1313
|
|
|
1187
1314
|
newline: () => "\n",
|
|
1188
|
-
|
|
1189
|
-
line_continuation: () => token(seq("\\", "\n")),
|
|
1190
|
-
|
|
1191
|
-
_number_digit_chunk: () => token.immediate(/[0-9]+/),
|
|
1192
|
-
|
|
1193
|
-
_escape_introducer: () => token.immediate(/\\/),
|
|
1194
|
-
|
|
1195
|
-
_escape_character: () => token.immediate(/[^0-7\n]/),
|
|
1196
|
-
|
|
1197
|
-
_escape_octal_digits: () => token.immediate(/[0-7]{1,3}/),
|
|
1198
1315
|
},
|
|
1199
1316
|
});
|