Skip to main content

Module python_parser

Module python_parser 

Source
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::FunctionPythonFunction or PythonAsync
CodeNodeKind::MethodPythonMethod, PythonProperty, or PythonAsync
CodeNodeKind::ClassPythonClass
CodeNodeKind::ModulePythonModule
No position metadataAll nodes have start/end line/col + byte_offset
No decorator nodesPythonDecorator nodes emitted
No import nodesPythonImport nodes emitted
No lambda nodesPythonLambda 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§

PythonParseResult
Result of parsing a Python file with the Python-specific parser.
PythonParser
A Python-specific tree-sitter parser.

Enums§

PythonParserError
Errors from the Python-specific parser.