Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions docs/ripper_translation.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
# Ripper translation

Prism provides the ability to mirror the `Ripper` standard library. You can do this by:

```ruby
require "prism/translation/ripper/shim"
```

This provides the APIs like:

```ruby
Ripper.lex
Ripper.parse
Ripper.sexp_raw
Ripper.sexp

Ripper::SexpBuilder
Ripper::SexpBuilderPP
```
Prism provides the ability to mirror the `Ripper` standard library. It is available under `Prism::Translation::Ripper`. You can use the entire public API, and also some undocumented features that are commonly used.

Briefly, `Ripper` is a streaming parser that allows you to construct your own syntax tree. As an example:

Expand Down Expand Up @@ -49,6 +33,13 @@ ArithmeticRipper.new("1 + 2 - 3").parse # => [0]

The exact names of the `on_*` methods are listed in the `Ripper` source.

You can can also automatically use the ripper translation in places that don't explicitly use the translation layer by doing the following:

```ruby
# Will redirect access of the `Ripper` constant to `Prism::Translation::Ripper`.
require "prism/translation/ripper/shim"
```

## Background

It is helpful to understand the differences between the `Ripper` library and the `Prism` library. Both libraries perform parsing and provide you with APIs to manipulate and understand the resulting syntax tree. However, there are a few key differences.
Expand Down