Skip to content

Replace Python parser with ruff parser#5453

Closed
etaloof wants to merge 44 commits into
RustPython:mainfrom
etaloof:ruff-parser
Closed

Replace Python parser with ruff parser#5453
etaloof wants to merge 44 commits into
RustPython:mainfrom
etaloof:ruff-parser

Conversation

@etaloof

@etaloof etaloof commented Dec 2, 2024

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Member

@qingshi163 @coolreader18 do you also have advices?

@youknowone

Copy link
Copy Markdown
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

etaloof commented Jan 25, 2025

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
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
Copy Markdown
Member

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

@youknowone youknowone left a comment

Copy link
Copy Markdown
Member

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?

Comment thread compiler/core/src/mode.rs
Comment thread vm/src/stdlib/ast/basic.rs
Comment thread compiler/codegen/src/compile.rs
@etaloof etaloof closed this by deleting the head repository Jan 27, 2025
@etaloof

etaloof commented Jan 27, 2025

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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

etaloof commented Jan 28, 2025

Copy link
Copy Markdown
Contributor Author

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