class SyntaxTree::Parser

def on_aryptn(constant, requireds, rest, posts)

) -> AryPtn
(nil | Array[untyped]) posts
(nil | VarField) rest,
(nil | Array[untyped]) requireds,
(nil | VarRef) constant,
on_aryptn: (
:call-seq:
def on_aryptn(constant, requireds, rest, posts)
  lbracket = find_token(LBracket)
  lbracket ||= find_token(LParen) if constant
  rbracket = find_token(RBracket)
  rbracket ||= find_token(RParen) if constant
  parts = [constant, lbracket, *requireds, rest, *posts, rbracket].compact
  # The location is going to be determined by the first part to the last
  # part. This includes potential brackets.
  location = parts[0].location.to(parts[-1].location)
  # Now that we have the location calculated, we can remove the brackets
  # from the list of tokens.
  tokens.delete(lbracket) if lbracket
  tokens.delete(rbracket) if rbracket
  # If there is a plain *, then we're going to fix up the location of it
  # here because it currently doesn't have anything to use for its precise
  # location. If we hit a comma, then we've gone too far.
  if rest.is_a?(VarField) && rest.value.nil?
    tokens.rindex do |rtoken|
      case rtoken
      when Comma
        break
      when Op
        if rtoken.value == "*"
          rest = VarField.new(value: nil, location: rtoken.location)
          break
        end
      end
    end
  end
  AryPtn.new(
    constant: constant,
    requireds: requireds || [],
    rest: rest,
    posts: posts || [],
    location: location
  )
end