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

Ruby Parser Basics

ydah
February 05, 2024

Ruby Parser Basics

Kyobashi.rb Offline #1 『Ruby Parser Basics』のスライド
https://kyobashirb.connpass.com/event/307312/

ydah

February 05, 2024
Tweet

More Decks by ydah

Other Decks in Technology

Transcript

  1. Ruby Parser Basics @y d a h Ky ob a

    sh i .r b Of f l i ne #1 2 02 4 .0 2 .0 5 (Mo n .)
  2. ɾ Name: Yudai Takada ɾ GitHub: @ydah / X: @ydah_

    ɾ Software Engineer at ANDPAD, Inc. ɾ Co-Founder of Kyobashi.rb ɾ Member of RuboCop RSpec team ɾ Contributor of Lrama ɾ Implementation of Parameterizing rules self.inspect
  3. • Lrama • A pure Ruby parser generator, not a

    parser • Created as a CRuby parser generator to replace GNU Bison • By adding new features, Lrama aims to make parse.y simpler and more maintainable Two new Ruby parsers (1)
  4. • Prism • A Ruby parser library written by hand

    from scratch • It is under development to replace the Ruby parser with Prism • For node structure, AST is also designed from scratch Two new Ruby parsers (2)
  5. • Lexer • Reads the source code character by character

    and returns a single token when it is meaningfully cohesive • Parser • Check the Lexer output token for grammatical conformance and create an AST • Appropriate error handling is done for grammatically incorrect programs • Compiler • Ruby compiles into machine language for virtual machines(YARV), and then the virtual machines execute Components related to parsing
  6. • A type of bottom-up parsing • Lookahead Left to

    Right, Rightmost derivation parser • Parser generators such as racc, Bison, and Lrama generate parsers of this type What is LALR(1) parser?
  7. • Ruby parsers are one of the hottest topics •

    Maybe, there will be sessions at RubyKaigi 2024 where the progress of each (Lrama and Prism) is presented (No, there must be.) • Please enjoy the Parser session! Finally…
  8. end