Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken extension on Ruby 2.5 #56

Open
vnluc opened this issue Jan 26, 2018 · 1 comment
Open

Broken extension on Ruby 2.5 #56

vnluc opened this issue Jan 26, 2018 · 1 comment

Comments

@vnluc
Copy link

vnluc commented Jan 26, 2018

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?

@rafaelbiriba
Copy link

no solution for this yet? 😢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants