@konomanoasa/tree-sitter-posix-awk 0.19.0 → 0.20.1

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/grammar.js CHANGED
@@ -19,6 +19,8 @@ export const EXPRESSION = {
19
19
  field: { precedence: 24, associativity: "right" },
20
20
  };
21
21
 
22
+ export const FILE_SOURCE_TIER = "additive";
23
+
22
24
  export const RESERVED_WORDS = {
23
25
  keyword: [
24
26
  "BEGIN",
@@ -67,35 +69,48 @@ export const RESERVED_WORDS = {
67
69
  ],
68
70
  };
69
71
 
70
- const OPERAND_PRECEDENCE = 2;
71
- const CLASSIFICATIONS = ["unary", "non_unary"];
72
-
73
- function nextExpressionTier(tier, comparison) {
74
- return Object.keys(EXPRESSION)
75
- .filter(
76
- (name) =>
77
- (comparison || name !== "comparison") &&
78
- EXPRESSION[name].precedence > EXPRESSION[tier].precedence,
79
- )
80
- .sort(
81
- (left, right) =>
82
- EXPRESSION[left].precedence - EXPRESSION[right].precedence,
83
- )[0];
84
- }
85
-
86
- const bind = ({ precedence, associativity }, rule) =>
87
- associativity === "left"
88
- ? prec.left(precedence, rule)
89
- : associativity === "right"
90
- ? prec.right(precedence, rule)
91
- : prec(precedence, rule);
92
-
93
72
  // Skipping blanks can reach a backslash the external scanner never saw.
94
73
  const continuationMarker = () => token.immediate("\\");
95
74
 
96
75
  const signOperator = ($, character) =>
97
76
  alias(character === "+" ? $._plus_operator : $._minus_operator, character);
98
77
 
78
+ const prefixOperator = ($, unary) =>
79
+ field(
80
+ "operator",
81
+ unary
82
+ ? choice(signOperator($, "+"), signOperator($, "-"))
83
+ : alias($._not_operator, "!"),
84
+ );
85
+
86
+ const updateOperator = ($) => field("operator", choice($.incr, $.decr));
87
+
88
+ const fieldOperator = ($) => field("operator", alias($._field_operator, "$"));
89
+
90
+ const assignmentOperator = ($) =>
91
+ choice(
92
+ "=",
93
+ $.pow_assign,
94
+ $.mod_assign,
95
+ $.mul_assign,
96
+ $.div_assign,
97
+ $.add_assign,
98
+ $.sub_assign,
99
+ );
100
+
101
+ const binaryOperators = ($) => ({
102
+ additive: [signOperator($, "+"), signOperator($, "-")],
103
+ multiplicative: ["*", alias($._division_slash, "/"), "%"],
104
+ exponentiation: ["^"],
105
+ match: ["~", $.no_match],
106
+ comparison: ["<", ">", $.le, $.ge, $.eq, $.ne],
107
+ logical_and: [$.and],
108
+ logical_or: [$.or],
109
+ });
110
+
111
+ const oneOf = (members) =>
112
+ members.length === 1 ? members[0] : choice(...members);
113
+
99
114
  const twoCharacterTokenRules = Object.fromEntries(
100
115
  Object.entries({
101
116
  add_assign: "+=",
@@ -115,11 +130,6 @@ const twoCharacterTokenRules = Object.fromEntries(
115
130
  }).map(([name, spelling]) => [name, () => spelling]),
116
131
  );
117
132
 
118
- const trailingUpdateOperators = ($) => [
119
- alias($.trailing_incr, $.incr),
120
- alias($.trailing_decr, $.decr),
121
- ];
122
-
123
133
  const newlineLayout = ($) => optional($.newline_opt);
124
134
 
125
135
  const afterOptionalNewline = ($, member) => seq(newlineLayout($), member);
@@ -239,439 +249,506 @@ const controlStatements = ($, body) => [
239
249
  const parenthesized = (member) => seq("(", member, ")");
240
250
 
241
251
  const parenthesizedPrintStatement = ($, keyword) =>
242
- seq(keyword, parenthesized(field("arguments", $.multiple_expr_list)));
243
-
244
- const callArguments = ($) => parenthesized(optional($.expr_list));
245
-
246
- const subscript = (subscripts) => seq("[", subscripts, "]");
247
-
248
- const redirectedInput = ($, get, source = $.expr) =>
249
- prec.right(
250
- EXPRESSION.field.precedence,
251
- seq(field("get", get), "<", field("source", source)),
252
- );
253
-
254
- const pipedInput = ($, source, get) =>
255
- prec.right(
256
- EXPRESSION.field.precedence,
257
- seq(
258
- field("source", source),
259
- alias($._getline_pipe, "|"),
260
- field("get", get),
261
- ),
252
+ seq(
253
+ keyword,
254
+ $._print_arguments,
255
+ parenthesized(field("arguments", $.multiple_expr_list)),
262
256
  );
263
257
 
264
258
  const rawNewlines = ($) => repeat1($.newline);
265
259
 
266
- const simpleGet = ($, sourceContext = false) => {
267
- const keyword = (rule) => alias(rule, $.getline_keyword);
268
- return choice(
269
- $.getline_keyword,
270
- keyword($.omitted_getline_keyword),
271
- keyword($.preferred_omitted_getline_keyword),
272
- seq(
273
- choice(
274
- keyword($.target_getline_keyword),
275
- keyword($.preferred_target_getline_keyword),
276
- ),
277
- field("target", $._lvalue),
278
- ),
279
- prec.dynamic(-1, keyword($.preferred_target_getline_keyword)),
280
- prec.dynamic(
281
- -1,
282
- seq(
283
- choice(
284
- keyword($.preferred_omitted_getline_keyword),
285
- ...(sourceContext ? [keyword($.omitted_getline_keyword)] : []),
286
- ),
287
- field("target", $._lvalue),
288
- ),
289
- ),
290
- );
291
- };
292
-
293
- const EXPRESSION_CONTEXT = {
294
- normal: {
295
- prefix: "normal",
296
- expression: "expr",
297
- unaryExpression: "unary_expr",
298
- nonUnaryExpression: "non_unary_expr",
299
- comparison: true,
300
- input: ($) =>
301
- choice(
302
- alias($.direct_input_function, $.non_unary_input_function),
303
- alias($.piped_input_function, $.non_unary_input_function),
304
- ),
305
- unaryInput: ($) => $.unary_input_function,
306
- },
307
- source: {
308
- prefix: "source",
309
- expression: "source_expr",
310
- publicExpression: "expr",
311
- unaryExpression: "unary_expr",
312
- nonUnaryExpression: "non_unary_expr",
313
- comparison: true,
314
- input: ($) =>
315
- choice(
316
- alias($.source_direct_input_function, $.non_unary_input_function),
317
- alias($.source_piped_input_function, $.non_unary_input_function),
318
- ),
319
- unaryInput: ($) =>
320
- alias($.source_unary_input_function, $.unary_input_function),
321
- },
322
- print: {
323
- prefix: "print",
324
- expression: "print_expr",
325
- unaryExpression: "unary_print_expr",
326
- nonUnaryExpression: "non_unary_print_expr",
327
- comparison: false,
328
- },
329
- field: {
330
- prefix: "field",
331
- expression: "expr",
332
- unaryExpression: "unary_expr",
333
- nonUnaryExpression: "non_unary_expr",
334
- input: ($) => alias($.direct_input_function, $.non_unary_input_function),
335
- },
336
- };
337
-
338
- const classTierName = (context, classification, tier) =>
339
- `_${context.prefix}_${classification}_${tier}_expr`;
340
-
341
- // Hidden operand rules leak inner fields into the parent.
342
- const classOperandName = (context, classification, tier) =>
343
- `${context.prefix}_${classification}_${tier}_operand`;
344
-
345
- const anyTierName = (context, tier) => `${context.prefix}_${tier}_expr`;
346
-
347
- const classTier = ($, context, classification, tier) =>
348
- $[classTierName(context, classification, tier)];
349
-
350
- const aliasedClassTier = ($, context, classification, tier) =>
351
- alias(
352
- $[classOperandName(context, classification, tier)],
353
- $[
354
- classification === "unary"
355
- ? context.unaryExpression
356
- : context.nonUnaryExpression
357
- ],
358
- );
359
-
360
- const tierHelpers = (context, rules) => ({
361
- unary: (tier) => classTierName(context, "unary", tier),
362
- nonUnary: (tier) => classTierName(context, "non_unary", tier),
363
- addOperand: (classification, tier) =>
364
- Object.assign(rules, classOperandRules(context, classification, tier)),
365
- });
366
-
367
- const aliasedAnyTier = ($, context, tier) =>
368
- alias(
369
- $[anyTierName(context, tier)],
370
- $[context.publicExpression ?? context.expression],
371
- );
372
-
373
- const nonUnaryAtom = ($, context, lvalue = $._lvalue) => {
374
- const atoms = [
375
- $._parenthesized_expression,
376
- $.number,
377
- $.string,
378
- lvalue,
379
- $._user_function_call,
380
- $._builtin_function_call,
381
- $.builtin_func_name,
382
- $.ere,
383
- ];
384
- if (context.input) {
385
- atoms.push(context.input($));
386
- }
387
- return choice(...atoms);
388
- };
260
+ const listElementTail = ($, element) =>
261
+ seq(",", afterOptionalNewline($, element));
389
262
 
390
- const classOperandRules = (context, classification, tier) => ({
391
- [classOperandName(context, classification, tier)]: ($) =>
392
- prec(OPERAND_PRECEDENCE, classTier($, context, classification, tier)),
393
- });
263
+ const boundaryKinds = [
264
+ "atom",
265
+ "name",
266
+ "group",
267
+ "call",
268
+ "subscript",
269
+ "get",
270
+ "target_get",
271
+ "file",
272
+ "field",
273
+ "prefix",
274
+ "postfix",
275
+ "binary",
276
+ "concat",
277
+ "assignment",
278
+ "conditional",
279
+ "branches",
280
+ "pipe",
281
+ "membership",
282
+ "tuple",
283
+ ];
284
+ const boundaryDigits = [0, 1, 2, 3];
285
+ const boundaryExternals = ($) => [
286
+ $._root,
287
+ $._print_root,
288
+ $._for_in,
289
+ $._print_arguments,
290
+ $._begin_child,
291
+ $._end_child,
292
+ $._resume,
293
+ $._next_argument,
294
+ ...boundaryDigits.map((digit) => $[`_save_${digit}`]),
295
+ ...boundaryDigits.map((digit) => $[`_restore_${digit}`]),
296
+ $._class_unary,
297
+ $._class_non_unary,
298
+ ...boundaryKinds.map((kind) => $[`_select_${kind}`]),
299
+ $._local_root,
300
+ $._local_print_root,
301
+ ];
394
302
 
395
- const anyTierRules = (context, tier) => ({
396
- ...classOperandRules(context, "unary", tier),
397
- ...classOperandRules(context, "non_unary", tier),
398
- [anyTierName(context, tier)]: ($) =>
399
- choice(
400
- aliasedClassTier($, context, "unary", tier),
401
- aliasedClassTier($, context, "non_unary", tier),
303
+ const boundaryRules = {};
304
+ for (const [kind, body] of Object.entries({
305
+ expr: ($) => alias($._boundary_expr, $.expr),
306
+ unary: ($) => $.unary_expr,
307
+ non_unary: ($) => $.non_unary_expr,
308
+ print_expr: ($) => alias($._boundary_print_expr, $.print_expr),
309
+ print_unary: ($) => $.unary_print_expr,
310
+ print_non_unary: ($) => $.non_unary_print_expr,
311
+ name: ($) => seq($._select_name, $.name),
312
+ tuple: ($) =>
313
+ seq(
314
+ $._select_group,
315
+ "(",
316
+ field(
317
+ "left",
318
+ alias($._boundary_multiple_arguments, $.multiple_expr_list),
319
+ ),
320
+ ")",
402
321
  ),
403
- });
404
-
405
- const unaryExpressionRules = (context) => {
406
- const rules = {};
407
- Object.assign(rules, anyTierRules(context, "unary"));
408
- const { unary, nonUnary, addOperand } = tierHelpers(context, rules);
409
- const not = `_${context.prefix}_not_expr`;
410
- rules[unary("unary")] = ($) =>
322
+ lvalue: ($) => $.lvalue,
323
+ get: ($) => $.simple_get,
324
+ branches: ($) => $._branches,
325
+ print_branches: ($) => $._print_branches,
326
+ })) {
327
+ boundaryRules[`_checkpoint_${kind}`] = ($) =>
411
328
  choice(
412
- ...(context.unaryInput
413
- ? [classTier($, context, "unary", "exponentiation")]
414
- : []),
415
- ...["+", "-"].map((operator) =>
329
+ ...boundaryDigits.map((digit) =>
416
330
  seq(
417
- field("operator", signOperator($, operator)),
418
- field("operand", aliasedAnyTier($, context, "unary")),
331
+ $[`_save_${digit}`],
332
+ $[`_checkpoint_${kind}`],
333
+ $[`_restore_${digit}`],
419
334
  ),
420
335
  ),
336
+ seq($._begin_child, body($), $._end_child),
421
337
  );
422
- rules[not] = ($) =>
423
- seq(
424
- field("operator", "!"),
425
- field("operand", aliasedAnyTier($, context, "unary")),
426
- );
427
- rules[nonUnary("unary")] = ($) =>
428
- choice($[nonUnary("exponentiation")], $[not]);
338
+ boundaryRules[`_child_${kind}`] = ($) =>
339
+ seq($[`_checkpoint_${kind}`], $._resume);
340
+ }
429
341
 
430
- const exponentiationTail = `_${context.prefix}_exponentiation_tail`;
431
- rules[exponentiationTail] = ($) =>
432
- seq(
433
- $._exponentiation_operator,
434
- field(
435
- "right",
436
- aliasedAnyTier($, context, EXPRESSION.exponentiation.rightOperand),
437
- ),
438
- );
439
- const exponentiationClassifications = context.unaryInput
440
- ? CLASSIFICATIONS
441
- : ["non_unary"];
442
- for (const classification of exponentiationClassifications) {
443
- addOperand(classification, "update");
444
- rules[classTierName(context, classification, "exponentiation")] = ($) =>
445
- choice(
446
- classTier($, context, classification, "update"),
447
- seq(
448
- field("left", aliasedClassTier($, context, classification, "update")),
449
- $[exponentiationTail],
342
+ for (const print of [false, true]) {
343
+ const prefix = print ? "print_" : "";
344
+ const expr = ($) => $[`_child_${prefix}expr`];
345
+ for (const unary of [false, true]) {
346
+ const classification = unary ? "unary" : "non_unary";
347
+ const klass = ($) => $[`_child_${prefix}${classification}`];
348
+ boundaryRules[`${classification}_${prefix}expr`] = ($) =>
349
+ seq(
350
+ unary ? $._class_unary : $._class_non_unary,
351
+ choice(
352
+ seq(
353
+ $._select_prefix,
354
+ prefixOperator($, unary),
355
+ field("operand", expr($)),
356
+ ),
357
+ seq(
358
+ $._select_binary,
359
+ field("left", klass($)),
360
+ field(
361
+ "operator",
362
+ choice(
363
+ ...Object.entries(binaryOperators($)).flatMap(
364
+ ([tier, operators]) =>
365
+ // A unary left operand of ^ is a pipe, which print excludes.
366
+ (print && tier === "comparison") ||
367
+ (print && unary && tier === "exponentiation")
368
+ ? []
369
+ : operators,
370
+ ),
371
+ ),
372
+ ),
373
+ newlineLayout($),
374
+ field("right", expr($)),
375
+ ),
376
+ seq(
377
+ $._select_concat,
378
+ field("left", klass($)),
379
+ field("right", $[`_child_${prefix}non_unary`]),
380
+ ),
381
+ seq(
382
+ $._select_conditional,
383
+ field("condition", klass($)),
384
+ "?",
385
+ $[`_child_${prefix}branches`],
386
+ ),
387
+ seq(
388
+ $._select_membership,
389
+ field("left", klass($)),
390
+ $._membership_operator,
391
+ field("right", $._child_name),
392
+ ),
393
+ ...(!print
394
+ ? [unary ? $.unary_input_function : $.non_unary_input_function]
395
+ : []),
396
+ ...(unary
397
+ ? []
398
+ : [
399
+ seq(
400
+ $._select_tuple,
401
+ $._child_tuple,
402
+ $._membership_operator,
403
+ field("right", $._child_name),
404
+ ),
405
+ seq(
406
+ $._select_atom,
407
+ choice($.number, $.string, $.ere, $.builtin_func_name),
408
+ ),
409
+ $.lvalue,
410
+ seq($._select_group, "(", $._child_expr, ")"),
411
+ seq(
412
+ $._select_call,
413
+ choice($.func_name, $.builtin_func_name),
414
+ "(",
415
+ optional(alias($._boundary_arguments, $.expr_list)),
416
+ ")",
417
+ ),
418
+ seq(
419
+ $._select_postfix,
420
+ field("operand", $._child_lvalue),
421
+ updateOperator($),
422
+ ),
423
+ seq(
424
+ $._select_prefix,
425
+ updateOperator($),
426
+ field("operand", $._child_lvalue),
427
+ ),
428
+ seq(
429
+ $._select_assignment,
430
+ field("left", $._child_lvalue),
431
+ field("operator", assignmentOperator($)),
432
+ field("right", expr($)),
433
+ ),
434
+ ]),
450
435
  ),
451
436
  );
452
437
  }
453
- if (context.unaryInput) {
454
- rules[unary("update")] = context.unaryInput;
455
- }
456
-
457
- rules[nonUnary("update")] = ($) =>
438
+ boundaryRules[`_${prefix}branches`] = ($) =>
439
+ seq(
440
+ $._select_branches,
441
+ field("consequence", expr($)),
442
+ ":",
443
+ field("alternative", expr($)),
444
+ );
445
+ }
446
+ Object.assign(boundaryRules, {
447
+ _boundary_expr: ($) => choice($.unary_expr, $.non_unary_expr),
448
+ _boundary_print_expr: ($) =>
449
+ choice($.unary_print_expr, $.non_unary_print_expr),
450
+ lvalue: ($) =>
458
451
  choice(
459
- $[nonUnary("atom")],
460
- $._prefix_update_expr,
452
+ seq($._select_name, $.name),
461
453
  seq(
462
- field("operand", alias($.postfix_lvalue, $.lvalue)),
463
- field(
464
- "operator",
465
- choice($.incr, $.decr, ...trailingUpdateOperators($)),
466
- ),
454
+ $._select_subscript,
455
+ $.name,
456
+ "[",
457
+ alias($._boundary_arguments, $.expr_list),
458
+ "]",
467
459
  ),
460
+ seq($._select_field, fieldOperator($), field("operand", $._child_expr)),
461
+ ),
462
+ _boundary_arguments: ($) =>
463
+ choice(
464
+ $._child_expr,
465
+ alias($._boundary_multiple_arguments, $.multiple_expr_list),
466
+ ),
467
+ _boundary_multiple_arguments: ($) =>
468
+ seq(
469
+ $._child_expr,
470
+ repeat1(seq(",", newlineLayout($), $._next_argument, $._child_expr)),
471
+ ),
472
+ simple_get: ($) =>
473
+ choice(
474
+ seq($._select_get, $.getline_keyword),
468
475
  seq(
469
- field("operand", alias($.redirected_field, $.lvalue)),
470
- field("operator", choice(...trailingUpdateOperators($))),
476
+ $._select_target_get,
477
+ $.getline_keyword,
478
+ field("target", $._child_lvalue),
471
479
  ),
472
- );
473
-
474
- rules[nonUnary("atom")] = ($) =>
475
- nonUnaryAtom($, context, prec(-1, $._lvalue));
476
-
477
- return rules;
478
- };
479
-
480
- const tieredExpressionRules = (context) => {
481
- const rules = {};
482
- const { unary, nonUnary, addOperand } = tierHelpers(context, rules);
483
- const conditionalTail = `_${context.prefix}_conditional_tail`;
484
- const expression = ($) =>
485
- context.publicExpression
486
- ? alias($[context.expression], $[context.publicExpression])
487
- : $[context.expression];
488
- rules[conditionalTail] = ($) =>
480
+ ),
481
+ non_unary_input_function: ($) =>
482
+ choice(
483
+ field("get", $.simple_get),
484
+ seq(
485
+ $._select_file,
486
+ field("get", $._child_get),
487
+ "<",
488
+ field("source", $._child_expr),
489
+ ),
490
+ seq(
491
+ $._select_pipe,
492
+ field("source", $._child_non_unary),
493
+ alias($._getline_pipe, "|"),
494
+ field("get", $._child_get),
495
+ ),
496
+ ),
497
+ unary_input_function: ($) =>
489
498
  seq(
490
- "?",
491
- field("consequence", expression($)),
492
- ":",
493
- field("alternative", aliasedAnyTier($, context, "conditional")),
494
- );
499
+ $._select_pipe,
500
+ field("source", $._child_unary),
501
+ alias($._getline_pipe, "|"),
502
+ field("get", $._child_get),
503
+ ),
504
+ getline_keyword: ($) => $._getline_word,
505
+ });
495
506
 
496
- const addAnyTier = (tier) =>
497
- Object.assign(rules, anyTierRules(context, tier));
498
-
499
- const addBinaryTier = (
500
- tier,
501
- operator,
502
- { newlineAfterOperator = false } = {},
503
- ) => {
504
- const binding = EXPRESSION[tier];
505
- const nextTier = nextExpressionTier(tier, context.comparison);
506
- const leftAssociative = binding.associativity === "left";
507
- addAnyTier(nextTier);
508
- const tail = `_${context.prefix}_${tier}_tail`;
509
- rules[tail] = ($) => {
510
- const right = field("right", aliasedAnyTier($, context, nextTier));
511
- return seq(
512
- operator($),
513
- newlineAfterOperator ? afterOptionalNewline($, right) : right,
514
- );
515
- };
516
- for (const classification of CLASSIFICATIONS) {
517
- if (leftAssociative) {
518
- addOperand(classification, tier);
519
- }
520
- const operation = ($) =>
507
+ const localRules = {};
508
+ const localNode = ($, name) => alias($[`local_${name}`], $[name]);
509
+ const localSubscriptable = ($) =>
510
+ seq($.name, optional(seq("[", localNode($, "expr_list"), "]")));
511
+ const localPrefixUpdate = ($) =>
512
+ seq(updateOperator($), field("operand", localNode($, "lvalue")));
513
+ const localAtoms = ($, print, lvalue = localNode($, "lvalue")) =>
514
+ choice(
515
+ $._local_atom,
516
+ lvalue,
517
+ ...(!print ? [localNode($, "non_unary_input_function")] : []),
518
+ );
519
+ for (const print of [false, true]) {
520
+ const prefix = print ? "print_" : "";
521
+ const expression = ($) => localNode($, `${prefix}expr`);
522
+ const tiers = Object.keys(EXPRESSION).filter(
523
+ (name) => name !== "field" && (!print || name !== "comparison"),
524
+ );
525
+ const classifications = (name) =>
526
+ name === "atom" || EXPRESSION[name].precedence > EXPRESSION.unary.precedence
527
+ ? ["non_unary"]
528
+ : ["unary", "non_unary"];
529
+ const tier = (classification, name) =>
530
+ `_local_${prefix}${classification}_${name}`;
531
+ const operand = (classification, name) =>
532
+ `local_${prefix}${classification}_${name}`;
533
+ const union = (name) => `local_${prefix}${name}`;
534
+ const classified = (classification, name) => ($) =>
535
+ alias(
536
+ $[operand(classification, name)],
537
+ $[`${classification}_${prefix}expr`],
538
+ );
539
+ const referenced = new Set();
540
+ const member = (classification, name) => {
541
+ referenced.add(operand(classification, name));
542
+ return classified(classification, name);
543
+ };
544
+ const any = (name) => {
545
+ referenced.add(union(name));
546
+ for (const classification of classifications(name))
547
+ member(classification, name);
548
+ return ($) => alias($[union(name)], $[`${prefix}expr`]);
549
+ };
550
+ const tierOperations = (classification, name, next) => {
551
+ if (name === "assignment") {
552
+ return ($) =>
553
+ classification === "unary"
554
+ ? []
555
+ : [
556
+ seq(
557
+ field("left", localNode($, "lvalue")),
558
+ field("operator", assignmentOperator($)),
559
+ field("right", expression($)),
560
+ ),
561
+ ];
562
+ }
563
+ if (name === "conditional") {
564
+ const condition = member(classification, next);
565
+ const alternative = any(name);
566
+ return ($) => [
521
567
  seq(
522
- field(
523
- "left",
524
- aliasedClassTier(
525
- $,
526
- context,
527
- classification,
528
- leftAssociative ? tier : nextTier,
529
- ),
530
- ),
531
- $[tail],
532
- );
533
- rules[classTierName(context, classification, tier)] = ($) =>
534
- choice(
535
- classTier($, context, classification, nextTier),
536
- bind(binding, operation($)),
537
- );
568
+ field("condition", condition($)),
569
+ "?",
570
+ field("consequence", expression($)),
571
+ ":",
572
+ field("alternative", alternative($)),
573
+ ),
574
+ ];
538
575
  }
539
- };
540
-
541
- rules[unary("assignment")] = ($) =>
542
- classTier($, context, "unary", "conditional");
543
- rules[nonUnary("assignment")] = ($) =>
544
- choice(
545
- classTier($, context, "non_unary", "conditional"),
546
- bind(
547
- EXPRESSION.assignment,
576
+ if (name === "membership") {
577
+ const left = member(classification, name);
578
+ return ($) => [
548
579
  seq(
549
- field("left", $._lvalue),
550
- field(
551
- "operator",
552
- choice(
553
- $.pow_assign,
554
- $.mod_assign,
555
- $.mul_assign,
556
- $.div_assign,
557
- $.add_assign,
558
- $.sub_assign,
559
- "=",
560
- ),
561
- ),
562
- field("right", expression($)),
580
+ field("left", left($)),
581
+ $._membership_operator,
582
+ field("right", $.name),
563
583
  ),
564
- ),
565
- );
566
-
567
- addAnyTier("conditional");
568
- for (const classification of CLASSIFICATIONS) {
569
- addOperand(classification, "logical_or");
570
- rules[classTierName(context, classification, "conditional")] = ($) =>
571
- choice(
572
- classTier($, context, classification, "logical_or"),
584
+ ...(classification === "non_unary"
585
+ ? [
586
+ seq(
587
+ "(",
588
+ field("left", localNode($, "multiple_expr_list")),
589
+ ")",
590
+ $._membership_operator,
591
+ field("right", $.name),
592
+ ),
593
+ ]
594
+ : []),
595
+ ];
596
+ }
597
+ if (name === "concatenation") {
598
+ const left = member(classification, name);
599
+ const right = member("non_unary", next);
600
+ return ($) => [seq(field("left", left($)), field("right", right($)))];
601
+ }
602
+ if (name === "unary") {
603
+ const operand = any(name);
604
+ return ($) => [
573
605
  seq(
574
- field(
575
- "condition",
576
- aliasedClassTier($, context, classification, "logical_or"),
577
- ),
578
- $[conditionalTail],
606
+ prefixOperator($, classification === "unary"),
607
+ field("operand", operand($)),
579
608
  ),
580
- );
581
- }
582
-
583
- addBinaryTier("logical_or", ($) => $._logical_or_operator, {
584
- newlineAfterOperator: true,
585
- });
586
-
587
- addBinaryTier("logical_and", ($) => $._logical_and_operator, {
588
- newlineAfterOperator: true,
589
- });
590
-
591
- const membershipTail = `_${context.prefix}_membership_tail`;
592
- rules[membershipTail] = ($) =>
593
- seq($._membership_operator, field("right", $.name));
594
- for (const classification of CLASSIFICATIONS) {
595
- rules[classTierName(context, classification, "membership")] = ($) => {
596
- const members = [
597
- classTier($, context, classification, "match"),
598
- bind(
599
- EXPRESSION.membership,
600
- seq(
601
- field(
602
- "left",
603
- aliasedClassTier($, context, classification, "membership"),
604
- ),
605
- $[membershipTail],
606
- ),
609
+ ];
610
+ }
611
+ if (name === "postfix") {
612
+ return ($) => [
613
+ seq(
614
+ field("operand", alias($.local_postfix_lvalue, $.lvalue)),
615
+ updateOperator($),
607
616
  ),
617
+ localPrefixUpdate($),
608
618
  ];
609
- if (classification === "non_unary") {
610
- members.push(
611
- seq(
612
- parenthesized(field("left", $.multiple_expr_list)),
613
- $._membership_operator,
614
- field("right", $.name),
619
+ }
620
+ const left = member(
621
+ classification,
622
+ EXPRESSION[name].associativity === "left" ? name : next,
623
+ );
624
+ const right = any(EXPRESSION[name].rightOperand ?? next);
625
+ return ($) => [
626
+ seq(
627
+ field("left", left($)),
628
+ field("operator", oneOf(binaryOperators($)[name])),
629
+ ...(name === "logical_or" || name === "logical_and"
630
+ ? [newlineLayout($)]
631
+ : []),
632
+ field("right", right($)),
633
+ ),
634
+ ];
635
+ };
636
+ const tierRules = {};
637
+ for (const classification of ["unary", "non_unary"]) {
638
+ for (const [index, name] of tiers.entries()) {
639
+ if (!classifications(name).includes(classification)) continue;
640
+ const next = tiers[index + 1] ?? "atom";
641
+ const operations = tierOperations(classification, name, next);
642
+ const fallback = name !== "unary" || classification !== "unary";
643
+ tierRules[tier(classification, name)] = ($) =>
644
+ oneOf([
645
+ ...(fallback ? [$[tier(classification, next)]] : []),
646
+ ...operations($),
647
+ ]);
648
+ }
649
+ }
650
+ const assignments = ["unary", "non_unary"].map((classification) =>
651
+ member(classification, "assignment"),
652
+ );
653
+ for (const name of [...tiers, "atom"]) {
654
+ for (const classification of classifications(name)) {
655
+ if (referenced.has(operand(classification, name)))
656
+ localRules[operand(classification, name)] = ($) =>
657
+ prec(
658
+ EXPRESSION[name]?.precedence ?? EXPRESSION.field.precedence,
659
+ $[tier(classification, name)],
660
+ );
661
+ }
662
+ if (referenced.has(union(name)))
663
+ localRules[union(name)] = ($) =>
664
+ choice(
665
+ ...classifications(name).map((classification) =>
666
+ classified(classification, name)($),
615
667
  ),
616
668
  );
617
- }
618
- return choice(...members);
619
- };
620
- }
621
-
622
- addBinaryTier("match", ($) => $._match_operator);
623
-
624
- if (context.comparison) {
625
- addBinaryTier("comparison", ($) => $._comparison_operator);
626
669
  }
627
-
628
- const concatenationTail = `_${context.prefix}_concatenation_tail`;
629
- // Reusing an arithmetic left operand here can bypass postfix lookahead.
630
- const concatenationOperand = `${context.prefix}_concatenation_operand`;
631
- rules[concatenationOperand] = ($) =>
632
- prec(1, classTier($, context, "non_unary", "additive"));
633
- rules[concatenationTail] = ($) =>
634
- field(
635
- "right",
636
- alias($[concatenationOperand], $[context.nonUnaryExpression]),
637
- );
638
- for (const classification of CLASSIFICATIONS) {
639
- rules[classTierName(context, classification, "concatenation")] = ($) =>
670
+ Object.assign(localRules, tierRules);
671
+ localRules[tier("non_unary", "atom")] = ($) => localAtoms($, print);
672
+ localRules[`local_${prefix}expr`] = ($) =>
673
+ choice(...assignments.map((assignment) => assignment($)));
674
+ }
675
+ Object.assign(localRules, {
676
+ _local_atom: ($) =>
677
+ choice(
678
+ $.number,
679
+ $.string,
680
+ $.ere,
681
+ $.builtin_func_name,
682
+ seq("(", localNode($, "expr"), ")"),
683
+ prec(
684
+ 1,
685
+ seq(
686
+ choice($.func_name, $.builtin_func_name),
687
+ "(",
688
+ optional(localNode($, "expr_list")),
689
+ ")",
690
+ ),
691
+ ),
692
+ ),
693
+ local_lvalue: ($) =>
694
+ choice(
695
+ localSubscriptable($),
696
+ seq(
697
+ fieldOperator($),
698
+ field("operand", alias($.local_field_expr, $.expr)),
699
+ ),
700
+ ),
701
+ local_postfix_lvalue: ($) =>
702
+ prec(
703
+ 1,
640
704
  choice(
641
- classTier($, context, classification, "additive"),
642
- bind(
643
- EXPRESSION.concatenation,
644
- seq(
645
- field(
646
- "left",
647
- aliasedClassTier($, context, classification, "concatenation"),
648
- ),
649
- $[concatenationTail],
650
- ),
705
+ localSubscriptable($),
706
+ seq(
707
+ fieldOperator($),
708
+ field("operand", alias($.local_postfix_field_expr, $.expr)),
651
709
  ),
652
- );
653
- }
654
-
655
- addBinaryTier("additive", ($) => $._additive_operator);
656
-
657
- addBinaryTier("multiplicative", ($) => $._multiplicative_operator);
658
-
659
- return { ...rules, ...unaryExpressionRules(context) };
660
- };
661
-
662
- const listElementTail = ($, element) =>
663
- seq(",", afterOptionalNewline($, element));
710
+ ),
711
+ ),
712
+ local_postfix_field_expr: ($) =>
713
+ alias($.local_postfix_field_atom, $.non_unary_expr),
714
+ local_postfix_field_atom: ($) =>
715
+ prec(1, localAtoms($, false, alias($.local_postfix_lvalue, $.lvalue))),
716
+ local_field_expr: ($) =>
717
+ choice(
718
+ alias($.local_unary_unary, $.unary_expr),
719
+ alias($.local_field_non_unary, $.non_unary_expr),
720
+ ),
721
+ local_field_non_unary: ($) =>
722
+ choice(
723
+ $._local_non_unary_atom,
724
+ seq(
725
+ prefixOperator($, false),
726
+ field("operand", alias($.local_unary, $.expr)),
727
+ ),
728
+ localPrefixUpdate($),
729
+ ),
730
+ local_expr_list: ($) =>
731
+ choice(localNode($, "expr"), localNode($, "multiple_expr_list")),
732
+ local_multiple_expr_list: ($) =>
733
+ seq(
734
+ localNode($, "expr"),
735
+ repeat1(listElementTail($, localNode($, "expr"))),
736
+ ),
737
+ local_non_unary_input_function: ($) =>
738
+ field("get", localNode($, "simple_get")),
739
+ local_simple_get: ($) =>
740
+ prec.right(
741
+ EXPRESSION.field.precedence,
742
+ seq($.getline_keyword, optional(field("target", localNode($, "lvalue")))),
743
+ ),
744
+ });
664
745
 
665
- export default globalThis.grammar?.({
746
+ const definition = {
666
747
  name: "posix_awk",
667
748
 
668
749
  externals: ($) => [
750
+ ...boundaryExternals($),
669
751
  $._getline_word,
670
- $._getline_target_word,
671
- $._getline_omitted_word,
672
- $._getline_field_word,
673
- $._getline_prefer_target_word,
674
- $._getline_prefer_omitted_word,
675
752
  $._func_name_word,
676
753
  $._division_slash,
677
754
  $._ere_opening_slash,
@@ -679,6 +756,8 @@ export default globalThis.grammar?.({
679
756
  $._decr_operator,
680
757
  $._plus_operator,
681
758
  $._minus_operator,
759
+ $._field_operator,
760
+ $._not_operator,
682
761
  $._getline_pipe,
683
762
  $._ere_compound_opening,
684
763
  $._ere_escaped_compound_opening,
@@ -727,62 +806,19 @@ export default globalThis.grammar?.({
727
806
  ],
728
807
 
729
808
  inline: ($) => [
730
- // Shared operator reductions can freeze reused operands after edits.
731
- $._additive_operator,
732
- $._multiplicative_operator,
733
- $._exponentiation_operator,
734
- $._comparison_operator,
735
- $._match_operator,
736
- $._membership_operator,
737
- $._logical_and_operator,
738
- $._logical_or_operator,
739
- $._lvalue,
740
- $._field_simple_get,
741
809
  $._item,
742
- // A recovered tail can retain errors when reused after its prefix changes.
743
- $._normal_conditional_tail,
744
- // Unit-reduction merging can leak update fields through atom children.
745
- $._normal_non_unary_update_expr,
746
- $._print_non_unary_update_expr,
747
- $._field_non_unary_update_expr,
748
- $._normal_unary_assignment_expr,
749
- $._normal_unary_update_expr,
750
- $._print_unary_assignment_expr,
751
- $._source_non_unary_update_expr,
752
- $._source_unary_assignment_expr,
753
- $._source_unary_update_expr,
754
- $._source_conditional_tail,
755
- ],
756
-
757
- conflicts: ($) => [
758
- [$._for_in_clause, $.postfix_lvalue],
759
- [$.item_list, $._item_list],
760
- [$.simple_get],
761
- [$.source_simple_get],
810
+ $._membership_operator,
811
+ ...Object.keys(localRules)
812
+ .filter((name) => name.startsWith("_") && name !== "_local_atom")
813
+ .map((name) => $[name]),
762
814
  ],
815
+ conflicts: ($) => [[$.item_list, $._item_list]],
763
816
 
764
817
  rules: {
765
818
  program: ($) => seq(optional($.item_list), optional($._item)),
766
819
 
767
- _additive_operator: ($) =>
768
- field("operator", choice(signOperator($, "+"), signOperator($, "-"))),
769
-
770
- _multiplicative_operator: ($) =>
771
- field("operator", choice("*", alias($._division_slash, "/"), "%")),
772
-
773
- _exponentiation_operator: () => field("operator", "^"),
774
-
775
- _comparison_operator: ($) =>
776
- field("operator", choice("<", $.le, $.ne, $.eq, ">", $.ge)),
777
-
778
- _match_operator: ($) => field("operator", choice("~", $.no_match)),
779
-
780
820
  _membership_operator: ($) => field("operator", $.in_keyword),
781
821
 
782
- _logical_and_operator: ($) => field("operator", $.and),
783
-
784
- _logical_or_operator: ($) => field("operator", $.or),
785
-
786
822
  item_list: ($) => $._item_list,
787
823
 
788
824
  _item_list: ($) =>
@@ -877,7 +913,12 @@ export default globalThis.grammar?.({
877
913
  ),
878
914
 
879
915
  _for_in_clause: ($) =>
880
- seq(field("variable", $.name), $.in_keyword, field("array", $.name)),
916
+ seq(
917
+ $._for_in,
918
+ field("variable", $.name),
919
+ $.in_keyword,
920
+ field("array", $.name),
921
+ ),
881
922
 
882
923
  _for_header: ($) =>
883
924
  header(
@@ -929,7 +970,7 @@ export default globalThis.grammar?.({
929
970
  seq(
930
971
  $.delete_keyword,
931
972
  field("array", $.name),
932
- optional(subscript(field("subscripts", $.expr_list))),
973
+ optional(seq("[", field("subscripts", $.expr_list), "]")),
933
974
  ),
934
975
  $.expr,
935
976
  $.print_statement,
@@ -958,242 +999,6 @@ export default globalThis.grammar?.({
958
999
 
959
1000
  multiple_expr_list: ($) => seq($.expr, repeat1(listElementTail($, $.expr))),
960
1001
 
961
- print_expr: ($) => choice($.unary_print_expr, $.non_unary_print_expr),
962
-
963
- unary_print_expr: ($) => $._print_unary_assignment_expr,
964
-
965
- non_unary_print_expr: ($) => $._print_non_unary_assignment_expr,
966
-
967
- expr: ($) => choice($.unary_expr, $.non_unary_expr),
968
-
969
- unary_expr: ($) => $._normal_unary_assignment_expr,
970
-
971
- non_unary_expr: ($) => $._normal_non_unary_assignment_expr,
972
-
973
- _prefix_update_expr: ($) =>
974
- seq(
975
- field("operator", choice($.incr, $.decr)),
976
- field("operand", choice($._lvalue, alias($.prefix_field, $.lvalue))),
977
- ),
978
-
979
- ...tieredExpressionRules(EXPRESSION_CONTEXT.normal),
980
-
981
- source_expr: ($) =>
982
- choice(
983
- alias($.source_full_unary_expr, $.unary_expr),
984
- alias($.source_full_non_unary_expr, $.non_unary_expr),
985
- ),
986
-
987
- source_full_unary_expr: ($) => $._source_unary_assignment_expr,
988
-
989
- source_full_non_unary_expr: ($) => $._source_non_unary_assignment_expr,
990
-
991
- ...tieredExpressionRules(EXPRESSION_CONTEXT.source),
992
-
993
- ...tieredExpressionRules(EXPRESSION_CONTEXT.print),
994
-
995
- ...unaryExpressionRules(EXPRESSION_CONTEXT.field),
996
-
997
- nonpostfix_field_expr: ($) =>
998
- choice(
999
- alias($.normal_unary_field_expr, $.unary_expr),
1000
- alias($.nonpostfix_non_unary_field_expr, $.non_unary_expr),
1001
- ),
1002
-
1003
- normal_unary_field_expr: ($) =>
1004
- prec(EXPRESSION.field.precedence, $._field_unary_unary_expr),
1005
-
1006
- nonpostfix_non_unary_field_expr: ($) =>
1007
- prec(
1008
- EXPRESSION.field.precedence,
1009
- choice(
1010
- $._field_not_expr,
1011
- $._prefix_update_expr,
1012
- alias($.nonpostfix_lvalue, $.lvalue),
1013
- alias($.nonpostfix_field_input_function, $.non_unary_input_function),
1014
- ),
1015
- ),
1016
-
1017
- _parenthesized_expression: ($) => parenthesized($.expr),
1018
-
1019
- _user_function_call: ($) => seq($.func_name, callArguments($)),
1020
-
1021
- _builtin_function_call: ($) =>
1022
- prec(
1023
- EXPRESSION.field.precedence + 1,
1024
- seq($.builtin_func_name, callArguments($)),
1025
- ),
1026
-
1027
- _lvalue: ($) =>
1028
- choice(
1029
- alias($.postfix_lvalue, $.lvalue),
1030
- alias($.nonpostfix_lvalue, $.lvalue),
1031
- ),
1032
-
1033
- nonpostfix_lvalue: ($) =>
1034
- seq(
1035
- field("operator", "$"),
1036
- field("operand", alias($.nonpostfix_field_expr, $.expr)),
1037
- ),
1038
-
1039
- postfix_lvalue: ($) =>
1040
- choice(
1041
- seq($.name, optional(subscript($.expr_list))),
1042
- seq(
1043
- field("operator", "$"),
1044
- field("operand", alias($.postfix_field_expr, $.expr)),
1045
- ),
1046
- ),
1047
-
1048
- postfix_field_expr: ($) =>
1049
- alias($.postfix_non_unary_field_expr, $.non_unary_expr),
1050
-
1051
- postfix_non_unary_field_expr: ($) =>
1052
- prec(
1053
- EXPRESSION.field.precedence,
1054
- nonUnaryAtom(
1055
- $,
1056
- {
1057
- ...EXPRESSION_CONTEXT.field,
1058
- input: ($) =>
1059
- alias($.postfix_field_input_function, $.non_unary_input_function),
1060
- },
1061
- alias($.postfix_lvalue, $.lvalue),
1062
- ),
1063
- ),
1064
-
1065
- prefix_field: ($) =>
1066
- seq(
1067
- field("operator", "$"),
1068
- field("operand", alias($.prefix_field_expr, $.expr)),
1069
- ),
1070
-
1071
- prefix_field_expr: ($) =>
1072
- alias($.prefix_non_unary_field_expr, $.non_unary_expr),
1073
-
1074
- prefix_non_unary_field_expr: ($) =>
1075
- prec(
1076
- EXPRESSION.field.precedence,
1077
- choice(
1078
- alias($.direct_input_function, $.non_unary_input_function),
1079
- alias($.prefix_field, $.lvalue),
1080
- ),
1081
- ),
1082
-
1083
- redirected_field: ($) =>
1084
- seq(
1085
- field("operator", "$"),
1086
- field("operand", alias($.redirected_field_expr, $.expr)),
1087
- ),
1088
-
1089
- redirected_field_expr: ($) =>
1090
- alias($.redirected_non_unary_field_expr, $.non_unary_expr),
1091
-
1092
- redirected_non_unary_field_expr: ($) =>
1093
- prec(
1094
- EXPRESSION.field.precedence,
1095
- choice(
1096
- alias($.redirected_field_input_function, $.non_unary_input_function),
1097
- alias($.redirected_field, $.lvalue),
1098
- ),
1099
- ),
1100
-
1101
- redirected_field_input_function: ($) =>
1102
- choice(
1103
- prec(1, $._redirected_field_input),
1104
- field("get", alias($.redirected_field_simple_get, $.simple_get)),
1105
- ),
1106
-
1107
- redirected_field_simple_get: ($) =>
1108
- seq(
1109
- alias($.field_getline_keyword, $.getline_keyword),
1110
- field("target", alias($.redirected_field, $.lvalue)),
1111
- ),
1112
-
1113
- _redirected_field_input: ($) =>
1114
- redirectedInput($, $._field_simple_get, alias($.source_expr, $.expr)),
1115
-
1116
- nonpostfix_field_input_function: ($) =>
1117
- choice(
1118
- field("get", alias($.nonpostfix_field_simple_get, $.simple_get)),
1119
- $._redirected_field_input,
1120
- ),
1121
-
1122
- postfix_field_input_function: ($) =>
1123
- field("get", alias($.postfix_field_simple_get, $.simple_get)),
1124
-
1125
- _field_simple_get: ($) =>
1126
- choice(
1127
- alias($.postfix_field_simple_get, $.simple_get),
1128
- alias($.nonpostfix_field_simple_get, $.simple_get),
1129
- ),
1130
-
1131
- nonpostfix_field_simple_get: ($) =>
1132
- seq(
1133
- alias($.field_getline_keyword, $.getline_keyword),
1134
- field("target", alias($.nonpostfix_lvalue, $.lvalue)),
1135
- ),
1136
-
1137
- postfix_field_simple_get: ($) =>
1138
- choice(
1139
- prec(-1, alias($.field_getline_keyword, $.getline_keyword)),
1140
- seq(
1141
- alias($.field_getline_keyword, $.getline_keyword),
1142
- field("target", alias($.postfix_lvalue, $.lvalue)),
1143
- ),
1144
- ),
1145
-
1146
- direct_input_function: ($) =>
1147
- choice(field("get", $.simple_get), redirectedInput($, $.simple_get)),
1148
-
1149
- source_direct_input_function: ($) =>
1150
- choice(
1151
- field("get", alias($.source_simple_get, $.simple_get)),
1152
- redirectedInput(
1153
- $,
1154
- alias($.source_simple_get, $.simple_get),
1155
- alias($.source_expr, $.expr),
1156
- ),
1157
- ),
1158
-
1159
- source_piped_input_function: ($) =>
1160
- pipedInput(
1161
- $,
1162
- alias($.source_full_non_unary_expr, $.non_unary_expr),
1163
- alias($.source_simple_get, $.simple_get),
1164
- ),
1165
-
1166
- source_unary_input_function: ($) =>
1167
- pipedInput(
1168
- $,
1169
- alias($.source_full_unary_expr, $.unary_expr),
1170
- alias($.source_simple_get, $.simple_get),
1171
- ),
1172
-
1173
- piped_input_function: ($) => pipedInput($, $.non_unary_expr, $.simple_get),
1174
-
1175
- unary_input_function: ($) => pipedInput($, $.unary_expr, $.simple_get),
1176
-
1177
- simple_get: ($) => simpleGet($),
1178
-
1179
- source_simple_get: ($) => simpleGet($, true),
1180
-
1181
- trailing_incr: () => "++",
1182
-
1183
- trailing_decr: () => "--",
1184
-
1185
- getline_keyword: ($) => $._getline_word,
1186
-
1187
- target_getline_keyword: ($) => $._getline_target_word,
1188
-
1189
- omitted_getline_keyword: ($) => $._getline_omitted_word,
1190
-
1191
- field_getline_keyword: ($) => $._getline_field_word,
1192
-
1193
- preferred_target_getline_keyword: ($) => $._getline_prefer_target_word,
1194
-
1195
- preferred_omitted_getline_keyword: ($) => $._getline_prefer_omitted_word,
1196
-
1197
1002
  ...Object.fromEntries(
1198
1003
  [...RESERVED_WORDS.keyword, ...RESERVED_WORDS.membership].map(
1199
1004
  (keyword) => [`${keyword.toLowerCase()}_keyword`, () => keyword],
@@ -1462,5 +1267,30 @@ export default globalThis.grammar?.({
1462
1267
  terminator: ($) => choice(rawNewlines($), seq(";", repeat($.newline))),
1463
1268
 
1464
1269
  newline: () => "\n",
1270
+ ...boundaryRules,
1271
+ ...localRules,
1272
+ expr: ($) =>
1273
+ choice(
1274
+ seq($._root, $._boundary_expr),
1275
+ seq($._local_root, alias($.local_unary_assignment, $.unary_expr)),
1276
+ seq(
1277
+ $._local_root,
1278
+ alias($.local_non_unary_assignment, $.non_unary_expr),
1279
+ ),
1280
+ ),
1281
+ print_expr: ($) =>
1282
+ choice(
1283
+ seq($._print_root, $._boundary_print_expr),
1284
+ seq(
1285
+ $._local_print_root,
1286
+ alias($.local_print_unary_assignment, $.unary_print_expr),
1287
+ ),
1288
+ seq(
1289
+ $._local_print_root,
1290
+ alias($.local_print_non_unary_assignment, $.non_unary_print_expr),
1291
+ ),
1292
+ ),
1465
1293
  },
1466
- });
1294
+ };
1295
+
1296
+ export default globalThis.grammar?.(definition);