Prism Ruby parser
This is a parser for the Ruby programming language. It is designed to be portable, error tolerant, and maintainable. It is written in C99 and has no dependencies.
Overview
The repository contains the infrastructure for both a shared library (libprism) and a native CRuby extension. The shared library has no bindings to CRuby itself, and so can be used by other projects. The native CRuby extension links against ruby.h
, and so is suitable in the context of CRuby.
.
Getting started
To compile the shared library, you will need:
- C99 compiler
- GNU make
- Ruby 2.7.0 or later
Once you have these dependencies, run:
bundle install
to fetch the Ruby dependencies. Finally, run:
bundle exec rake compile
to compile the shared library. It will be built in the build
directory. To test that everything is working, run:
bin/parse -e "1 + 2"
to see the syntax tree for the expression 1 + 2
.
Contributing
See the CONTRIBUTING.md file for more information. We additionally have documentation about the overall design of the project as well as various subtopics.
- Build system
- Configuration
- CRuby compilation
- Design
- Encoding
- Fuzzing
- Heredocs
- JavaScript
- Local variable depth
- Mapping
- Parser translation
- Parsing rules
- Releasing
- Ripper translation
- Ruby API
- RubyParser translation
- Serialization
- Testing
Examples
Prism has been integrated into the majority of Ruby runtimes, many libraries, and some applications. Below is a list of some of the projects that use Prism:
Runtimes
- CRuby (via C)
- Garnet (via WASM)
- JRuby (via Java)
- Natalie (via C++ and Ruby)
- Opal (via Ruby and WASM)
- TruffleRuby (via Java)
Libraries
- dispersion
- minifyrb
- packwerk (via parser translator)
- rbi
- rails
- repl_type_completor
- rubocop (via parser translator)
- ruby-lsp
- smart_todo
- sorbet-eraser
- synvert
- typeprof