Skip to content

Commit 0b2a318

Browse files
authored
Merge pull request #3850 from Earlopain/ripper-docs
Update ripper translation docs
2 parents 90c0578 + 219ee35 commit 0b2a318

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

docs/ripper_translation.md

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,6 @@
11
# Ripper translation
22

3-
Prism provides the ability to mirror the `Ripper` standard library. You can do this by:
4-
5-
```ruby
6-
require "prism/translation/ripper/shim"
7-
```
8-
9-
This provides the APIs like:
10-
11-
```ruby
12-
Ripper.lex
13-
Ripper.parse
14-
Ripper.sexp_raw
15-
Ripper.sexp
16-
17-
Ripper::SexpBuilder
18-
Ripper::SexpBuilderPP
19-
```
3+
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.
204

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

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

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

36+
You can can also automatically use the ripper translation in places that don't explicitly use the translation layer by doing the following:
37+
38+
```ruby
39+
# Will redirect access of the `Ripper` constant to `Prism::Translation::Ripper`.
40+
require "prism/translation/ripper/shim"
41+
```
42+
5243
## Background
5344

5445
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.

0 commit comments

Comments
 (0)