@konomanoasa/tree-sitter-posix-awk 0.13.0 → 0.14.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 +391 -275
- package/package.json +1 -1
- package/queries/highlights.scm +1 -1
- package/src/grammar.json +1321 -589
- package/src/node-types.json +72 -98
- package/src/parser.c +142595 -57898
- 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,7 @@ export default grammar({
|
|
|
645
796
|
")",
|
|
646
797
|
),
|
|
647
798
|
|
|
648
|
-
param_list: ($) => seq($.name, repeat(
|
|
799
|
+
param_list: ($) => seq($.name, repeat(seq(",", $.name))),
|
|
649
800
|
|
|
650
801
|
pattern: ($) => choice($.normal_pattern, $.special_pattern),
|
|
651
802
|
|
|
@@ -661,8 +812,6 @@ export default grammar({
|
|
|
661
812
|
|
|
662
813
|
special_pattern: ($) => choice($.begin_keyword, $.end_keyword),
|
|
663
814
|
|
|
664
|
-
...keywordRules,
|
|
665
|
-
|
|
666
815
|
action: ($) =>
|
|
667
816
|
seq(
|
|
668
817
|
field("opening", "{"),
|
|
@@ -702,11 +851,13 @@ export default grammar({
|
|
|
702
851
|
|
|
703
852
|
_for_in_clause: ($) =>
|
|
704
853
|
seq(
|
|
705
|
-
field("variable", alias($.
|
|
854
|
+
field("variable", alias($.for_in_variable, $.name)),
|
|
706
855
|
$.in_keyword,
|
|
707
856
|
field("array", $.name),
|
|
708
857
|
),
|
|
709
858
|
|
|
859
|
+
for_in_variable: ($) => $._for_in_variable_word,
|
|
860
|
+
|
|
710
861
|
_for_header: ($) =>
|
|
711
862
|
header(
|
|
712
863
|
$,
|
|
@@ -775,7 +926,7 @@ export default grammar({
|
|
|
775
926
|
|
|
776
927
|
output_redirection: ($) =>
|
|
777
928
|
seq(
|
|
778
|
-
choice(
|
|
929
|
+
choice(alias($._output_greater, ">"), $.append, singleOperator($, "|")),
|
|
779
930
|
$.expr,
|
|
780
931
|
),
|
|
781
932
|
|
|
@@ -806,32 +957,33 @@ export default grammar({
|
|
|
806
957
|
_prefix_update_expr: ($) =>
|
|
807
958
|
seq(
|
|
808
959
|
field("operator", choice($.incr, $.decr)),
|
|
809
|
-
field("operand", $.
|
|
960
|
+
field("operand", $._lvalue),
|
|
810
961
|
),
|
|
811
962
|
|
|
812
963
|
...normalExpressionRules,
|
|
813
964
|
|
|
814
965
|
...printExpressionRules,
|
|
815
966
|
|
|
816
|
-
|
|
967
|
+
// A pending field operand cannot start a competing pipe source.
|
|
968
|
+
...fieldExpressionRules,
|
|
969
|
+
|
|
970
|
+
nonpostfix_field_expr: ($) =>
|
|
817
971
|
choice(
|
|
818
972
|
alias($.normal_unary_field_expr, $.unary_expr),
|
|
819
|
-
alias($.
|
|
973
|
+
alias($.nonpostfix_non_unary_field_expr, $.non_unary_expr),
|
|
820
974
|
),
|
|
821
975
|
|
|
822
976
|
normal_unary_field_expr: ($) =>
|
|
823
|
-
prec(PRECEDENCE.field, $.
|
|
824
|
-
|
|
825
|
-
_normal_non_unary_field_atom_expr: ($) =>
|
|
826
|
-
prec(PRECEDENCE.field, nonUnaryAtom($, EXPRESSION_CONTEXT.normal)),
|
|
977
|
+
prec(PRECEDENCE.field, $._field_unary_unary_expr),
|
|
827
978
|
|
|
828
|
-
|
|
979
|
+
nonpostfix_non_unary_field_expr: ($) =>
|
|
829
980
|
prec(
|
|
830
981
|
PRECEDENCE.field,
|
|
831
982
|
choice(
|
|
832
|
-
$.
|
|
833
|
-
$._normal_not_expr,
|
|
983
|
+
$._field_not_expr,
|
|
834
984
|
$._prefix_update_expr,
|
|
985
|
+
alias($.nonpostfix_lvalue, $.lvalue),
|
|
986
|
+
alias($.nonpostfix_direct_input_function, $.non_unary_input_function),
|
|
835
987
|
),
|
|
836
988
|
),
|
|
837
989
|
|
|
@@ -840,45 +992,90 @@ export default grammar({
|
|
|
840
992
|
_user_function_call: ($) => seq($.func_name, callArguments($)),
|
|
841
993
|
|
|
842
994
|
_builtin_function_call: ($) =>
|
|
843
|
-
seq(alias($.
|
|
995
|
+
seq(alias($.builtin_call_name, $.builtin_func_name), callArguments($)),
|
|
844
996
|
|
|
845
|
-
|
|
997
|
+
builtin_call_name: ($) => $._builtin_call_word,
|
|
998
|
+
|
|
999
|
+
_lvalue: ($) =>
|
|
846
1000
|
choice(
|
|
847
|
-
$.
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
1001
|
+
alias($.postfix_lvalue, $.lvalue),
|
|
1002
|
+
alias($.nonpostfix_lvalue, $.lvalue),
|
|
1003
|
+
),
|
|
1004
|
+
|
|
1005
|
+
nonpostfix_lvalue: ($) =>
|
|
1006
|
+
seq(
|
|
1007
|
+
field("operator", "$"),
|
|
1008
|
+
field("operand", alias($.nonpostfix_field_expr, $.expr)),
|
|
1009
|
+
),
|
|
1010
|
+
|
|
1011
|
+
postfix_lvalue: ($) =>
|
|
1012
|
+
lvalueWithFieldOperand($, alias($.postfix_field_expr, $.expr)),
|
|
1013
|
+
|
|
1014
|
+
postfix_field_expr: ($) =>
|
|
1015
|
+
alias($.postfix_non_unary_field_expr, $.non_unary_expr),
|
|
1016
|
+
|
|
1017
|
+
postfix_non_unary_field_expr: ($) =>
|
|
1018
|
+
prec(
|
|
1019
|
+
PRECEDENCE.field,
|
|
1020
|
+
nonUnaryAtom(
|
|
1021
|
+
$,
|
|
1022
|
+
{
|
|
1023
|
+
...EXPRESSION_CONTEXT.field,
|
|
1024
|
+
input: ($) =>
|
|
1025
|
+
alias(
|
|
1026
|
+
$.postfix_direct_input_function,
|
|
1027
|
+
$.non_unary_input_function,
|
|
1028
|
+
),
|
|
1029
|
+
},
|
|
1030
|
+
alias($.postfix_lvalue, $.lvalue),
|
|
852
1031
|
),
|
|
853
1032
|
),
|
|
854
1033
|
|
|
855
|
-
|
|
1034
|
+
_direct_input_function: ($) =>
|
|
856
1035
|
choice(
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
1036
|
+
alias($.postfix_direct_input_function, $.non_unary_input_function),
|
|
1037
|
+
alias($.nonpostfix_direct_input_function, $.non_unary_input_function),
|
|
1038
|
+
),
|
|
1039
|
+
|
|
1040
|
+
nonpostfix_direct_input_function: ($) =>
|
|
1041
|
+
directInputFunction($, alias($.nonpostfix_simple_get, $.simple_get)),
|
|
1042
|
+
|
|
1043
|
+
postfix_direct_input_function: ($) =>
|
|
1044
|
+
directInputFunction($, alias($.postfix_simple_get, $.simple_get)),
|
|
1045
|
+
|
|
1046
|
+
piped_input_function: ($) =>
|
|
1047
|
+
prec.right(
|
|
1048
|
+
PRECEDENCE.field,
|
|
1049
|
+
seq(
|
|
1050
|
+
field("source", $.non_unary_expr),
|
|
1051
|
+
singleOperator($, "|"),
|
|
1052
|
+
field("get", $._simple_get),
|
|
869
1053
|
),
|
|
870
1054
|
),
|
|
871
1055
|
|
|
872
1056
|
unary_input_function: ($) =>
|
|
873
1057
|
prec.right(
|
|
874
1058
|
PRECEDENCE.field,
|
|
875
|
-
seq(
|
|
1059
|
+
seq(
|
|
1060
|
+
field("source", $.unary_expr),
|
|
1061
|
+
singleOperator($, "|"),
|
|
1062
|
+
field("get", $._simple_get),
|
|
1063
|
+
),
|
|
876
1064
|
),
|
|
877
1065
|
|
|
878
|
-
|
|
1066
|
+
_simple_get: ($) =>
|
|
1067
|
+
choice(
|
|
1068
|
+
alias($.postfix_simple_get, $.simple_get),
|
|
1069
|
+
alias($.nonpostfix_simple_get, $.simple_get),
|
|
1070
|
+
),
|
|
1071
|
+
|
|
1072
|
+
nonpostfix_simple_get: ($) =>
|
|
1073
|
+
getWithTarget($, alias($.nonpostfix_lvalue, $.lvalue)),
|
|
1074
|
+
|
|
1075
|
+
postfix_simple_get: ($) =>
|
|
879
1076
|
choice(
|
|
880
1077
|
$.getline_keyword,
|
|
881
|
-
|
|
1078
|
+
getWithTarget($, alias($.postfix_lvalue, $.lvalue)),
|
|
882
1079
|
),
|
|
883
1080
|
|
|
884
1081
|
getline_keyword: ($) => $._getline_word,
|
|
@@ -891,24 +1088,18 @@ export default grammar({
|
|
|
891
1088
|
|
|
892
1089
|
name: ($) => $._name_word,
|
|
893
1090
|
|
|
894
|
-
number: ($) =>
|
|
895
|
-
choice($._number_integer, $._number_fraction, $._number_exponent),
|
|
1091
|
+
number: ($) => $._number,
|
|
896
1092
|
|
|
897
1093
|
string: ($) =>
|
|
898
1094
|
seq(
|
|
899
1095
|
field("opening", alias($._string_opening, '"')),
|
|
900
1096
|
repeat(choice($.string_content, $.escape_sequence)),
|
|
901
|
-
$.
|
|
902
|
-
field("closing", token.immediate('"')),
|
|
1097
|
+
field("closing", alias($._string_closing, '"')),
|
|
903
1098
|
),
|
|
904
1099
|
|
|
905
|
-
string_content: () =>
|
|
1100
|
+
string_content: ($) => $._string_content,
|
|
906
1101
|
|
|
907
|
-
escape_sequence: ($) =>
|
|
908
|
-
seq(
|
|
909
|
-
$._escape_introducer,
|
|
910
|
-
choice($._escape_character, $._escape_octal_digits),
|
|
911
|
-
),
|
|
1102
|
+
escape_sequence: ($) => $._string_escape,
|
|
912
1103
|
|
|
913
1104
|
...twoCharacterTokenRules,
|
|
914
1105
|
|
|
@@ -919,59 +1110,11 @@ export default grammar({
|
|
|
919
1110
|
field("closing", alias($._ere_closing, "/")),
|
|
920
1111
|
),
|
|
921
1112
|
|
|
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
|
-
),
|
|
1113
|
+
...ereExpressionRules(false),
|
|
1114
|
+
...ereExpressionRules(true),
|
|
972
1115
|
|
|
973
1116
|
quoted_character: ($) =>
|
|
974
|
-
alias($.
|
|
1117
|
+
alias($.ere_quoted_escape_sequence, $.escape_sequence),
|
|
975
1118
|
|
|
976
1119
|
wildcard: () => token.immediate("."),
|
|
977
1120
|
|
|
@@ -1002,7 +1145,7 @@ export default grammar({
|
|
|
1002
1145
|
$._ere_close_brace,
|
|
1003
1146
|
),
|
|
1004
1147
|
|
|
1005
|
-
dup_count: ($) => $.
|
|
1148
|
+
dup_count: ($) => $._ere_dup_count,
|
|
1006
1149
|
|
|
1007
1150
|
bracket_expression: ($) =>
|
|
1008
1151
|
seq(
|
|
@@ -1057,9 +1200,9 @@ export default grammar({
|
|
|
1057
1200
|
collating_element: ($) =>
|
|
1058
1201
|
choice(
|
|
1059
1202
|
alias($._ere_bracket_character, $.collating_element_content),
|
|
1060
|
-
alias(
|
|
1203
|
+
alias($._ere_bracket_literal_open, $.collating_element_content),
|
|
1061
1204
|
$.escaped_delimiter,
|
|
1062
|
-
alias($.
|
|
1205
|
+
alias($.ere_bracket_escape_sequence, $.escape_sequence),
|
|
1063
1206
|
),
|
|
1064
1207
|
|
|
1065
1208
|
collating_symbol: ($) =>
|
|
@@ -1082,7 +1225,7 @@ export default grammar({
|
|
|
1082
1225
|
character_class: ($) =>
|
|
1083
1226
|
seq($._ere_open_colon, $.class_name, $._ere_colon_close),
|
|
1084
1227
|
|
|
1085
|
-
class_name: ($) => $.
|
|
1228
|
+
class_name: ($) => $._ere_class_name,
|
|
1086
1229
|
|
|
1087
1230
|
meta_character: ($) => $._ere_compound_meta_character,
|
|
1088
1231
|
|
|
@@ -1105,47 +1248,39 @@ export default grammar({
|
|
|
1105
1248
|
_ere_compound_nonmeta_atom: ($) =>
|
|
1106
1249
|
choice(
|
|
1107
1250
|
alias($._ere_compound_nonmeta_character, $.collating_element_content),
|
|
1251
|
+
alias($._ere_compound_content, $.collating_element_content),
|
|
1108
1252
|
$.escaped_delimiter,
|
|
1109
|
-
alias($.
|
|
1253
|
+
alias($.ere_bracket_escape_sequence, $.escape_sequence),
|
|
1110
1254
|
),
|
|
1111
1255
|
|
|
1112
1256
|
_ere_open_dot: ($) => ereCompoundOpening($, "."),
|
|
1113
1257
|
|
|
1114
|
-
_ere_dot_close: ($) => ereCompoundClosing($.
|
|
1258
|
+
_ere_dot_close: ($) => ereCompoundClosing($._ere_dot_closing, "."),
|
|
1115
1259
|
|
|
1116
1260
|
_ere_open_equal: ($) => ereCompoundOpening($, "="),
|
|
1117
1261
|
|
|
1118
|
-
_ere_equal_close: ($) => ereCompoundClosing($.
|
|
1262
|
+
_ere_equal_close: ($) => ereCompoundClosing($._ere_equal_closing, "="),
|
|
1119
1263
|
|
|
1120
1264
|
_ere_open_colon: ($) => ereCompoundOpening($, ":"),
|
|
1121
1265
|
|
|
1122
|
-
_ere_colon_close: ($) => ereCompoundClosing($.
|
|
1266
|
+
_ere_colon_close: ($) => ereCompoundClosing($._ere_colon_closing, ":"),
|
|
1123
1267
|
|
|
1124
|
-
escaped_delimiter: ($) =>
|
|
1125
|
-
seq(
|
|
1126
|
-
$._ere_escaped_delimiter_start,
|
|
1127
|
-
$._escape_introducer,
|
|
1128
|
-
$._ere_escaped_delimiter_end,
|
|
1129
|
-
),
|
|
1268
|
+
escaped_delimiter: ($) => $._ere_escaped_delimiter,
|
|
1130
1269
|
|
|
1131
|
-
|
|
1132
|
-
ereEscapeWithCharacter($, $._ere_named_escape_character),
|
|
1270
|
+
ere_named_escape_sequence: ($) => $._ere_named_escape,
|
|
1133
1271
|
|
|
1134
|
-
|
|
1135
|
-
ereEscapeWithCharacter($, $._ere_quoted_escape_character),
|
|
1272
|
+
ere_quoted_escape_sequence: ($) => $._ere_quoted_escape,
|
|
1136
1273
|
|
|
1137
|
-
|
|
1138
|
-
ereEscapeWithCharacter($, $._escape_octal_digits),
|
|
1274
|
+
ere_octal_escape_sequence: ($) => $._ere_octal_escape,
|
|
1139
1275
|
|
|
1140
|
-
|
|
1141
|
-
ereEscapeWithCharacter($, $._ere_undefined_escape_character),
|
|
1276
|
+
ere_undefined_escape_sequence: ($) => $._ere_undefined_escape,
|
|
1142
1277
|
|
|
1143
|
-
|
|
1278
|
+
ere_bracket_escape_sequence: ($) =>
|
|
1144
1279
|
choice(
|
|
1145
|
-
$.
|
|
1146
|
-
$.
|
|
1147
|
-
$.
|
|
1148
|
-
$.
|
|
1280
|
+
$._ere_named_escape,
|
|
1281
|
+
$._ere_quoted_escape,
|
|
1282
|
+
$._ere_octal_escape,
|
|
1283
|
+
$._ere_undefined_escape,
|
|
1149
1284
|
),
|
|
1150
1285
|
|
|
1151
1286
|
// Tree-sitter rejects the POSIX bracket spelling for these delimiter
|
|
@@ -1167,33 +1302,14 @@ export default grammar({
|
|
|
1167
1302
|
_ere_bracket_character: () => token.immediate(/[^\x2D\x2F\x5B\x5C\x5D\n]/),
|
|
1168
1303
|
|
|
1169
1304
|
_ere_compound_nonmeta_character: () =>
|
|
1170
|
-
token.immediate(/[
|
|
1305
|
+
token.immediate(/[^.:=\x2D\x2F\x5C\x5D\n]/),
|
|
1171
1306
|
|
|
1172
1307
|
_ere_compound_meta_character: () => token.immediate(/[\x2D\x5D]/),
|
|
1173
1308
|
|
|
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
1309
|
newline_opt: ($) => rawNewlines($),
|
|
1184
1310
|
|
|
1185
1311
|
terminator: ($) => choice(rawNewlines($), seq(";", repeat($.newline))),
|
|
1186
1312
|
|
|
1187
1313
|
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
1314
|
},
|
|
1199
1315
|
});
|