This class is the entry-point for converting a prism syntax tree into the whitequark/parser gem’s syntax tree. It inherits from the base parser for the parser gem, and overrides the parse* methods to parse with prism and then translate.

Constants
No documentation available
No documentation available

For Ruby 3.3

For Ruby 3.4

Instance Methods

Build the parser gem AST from the prism AST.

Build the parser gem comments from the prism comments.

Prism deals with offsets in bytes, while the parser gem deals with offsets in characters. We need to handle this conversion in order to build the parser gem AST.

If the bytesize of the source is the same as the length, then we can just use the offset directly. Otherwise, we build an array where the index is the byte offset and the value is the character offset.

Build a range from a prism location.

Build the parser gem tokens from the prism tokens.

Converts the version format handled by Parser to the format handled by Prism.

The default encoding for Ruby files is UTF-8.

Build a diagnostic from the given prism parse error.

Parses a source buffer and returns the AST.

Parses a source buffer and returns the AST and the source code comments.

Parses a source buffer and returns the AST, the source code comments, and the tokens emitted by the lexer.

Since prism resolves num params for us, we don’t need to support this kind of logic here.

If there was a error generated during the parse, then raise an appropriate syntax error. Otherwise return the result.

This is a hook to allow consumers to disable some errors if they don’t want them to block creating the syntax tree.

This is a hook to allow consumers to disable some warnings if they don’t want them to block creating the syntax tree.

Build a diagnostic from the given prism parse warning.