In Grammar§

See primary documentation in context for method subparse

method subparse($target:$rule = 'TOP'Capture() :$args = \(),  Mu :$actions = Mu*%opt)

Does exactly the same as method parse, except that cursor doesn't have to reach the end of the string to succeed. That is, it doesn't have to match the whole string.

Note that unlike method parse, subparse always returns a Match, which will be a failed match (and thus falsy), if the grammar failed to match.

grammar RepeatChar {
    token start($character) { $character+ }
}
 
say RepeatChar.subparse('bbbabb':rule('start'), :args(\('b')));
say RepeatChar.parse(   'bbbabb':rule('start'), :args(\('b')));
say RepeatChar.subparse('bbbabb':rule('start'), :args(\('a')));
say RepeatChar.subparse('bbbabb':rule('start'), :args(\('a')), :pos(3));
 
 
# OUTPUT: 
# 「bbb」 
# Nil 
# #<failed match> 
# 「a」