class RDoc::RubyLex

def each_top_level_statement

def each_top_level_statement
  initialize_input
  catch(:TERM_INPUT) do
    loop do
      begin
        @continue = false
        prompt
        unless l = lex
          throw :TERM_INPUT if @line == ''
        else
          #p l
          @line.concat l
          if @ltype or @continue or @indent > 0
            next
          end
        end
        if @line != "\n"
          yield @line, @exp_line_no
        end
        break unless l
        @line = ''
        @exp_line_no = @line_no
        @indent = 0
        @indent_stack = []
        prompt
      rescue TerminateLineInput
        initialize_input
        prompt
        get_readed
      end
    end
  end
end