grammar G {
token TOP { <sentRefEnd> }
token word { \w+ }
token sentence { <word>+ % <.ws> <endPunc> }
token sentRefEnd { <sentence>+ <ref> }
# token sentRefEnd { <char>+? <endPunc> <ref> }
token endPunc { \. }
token ref { \(\d+\) }
}
class GActions {
method sentRefEnd($/) {
say $/.Str;
}
}
my $book = "Hello how are you.(1)";
my $match = G.parse($book, :actions(GActions.new()));
say $match;