class SyntaxTree::Parser

def on_else(statements)

on_else: (Statements statements) -> Else
:call-seq:
def on_else(statements)
  keyword = consume_keyword(:else)
  # else can either end with an end keyword (in which case we'll want to
  # consume that event) or it can end with an ensure keyword (in which case
  # we'll leave that to the ensure to handle).
  index =
    tokens.rindex do |token|
      token.is_a?(Kw) && %w[end ensure].include?(token.value)
    end
  if index.nil?
    message = "Cannot find expected else ending"
    raise ParseError.new(message, *find_token_error(keyword.location))
  end
  node = tokens[index]
  ending = node.value == "end" ? tokens.delete_at(index) : node
  start_char = find_next_statement_start(keyword.location.end_char)
  statements.bind(
    self,
    start_char,
    start_char - line_counts[keyword.location.start_line - 1].start,
    ending.location.start_char,
    ending.location.start_column
  )
  Else.new(
    keyword: keyword,
    statements: statements,
    location: keyword.location.to(ending.location)
  )
end