module Haml::Precompiler

def precompile

def precompile
  @haml_comment = @dont_indent_next_line = @dont_tab_up_next_text = false
  @indentation = nil
  @line = next_line
  resolve_newlines
  newline
  raise SyntaxError.new("Indenting at the beginning of the document is illegal.", @line.index) if @line.tabs != 0
  while next_line
    process_indent(@line) unless @line.text.empty?
    if flat?
      push_flat(@line)
      @line = @next_line
      next
    end
    process_line(@line.text, @line.index) unless @line.text.empty? || @haml_comment
    if !flat? && @next_line.tabs - @line.tabs > 1
      raise SyntaxError.new("The line was indented #{@next_line.tabs - @line.tabs} levels deeper than the previous line.", @next_line.index)
    end
    resolve_newlines unless @next_line.eod?
    @line = @next_line
    newline unless @next_line.eod?
  end
  # Close all the open tags
  close until @to_close_stack.empty?
  flush_merged_text
end