chriswailes / RLTK

The Ruby Language Toolkit
http://chriswailes.github.io/RLTK/
University of Illinois/NCSA Open Source License
453 stars 35 forks source link

undefined method 'subclass_of?', no such file or directory #63

Open SlashScreen opened 1 year ago

SlashScreen commented 1 year ago

I've been following the tutorial to build Kazoo, but have come across 2 problems: 1) When finalizing, if the .tbl file exists, it gives me this stack trace:

S:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rltk-3.0.1/lib/rltk/parser.rb:568:in `mtime': No such file or directory @ rb_file_s_mtime - J (Errno::ENOENT)
        from S:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rltk-3.0.1/lib/rltk/parser.rb:568:in `finalize'
        from J:/Programs/ruby/beetbasicrb/parser.rb:58:in `<class:Parser>'
        from J:/Programs/ruby/beetbasicrb/parser.rb:4:in `<module:BeetBasic>'
        from J:/Programs/ruby/beetbasicrb/parser.rb:3:in `<top (required)>'
        from <internal:S:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:S:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from main.rb:4:in `<main>'

My parser.rb calls

finalize({:use => 'bbparser.tbl'})

and my directory structure looks like: image When I delete the file, it generates as planned.

2) When it gets past the tbl issue, it gives me the following trace:

S:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/rltk-3.0.1/lib/rltk/ast.rb:120:in `child': undefined method `subclass_of?' for BeetBasic::Expression:Class (NoMethodError)

                                if not t.subclass_of?(ASTNode)
                                        ^^^^^^^^^^^^^
Did you mean?  subclasses
        from J:/Programs/ruby/beetbasicrb/ast.rb:17:in `<class:Binary>'
        from J:/Programs/ruby/beetbasicrb/ast.rb:16:in `<module:BeetBasic>'
        from J:/Programs/ruby/beetbasicrb/ast.rb:3:in `<top (required)>'
        from <internal:S:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from <internal:S:/Ruby31-x64/lib/ruby/3.1.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
        from main.rb:5:in `<main>'

I guess they must have removed this method? I'm defining Expression and Binary like this:

class Expression < RLTK::ASTNode; end
#...
class Binary < Expression
        child :left, Expression #* child is a method that takes a symbol and a type. The lack of parenthesis is kiling me.
        child :right, Expression
    end

I don't think I can fix this one on my end.

I'm new to Ruby (although not new to programming) so if I made a rookie mistake let me know. I'm using the Gem version of RLTK and the latest release of Ruby, if that wasn't clear. If you need a closer look, this project is a public repo.

SlashScreen commented 1 year ago

Noticed that a lot of these issues have been fixed (relatively) recently, but the gem hasn't been updated since 2015. I'll build this gem locally and use it myself for now, but I think a new official one should be built.

SlashScreen commented 1 year ago

If anyone else wants to build their own gemfile, it's pretty easy: 1) Clone the repo 2) cd into it/open a terminal into it 3) run gem build 4) The gem file is now in the directory. Run sudo gem install ./[gem filename] You're good to go.