Skip to content

Project Ideas

Ivan Ogasawara edited this page Feb 11, 2025 · 4 revisions

ASTx

Project Idea 1: Transpiler from ASTx to Python AST

Abstract

This project aims to develop a transpiler from ASTx to Python's built-in AST, allowing seamless conversion of ASTx representations into Python's ast module structures. This feature will enable Python code generation from ASTx, making it easier to integrate ASTx with Python-based tools, static analysis, and compilers. The implementation should follow ASTx's existing transpiler structure, leveraging the current ASTx to Python Source Transpiler as a reference.

Current State

  • ASTx provides a transpiler from ASTx to Python source code.
  • There is no direct conversion from ASTx to Python's ast module.
  • Python's ast module allows programmatic manipulation of Python code.
  • A structured approach is required to map ASTx node types to their Python AST equivalents.

Tasks

  • Implement a node visitor pattern to translate ASTx nodes into Python AST nodes.
  • Define mappings for:
    • Expressions (BinaryOp, FunctionCall, Literals, etc.)
    • Statements (IfStmt, WhileStmt, FunctionDef, etc.)
    • Declarations (VariableDeclaration, FunctionPrototype, etc.)
  • Ensure correct handling of variable scoping and function definitions.
  • Integrate the new transpiler into astx.tools.transpilers.python.py.
  • Write unit tests to validate conversions between ASTx and Python AST.
  • Provide examples and documentation for users.

Expected Outcomes

  • A working transpiler from ASTx to Python AST.
  • A test suite ensuring accurate translation.
  • Documentation explaining how to use the transpiler.
  • Examples showcasing ASTx → Python AST → Python code execution.

Details

  • Prerequisites:

    • Understanding of Python's ast module (basic level).
    • Familiarity with ASTx and its structure (basic level).
    • Experience in compiler design, transpilers, or code generation (basic level).
    • Proficiency in Python and visitor patterns (basic level).
  • Duration: 350 hours

  • Complexity: Medium

  • Potential Mentor(s): Ivan Ogasawara, Ana Krelling, Devansh Parmar

References

Clone this wiki locally