Ignore space
This commit is contained in:
parent
b89add6adf
commit
9fac1514c9
3 changed files with 62 additions and 59 deletions
|
@ -2,7 +2,9 @@ module Mm2ep
|
||||||
module Depend
|
module Depend
|
||||||
class Lexer < Rly::Lex
|
class Lexer < Rly::Lex
|
||||||
|
|
||||||
token :SPACE, /\s+/
|
ignore "\t\n "
|
||||||
|
|
||||||
|
# token :SPACE, /\s+/
|
||||||
token :L_PAR, /\(/
|
token :L_PAR, /\(/
|
||||||
token :R_PAR, /\)/
|
token :R_PAR, /\)/
|
||||||
token :NUMBER, /[0-9]+(\.[0-9]+)?/
|
token :NUMBER, /[0-9]+(\.[0-9]+)?/
|
||||||
|
|
|
@ -148,43 +148,43 @@ module Mm2ep
|
||||||
ex.value = BoolValue.new(l.value.to_s)
|
ex.value = BoolValue.new(l.value.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : NOT_OP SPACE expr %prec UMINUS' do |ex, l, s, e|
|
rule 'expr : NOT_OP expr %prec UMINUS' do |ex, l, e|
|
||||||
ex.value = NotOp.new(e.value)
|
ex.value = NotOp.new(e.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : expr SPACE AND_OP SPACE expr' do |ex, l, s, e, sp, r|
|
rule 'expr : expr AND_OP expr' do |ex, l, e, r|
|
||||||
ex.value = AndOp.new(l.value, r.value)
|
ex.value = AndOp.new(l.value, r.value)
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : expr SPACE OR_OP SPACE expr' do |ex, l, s, e, sp, r|
|
rule 'expr : expr OR_OP expr' do |ex, l, e, r|
|
||||||
ex.value = OrOp.new(l.value, r.value)
|
ex.value = OrOp.new(l.value, r.value)
|
||||||
end
|
end
|
||||||
rule 'expr : L_PAR SPACE expr SPACE R_PAR' do |ex, l, s, e, sp, r|
|
rule 'expr : L_PAR expr R_PAR' do |ex, l, e, r|
|
||||||
ex.value = e.value
|
ex.value = e.value
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : VAR SPACE EQ_OP SPACE F_BOOL' do |ex, v, s, eq, _, n|
|
rule 'expr : VAR EQ_OP F_BOOL' do |ex, v, eq, n|
|
||||||
ex.value = EqOp.new(
|
ex.value = EqOp.new(
|
||||||
VarValue.new(v.value.to_s),
|
VarValue.new(v.value.to_s),
|
||||||
BoolValue.new(n.value)
|
BoolValue.new(n.value)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : VAR SPACE EQ_OP SPACE T_BOOL' do |ex, v, s, eq, _, n|
|
rule 'expr : VAR EQ_OP T_BOOL' do |ex, v, eq, n|
|
||||||
ex.value = EqOp.new(
|
ex.value = EqOp.new(
|
||||||
VarValue.new(v.value.to_s),
|
VarValue.new(v.value.to_s),
|
||||||
BoolValue.new(n.value)
|
BoolValue.new(n.value)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : VAR SPACE EQ_OP SPACE STRING' do |ex, v, s, eq, _, n|
|
rule 'expr : VAR EQ_OP STRING' do |ex, v, eq, n|
|
||||||
ex.value = EqOp.new(
|
ex.value = EqOp.new(
|
||||||
VarValue.new(v.value.to_s),
|
VarValue.new(v.value.to_s),
|
||||||
StringValue.new(n.value)
|
StringValue.new(n.value)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
rule 'expr : VAR SPACE EQ_OP SPACE NUMBER' do |ex, v, s, eq, _, n|
|
rule 'expr : VAR EQ_OP NUMBER' do |ex, v, eq, n|
|
||||||
ex.value = EqOp.new(
|
ex.value = EqOp.new(
|
||||||
VarValue.new(v.value.to_s),
|
VarValue.new(v.value.to_s),
|
||||||
NumberValue.new(n.value)
|
NumberValue.new(n.value)
|
||||||
|
|
1
spec/files/test5.txt
Normal file
1
spec/files/test5.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
truc bidule
|
Loading…
Reference in a new issue