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