Fix AND evaluation

This commit is contained in:
Glenn Y. Rolland 2017-09-12 17:52:38 +02:00
parent 12b310b7c2
commit e76e11535d

View file

@ -124,10 +124,10 @@ module Mm2ep
class Parser < Rly::Yacc
precedence :left, 'OR_OP'
precedence :left, 'AND_OP'
precedence :left, 'EQ_OP'
precedence :left, 'L_PAR', 'R_PAR'
precedence :left, :OR_OP
precedence :left, :AND_OP
precedence :left, :EQ_OP
precedence :right, :L_PAR, :R_PAR
precedence :right, :UMINUS
rule 'statement : expr' do |st, e|
@ -153,13 +153,14 @@ module Mm2ep
ex.value = NotOp.new(e.value)
end
rule 'expr : expr OR_OP expr' do |ex, l, e, r|
ex.value = OrOp.new(l.value, r.value)
end
rule 'expr : expr AND_OP expr' do |ex, l, e, r|
ex.value = AndOp.new(l.value, r.value)
end
rule 'expr : expr OR_OP expr' do |ex, l, e, r|
ex.value = OrOp.new(l.value, r.value)
end
rule 'expr : L_PAR expr R_PAR' do |ex, l, e, r|
ex.value = e.value
end