Various little fixes
This commit is contained in:
parent
202d841be4
commit
4d1cadd4f6
2 changed files with 10 additions and 23 deletions
|
@ -6,6 +6,7 @@ require 'thor'
|
||||||
require 'rly'
|
require 'rly'
|
||||||
require 'pry'
|
require 'pry'
|
||||||
require 'mm2ep_depend'
|
require 'mm2ep_depend'
|
||||||
|
require 'pp'
|
||||||
|
|
||||||
module Mm2ep
|
module Mm2ep
|
||||||
module Depend
|
module Depend
|
||||||
|
@ -17,7 +18,7 @@ module Mm2ep
|
||||||
parser = Parser.new(Lexer.new)
|
parser = Parser.new(Lexer.new)
|
||||||
puts line.inspect
|
puts line.inspect
|
||||||
token = parser.parse(line.chomp, true)
|
token = parser.parse(line.chomp, true)
|
||||||
puts token
|
pp token
|
||||||
# puts false && true
|
# puts false && true
|
||||||
# puts false || false
|
# puts false || false
|
||||||
# binding.pry
|
# binding.pry
|
||||||
|
|
|
@ -40,7 +40,6 @@ module Mm2ep
|
||||||
end
|
end
|
||||||
|
|
||||||
class AndOp < TreeExpr
|
class AndOp < TreeExpr
|
||||||
attr_reader :expr1, :expr2
|
|
||||||
def initialize expr1, expr2
|
def initialize expr1, expr2
|
||||||
@expr1 = expr1
|
@expr1 = expr1
|
||||||
@expr2 = expr2
|
@expr2 = expr2
|
||||||
|
@ -53,47 +52,34 @@ module Mm2ep
|
||||||
end
|
end
|
||||||
|
|
||||||
class OrOp
|
class OrOp
|
||||||
attr_reader :expr1, :expr2
|
|
||||||
def initialize expr1, expr2
|
def initialize expr1, expr2
|
||||||
unless expr1.value.to_s.match(/true/).nil?
|
@expr1 = expr1
|
||||||
@expr1 = true
|
@expr2 = expr2
|
||||||
else
|
|
||||||
@expr1 = false
|
|
||||||
end
|
|
||||||
unless expr2.value.to_s.match(/true/).nil?
|
|
||||||
@expr2 = true
|
|
||||||
else
|
|
||||||
@expr2 = false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def compute
|
def compute
|
||||||
return @expr1 || @expr2
|
return @expr1.compute || @expr2.compute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class NotOp
|
class NotOp
|
||||||
attr_reader :expr
|
|
||||||
def initialize expr
|
def initialize expr
|
||||||
@expr = expr
|
@expr = expr
|
||||||
end
|
end
|
||||||
|
|
||||||
def compute
|
def compute
|
||||||
# binding.pry
|
return ! @expr.compute
|
||||||
return true unless @expr.value.to_s.eql? 'true'
|
|
||||||
return false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class EqOp
|
class EqOp
|
||||||
attr_reader :val, :other
|
def initialize lval, rval
|
||||||
def initialize var, value
|
@lval = lval
|
||||||
@var = var
|
@rval = rval
|
||||||
@value = value
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def compute
|
def compute
|
||||||
return if @val.value == @other.value
|
return if @lval.value == @rval.value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue