@konomanoasa/tree-sitter-posix-awk 0.12.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 -273
- package/package.json +1 -1
- package/queries/highlights.scm +1 -1
- package/src/grammar.json +1658 -918
- package/src/node-types.json +73 -94
- package/src/parser.c +142728 -56204
- package/src/scanner.c +401 -408
- 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,56 +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,
|
|
685
|
+
$._continuation_backslash,
|
|
686
|
+
$._continuation_newline,
|
|
568
687
|
$._error_sentinel,
|
|
569
688
|
],
|
|
570
689
|
|
|
571
690
|
extras: ($) => [
|
|
572
691
|
token(repeat1(choice(" ", "\t"))),
|
|
573
692
|
$.comment,
|
|
574
|
-
$.
|
|
693
|
+
$._continuation_marker,
|
|
694
|
+
$._continuation_newline,
|
|
575
695
|
],
|
|
576
696
|
|
|
577
697
|
inline: ($) => [
|
|
698
|
+
$._lvalue,
|
|
699
|
+
$._simple_get,
|
|
700
|
+
$._direct_input_function,
|
|
578
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,
|
|
579
706
|
$._normal_unary_assignment_expr,
|
|
580
707
|
$._normal_unary_update_expr,
|
|
581
708
|
$._print_unary_assignment_expr,
|
|
582
709
|
],
|
|
583
710
|
|
|
584
|
-
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
|
+
],
|
|
585
717
|
|
|
586
718
|
rules: {
|
|
587
|
-
program: ($) =>
|
|
588
|
-
seq(optional(alias($._item_list, $.item_list)), optional($._item)),
|
|
719
|
+
program: ($) => seq(optional($.item_list), optional($._item)),
|
|
589
720
|
|
|
590
|
-
|
|
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($, "-"))),
|
|
591
726
|
|
|
592
727
|
_multiplicative_operator: ($) =>
|
|
593
|
-
field(
|
|
728
|
+
field(
|
|
729
|
+
"operator",
|
|
730
|
+
choice(
|
|
731
|
+
singleOperator($, "*"),
|
|
732
|
+
alias($._division_slash, "/"),
|
|
733
|
+
singleOperator($, "%"),
|
|
734
|
+
),
|
|
735
|
+
),
|
|
594
736
|
|
|
595
|
-
_exponentiation_operator: () => field("operator", "^"),
|
|
737
|
+
_exponentiation_operator: ($) => field("operator", singleOperator($, "^")),
|
|
596
738
|
|
|
597
739
|
_comparison_operator: ($) =>
|
|
598
|
-
field(
|
|
740
|
+
field(
|
|
741
|
+
"operator",
|
|
742
|
+
choice(
|
|
743
|
+
singleOperator($, "<"),
|
|
744
|
+
$.le,
|
|
745
|
+
$.ne,
|
|
746
|
+
$.eq,
|
|
747
|
+
singleOperator($, ">"),
|
|
748
|
+
$.ge,
|
|
749
|
+
),
|
|
750
|
+
),
|
|
599
751
|
|
|
600
752
|
_match_operator: ($) => field("operator", choice("~", $.no_match)),
|
|
601
753
|
|
|
@@ -605,7 +757,8 @@ export default grammar({
|
|
|
605
757
|
|
|
606
758
|
_logical_or_operator: ($) => field("operator", $.or),
|
|
607
759
|
|
|
608
|
-
|
|
760
|
+
item_list: ($) => $._item_list,
|
|
761
|
+
|
|
609
762
|
_item_list: ($) =>
|
|
610
763
|
choice(
|
|
611
764
|
field("leading", $.newline_opt),
|
|
@@ -614,14 +767,14 @@ export default grammar({
|
|
|
614
767
|
|
|
615
768
|
_item: ($) =>
|
|
616
769
|
choice(
|
|
617
|
-
alias($.
|
|
618
|
-
alias($.
|
|
770
|
+
alias($.closed_item, $.item),
|
|
771
|
+
alias($.normal_pattern_item, $.item),
|
|
619
772
|
),
|
|
620
773
|
|
|
621
774
|
_terminated_item: ($) =>
|
|
622
775
|
seq(field("item", $._item), field("terminator", $.terminator)),
|
|
623
776
|
|
|
624
|
-
|
|
777
|
+
closed_item: ($) =>
|
|
625
778
|
choice($._action_item, $._pattern_action_item, $._function_item),
|
|
626
779
|
|
|
627
780
|
_action_item: ($) => field("action", $.action),
|
|
@@ -629,7 +782,7 @@ export default grammar({
|
|
|
629
782
|
_pattern_action_item: ($) =>
|
|
630
783
|
seq(field("pattern", $.pattern), field("action", $.action)),
|
|
631
784
|
|
|
632
|
-
|
|
785
|
+
normal_pattern_item: ($) => field("pattern", $.normal_pattern),
|
|
633
786
|
|
|
634
787
|
_function_item: ($) => seq($._function_header, functionBody($)),
|
|
635
788
|
|
|
@@ -643,7 +796,7 @@ export default grammar({
|
|
|
643
796
|
")",
|
|
644
797
|
),
|
|
645
798
|
|
|
646
|
-
param_list: ($) => seq($.name, repeat(
|
|
799
|
+
param_list: ($) => seq($.name, repeat(seq(",", $.name))),
|
|
647
800
|
|
|
648
801
|
pattern: ($) => choice($.normal_pattern, $.special_pattern),
|
|
649
802
|
|
|
@@ -659,8 +812,6 @@ export default grammar({
|
|
|
659
812
|
|
|
660
813
|
special_pattern: ($) => choice($.begin_keyword, $.end_keyword),
|
|
661
814
|
|
|
662
|
-
...keywordRules,
|
|
663
|
-
|
|
664
815
|
action: ($) =>
|
|
665
816
|
seq(
|
|
666
817
|
field("opening", "{"),
|
|
@@ -700,11 +851,13 @@ export default grammar({
|
|
|
700
851
|
|
|
701
852
|
_for_in_clause: ($) =>
|
|
702
853
|
seq(
|
|
703
|
-
field("variable", alias($.
|
|
854
|
+
field("variable", alias($.for_in_variable, $.name)),
|
|
704
855
|
$.in_keyword,
|
|
705
856
|
field("array", $.name),
|
|
706
857
|
),
|
|
707
858
|
|
|
859
|
+
for_in_variable: ($) => $._for_in_variable_word,
|
|
860
|
+
|
|
708
861
|
_for_header: ($) =>
|
|
709
862
|
header(
|
|
710
863
|
$,
|
|
@@ -773,7 +926,7 @@ export default grammar({
|
|
|
773
926
|
|
|
774
927
|
output_redirection: ($) =>
|
|
775
928
|
seq(
|
|
776
|
-
choice(
|
|
929
|
+
choice(alias($._output_greater, ">"), $.append, singleOperator($, "|")),
|
|
777
930
|
$.expr,
|
|
778
931
|
),
|
|
779
932
|
|
|
@@ -804,32 +957,33 @@ export default grammar({
|
|
|
804
957
|
_prefix_update_expr: ($) =>
|
|
805
958
|
seq(
|
|
806
959
|
field("operator", choice($.incr, $.decr)),
|
|
807
|
-
field("operand", $.
|
|
960
|
+
field("operand", $._lvalue),
|
|
808
961
|
),
|
|
809
962
|
|
|
810
963
|
...normalExpressionRules,
|
|
811
964
|
|
|
812
965
|
...printExpressionRules,
|
|
813
966
|
|
|
814
|
-
|
|
967
|
+
// A pending field operand cannot start a competing pipe source.
|
|
968
|
+
...fieldExpressionRules,
|
|
969
|
+
|
|
970
|
+
nonpostfix_field_expr: ($) =>
|
|
815
971
|
choice(
|
|
816
972
|
alias($.normal_unary_field_expr, $.unary_expr),
|
|
817
|
-
alias($.
|
|
973
|
+
alias($.nonpostfix_non_unary_field_expr, $.non_unary_expr),
|
|
818
974
|
),
|
|
819
975
|
|
|
820
976
|
normal_unary_field_expr: ($) =>
|
|
821
|
-
prec(PRECEDENCE.field, $.
|
|
822
|
-
|
|
823
|
-
_normal_non_unary_field_atom_expr: ($) =>
|
|
824
|
-
prec(PRECEDENCE.field, nonUnaryAtom($, EXPRESSION_CONTEXT.normal)),
|
|
977
|
+
prec(PRECEDENCE.field, $._field_unary_unary_expr),
|
|
825
978
|
|
|
826
|
-
|
|
979
|
+
nonpostfix_non_unary_field_expr: ($) =>
|
|
827
980
|
prec(
|
|
828
981
|
PRECEDENCE.field,
|
|
829
982
|
choice(
|
|
830
|
-
$.
|
|
831
|
-
$._normal_not_expr,
|
|
983
|
+
$._field_not_expr,
|
|
832
984
|
$._prefix_update_expr,
|
|
985
|
+
alias($.nonpostfix_lvalue, $.lvalue),
|
|
986
|
+
alias($.nonpostfix_direct_input_function, $.non_unary_input_function),
|
|
833
987
|
),
|
|
834
988
|
),
|
|
835
989
|
|
|
@@ -838,45 +992,90 @@ export default grammar({
|
|
|
838
992
|
_user_function_call: ($) => seq($.func_name, callArguments($)),
|
|
839
993
|
|
|
840
994
|
_builtin_function_call: ($) =>
|
|
841
|
-
seq(alias($.
|
|
995
|
+
seq(alias($.builtin_call_name, $.builtin_func_name), callArguments($)),
|
|
842
996
|
|
|
843
|
-
|
|
997
|
+
builtin_call_name: ($) => $._builtin_call_word,
|
|
998
|
+
|
|
999
|
+
_lvalue: ($) =>
|
|
844
1000
|
choice(
|
|
845
|
-
$.
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
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),
|
|
850
1031
|
),
|
|
851
1032
|
),
|
|
852
1033
|
|
|
853
|
-
|
|
1034
|
+
_direct_input_function: ($) =>
|
|
854
1035
|
choice(
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
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),
|
|
867
1053
|
),
|
|
868
1054
|
),
|
|
869
1055
|
|
|
870
1056
|
unary_input_function: ($) =>
|
|
871
1057
|
prec.right(
|
|
872
1058
|
PRECEDENCE.field,
|
|
873
|
-
seq(
|
|
1059
|
+
seq(
|
|
1060
|
+
field("source", $.unary_expr),
|
|
1061
|
+
singleOperator($, "|"),
|
|
1062
|
+
field("get", $._simple_get),
|
|
1063
|
+
),
|
|
874
1064
|
),
|
|
875
1065
|
|
|
876
|
-
|
|
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: ($) =>
|
|
877
1076
|
choice(
|
|
878
1077
|
$.getline_keyword,
|
|
879
|
-
|
|
1078
|
+
getWithTarget($, alias($.postfix_lvalue, $.lvalue)),
|
|
880
1079
|
),
|
|
881
1080
|
|
|
882
1081
|
getline_keyword: ($) => $._getline_word,
|
|
@@ -889,24 +1088,18 @@ export default grammar({
|
|
|
889
1088
|
|
|
890
1089
|
name: ($) => $._name_word,
|
|
891
1090
|
|
|
892
|
-
number: ($) =>
|
|
893
|
-
choice($._number_integer, $._number_fraction, $._number_exponent),
|
|
1091
|
+
number: ($) => $._number,
|
|
894
1092
|
|
|
895
1093
|
string: ($) =>
|
|
896
1094
|
seq(
|
|
897
1095
|
field("opening", alias($._string_opening, '"')),
|
|
898
1096
|
repeat(choice($.string_content, $.escape_sequence)),
|
|
899
|
-
$.
|
|
900
|
-
field("closing", token.immediate('"')),
|
|
1097
|
+
field("closing", alias($._string_closing, '"')),
|
|
901
1098
|
),
|
|
902
1099
|
|
|
903
|
-
string_content: () =>
|
|
1100
|
+
string_content: ($) => $._string_content,
|
|
904
1101
|
|
|
905
|
-
escape_sequence: ($) =>
|
|
906
|
-
seq(
|
|
907
|
-
$._escape_introducer,
|
|
908
|
-
choice($._escape_character, $._escape_octal_digits),
|
|
909
|
-
),
|
|
1102
|
+
escape_sequence: ($) => $._string_escape,
|
|
910
1103
|
|
|
911
1104
|
...twoCharacterTokenRules,
|
|
912
1105
|
|
|
@@ -917,59 +1110,11 @@ export default grammar({
|
|
|
917
1110
|
field("closing", alias($._ere_closing, "/")),
|
|
918
1111
|
),
|
|
919
1112
|
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
$.ere_branch,
|
|
923
|
-
seq(
|
|
924
|
-
field("left", $.extended_reg_exp),
|
|
925
|
-
field("operator", token.immediate("|")),
|
|
926
|
-
field("right", $.ere_branch),
|
|
927
|
-
),
|
|
928
|
-
),
|
|
929
|
-
|
|
930
|
-
ere_branch: ($) =>
|
|
931
|
-
choice(
|
|
932
|
-
$.ere_expression,
|
|
933
|
-
seq(field("left", $.ere_branch), field("right", $.ere_expression)),
|
|
934
|
-
),
|
|
935
|
-
|
|
936
|
-
ere_expression: ($) =>
|
|
937
|
-
choice(
|
|
938
|
-
$.one_char_or_coll_elem_ere,
|
|
939
|
-
$.left_anchor,
|
|
940
|
-
$.right_anchor,
|
|
941
|
-
seq(
|
|
942
|
-
field("opening", token.immediate("(")),
|
|
943
|
-
field("expression", $.extended_reg_exp),
|
|
944
|
-
field("closing", $._ere_close_parenthesis),
|
|
945
|
-
),
|
|
946
|
-
seq(
|
|
947
|
-
field("operand", $.ere_expression),
|
|
948
|
-
field("operator", $.ere_dupl_symbol),
|
|
949
|
-
),
|
|
950
|
-
),
|
|
951
|
-
|
|
952
|
-
one_char_or_coll_elem_ere: ($) =>
|
|
953
|
-
choice(
|
|
954
|
-
$.ordinary_character,
|
|
955
|
-
$.quoted_character,
|
|
956
|
-
$.wildcard,
|
|
957
|
-
$.bracket_expression,
|
|
958
|
-
alias($._ere_octal_escape_sequence, $.escape_sequence),
|
|
959
|
-
alias($._ere_undefined_escape_sequence, $.escape_sequence),
|
|
960
|
-
),
|
|
961
|
-
|
|
962
|
-
ordinary_character: ($) =>
|
|
963
|
-
choice(
|
|
964
|
-
alias($._ordinary_character, $.ordinary_character_content),
|
|
965
|
-
$._ere_ordinary_close_parenthesis,
|
|
966
|
-
$._ere_ordinary_close_brace,
|
|
967
|
-
$.escaped_delimiter,
|
|
968
|
-
alias($._ere_named_escape_sequence, $.escape_sequence),
|
|
969
|
-
),
|
|
1113
|
+
...ereExpressionRules(false),
|
|
1114
|
+
...ereExpressionRules(true),
|
|
970
1115
|
|
|
971
1116
|
quoted_character: ($) =>
|
|
972
|
-
alias($.
|
|
1117
|
+
alias($.ere_quoted_escape_sequence, $.escape_sequence),
|
|
973
1118
|
|
|
974
1119
|
wildcard: () => token.immediate("."),
|
|
975
1120
|
|
|
@@ -1000,7 +1145,7 @@ export default grammar({
|
|
|
1000
1145
|
$._ere_close_brace,
|
|
1001
1146
|
),
|
|
1002
1147
|
|
|
1003
|
-
dup_count: ($) => $.
|
|
1148
|
+
dup_count: ($) => $._ere_dup_count,
|
|
1004
1149
|
|
|
1005
1150
|
bracket_expression: ($) =>
|
|
1006
1151
|
seq(
|
|
@@ -1055,9 +1200,9 @@ export default grammar({
|
|
|
1055
1200
|
collating_element: ($) =>
|
|
1056
1201
|
choice(
|
|
1057
1202
|
alias($._ere_bracket_character, $.collating_element_content),
|
|
1058
|
-
alias(
|
|
1203
|
+
alias($._ere_bracket_literal_open, $.collating_element_content),
|
|
1059
1204
|
$.escaped_delimiter,
|
|
1060
|
-
alias($.
|
|
1205
|
+
alias($.ere_bracket_escape_sequence, $.escape_sequence),
|
|
1061
1206
|
),
|
|
1062
1207
|
|
|
1063
1208
|
collating_symbol: ($) =>
|
|
@@ -1080,7 +1225,7 @@ export default grammar({
|
|
|
1080
1225
|
character_class: ($) =>
|
|
1081
1226
|
seq($._ere_open_colon, $.class_name, $._ere_colon_close),
|
|
1082
1227
|
|
|
1083
|
-
class_name: ($) => $.
|
|
1228
|
+
class_name: ($) => $._ere_class_name,
|
|
1084
1229
|
|
|
1085
1230
|
meta_character: ($) => $._ere_compound_meta_character,
|
|
1086
1231
|
|
|
@@ -1103,47 +1248,39 @@ export default grammar({
|
|
|
1103
1248
|
_ere_compound_nonmeta_atom: ($) =>
|
|
1104
1249
|
choice(
|
|
1105
1250
|
alias($._ere_compound_nonmeta_character, $.collating_element_content),
|
|
1251
|
+
alias($._ere_compound_content, $.collating_element_content),
|
|
1106
1252
|
$.escaped_delimiter,
|
|
1107
|
-
alias($.
|
|
1253
|
+
alias($.ere_bracket_escape_sequence, $.escape_sequence),
|
|
1108
1254
|
),
|
|
1109
1255
|
|
|
1110
1256
|
_ere_open_dot: ($) => ereCompoundOpening($, "."),
|
|
1111
1257
|
|
|
1112
|
-
_ere_dot_close: ($) => ereCompoundClosing($.
|
|
1258
|
+
_ere_dot_close: ($) => ereCompoundClosing($._ere_dot_closing, "."),
|
|
1113
1259
|
|
|
1114
1260
|
_ere_open_equal: ($) => ereCompoundOpening($, "="),
|
|
1115
1261
|
|
|
1116
|
-
_ere_equal_close: ($) => ereCompoundClosing($.
|
|
1262
|
+
_ere_equal_close: ($) => ereCompoundClosing($._ere_equal_closing, "="),
|
|
1117
1263
|
|
|
1118
1264
|
_ere_open_colon: ($) => ereCompoundOpening($, ":"),
|
|
1119
1265
|
|
|
1120
|
-
_ere_colon_close: ($) => ereCompoundClosing($.
|
|
1266
|
+
_ere_colon_close: ($) => ereCompoundClosing($._ere_colon_closing, ":"),
|
|
1121
1267
|
|
|
1122
|
-
escaped_delimiter: ($) =>
|
|
1123
|
-
seq(
|
|
1124
|
-
$._ere_escaped_delimiter_start,
|
|
1125
|
-
$._escape_introducer,
|
|
1126
|
-
$._ere_escaped_delimiter_end,
|
|
1127
|
-
),
|
|
1268
|
+
escaped_delimiter: ($) => $._ere_escaped_delimiter,
|
|
1128
1269
|
|
|
1129
|
-
|
|
1130
|
-
ereEscapeWithCharacter($, $._ere_named_escape_character),
|
|
1270
|
+
ere_named_escape_sequence: ($) => $._ere_named_escape,
|
|
1131
1271
|
|
|
1132
|
-
|
|
1133
|
-
ereEscapeWithCharacter($, $._ere_quoted_escape_character),
|
|
1272
|
+
ere_quoted_escape_sequence: ($) => $._ere_quoted_escape,
|
|
1134
1273
|
|
|
1135
|
-
|
|
1136
|
-
ereEscapeWithCharacter($, $._escape_octal_digits),
|
|
1274
|
+
ere_octal_escape_sequence: ($) => $._ere_octal_escape,
|
|
1137
1275
|
|
|
1138
|
-
|
|
1139
|
-
ereEscapeWithCharacter($, $._ere_undefined_escape_character),
|
|
1276
|
+
ere_undefined_escape_sequence: ($) => $._ere_undefined_escape,
|
|
1140
1277
|
|
|
1141
|
-
|
|
1278
|
+
ere_bracket_escape_sequence: ($) =>
|
|
1142
1279
|
choice(
|
|
1143
|
-
$.
|
|
1144
|
-
$.
|
|
1145
|
-
$.
|
|
1146
|
-
$.
|
|
1280
|
+
$._ere_named_escape,
|
|
1281
|
+
$._ere_quoted_escape,
|
|
1282
|
+
$._ere_octal_escape,
|
|
1283
|
+
$._ere_undefined_escape,
|
|
1147
1284
|
),
|
|
1148
1285
|
|
|
1149
1286
|
// Tree-sitter rejects the POSIX bracket spelling for these delimiter
|
|
@@ -1165,33 +1302,14 @@ export default grammar({
|
|
|
1165
1302
|
_ere_bracket_character: () => token.immediate(/[^\x2D\x2F\x5B\x5C\x5D\n]/),
|
|
1166
1303
|
|
|
1167
1304
|
_ere_compound_nonmeta_character: () =>
|
|
1168
|
-
token.immediate(/[
|
|
1305
|
+
token.immediate(/[^.:=\x2D\x2F\x5C\x5D\n]/),
|
|
1169
1306
|
|
|
1170
1307
|
_ere_compound_meta_character: () => token.immediate(/[\x2D\x5D]/),
|
|
1171
1308
|
|
|
1172
|
-
_ere_class_name_spelling: () => token.immediate(/[A-Za-z][A-Za-z0-9]*/),
|
|
1173
|
-
|
|
1174
|
-
_ere_named_escape_character: () => token.immediate(prec(1, /[abfnrtv]/)),
|
|
1175
|
-
|
|
1176
|
-
_ere_quoted_escape_character: () =>
|
|
1177
|
-
token.immediate(prec(1, /[().*+?{}|^$\x5B\x5C\x5D]/)),
|
|
1178
|
-
|
|
1179
|
-
_ere_undefined_escape_character: () => token.immediate(/[^0-7\x2F\x5C\n]/),
|
|
1180
|
-
|
|
1181
1309
|
newline_opt: ($) => rawNewlines($),
|
|
1182
1310
|
|
|
1183
1311
|
terminator: ($) => choice(rawNewlines($), seq(";", repeat($.newline))),
|
|
1184
1312
|
|
|
1185
1313
|
newline: () => "\n",
|
|
1186
|
-
|
|
1187
|
-
line_continuation: () => token(seq("\\", "\n")),
|
|
1188
|
-
|
|
1189
|
-
_number_digit_chunk: () => token.immediate(/[0-9]+/),
|
|
1190
|
-
|
|
1191
|
-
_escape_introducer: () => token.immediate(/\\/),
|
|
1192
|
-
|
|
1193
|
-
_escape_character: () => token.immediate(/[^0-7\n]/),
|
|
1194
|
-
|
|
1195
|
-
_escape_octal_digits: () => token.immediate(/[0-7]{1,3}/),
|
|
1196
1314
|
},
|
|
1197
1315
|
});
|