Class: Hilbert::Parser::WorldParser

Inherits:
Object
  • Object
show all
Defined in:
lib/hilbert/parser/world_parser.rb

Constant Summary collapse

@@parsed_ary =
[]

Class Method Summary collapse

Class Method Details

.clear!Object



37
38
39
# File 'lib/hilbert/parser/world_parser.rb', line 37

def clear!
  @@parsed_ary = []
end

.execute(lexeds) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/hilbert/parser/world_parser.rb', line 7

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

.parsed_srtObject



33
34
35
# File 'lib/hilbert/parser/world_parser.rb', line 33

def parsed_srt
  @@parsed_ary.join
end

.push(parsed) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/hilbert/parser/world_parser.rb', line 25

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