grammar G {
token TOP { <sentRefEnd> }
token sentFrag { <char>+ <?before endPunc> }
token sentRefEnd { <sentFrag> <endPunc> <ref> }
# token sentRefEnd { <char>+? <endPunc> <ref> }
token endPunc { \. }
token char { \w || \s | \.}
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;