Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Exploration] Translate Prism nodes directly into AST::Expression nodes #238

Draft
wants to merge 152 commits into
base: prism
Choose a base branch
from

Conversation

amomchilov
Copy link

Motivation

Test plan

See included automated tests.

egiurleo and others added 30 commits September 4, 2024 12:55
Instead of listing all the `srcs` and `hdrs` for the Prism C library,
use a glob to pull all `.c` and `.h` files, excluding the ones that are
generated by the genrule so that we can specify that the library
depends on that genrule without listing those files twice.
…et or prism

If `--parser=prism`, diverge in the `pipeline.cc` file and run a separate method that parses the source with prism.
This involves setting up a `convertPrismToSorbet` method that checks against every
possible node type. Program and Statements are basically skipped because Sorbet doesn't
use them, and then Integer is converted from a prism node to a Sorbet node.

Co-authored-by: Vinicius Stock <[email protected]>
1. Add a new test suite that only tests files in the `test/prism_regression` folder
2. Modify Sorbet's test code to allow the user to specify a parser
3. Add logic to the pipeline test runner to call `runPrismParser` when specified
Sorbet constructs slightly different ASTs depending on whether a program contains
one statement or more than one statements. Correctly parsing programs with more
than one statement will make it easier to benchmark this project.
In order to compare the performance of Prism with the Sorbet parser,
we need to be able to stop AST generation after Prism has run and
before we translate the Prism AST into the Sorbet AST.
These benchmarks will help us measure the progress of the prism in Sorbet project.
While they can be run from any machine, for "official" results, they should be run
on an AWS bare metal instance. Results should be added to the prism_benchmarks/data
directory.
Relocate it to the `PM_STATEMENTS_NODE` case so it can be reused
by multiple parent nodes.
egiurleo and others added 27 commits September 4, 2024 12:55
Implement Prism -> Sorbet translation for index assign nodes
Implement missed translations for anonymous `*`, `**` and `&` params
And use the template on all nodes where we create an `Assign` Sorbet node.
Implement Prism -> Sorbet translation for `PM_CONSTANT_WRITE_NODE`
Implement translation for `PM_CONSTANT_PATH_WRITE_NODE`
It was still a copy of `def_kw_rest_params`, and were still testing method defs, not calls.
Implement Prism -> Sorbet translation for anonymous Array and Hash splats
Implement Prism -> Sorbet translation for `it` keyword
// A Whitequark node which wraps a Prism node, for use during our migration to Prism.
class WrappedPrismNode : public WhitequarkNode {
public:
WrappedPrismNode(Prism::Node node) : WhitequarkNode(node.getLoc()) {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

./parser/prism/WrappedPrismNode.h:23:22: error: use of undeclared identifier 'Prism'
    WrappedPrismNode(Prism::Node node) : WhitequarkNode(node.getLoc()) {}
                     ^

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.

2 participants