class SyntaxTree::Parser

def on_lambda(params, statements)

) -> Lambda
(BodyStmt | Statements) statements
(Params | Paren) params,
on_lambda: (
:call-seq:
def on_lambda(params, statements)
  beginning = consume_token(TLambda)
  braces =
    tokens.any? do |token|
      token.is_a?(TLamBeg) &&
        token.location.start_char > beginning.location.start_char
    end
  if braces
    opening = consume_token(TLamBeg)
    closing = consume_token(RBrace)
  else
    opening = consume_keyword(:do)
    closing = consume_keyword(:end)
  end
  # We need to do some special mapping here. Since ripper doesn't support
  # capturing lambda vars, we need to normalize all of that here.
  params =
    if params.is_a?(Paren)
      # In this case we've gotten to the parentheses wrapping a set of
      # parameters case. Here we need to manually scan for lambda locals.
      range = (params.location.start_char + 1)...params.location.end_char
      locals = lambda_locals(source[range])
      location = params.contents.location
      location = location.to(locals.last.location) if locals.any?
      node =
        Paren.new(
          lparen: params.lparen,
          contents:
            LambdaVar.new(
              params: params.contents,
              locals: locals,
              location: location
            ),
          location: params.location
        )
      node.comments.concat(params.comments)
      node
    else
      # If there are no parameters, then we didn't have anything to base the
      # location information of off. Now that we have an opening of the
      # block, we can correct this.
      if params.empty?
        opening_location = opening.location
        location =
          Location.fixed(
            line: opening_location.start_line,
            char: opening_location.start_char,
            column: opening_location.start_column
          )
        params = params.copy(location: location)
      end
      # In this case we've gotten to the plain set of parameters. In this
      # case there cannot be lambda locals, so we will wrap the parameters
      # into a lambda var that has no locals.
      LambdaVar.new(params: params, locals: [], location: params.location)
    end
  start_char = find_next_statement_start(opening.location.end_char)
  statements.bind(
    self,
    start_char,
    start_char - line_counts[opening.location.end_line - 1].start,
    closing.location.start_char,
    closing.location.start_column
  )
  Lambda.new(
    params: params,
    statements: statements,
    location: beginning.location.to(closing.location)
  )
end