Use *Value classes
This commit is contained in:
parent
390caddd52
commit
56160042e8
1 changed files with 21 additions and 7 deletions
|
@ -94,10 +94,12 @@ module Mm2ep
|
||||||
class EqOp
|
class EqOp
|
||||||
attr_reader :val, :other
|
attr_reader :val, :other
|
||||||
def initialize var, value
|
def initialize var, value
|
||||||
|
@var = var
|
||||||
|
@value = value
|
||||||
end
|
end
|
||||||
|
|
||||||
def compute
|
def compute
|
||||||
return if val.value == @other.value
|
return if @val.value == @other.value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -118,11 +120,11 @@ module Mm2ep
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : T_BOOL' do |ex, l|
|
rule 'expr : T_BOOL' do |ex, l|
|
||||||
ex.value = BoolExpr.new(l.value)
|
ex.value = BoolValue.new(l.value.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : F_BOOL' do |ex, l|
|
rule 'expr : F_BOOL' do |ex, l|
|
||||||
ex.value = BoolExpr.new(l.value)
|
ex.value = BoolValue.new(l.value.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : NOT_OP SPACE expr' do |ex, l, s, e|
|
rule 'expr : NOT_OP SPACE expr' do |ex, l, s, e|
|
||||||
|
@ -141,19 +143,31 @@ module Mm2ep
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : VAR SPACE EQ_OP SPACE F_BOOL' do |ex, v, s, eq, _, n|
|
rule 'expr : VAR SPACE EQ_OP SPACE F_BOOL' do |ex, v, s, eq, _, n|
|
||||||
ex.value = EqOp.new(v.value, n.value)
|
ex.value = EqOp.new(
|
||||||
|
VarValue.new(v.value.to_s),
|
||||||
|
BoolValue.new(n.value)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : VAR SPACE EQ_OP SPACE T_BOOL' do |ex, v, s, eq, _, n|
|
rule 'expr : VAR SPACE EQ_OP SPACE T_BOOL' do |ex, v, s, eq, _, n|
|
||||||
ex.value = EqOp.new(v.value, n.value)
|
ex.value = EqOp.new(
|
||||||
|
VarValue.new(v.value.to_s),
|
||||||
|
BoolValue.new(n.value)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : VAR SPACE EQ_OP SPACE STRING' do |ex, v, s, eq, _, n|
|
rule 'expr : VAR SPACE EQ_OP SPACE STRING' do |ex, v, s, eq, _, n|
|
||||||
ex.value = EqOp.new(v.value, n.value)
|
ex.value = EqOp.new(
|
||||||
|
VarValue.new(v.value.to_s),
|
||||||
|
StringValue.new(n.value)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : VAR SPACE EQ_OP SPACE NUMBER' do |ex, v, s, eq, _, n|
|
rule 'expr : VAR SPACE EQ_OP SPACE NUMBER' do |ex, v, s, eq, _, n|
|
||||||
ex.value = EqOp.new(v.value, n.value)
|
ex.value = EqOp.new(
|
||||||
|
VarValue.new(v.value.to_s),
|
||||||
|
NumberValue.new(n.value)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
end # class
|
end # class
|
||||||
|
|
Loading…
Reference in a new issue