Accepts a list of prism tokens and converts them into the expected format for the parser gem.

Constants

The direct translating of types between the two lexers.

These constants represent flags in our lex state. We really, really don’t want to be using them and we really, really don’t want to be exposing them as part of our public API. Unfortunately, we don’t have another way of matching the exact tokens that the parser gem expects without them. We should find another way to do this, but in the meantime we’ll hide them from the documentation and mark them as private constants.

No documentation available

It is used to determine whether ‘do` is of the token type `kDO` or `kDO_LAMBDA`.

NOTE: In edge cases like ‘-> (foo = -> (bar) {}) do end`, please note that `kDO` is still returned instead of `kDO_LAMBDA`, which is expected: github.com/ruby/prism/pull/3046

The ‘PARENTHESIS_LEFT` token in Prism is classified as either `tLPAREN` or `tLPAREN2` in the Parser gem. The following token types are listed as those classified as `tLPAREN`.

Types of tokens that are allowed to continue a method call with comments in-between. For these, the parser gem doesn’t emit a newline token after the last comment.

Heredocs are complex and require us to keep track of a bit of info to refer to later

No documentation available

Escape sequences that have special and should appear unescaped in the resulting string.

When one of these delimiters is encountered, then the other one is allowed to be escaped as well.

Attributes

The Parser::Source::Buffer that the tokens were lexed from.

Read

An array of tuples that contain prism tokens and their associated lex state when they were lexed.

A hash that maps offsets in bytes to offsets in characters.

Class Methods

Initialize the lexer with the given source buffer, prism tokens, and offset cache.

Instance Methods

Determine if characters preceeded by a backslash should be escaped or not

Parse a complex from the string representation.

Parse a float from the string representation.

Parse an integer from the string representation.

Parse a rational from the string representation.

Determine if the string is part of a %-style array.

Creates a new parser range, taking prisms byte offsets into account

Regexp allow interpolation but are handled differently during unescaping

Convert the prism tokens into the expected format for the parser gem.

Apply Ruby string escaping rules