From 56160042e833edbb92223cad2351f6cb3fa5ace9 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Tue, 12 Sep 2017 16:16:57 +0200 Subject: [PATCH] Use *Value classes --- lib/mm2ep_depend/parser.rb | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/lib/mm2ep_depend/parser.rb b/lib/mm2ep_depend/parser.rb index af9002c..b328fbe 100755 --- a/lib/mm2ep_depend/parser.rb +++ b/lib/mm2ep_depend/parser.rb @@ -94,10 +94,12 @@ module Mm2ep class EqOp attr_reader :val, :other def initialize var, value + @var = var + @value = value end def compute - return if val.value == @other.value + return if @val.value == @other.value end end @@ -118,11 +120,11 @@ module Mm2ep end rule 'expr : T_BOOL' do |ex, l| - ex.value = BoolExpr.new(l.value) + ex.value = BoolValue.new(l.value.to_s) end rule 'expr : F_BOOL' do |ex, l| - ex.value = BoolExpr.new(l.value) + ex.value = BoolValue.new(l.value.to_s) end rule 'expr : NOT_OP SPACE expr' do |ex, l, s, e| @@ -141,19 +143,31 @@ module Mm2ep end 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 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 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 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 # class