class SyntaxTree::Parser
def on_fndptn(constant, left, values, right)
VarField right
Array[untyped] values,
VarField left,
(nil | untyped) constant,
on_fndptn: (
:call-seq:
def on_fndptn(constant, left, values, right) # The left and right of a find pattern are always going to be splats, so # we're going to consume the * operators and use their location # information to extend the location of the splats. right, left = [right, left].map do |node| operator = consume_operator(:*) location = if node.value operator.location.to(node.location) else operator.location end node.copy(location: location) end # The opening of this find pattern is either going to be a left bracket, a # right left parenthesis, or the left splat. We're going to use this to # determine how to find the closing of the pattern, as well as determining # the location of the node. opening = find_token(LBracket) || find_token(LParen) || left # The closing is based on the opening, which is either the matched # punctuation or the right splat. closing = case opening when LBracket tokens.delete(opening) consume_token(RBracket) when LParen tokens.delete(opening) consume_token(RParen) else right end FndPtn.new( constant: constant, left: left, values: values, right: right, location: (constant || opening).location.to(closing.location) ) end