Thanks! Timo's explanation nailed it, the problem is with the action not defining a method for "sum" so Any.sum becomes the action.
The parsing works in grammar B without actions; "sum" is fine as a token
name in that case.
grammar B {
rule TOP { <sum> }
token sum { <int>+ % '+' }
token int { \d+ }
}
say B.parse('5'); # OK
