Sha256: 77a25de1f335d67ee993738d9bc19ec138cb3939aba053c3d06cabac3a81d059

Contents?: true

Size: 971 Bytes

Versions: 8

Compression:

Stored size: 971 Bytes

Contents

module Hilbert
  module Parser
    class WorldParser
      @@parsed_ary = []
      @@stage
      class << self
        def execute(lexeds)
          clear!

          lexeds.each do |lexed|
            parsed =  case lexed[:token]
                      when :DISJ   then ' + '
                      when :CONJ   then ' * '
                      when :COND   then ' >= '
                      when :BICO   then ' <=> '
                      when :PROVAR then "$world.atom(:#{lexed[:value]})"
                      when :NEGA   then " ~"
                      else              lexed[:value]
                      end

            push(parsed)
          end
        end

        def push(parsed)
          if parsed
            @@parsed_ary << parsed
          else
            @@stage << lexed
          end
        end

        def parsed_srt
          @@parsed_ary.join
        end

        def clear!
          @@parsed_ary = []
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hilbert-0.0.2700420 lib/hilbert/parser/world_parser.rb
hilbert-0.0.2700410 lib/hilbert/parser/world_parser.rb
hilbert-0.0.2700400 lib/hilbert/parser/world_parser.rb
hilbert-0.0.2700320 lib/hilbert/parser/world_parser.rb
hilbert-0.0.2700300 lib/hilbert/parser/world_parser.rb
hilbert-0.0.2700210 lib/hilbert/parser/world_parser.rb
hilbert-0.0.2700110 lib/hilbert/parser/world_parser.rb
hilbert-0.0.2700100 lib/hilbert/parser/world_parser.rb