Skip to content

Add an implicit words sep token - #4239

Open
kddnewton wants to merge 2 commits into
mainfrom
implicit-words-sep
Open

kddnewton wants to merge 2 commits into
mainfrom
implicit-words-sep

Conversation

@kddnewton

Copy link
Copy Markdown
Collaborator

The parse.y grammar has the concept of a words separator that must delimit words in a word list literal. Prism previously didn't emit these in the token stream because they don't actually correspond to any source code.

However, in order to better compare against the vendored grammars, it's much easier if we do emit them. This commit adds them into the token stream without actually touching the parser, so it barely effects anything except conformance.

Since we have split up all those other tokens now and we have this in place, we now don't need any special handling: our tokens stream is pretty much exactly a superset of parse.y's token stream, meaning it's very easy to drive a parse.y grammar using prism's token stream provided you have a mapping of token names.

A bunch of things are required to match ripper state, including
looking backward sometimes to pull a state forward because of the
nature of parse.y. This changes the structure from a backward look
to a forward look by keeping a couple of stacks of state.
The parse.y grammar has the concept of a words separator that must
delimit words in a word list literal. Prism previously didn't emit
these in the token stream because they don't actually correspond
to any source code.

However, in order to better compare against the vendored grammars,
it's much easier if we do emit them. This commit adds them into
the token stream without actually touching the parser, so it
barely effects anything except conformance.

Since we have split up all those other tokens now and we have this
in place, we now don't need any special handling: our tokens stream
is pretty much exactly a superset of parse.y's token stream,
meaning it's very easy to drive a parse.y grammar using prism's
token stream provided you have a mapping of token names.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant