rubysolo/dentaku

Dentaku::ParseError when using basic operators with Ruby Math module methods

dhnaranjo opened this issue · 2 comments

Hello! So, I'm truly amazed at my capacity to mess up simple things. I'm getting a Dentaku::ParseError when running real simple equations, ex Dentakuk::Calculator.new.evaluate!('EXP(1)+1'). I get the same result across a number of Math module methods (SIN COS TAN) and basic ops (- * /).

I am on an Apple Silicon / M1 processor device. Dunno if that's relevant, but I feel like the error I'm seeing is so like... fundamental that maybe it's related.

Full trace below:

irb(main):037:0> c = Dentaku::Calculator.new
=> #<Dentaku::Calculator:0x00007fefe0855098 @memory={}, @tokenizer=#<Dentaku::Tokenizer:0x00007fefe0854e40>, @case_sensitive=nil, @aliases={}, @nested_data_support=true, @ast_cache={}, @disable_ast_cache=false, @function_registry={}>
irb(main):038:0> c.evaluate!('EXP(1)+1')
Traceback (most recent call last):
       16: from /Users/dazmin/.gem/ruby/2.6.6/gems/railties-5.0.7.2/lib/rails/commands.rb:18:in `<top (required)>'
       15: from /Users/dazmin/.gem/ruby/2.6.6/gems/railties-5.0.7.2/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
       14: from /Users/dazmin/.gem/ruby/2.6.6/gems/railties-5.0.7.2/lib/rails/commands/commands_tasks.rb:78:in `console'
       13: from /Users/dazmin/.gem/ruby/2.6.6/gems/railties-5.0.7.2/lib/rails/commands/console_helper.rb:9:in `start'
       12: from /Users/dazmin/.gem/ruby/2.6.6/gems/railties-5.0.7.2/lib/rails/commands/console.rb:65:in `start'
       11: from (irb):38
       10: from /Users/dazmin/.gem/ruby/2.6.6/gems/dentaku-3.4.1/lib/dentaku/calculator.rb:59:in `evaluate!'
        9: from /Users/dazmin/.gem/ruby/2.6.6/gems/dentaku-3.4.1/lib/dentaku/calculator.rb:140:in `store'
        8: from /Users/dazmin/.gem/ruby/2.6.6/gems/dentaku-3.4.1/lib/dentaku/calculator.rb:61:in `block in evaluate!'
        7: from /Users/dazmin/.gem/ruby/2.6.6/gems/dentaku-3.4.1/lib/dentaku/calculator.rb:95:in `ast'
        6: from /Users/dazmin/.gem/ruby/2.6.6/gems/dentaku-3.4.1/lib/dentaku/calculator.rb:95:in `fetch'
        5: from /Users/dazmin/.gem/ruby/2.6.6/gems/dentaku-3.4.1/lib/dentaku/calculator.rb:103:in `block in ast'
        4: from /Users/dazmin/.gem/ruby/2.6.6/gems/dentaku-3.4.1/lib/dentaku/parser.rb:286:in `parse'
        3: from /Users/dazmin/.gem/ruby/2.6.6/gems/dentaku-3.4.1/lib/dentaku/parser.rb:38:in `consume'
        2: from /Users/dazmin/.gem/ruby/2.6.6/gems/dentaku-3.4.1/lib/dentaku/parser.rb:61:in `rescue in consume'
        1: from /Users/dazmin/.gem/ruby/2.6.6/gems/dentaku-3.4.1/lib/dentaku/parser.rb:339:in `fail!'
Dentaku::ParseError (Dentaku::AST::Addition requires numeric operands, but got )
irb(main):039:0> 

It's not you, it's me! Thanks for reporting this, it's fixed now.

Appreciate you.