You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ripper_translation.md
+8-17Lines changed: 8 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,22 +1,6 @@
1
1
# Ripper translation
2
2
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.
20
4
21
5
Briefly, `Ripper` is a streaming parser that allows you to construct your own syntax tree. As an example:
The exact names of the `on_*` methods are listed in the `Ripper` source.
51
35
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
+
52
43
## Background
53
44
54
45
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