@konomanoasa/tree-sitter-posix-awk 0.15.0 → 0.16.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 +11 -16
- package/README.md +13 -4
- package/bindings/rust/build.rs +18 -48
- package/bindings/rust/lib.rs +0 -708
- package/grammar.js +166 -125
- package/package.json +8 -6
- package/queries/highlights.scm +0 -24
- package/src/grammar.json +428 -59
- package/src/node-types.json +2 -1
- package/src/parser.c +91670 -89081
- package/src/scanner.c +125 -295
- package/test/bindings.test.rs +983 -0
- package/tree-sitter.json +1 -6
package/grammar.js
CHANGED
|
@@ -63,6 +63,9 @@ const SINGLE_CHARACTER_OPERATORS = {
|
|
|
63
63
|
"|": "pipe",
|
|
64
64
|
};
|
|
65
65
|
|
|
66
|
+
// Skipping blanks can reach a backslash the external scanner never saw.
|
|
67
|
+
const continuationMarker = token.immediate("\\");
|
|
68
|
+
|
|
66
69
|
const singleOperator = ($, character) =>
|
|
67
70
|
alias($[`_${SINGLE_CHARACTER_OPERATORS[character]}_operator`], character);
|
|
68
71
|
|
|
@@ -74,8 +77,6 @@ const newlineLayout = ($) => optional($.newline_opt);
|
|
|
74
77
|
|
|
75
78
|
const afterOptionalNewline = ($, member) => seq(newlineLayout($), member);
|
|
76
79
|
|
|
77
|
-
const functionBody = ($) => afterOptionalNewline($, field("body", $.action));
|
|
78
|
-
|
|
79
80
|
// A separate closing-hyphen token avoids competing with range separators.
|
|
80
81
|
const ereClosingHyphen = ($) => alias($._ere_closing_hyphen, "-");
|
|
81
82
|
|
|
@@ -190,8 +191,6 @@ const conditionalHeader = ($, keyword) =>
|
|
|
190
191
|
|
|
191
192
|
const keywordHeader = ($, keyword) => seq(keyword, newlineLayout($));
|
|
192
193
|
|
|
193
|
-
const doWhileTail = ($) => seq($.while_keyword, $._parenthesized_condition);
|
|
194
|
-
|
|
195
194
|
const controlStatements = ($, body) => [
|
|
196
195
|
prec.right(seq($._if_header, field("consequence", body))),
|
|
197
196
|
seq(
|
|
@@ -220,13 +219,6 @@ const callArguments = ($) => parenthesized(optional($.expr_list));
|
|
|
220
219
|
|
|
221
220
|
const subscript = (subscripts) => seq("[", subscripts, "]");
|
|
222
221
|
|
|
223
|
-
const lvalueWithFieldOperand = ($, operand) =>
|
|
224
|
-
choice(
|
|
225
|
-
$.name,
|
|
226
|
-
seq($.name, subscript($.expr_list)),
|
|
227
|
-
seq(field("operator", "$"), field("operand", operand)),
|
|
228
|
-
);
|
|
229
|
-
|
|
230
222
|
const directInputFunction = ($, get) =>
|
|
231
223
|
choice(
|
|
232
224
|
field("get", get),
|
|
@@ -237,12 +229,15 @@ const directInputFunction = ($, get) =>
|
|
|
237
229
|
);
|
|
238
230
|
|
|
239
231
|
const getWithTarget = ($, target) =>
|
|
240
|
-
prec.dynamic(1, seq($.getline_keyword, field("target", target)));
|
|
232
|
+
prec(1, prec.dynamic(1, seq($.getline_keyword, field("target", target))));
|
|
241
233
|
|
|
242
|
-
const
|
|
234
|
+
const pipedInput = ($, source, get) =>
|
|
235
|
+
prec.right(
|
|
236
|
+
PRECEDENCE.field,
|
|
237
|
+
seq(field("source", source), singleOperator($, "|"), field("get", get)),
|
|
238
|
+
);
|
|
243
239
|
|
|
244
|
-
const
|
|
245
|
-
seq(repeat($.terminated_statement), tail);
|
|
240
|
+
const omittedGet = ($) => alias($.postfix_omitted_get, $.simple_get);
|
|
246
241
|
|
|
247
242
|
const rawNewlines = ($) => repeat1($.newline);
|
|
248
243
|
|
|
@@ -279,9 +274,8 @@ const EXPRESSION_CONTEXT = {
|
|
|
279
274
|
const classTierName = (context, classification, tier) =>
|
|
280
275
|
`_${context.prefix}_${classification}_${tier}_expr`;
|
|
281
276
|
|
|
282
|
-
// Hidden operand rules
|
|
283
|
-
//
|
|
284
|
-
// aliases preserve field ownership without exposing extra node types.
|
|
277
|
+
// Hidden operand rules leak inner fields into the parent; aliased visible rules
|
|
278
|
+
// prevent this.
|
|
285
279
|
const classOperandName = (context, classification, tier) =>
|
|
286
280
|
`${context.prefix}_${classification}_${tier}_operand`;
|
|
287
281
|
|
|
@@ -302,6 +296,13 @@ const aliasedClassTier = ($, context, classification, tier) =>
|
|
|
302
296
|
|
|
303
297
|
const CLASSIFICATIONS = ["unary", "non_unary"];
|
|
304
298
|
|
|
299
|
+
const tierHelpers = (context, rules) => ({
|
|
300
|
+
unary: (tier) => classTierName(context, "unary", tier),
|
|
301
|
+
nonUnary: (tier) => classTierName(context, "non_unary", tier),
|
|
302
|
+
addOperand: (classification, tier) =>
|
|
303
|
+
Object.assign(rules, classOperandRules(context, classification, tier)),
|
|
304
|
+
});
|
|
305
|
+
|
|
305
306
|
const aliasedAnyTier = ($, context, tier) =>
|
|
306
307
|
alias($[anyTierName(context, tier)], $[context.expression]);
|
|
307
308
|
|
|
@@ -339,11 +340,8 @@ const anyTierRules = (context, tier) => ({
|
|
|
339
340
|
|
|
340
341
|
const unaryExpressionRules = (context) => {
|
|
341
342
|
const rules = anyTierRules(context, "unary");
|
|
342
|
-
const unary
|
|
343
|
-
const nonUnary = (tier) => classTierName(context, "non_unary", tier);
|
|
343
|
+
const { unary, nonUnary, addOperand } = tierHelpers(context, rules);
|
|
344
344
|
const not = `_${context.prefix}_not_expr`;
|
|
345
|
-
const addOperand = (classification, tier) =>
|
|
346
|
-
Object.assign(rules, classOperandRules(context, classification, tier));
|
|
347
345
|
rules[unary("unary")] = ($) =>
|
|
348
346
|
choice(
|
|
349
347
|
...(context.unaryInput
|
|
@@ -407,10 +405,7 @@ const unaryExpressionRules = (context) => {
|
|
|
407
405
|
|
|
408
406
|
const tieredExpressionRules = (context) => {
|
|
409
407
|
const rules = {};
|
|
410
|
-
const unary
|
|
411
|
-
const nonUnary = (tier) => classTierName(context, "non_unary", tier);
|
|
412
|
-
const addOperand = (classification, tier) =>
|
|
413
|
-
Object.assign(rules, classOperandRules(context, classification, tier));
|
|
408
|
+
const { unary, nonUnary, addOperand } = tierHelpers(context, rules);
|
|
414
409
|
const conditionalTail = `_${context.prefix}_conditional_tail`;
|
|
415
410
|
const expression = ($) => $[context.expression];
|
|
416
411
|
rules[conditionalTail] = ($) =>
|
|
@@ -424,46 +419,45 @@ const tieredExpressionRules = (context) => {
|
|
|
424
419
|
const addAnyTier = (tier) =>
|
|
425
420
|
Object.assign(rules, anyTierRules(context, tier));
|
|
426
421
|
|
|
427
|
-
const
|
|
422
|
+
const addBinaryTier = (
|
|
423
|
+
tier,
|
|
424
|
+
nextTier,
|
|
425
|
+
operator,
|
|
426
|
+
precedence,
|
|
427
|
+
{ leftAssociative, newlineAfterOperator = false },
|
|
428
|
+
) => {
|
|
428
429
|
addAnyTier(nextTier);
|
|
429
430
|
const tail = `_${context.prefix}_${tier}_tail`;
|
|
430
|
-
rules[tail] = ($) =>
|
|
431
|
-
|
|
431
|
+
rules[tail] = ($) => {
|
|
432
|
+
const right = field("right", aliasedAnyTier($, context, nextTier));
|
|
433
|
+
return seq(
|
|
434
|
+
operator($),
|
|
435
|
+
newlineAfterOperator ? afterOptionalNewline($, right) : right,
|
|
436
|
+
);
|
|
437
|
+
};
|
|
432
438
|
for (const classification of CLASSIFICATIONS) {
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
439
|
+
if (leftAssociative) {
|
|
440
|
+
addOperand(classification, tier);
|
|
441
|
+
}
|
|
442
|
+
const operation = ($) =>
|
|
443
|
+
seq(
|
|
444
|
+
field(
|
|
445
|
+
"left",
|
|
446
|
+
aliasedClassTier(
|
|
447
|
+
$,
|
|
448
|
+
context,
|
|
449
|
+
classification,
|
|
450
|
+
leftAssociative ? tier : nextTier,
|
|
442
451
|
),
|
|
443
452
|
),
|
|
453
|
+
$[tail],
|
|
444
454
|
);
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
const addNonAssociativeTier = (tier, nextTier, operator, precedence) => {
|
|
449
|
-
addAnyTier(nextTier);
|
|
450
|
-
const tail = `_${context.prefix}_${tier}_tail`;
|
|
451
|
-
rules[tail] = ($) =>
|
|
452
|
-
seq(operator($), field("right", aliasedAnyTier($, context, nextTier)));
|
|
453
|
-
for (const classification of CLASSIFICATIONS) {
|
|
454
455
|
rules[classTierName(context, classification, tier)] = ($) =>
|
|
455
456
|
choice(
|
|
456
457
|
classTier($, context, classification, nextTier),
|
|
457
|
-
|
|
458
|
-
precedence,
|
|
459
|
-
|
|
460
|
-
field(
|
|
461
|
-
"left",
|
|
462
|
-
aliasedClassTier($, context, classification, nextTier),
|
|
463
|
-
),
|
|
464
|
-
$[tail],
|
|
465
|
-
),
|
|
466
|
-
),
|
|
458
|
+
leftAssociative
|
|
459
|
+
? prec.left(precedence, operation($))
|
|
460
|
+
: prec(precedence, operation($)),
|
|
467
461
|
);
|
|
468
462
|
}
|
|
469
463
|
};
|
|
@@ -510,44 +504,20 @@ const tieredExpressionRules = (context) => {
|
|
|
510
504
|
);
|
|
511
505
|
}
|
|
512
506
|
|
|
513
|
-
|
|
514
|
-
addAnyTier(nextTier);
|
|
515
|
-
const tail = `_${context.prefix}_${tier}_tail`;
|
|
516
|
-
rules[tail] = ($) =>
|
|
517
|
-
seq(
|
|
518
|
-
operator($),
|
|
519
|
-
afterOptionalNewline(
|
|
520
|
-
$,
|
|
521
|
-
field("right", aliasedAnyTier($, context, nextTier)),
|
|
522
|
-
),
|
|
523
|
-
);
|
|
524
|
-
for (const classification of CLASSIFICATIONS) {
|
|
525
|
-
rules[classTierName(context, classification, tier)] = ($) =>
|
|
526
|
-
choice(
|
|
527
|
-
classTier($, context, classification, nextTier),
|
|
528
|
-
prec.left(
|
|
529
|
-
precedence,
|
|
530
|
-
seq(
|
|
531
|
-
field("left", aliasedClassTier($, context, classification, tier)),
|
|
532
|
-
$[tail],
|
|
533
|
-
),
|
|
534
|
-
),
|
|
535
|
-
);
|
|
536
|
-
}
|
|
537
|
-
};
|
|
538
|
-
|
|
539
|
-
addNewlineSeparatedTier(
|
|
507
|
+
addBinaryTier(
|
|
540
508
|
"logical_or",
|
|
541
509
|
"logical_and",
|
|
542
510
|
($) => $._logical_or_operator,
|
|
543
511
|
PRECEDENCE.logicalOr,
|
|
512
|
+
{ leftAssociative: true, newlineAfterOperator: true },
|
|
544
513
|
);
|
|
545
514
|
|
|
546
|
-
|
|
515
|
+
addBinaryTier(
|
|
547
516
|
"logical_and",
|
|
548
517
|
"membership",
|
|
549
518
|
($) => $._logical_and_operator,
|
|
550
519
|
PRECEDENCE.logicalAnd,
|
|
520
|
+
{ leftAssociative: true, newlineAfterOperator: true },
|
|
551
521
|
);
|
|
552
522
|
|
|
553
523
|
const membershipTail = `_${context.prefix}_membership_tail`;
|
|
@@ -582,22 +552,56 @@ const tieredExpressionRules = (context) => {
|
|
|
582
552
|
}
|
|
583
553
|
|
|
584
554
|
const comparisonTier = context.comparison ? "comparison" : "concatenation";
|
|
585
|
-
|
|
555
|
+
addBinaryTier(
|
|
586
556
|
"match",
|
|
587
557
|
comparisonTier,
|
|
588
558
|
($) => $._match_operator,
|
|
589
559
|
PRECEDENCE.match,
|
|
560
|
+
{ leftAssociative: false },
|
|
590
561
|
);
|
|
591
562
|
|
|
592
563
|
if (context.comparison) {
|
|
593
|
-
|
|
564
|
+
addBinaryTier(
|
|
594
565
|
"comparison",
|
|
595
566
|
"concatenation",
|
|
596
567
|
($) => $._comparison_operator,
|
|
597
568
|
PRECEDENCE.comparison,
|
|
569
|
+
{ leftAssociative: false },
|
|
598
570
|
);
|
|
599
571
|
}
|
|
600
572
|
|
|
573
|
+
// A following postfix update still needs the targetless getline path.
|
|
574
|
+
if (context.prefix === "normal") {
|
|
575
|
+
const prefix = "getline_updated";
|
|
576
|
+
const name = (tier) => `_${prefix}_${tier}`;
|
|
577
|
+
const operand = (tier) => `${prefix}_${tier}_operand`;
|
|
578
|
+
const wrapped = ($, tier) => alias($[operand(tier)], $.non_unary_expr);
|
|
579
|
+
rules[name("update")] = ($) =>
|
|
580
|
+
seq(
|
|
581
|
+
field("operand", alias($.postfix_lvalue, $.lvalue)),
|
|
582
|
+
field("operator", choice($.incr, $.decr)),
|
|
583
|
+
);
|
|
584
|
+
rules[operand("update")] = ($) => prec(1, $[name("update")]);
|
|
585
|
+
rules[name("exponentiation")] = ($) =>
|
|
586
|
+
choice(
|
|
587
|
+
$[name("update")],
|
|
588
|
+
seq(field("left", wrapped($, "update")), $._normal_exponentiation_tail),
|
|
589
|
+
);
|
|
590
|
+
for (const [tier, next, precedence] of [
|
|
591
|
+
["multiplicative", "exponentiation", PRECEDENCE.multiplicative],
|
|
592
|
+
["additive", "multiplicative", PRECEDENCE.additive],
|
|
593
|
+
]) {
|
|
594
|
+
rules[name(tier)] = ($) =>
|
|
595
|
+
choice(
|
|
596
|
+
$[name(next)],
|
|
597
|
+
prec.left(
|
|
598
|
+
precedence,
|
|
599
|
+
seq(field("left", wrapped($, tier)), $[`_normal_${tier}_tail`]),
|
|
600
|
+
),
|
|
601
|
+
);
|
|
602
|
+
rules[operand(tier)] = ($) => prec(1, $[name(tier)]);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
601
605
|
const concatenationTail = `_${context.prefix}_concatenation_tail`;
|
|
602
606
|
rules[concatenationTail] = ($) =>
|
|
603
607
|
field("right", aliasedClassTier($, context, "non_unary", "additive"));
|
|
@@ -605,6 +609,32 @@ const tieredExpressionRules = (context) => {
|
|
|
605
609
|
rules[classTierName(context, classification, "concatenation")] = ($) =>
|
|
606
610
|
choice(
|
|
607
611
|
classTier($, context, classification, "additive"),
|
|
612
|
+
...(context.prefix === "normal"
|
|
613
|
+
? [
|
|
614
|
+
prec.left(
|
|
615
|
+
PRECEDENCE.concatenation,
|
|
616
|
+
seq(
|
|
617
|
+
field(
|
|
618
|
+
"left",
|
|
619
|
+
alias(
|
|
620
|
+
classification === "unary"
|
|
621
|
+
? $.omitted_unary_get_operand
|
|
622
|
+
: $.omitted_get_operand,
|
|
623
|
+
$[
|
|
624
|
+
classification === "unary"
|
|
625
|
+
? "unary_expr"
|
|
626
|
+
: "non_unary_expr"
|
|
627
|
+
],
|
|
628
|
+
),
|
|
629
|
+
),
|
|
630
|
+
field(
|
|
631
|
+
"right",
|
|
632
|
+
alias($.getline_updated_additive_operand, $.non_unary_expr),
|
|
633
|
+
),
|
|
634
|
+
),
|
|
635
|
+
),
|
|
636
|
+
]
|
|
637
|
+
: []),
|
|
608
638
|
prec.left(
|
|
609
639
|
PRECEDENCE.concatenation,
|
|
610
640
|
seq(
|
|
@@ -618,18 +648,20 @@ const tieredExpressionRules = (context) => {
|
|
|
618
648
|
);
|
|
619
649
|
}
|
|
620
650
|
|
|
621
|
-
|
|
651
|
+
addBinaryTier(
|
|
622
652
|
"additive",
|
|
623
653
|
"multiplicative",
|
|
624
654
|
($) => $._additive_operator,
|
|
625
655
|
PRECEDENCE.additive,
|
|
656
|
+
{ leftAssociative: true },
|
|
626
657
|
);
|
|
627
658
|
|
|
628
|
-
|
|
659
|
+
addBinaryTier(
|
|
629
660
|
"multiplicative",
|
|
630
661
|
"unary",
|
|
631
662
|
($) => $._multiplicative_operator,
|
|
632
663
|
PRECEDENCE.multiplicative,
|
|
664
|
+
{ leftAssociative: true },
|
|
633
665
|
);
|
|
634
666
|
|
|
635
667
|
return { ...rules, ...unaryExpressionRules(context) };
|
|
@@ -682,15 +714,16 @@ export default grammar({
|
|
|
682
714
|
$._ere_class_name,
|
|
683
715
|
$._ere_dup_count,
|
|
684
716
|
$.comment,
|
|
685
|
-
|
|
717
|
+
continuationMarker,
|
|
686
718
|
$._continuation_newline,
|
|
719
|
+
$._stray_backslash,
|
|
687
720
|
$._error_sentinel,
|
|
688
721
|
],
|
|
689
722
|
|
|
690
723
|
extras: ($) => [
|
|
691
724
|
token(repeat1(choice(" ", "\t"))),
|
|
692
725
|
$.comment,
|
|
693
|
-
|
|
726
|
+
continuationMarker,
|
|
694
727
|
$._continuation_newline,
|
|
695
728
|
],
|
|
696
729
|
|
|
@@ -699,6 +732,8 @@ export default grammar({
|
|
|
699
732
|
$._simple_get,
|
|
700
733
|
$._direct_input_function,
|
|
701
734
|
$._item,
|
|
735
|
+
// A recovered tail can retain errors when reused after its prefix changes.
|
|
736
|
+
$._normal_conditional_tail,
|
|
702
737
|
// Unit-reduction merging must not inherit update fields through atom children.
|
|
703
738
|
$._normal_non_unary_update_expr,
|
|
704
739
|
$._print_non_unary_update_expr,
|
|
@@ -709,8 +744,8 @@ export default grammar({
|
|
|
709
744
|
],
|
|
710
745
|
|
|
711
746
|
conflicts: ($) => [
|
|
712
|
-
[$.postfix_simple_get],
|
|
713
|
-
[$.
|
|
747
|
+
[$.postfix_omitted_get, $.postfix_simple_get],
|
|
748
|
+
[$.postfix_omitted_get, $.nonpostfix_simple_get, $.postfix_simple_get],
|
|
714
749
|
// The final item joins item_list only after its terminator is known.
|
|
715
750
|
[$.item_list, $._item_list],
|
|
716
751
|
],
|
|
@@ -718,9 +753,6 @@ export default grammar({
|
|
|
718
753
|
rules: {
|
|
719
754
|
program: ($) => seq(optional($.item_list), optional($._item)),
|
|
720
755
|
|
|
721
|
-
// A literal extra would let the generated lexer accept raw backslashes.
|
|
722
|
-
_continuation_marker: ($) => alias($._continuation_backslash, "\\"),
|
|
723
|
-
|
|
724
756
|
_additive_operator: ($) =>
|
|
725
757
|
field("operator", choice(singleOperator($, "+"), singleOperator($, "-"))),
|
|
726
758
|
|
|
@@ -784,7 +816,8 @@ export default grammar({
|
|
|
784
816
|
|
|
785
817
|
normal_pattern_item: ($) => field("pattern", $.normal_pattern),
|
|
786
818
|
|
|
787
|
-
_function_item: ($) =>
|
|
819
|
+
_function_item: ($) =>
|
|
820
|
+
seq($._function_header, afterOptionalNewline($, field("body", $.action))),
|
|
788
821
|
|
|
789
822
|
_function_header_prefix: ($) =>
|
|
790
823
|
seq($.function_keyword, field("name", choice($.name, $.func_name)), "("),
|
|
@@ -826,10 +859,10 @@ export default grammar({
|
|
|
826
859
|
field("closing", "}"),
|
|
827
860
|
),
|
|
828
861
|
|
|
829
|
-
terminated_statement_list: ($) =>
|
|
862
|
+
terminated_statement_list: ($) => repeat1($.terminated_statement),
|
|
830
863
|
|
|
831
864
|
unterminated_statement_list: ($) =>
|
|
832
|
-
|
|
865
|
+
seq(repeat($.terminated_statement), $.unterminated_statement),
|
|
833
866
|
|
|
834
867
|
_parenthesized_condition: ($) => parenthesized(field("condition", $.expr)),
|
|
835
868
|
|
|
@@ -896,7 +929,8 @@ export default grammar({
|
|
|
896
929
|
seq(
|
|
897
930
|
$._do_header,
|
|
898
931
|
field("body", $.terminated_statement),
|
|
899
|
-
|
|
932
|
+
$.while_keyword,
|
|
933
|
+
$._parenthesized_condition,
|
|
900
934
|
),
|
|
901
935
|
),
|
|
902
936
|
|
|
@@ -1010,7 +1044,14 @@ export default grammar({
|
|
|
1010
1044
|
),
|
|
1011
1045
|
|
|
1012
1046
|
postfix_lvalue: ($) =>
|
|
1013
|
-
|
|
1047
|
+
choice(
|
|
1048
|
+
$.name,
|
|
1049
|
+
seq($.name, subscript($.expr_list)),
|
|
1050
|
+
seq(
|
|
1051
|
+
field("operator", "$"),
|
|
1052
|
+
field("operand", alias($.postfix_field_expr, $.expr)),
|
|
1053
|
+
),
|
|
1054
|
+
),
|
|
1014
1055
|
|
|
1015
1056
|
postfix_field_expr: ($) =>
|
|
1016
1057
|
alias($.postfix_non_unary_field_expr, $.non_unary_expr),
|
|
@@ -1044,25 +1085,9 @@ export default grammar({
|
|
|
1044
1085
|
postfix_direct_input_function: ($) =>
|
|
1045
1086
|
directInputFunction($, alias($.postfix_simple_get, $.simple_get)),
|
|
1046
1087
|
|
|
1047
|
-
piped_input_function: ($) =>
|
|
1048
|
-
prec.right(
|
|
1049
|
-
PRECEDENCE.field,
|
|
1050
|
-
seq(
|
|
1051
|
-
field("source", $.non_unary_expr),
|
|
1052
|
-
singleOperator($, "|"),
|
|
1053
|
-
field("get", $._simple_get),
|
|
1054
|
-
),
|
|
1055
|
-
),
|
|
1088
|
+
piped_input_function: ($) => pipedInput($, $.non_unary_expr, $._simple_get),
|
|
1056
1089
|
|
|
1057
|
-
unary_input_function: ($) =>
|
|
1058
|
-
prec.right(
|
|
1059
|
-
PRECEDENCE.field,
|
|
1060
|
-
seq(
|
|
1061
|
-
field("source", $.unary_expr),
|
|
1062
|
-
singleOperator($, "|"),
|
|
1063
|
-
field("get", $._simple_get),
|
|
1064
|
-
),
|
|
1065
|
-
),
|
|
1090
|
+
unary_input_function: ($) => pipedInput($, $.unary_expr, $._simple_get),
|
|
1066
1091
|
|
|
1067
1092
|
_simple_get: ($) =>
|
|
1068
1093
|
choice(
|
|
@@ -1079,6 +1104,22 @@ export default grammar({
|
|
|
1079
1104
|
getWithTarget($, alias($.postfix_lvalue, $.lvalue)),
|
|
1080
1105
|
),
|
|
1081
1106
|
|
|
1107
|
+
omitted_get_operand: ($) =>
|
|
1108
|
+
alias($.omitted_get_input, $.non_unary_input_function),
|
|
1109
|
+
|
|
1110
|
+
omitted_get_input: ($) =>
|
|
1111
|
+
choice(
|
|
1112
|
+
field("get", omittedGet($)),
|
|
1113
|
+
pipedInput($, $.non_unary_expr, omittedGet($)),
|
|
1114
|
+
),
|
|
1115
|
+
|
|
1116
|
+
omitted_unary_get_operand: ($) =>
|
|
1117
|
+
alias($.omitted_unary_get_input, $.unary_input_function),
|
|
1118
|
+
|
|
1119
|
+
omitted_unary_get_input: ($) => pipedInput($, $.unary_expr, omittedGet($)),
|
|
1120
|
+
|
|
1121
|
+
postfix_omitted_get: ($) => prec(1, $.getline_keyword),
|
|
1122
|
+
|
|
1082
1123
|
getline_keyword: ($) => $._getline_word,
|
|
1083
1124
|
|
|
1084
1125
|
in_keyword: ($) => $._in_word,
|
|
@@ -1117,7 +1158,8 @@ export default grammar({
|
|
|
1117
1158
|
quoted_character: ($) =>
|
|
1118
1159
|
alias($.ere_quoted_escape_sequence, $.escape_sequence),
|
|
1119
1160
|
|
|
1120
|
-
|
|
1161
|
+
// Aliasing preserves the wrapper even when no other rule shares the token.
|
|
1162
|
+
wildcard: () => alias(token.immediate("."), "."),
|
|
1121
1163
|
|
|
1122
1164
|
left_anchor: () => token.immediate("^"),
|
|
1123
1165
|
|
|
@@ -1136,7 +1178,7 @@ export default grammar({
|
|
|
1136
1178
|
),
|
|
1137
1179
|
),
|
|
1138
1180
|
|
|
1139
|
-
repetition_modifier: () => token.immediate("?"),
|
|
1181
|
+
repetition_modifier: () => alias(token.immediate("?"), "?"),
|
|
1140
1182
|
|
|
1141
1183
|
_ere_interval: ($) =>
|
|
1142
1184
|
seq(
|
|
@@ -1179,8 +1221,7 @@ export default grammar({
|
|
|
1179
1221
|
_ere_initial_close: ($) =>
|
|
1180
1222
|
alias(token.immediate("]"), $.collating_element_content),
|
|
1181
1223
|
|
|
1182
|
-
// Inlining
|
|
1183
|
-
// collating_element wrapper.
|
|
1224
|
+
// Inlining lets the hyphen alias replace the collating_element wrapper.
|
|
1184
1225
|
_ere_initial_hyphen: ($) =>
|
|
1185
1226
|
choice($._ere_bracket_hyphen, ereClosingHyphen($)),
|
|
1186
1227
|
|
|
@@ -1284,8 +1325,8 @@ export default grammar({
|
|
|
1284
1325
|
$._ere_undefined_escape,
|
|
1285
1326
|
),
|
|
1286
1327
|
|
|
1287
|
-
// Tree-sitter rejects the POSIX bracket spelling for these
|
|
1288
|
-
//
|
|
1328
|
+
// Tree-sitter rejects the POSIX bracket spelling for these excluded
|
|
1329
|
+
// delimiters.
|
|
1289
1330
|
_ordinary_character: () => token.immediate(/[^.\x5B\x5C*^$+?{|}()/\n]/),
|
|
1290
1331
|
|
|
1291
1332
|
_ere_ordinary_close_parenthesis: () => token.immediate(")"),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konomanoasa/tree-sitter-posix-awk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Tree-sitter grammar for POSIX awk.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,17 +13,19 @@
|
|
|
13
13
|
"src/*.c",
|
|
14
14
|
"src/*.json",
|
|
15
15
|
"src/tree_sitter/*.h",
|
|
16
|
+
"test/bindings.test.rs",
|
|
16
17
|
"tree-sitter.json"
|
|
17
18
|
],
|
|
18
19
|
"publishConfig": {
|
|
19
20
|
"access": "public"
|
|
20
21
|
},
|
|
21
22
|
"scripts": {
|
|
22
|
-
"
|
|
23
|
-
"
|
|
23
|
+
"build": "npm run tree-sitter -- build-all",
|
|
24
|
+
"check": "biome check . && node scripts/check-c.js && node scripts/check-generated.js && npm test",
|
|
25
|
+
"format": "biome check --write . && node scripts/check-c.js --write",
|
|
24
26
|
"generate": "npm run tree-sitter -- generate-all",
|
|
25
|
-
"
|
|
26
|
-
"test": "
|
|
27
|
+
"test": "npm run tree-sitter -- test-corpus --rebuild && node --test --test-concurrency=1 \"test/*.test.js\"",
|
|
28
|
+
"test:bindings": "cargo test --locked",
|
|
27
29
|
"test:fuzz": "node --test --test-name-pattern=\"fixed-seed generated histories\" test/incremental.test.js",
|
|
28
30
|
"test:fuzz:corpus": "npm run tree-sitter -- fuzz-all --iterations 100 --edits 5",
|
|
29
31
|
"test:highlights": "node --test test/highlight.test.js",
|
|
@@ -33,7 +35,7 @@
|
|
|
33
35
|
"tree-sitter": "node scripts/tree-sitter.js"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
|
-
"@biomejs/biome": "2.5.
|
|
38
|
+
"@biomejs/biome": "2.5.14",
|
|
37
39
|
"@types/node": "26.5.1",
|
|
38
40
|
"tree-sitter-cli": "0.27.0"
|
|
39
41
|
},
|
package/queries/highlights.scm
CHANGED
|
@@ -170,30 +170,6 @@
|
|
|
170
170
|
"}"
|
|
171
171
|
] @string.regexp)
|
|
172
172
|
|
|
173
|
-
(non_unary_expr
|
|
174
|
-
[
|
|
175
|
-
"?"
|
|
176
|
-
":"
|
|
177
|
-
] @keyword.conditional.ternary)
|
|
178
|
-
|
|
179
|
-
(unary_expr
|
|
180
|
-
[
|
|
181
|
-
"?"
|
|
182
|
-
":"
|
|
183
|
-
] @keyword.conditional.ternary)
|
|
184
|
-
|
|
185
|
-
(non_unary_print_expr
|
|
186
|
-
[
|
|
187
|
-
"?"
|
|
188
|
-
":"
|
|
189
|
-
] @keyword.conditional.ternary)
|
|
190
|
-
|
|
191
|
-
(unary_print_expr
|
|
192
|
-
[
|
|
193
|
-
"?"
|
|
194
|
-
":"
|
|
195
|
-
] @keyword.conditional.ternary)
|
|
196
|
-
|
|
197
173
|
(item
|
|
198
174
|
name: [
|
|
199
175
|
(name)
|