2017-09-04 09:19:29 +00:00
|
|
|
module Mm2ep
|
|
|
|
module Depend
|
2017-09-07 15:05:06 +00:00
|
|
|
class Parser < Rly::Yacc
|
|
|
|
|
2017-09-11 08:13:30 +00:00
|
|
|
precedence :left, 'OR_OP', 'EQ_OP'
|
|
|
|
precedence :right, 'AND_OP', 'NOT_OP'
|
|
|
|
|
2017-09-07 15:05:06 +00:00
|
|
|
rule 'statement : expr' do |st, e|
|
|
|
|
st.value = e.value
|
|
|
|
end
|
|
|
|
|
2017-09-11 08:13:30 +00:00
|
|
|
rule 'expr : VAR' do |ex, l|
|
|
|
|
ex.value = l.value
|
|
|
|
end
|
|
|
|
|
|
|
|
rule 'expr : T_BOOL' do |ex, l|
|
|
|
|
ex.value = l.value
|
|
|
|
end
|
|
|
|
|
|
|
|
rule 'expr : F_BOOL' do |ex, l|
|
|
|
|
ex.value = l.value
|
|
|
|
end
|
|
|
|
|
2017-09-07 15:05:06 +00:00
|
|
|
rule 'expr : NOT_OP SPACE expr' do |ex, l, s, e|
|
|
|
|
ex.value = "#{l.value} #{s.value} #{e.value}"
|
|
|
|
end
|
|
|
|
|
|
|
|
rule 'expr : expr SPACE AND_OP SPACE expr' do |ex, l, s, e, sp, r|
|
|
|
|
ex.value = "#{l.value} #{s.value} #{e.value} #{sp.value} #{r.value}"
|
|
|
|
end
|
|
|
|
|
|
|
|
rule 'expr : expr SPACE OR_OP SPACE expr' do |ex, l, s, e, sp, r|
|
|
|
|
ex.value = "#{l.value} #{s.value} #{e.value} #{sp.value} #{r.value}"
|
|
|
|
end
|
|
|
|
rule 'expr : L_PAR SPACE expr SPACE R_PAR' do |ex, l, s, e, sp, r|
|
|
|
|
ex.value = "#{l.value} #{s.value} #{e.value} #{sp.value} #{r.value}"
|
|
|
|
end
|
|
|
|
|
|
|
|
rule 'expr : VAR SPACE EQ_OP SPACE F_BOOL' do |ex, v, s, eq, _, n|
|
|
|
|
ex.value = "#{v.value} #{s.value} #{eq.value} #{s.value} #{n.value}"
|
|
|
|
end
|
|
|
|
|
|
|
|
rule 'expr : VAR SPACE EQ_OP SPACE T_BOOL' do |ex, v, s, eq, _, n|
|
|
|
|
ex.value = "#{v.value} #{s.value} #{eq.value} #{s.value} #{n.value}"
|
|
|
|
end
|
|
|
|
|
|
|
|
rule 'expr : VAR SPACE EQ_OP SPACE STRING' do |ex, v, s, eq, _, n|
|
|
|
|
ex.value = "#{v.value} #{s.value} #{eq.value} #{s.value} #{n.value}"
|
|
|
|
end
|
|
|
|
|
|
|
|
rule 'expr : VAR SPACE EQ_OP SPACE NUMBER' do |ex, v, s, eq, _, n|
|
|
|
|
ex.value = "#{v.value} #{s.value} #{eq.value} #{s.value} #{n.value}"
|
|
|
|
end
|
|
|
|
|
2017-09-04 09:19:29 +00:00
|
|
|
end # class
|
|
|
|
end # module
|
|
|
|
end # module
|