File tree Expand file tree Collapse file tree 1 file changed +17
-17
lines changed Expand file tree Collapse file tree 1 file changed +17
-17
lines changed Original file line number Diff line number Diff line change @@ -512,21 +512,21 @@ argument. If no such method exists, it is skipped.
512
512
513
513
Here is a contrived example of a grammar and actions in action:
514
514
515
- = begin code
516
- grammar TestGrammar {
517
- token TOP { \d+ }
518
- }
515
+ = begin code
516
+ grammar TestGrammar {
517
+ token TOP { \d+ }
518
+ }
519
519
520
- class TestActions {
521
- method TOP($/) {
522
- $/.make(2 + $/);
523
- }
520
+ class TestActions {
521
+ method TOP($/) {
522
+ $/.make(2 + $/);
524
523
}
524
+ }
525
525
526
- my $match = TestGrammar.parse('40', actions => TestActions.new);
527
- say $match; # OUTPUT: «「40」»
528
- say $match.made; # OUTPUT: «42»
529
- = end code
526
+ my $match = TestGrammar.parse('40', actions => TestActions.new);
527
+ say $match; # OUTPUT: «「40」»
528
+ say $match.made; # OUTPUT: «42»
529
+ = end code
530
530
531
531
An instance of C < TestActions > is passed as named argument C < actions > to the
532
532
L < parse|/routine/parse > call, and when token C < TOP > has matched successfully,
@@ -586,11 +586,11 @@ A slightly more involved example follows:
586
586
587
587
This produces the following output:
588
588
589
- = begin code :lang<text>
590
- Key: second Value: b
591
- Key: hits Value: 42
592
- Key: perl Value: 6
593
- = end code
589
+ = begin code :lang<text>
590
+ Key: second Value: b
591
+ Key: hits Value: 42
592
+ Key: perl Value: 6
593
+ = end code
594
594
595
595
Rule C < pair > , which parsed a pair separated by an equals sign, aliases the two
596
596
calls to token C < identifier > to separate capture names to make them available
You can’t perform that action at this time.
0 commit comments