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

Replace Python parser with ruff parser #5453

Closed
wants to merge 44 commits into from

Conversation

etaloof
Copy link

@etaloof etaloof commented Dec 2, 2024

This PR replaces the Python parser with the ruff Parser. It is based on the work of the earlier PR #5423 (thanks @qingshi163)! Code generation has been updated and should mostly work now. There is is still some work left to fix the built-in AST module, REPL (probably) and I haven't looked into WASM support.

Running the tests with cargo test --workspace --exclude rustpython_wasm --features freeze-stdlib gives me one remaining test failure: test_run_script in src/lib.rs. It seems fail when importing the extra_tests/snippets/dir_main but I am not sure why that happens.

Concerning the AST module: The previous implementation is using a lot of generated code (script). Not sure if we should continue updating this script, I'll look into it. @youknowone do you have any suggestions on this?

@youknowone
Copy link
Member

Thank you so much! Since ruff already has its own ast coworking with same parser, how about starting from ruff side again about it too?
I couldnt look in details yet, but i feel like code generated ast module is not cost efficient anymore. We now can borrow lots of code from other repository easy

@youknowone
Copy link
Member

@qingshi163 @coolreader18 do you also have advices?

@youknowone
Copy link
Member

I have to look in this PR, sorry for delay

# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	compiler/codegen/src/compile.rs
#	compiler/codegen/src/symboltable.rs
#	wasm/lib/src/convert.rs
@etaloof
Copy link
Author

etaloof commented Jan 25, 2025

@youknowone I think this is ready to be reviewed now. I went ahead and merged main into this branch to resolve the merge conflicts (see commit 1a3c5bb. Not sure if this is the correct way to do things, I can rebase and merge again if needed.

@youknowone
Copy link
Member

@etaloof could you make your fork of RustPython not from qingshi163's but from RustPython org's? Then I can directly push my edits to your PR

@youknowone
Copy link
Member

It looks going well. this commit will pin parser version to git version of Ruff c8acbf8

Copy link
Member

@youknowone youknowone left a comment

Choose a reason for hiding this comment

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

Awesome, I feel like everything is going to the right direction.
Is there any blocking issue?

compiler/core/src/mode.rs Show resolved Hide resolved
vm/src/stdlib/ast/basic.rs Show resolved Hide resolved
compiler/codegen/src/compile.rs Show resolved Hide resolved
@etaloof etaloof closed this by deleting the head repository Jan 27, 2025
@etaloof
Copy link
Author

etaloof commented Jan 27, 2025

Thank you, I deleted my fork from qingshi163's repository and forked again from RustPython. Could you please open this PR again? Sorry for the confusion.

@youknowone
Copy link
Member

a PR is only can be re-opened when the branch is not changed. This one doesn't seem so. Please open a new one.

@etaloof
Copy link
Author

etaloof commented Jan 28, 2025

Thanks, I have created a new PR #5494.

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.

3 participants