Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Converting AST

Converting AST

After RubyKaigi 2024 LR Parser Night w/ Asakusa.rb
https://andpad.connpass.com/event/321580/

yui-knk

June 25, 2024
Tweet

More Decks by yui-knk

Other Decks in Programming

Transcript

  1. Converting AST June 25, 2024 After RubyKaigi 2024 LR Parser

    Night w/ Asakusa.rb @yui-knk Yuichiro Kaneko
  2. About me Yuichiro Kaneko yui-knk (GitHub) / spikeolaf (Twitter) Treasure

    Data Engineering Manager of Applications Backend CRuby committer, mainly develop parser generator and parser Lrama LALR (1) parser generator (2023, Ruby 3.3) Love LR parser
  3. May 15th - 17th, 2024 NAHA CULTURAL ARTS THEATER NAHArt,

    Okinawa, Japan The Bison Slayer The parser monster Parser界の黎明卿 The world is now in the great age of parsers. People are setting sail into the vast sea of parsers. - RubyKaigi 2023 LT- Yuichiro Kaneko https://twitter.com/kakutani/status/1657762294431105025/ NEW !!! NEW !!!
  4. ast_to_prism https://github.com/yui-knk/ast_to_prism Converts RubyVM::AST to Prism::Node Motivations Provide the compatible

    layer Clarify the difference between current Node and Prism Node Send feedbacks to current struct RNode Writing codes is easier than writing docs It may heavily depend on ruby master branch
  5. The position of ast_to_prism This is a missing piece Source

    code RubyVM::AST::Node parse.y struct rb_ast_struct struct RNode ast.c Prism::Node ast_to_prism Parser::AST::Node Prism::Translation::Parser RuboCop <<uses>>
  6. How ast_to_prism works “convert” method is a large case statement

    Some node types are supported, others are not
  7. Insuf fi cient information Simply, add them to nodes RNode

    is already free from 3 fields restriction
  8. How to develop Add test cases to “spec/basic_spec.rb” Implement it

    on “lib/ast_to_prism/parser.rb” If test passes OK. Go next NG. “pending” test case Create PR to ruby/ruby
  9. If you can not implement pending test case Investigate the

    reason why it can not Create PR to ruby/ruby Implement the conversion logic after merge