Skip to content

Commit d928883

Browse files
authored
Show non-$/ var use in actions in example
- Already mentioned in the adjacent prose - Also include example that shows you don't have to use `$/.make` and can just make
1 parent 6996421 commit d928883

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

doc/Language/grammars.pod6

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,15 @@ grammar KeyValuePairs {
340340
}
341341
342342
class KeyValuePairsActions {
343-
method identifier($/) { $/.make: ~$/ }
344343
method pair ($/) { $/.make: $<key>.made => $<value>.made }
345-
method TOP ($/) { $/.make: $<pair>».made }
344+
method identifier($/) {
345+
# subroutine `make` is the same as calling .make on $/
346+
make ~$/
347+
}
348+
method TOP ($match) {
349+
# can use any variable name for parameter, not just $/
350+
$match.make: $match<pair>».made
351+
}
346352
}
347353
348354
my $res = KeyValuePairs.parse(q:to/EOI/, :actions(KeyValuePairsActions)).made;

0 commit comments

Comments
 (0)