Giter Club home page Giter Club logo

parser-prism's People

Contributors

hparker avatar kddnewton avatar maxprokopiev avatar takaram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

parser-prism's Issues

An error occurs when using partial assignment with the splat operator

"Partial assignment with the splat operator" syntax that can be parsed by the Parser gem results in an error with parser-prism:

Expected: The Parser gem

No errors and it can be parsed:

$ ruby-parse --33 -e 'expression, = *node'
(masgn
  (mlhs
    (lvasgn :expression))
  (array
    (splat
      (send nil :node))))

Actual: parser-prism

The following error occurs:

% ruby -v
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin22]
$ ruby -rparser/prism -e 'p Parser::Prism.parse("expression, = *node")'
/Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-prism-0.1.0/lib/parser/prism/compiler.rb:758:in `visit_implicit_rest_node': Cannot directly compile implicit rest nodes (RuntimeError)
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/prism-0.19.0/lib/prism/node.rb:8058:in `accept'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/prism-0.19.0/lib/prism/compiler.rb:34:in `block in visit_all'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/prism-0.19.0/lib/prism/compiler.rb:34:in `map'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/prism-0.19.0/lib/prism/compiler.rb:34:in `visit_all'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-prism-0.1.0/lib/parser/prism/compiler.rb:1083:in `visit_multi_write_node'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/prism-0.19.0/lib/prism/node.rb:12275:in `accept'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/prism-0.19.0/lib/prism/compiler.rb:34:in `block in visit_all'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/prism-0.19.0/lib/prism/compiler.rb:34:in `map'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/prism-0.19.0/lib/prism/compiler.rb:34:in `visit_all'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-prism-0.1.0/lib/parser/prism/compiler.rb:1407:in `visit_statements_node'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/prism-0.19.0/lib/prism/node.rb:15784:in `accept'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-prism-0.1.0/lib/parser/prism/compiler.rb:1231:in `visit_program_node'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/prism-0.19.0/lib/prism/node.rb:13913:in `accept'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-prism-0.1.0/lib/parser/prism.rb:109:in `build_ast'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-prism-0.1.0/lib/parser/prism.rb:31:in `parse'
        from /Users/koic/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/parser-3.3.0.5/lib/parser/base.rb:33:in `parse'
        from -e:1:in `<main>'

The same error also occurs with the combination of Ruby 3.0 and parser-prism.

Easier way to experiment with this gem

I just want to document what I used to not need Bundler as that makes it rather impratical:

git clone this-repo
cd parser-prism
gem build parser-prism.gemspec    
gem install parser-prism-*.gem

cd wherever
Change TargetRubyVersion in .rubocop.yml
time rubocop -rparser/prism/rubocop --cache=false FILES

It'd be great to add this to the README, unfortunately I don't have time for that right now.

key not found: :PERCENT_EQUAL

I was trying this on ruby/spec and I got this error:

$ cd rubyspec
$ git remote add eregon [email protected]:eregon/rubyspec.git
$ git checkout parser-yarp
$ bundle exec ruby -rparser/yarp/rubocop -r./check $(bundle show rubocop)/exe/rubocop --cache false language
Inspecting 157 files
[24001715.33, 24001715.33, true]
.[24001715.33, 24001715.33, true]
...
13 files inspected, no offenses detected
key not found: :PERCENT_EQUAL
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/bundler/gems/parser-yarp-6575613f26ec/lib/parser/yarp/lexer.rb:175:in `fetch'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/bundler/gems/parser-yarp-6575613f26ec/lib/parser/yarp/lexer.rb:175:in `to_a'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/bundler/gems/parser-yarp-6575613f26ec/lib/parser/yarp.rb:83:in `build_tokens'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/bundler/gems/parser-yarp-6575613f26ec/lib/parser/yarp.rb:57:in `tokenize'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.29.0/lib/rubocop/ast/processed_source.rb:215:in `tokenize'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.29.0/lib/rubocop/ast/processed_source.rb:210:in `parse'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.29.0/lib/rubocop/ast/processed_source.rb:38:in `initialize'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.29.0/lib/rubocop/ast/processed_source.rb:23:in `new'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-ast-1.29.0/lib/rubocop/ast/processed_source.rb:23:in `from_file'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:478:in `get_processed_source'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:273:in `do_inspection_loop'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:164:in `block in file_offenses'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:189:in `file_offense_cache'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:163:in `file_offenses'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:154:in `process_file'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:135:in `block in each_inspected_file'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:134:in `each'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:134:in `reduce'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:134:in `each_inspected_file'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:120:in `inspect_files'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/runner.rb:73:in `run'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli/command.rb:11:in `run'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli/environment.rb:18:in `run'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli.rb:118:in `run_command'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli.rb:125:in `execute_runners'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli.rb:51:in `block in run'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli.rb:77:in `profile_if_needed'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/lib/rubocop/cli.rb:43:in `run'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/exe/rubocop:19:in `block in <main>'
/home/eregon/.rubies/ruby-3.2.2/lib/ruby/3.2.0/benchmark.rb:311:in `realtime'
/home/eregon/code/rubyspec/vendor/bundle/ruby/3.2.0/gems/rubocop-1.56.3/exe/rubocop:19:in `<main>'

And FWIW running without this gem (and changing to TargetRubyVersion: 3.3):

$ bundle exec rubocop --cache false language
Inspecting 157 files
.............................................................................................................................................................

157 files inspected, no offenses detected
bundle exec rubocop --cache false language  3.83s user 0.09s system 99% cpu 3.935 total

String and Xstring literal with multiple lines returns incompatible result

Hi, I am experimenting to apply parser-prism to Opal.
During the experiment, I noticed some strings are parsed differently than parser gem.

Given this script:

"foo
bar"

%x{
  date
}

Parse result by whitequark/parser:

(begin
  (dstr
    (str "foo\n")
    (str "bar"))
  (xstr
    (str "\n")
    (str "  date\n")))

Parse result by parser-prism

(begin
  (str "foo\nbar")
  (xstr
    (str "\n  date\n")))

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.