-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Description
using Ruby 2.5 on Windows. I am testing simple Addition grammar to get the value from extension. Here is the output
irb(main):001:0> require 'citrus'
=> true
irb(main):002:0> Citrus.load 'addition'
=> [Addition]
irb(main):003:0> m = Addition.parse '1 + 2 + 3'
=> "1 + 2 + 3"
irb(main):004:0> m.inspect
=> "\"1 + 2 + 3\""
irb(main):005:0> puts m.value
Traceback (most recent call last):
3: from D:/ruby/ruby_packages_nobk/rubyinstaller-2.5.0-1-x64/bin/irb.cmd:19:in `<main>'
2: from (irb):5
1: from <main>:1:in `block in <main>'
NameError (undefined local variable or method `number' for "1 + 2 + 3":Citrus::Match)
irb(main):006:0>
I modified grammar a little and it can work but look not clean as before.
grammar Addition
rule additive
(number plus term:(additive | number)) {
capture("number").value + capture("term").value
}
end
rule number
([0-9]+ space) {
to_s.to_i
}
end
rule plus
'+' space
end
rule space
[ \t]*
end
end
can you check why the previous not working?
Metadata
Metadata
Assignees
Labels
No labels