-
Notifications
You must be signed in to change notification settings - Fork 26
added basic ASTX to python transpiler #278
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
base: main
Are you sure you want to change the base?
Conversation
@dispatch # type: ignore[no-redef] | ||
def visit(self, node: astx.BinaryOp) -> ast.BinOp: | ||
"""Handle BinaryOp nodes.""" | ||
op_map = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this variable should be moved to outside of the function nd class, otherwise it will be created every time it is executed.
it could be called OP_MAP
@dispatch # type: ignore[no-redef] | ||
def visit(self, node: astx.AugAssign) -> ast.AugAssign: | ||
"""Handle AugAssign nodes.""" | ||
op_map = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this variable should be moved to outside of the function nd class, otherwise it will be created every time it is executed.
it could be called OP_MAP
value = self.visit(node.value) | ||
return ast.YieldFrom(value=value) | ||
|
||
# For nodes that aren't directly implemented, use the unparse approach |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not really sure about this .. but we can keep it for now
just a few comments, in general looks good to me. appreciate it! |
This pull request has been marked as stale because it has been |
TASKS TO BE DONE: |
This pull request has been marked as stale because it has been |
Pull Request Description
This pull request introduces a new feature: an ASTx to Python AST transpiler. The
ASTxPythonASTTranspiler
class enables the conversion of ASTx nodes into Python AST nodes using Python's built-inast
module. This allows for programmatic manipulation of ASTx nodes and seamless integration with Python's AST ecosystem.Changes Made
ASTxPythonASTTranspiler
class inlibs/astx-transpilers/src/astx_transpilers/python_ast.py
.visit_*
methods for several ASTx node types:LiteralInt32
,Variable
BinaryOp
Assign
,If
,While
, and moreast.unparse
for unsupported or complex cases.Issue This PR Aims to Resolve
This PR introduces a new feature and does not resolve an existing issue directly.
How to Test These Changes
You can run the following Python script to test the transpiler functionality:
Expected Output:
Additionally, run any included unit tests to validate correctness.
Pull Request Checklists
Additional Information
Example Output:
Reviewer's Checklist
Copy and paste this template when reviewing: