Switch to case-implementation of parser
This commit is contained in:
		@@ -10,7 +10,7 @@ module Skeksis
 | 
			
		||||
  extend self
 | 
			
		||||
 | 
			
		||||
  def htmlize(data)
 | 
			
		||||
    puts Skeksis::Parser.parse(data).htmlize
 | 
			
		||||
    #puts Skeksis::Parser.parse(data).htmlize
 | 
			
		||||
    Skeksis::Parser.parse(data).htmlize
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 
 | 
			
		||||
@@ -59,7 +59,7 @@ module Skeksis
 | 
			
		||||
    extend self
 | 
			
		||||
 | 
			
		||||
    def parse(input)
 | 
			
		||||
      #puts("##### PARSING STARTED #####")
 | 
			
		||||
      puts("##### PARSING STARTED #####")
 | 
			
		||||
 | 
			
		||||
      list = IR.new
 | 
			
		||||
 | 
			
		||||
@@ -69,28 +69,48 @@ module Skeksis
 | 
			
		||||
      content = []
 | 
			
		||||
      data.each do |line|
 | 
			
		||||
        type = get_type(line)
 | 
			
		||||
        if type == :verbatim and in_verbatim_block == false
 | 
			
		||||
          in_verbatim_block = true
 | 
			
		||||
          content.push(line)
 | 
			
		||||
        elsif type != :verbatim and in_verbatim_block == true
 | 
			
		||||
          content.push(line)
 | 
			
		||||
        elsif type == :verbatim and in_verbatim_block == true
 | 
			
		||||
          in_verbatim_block = false
 | 
			
		||||
          content.push(line)
 | 
			
		||||
          list.push({ type: :verbatim, content: content })
 | 
			
		||||
          content = []
 | 
			
		||||
          next
 | 
			
		||||
 | 
			
		||||
        case type
 | 
			
		||||
        when :verbatim
 | 
			
		||||
          if in_verbatim_block == false
 | 
			
		||||
            in_verbatim_block = true
 | 
			
		||||
            content.push(line)
 | 
			
		||||
          elsif in_verbatim_block == true
 | 
			
		||||
            in_verbatim_block = false
 | 
			
		||||
            content.push(line)
 | 
			
		||||
            list.push({ type: :verbatim, content: content })
 | 
			
		||||
            content = []
 | 
			
		||||
            next
 | 
			
		||||
          end
 | 
			
		||||
        else
 | 
			
		||||
          if in_verbatim_block == true
 | 
			
		||||
            content.push(line)
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        #if type == :verbatim and in_verbatim_block == false
 | 
			
		||||
        #  in_verbatim_block = true
 | 
			
		||||
        #  content.push(line)
 | 
			
		||||
        #elsif type != :verbatim and in_verbatim_block == true
 | 
			
		||||
        #  content.push(line)
 | 
			
		||||
        #elsif type == :verbatim and in_verbatim_block == true
 | 
			
		||||
        #  in_verbatim_block = false
 | 
			
		||||
        #  content.push(line)
 | 
			
		||||
        #  list.push({ type: :verbatim, content: content })
 | 
			
		||||
        #  content = []
 | 
			
		||||
        #  next
 | 
			
		||||
        #end
 | 
			
		||||
        
 | 
			
		||||
        if in_verbatim_block == false
 | 
			
		||||
          list.push({ type: type, content: [line] })
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      list.strip_markers!
 | 
			
		||||
      #puts list
 | 
			
		||||
      puts list
 | 
			
		||||
      #puts strip_markers(list)
 | 
			
		||||
      #puts("##### PARSING FINISHED #####")
 | 
			
		||||
      puts("##### PARSING FINISHED #####")
 | 
			
		||||
 | 
			
		||||
      list
 | 
			
		||||
    end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user