public class PythonParser extends Object
Lightweight structural parser for Python source code (.py).
Extracts class, def, and async def declarations into a hierarchy of DeclarationNodes using Python indentation levels.
import klyn.code.python src = "class Pipeline:\n def execute(self, item: str) -> bool:\n return True\n" nodes = PythonParser.parseDeclarations(src) assert nodes.size == 1 assert nodes[0].name == "Pipeline" assert nodes[0].children.size == 1 assert nodes[0].children[0].name == "execute"
| Modifier and Type | Member | Description |
|---|---|---|
| public static | parseDeclarationsparseDeclarations(source as String) as ArrayList<DeclarationNode> |
Parses top-level Python classes and functions along with class methods. |