ml_switcheroo.core.ingestion¶
Ingestion logic for parsing source code into an Abstract Syntax Tree (AST).
This module handles the complexity of accepting different input formats (Python, MLIR, TikZ, Custom DSLs) and normalizing them into a LibCST Module to be processed by the core Transpilation Engine.
Functions¶
|
Parses input code handles non-python sources via adapters. |
Module Contents¶
- ml_switcheroo.core.ingestion.ingest_code(code: str, source_fw: str, target_fw: str, source_adapter: ml_switcheroo.frameworks.base.FrameworkAdapter | None, tracer: Any) libcst.Module[source]¶
Parses input code handles non-python sources via adapters.
Supports: 1. Adapter-specific parsers (e.g. LaTeX). 2. MLIR text parsing via MlirParser. 3. TikZ text parsing via TikzParser. 4. Standard Python parsing via libcst.
- Parameters:
code – Raw source code string.
source_fw – Key identifying the source framework (e.g., ‘torch’, ‘tikz’).
target_fw – Key identifying the target framework (used for synthesis contexts).
source_adapter – The loaded adapter for the source framework, if any.
tracer – The trace logger instance for recording phase events.
- Returns:
A validated Python LibCST Module.
- Raises:
Exception – If parsing fails for any reason (syntax errors, etc.).