class RubyLex

def readmultiline

def readmultiline
  save_prompt_to_context_io([], false, 0)
  # multiline
  return @input.call if @io.respond_to?(:check_termination)
  # nomultiline
  code = ''
  line_offset = 0
  loop do
    line = @input.call
    unless line
      return code.empty? ? nil : code
    end
    code << line
    # Accept any single-line input for symbol aliases or commands that transform args
    return code if single_line_command?(code)
    tokens, opens, terminated = check_code_state(code)
    return code if terminated
    line_offset += 1
    continue = should_continue?(tokens)
    save_prompt_to_context_io(opens, continue, line_offset)
  end
end