Expand description
Python-specific tree-sitter parser — extracts CodeNodes with position metadata.
This parser uses Python-specific CodeNodeKind variants (PythonFunction,
PythonClass, etc.) rather than the generic variants used by parser.rs.
All emitted nodes include position metadata (start_line, end_line, start_col,
end_col, file_path, byte_offset) populated from tree-sitter node positions.
§Differences from parser.rs
| parser.rs (generic) | python_parser.rs (Python-specific) |
|---|---|
CodeNodeKind::Function | PythonFunction or PythonAsync |
CodeNodeKind::Method | PythonMethod, PythonProperty, or PythonAsync |
CodeNodeKind::Class | PythonClass |
CodeNodeKind::Module | PythonModule |
| No position metadata | All nodes have start/end line/col + byte_offset |
| No decorator nodes | PythonDecorator nodes emitted |
| No import nodes | PythonImport nodes emitted |
| No lambda nodes | PythonLambda nodes (best-effort) |
§Usage
ⓘ
let parser = PythonParser::new()?;
let result = parser.parse_file(Path::new("brain/signal_fusion.py"), &source)?;
println!("{} nodes extracted", result.nodes.len());Structs§
- Python
Parse Result - Result of parsing a Python file with the Python-specific parser.
- Python
Parser - A Python-specific tree-sitter parser.
Enums§
- Python
Parser Error - Errors from the Python-specific parser.