zyntex.parsing¶
- class zyntex.parsing.SourceCode(source, lazy_parsing=False)[source]¶
Represents a parsed source code.
Parses the given source text into a translation unit and provides access to recognized top-level node elements.
Parameters¶
- source:
Source text to be parsed.
- lazy_parsing:
If True, the underlying PyTranslationUnit will not be created during construction. Instead, parsing is deferred until the translation unit or other derived properties (like .content) are first accessed.
Added in version 0.1.3.
- property content: list[INodeElement]¶
A list of top-level elements parsed from the source string.
- property errors: list[ErrorReport]¶
A list of error reports that occurred during parsing this file.
- property types: tuple[type[INodeElement], ...]¶
Supported top-level node element types.
- property unit: PyTranslationUnit¶
The parsed translation unit for this source.
Added in version 0.1.3.
- class zyntex.parsing.SourceFile(file_path, lazy_parsing=False)[source]¶
Represents a parsed source file.
Parses the given file into a translation unit and provides access to recognized top-level node elements.
Parameters¶
- file_path:
Path to the Zig source file to parse.
- lazy_parsing:
If True, the underlying PyTranslationUnit will not be created during construction. Instead, parsing is deferred until the translation unit or other derived properties (like .content) are first accessed.
Added in version 0.1.3.
- property content: list[INodeElement]¶
A list of top-level elements parsed from the file.
- property errors: list[ErrorReport]¶
A list of error reports that occurred during parsing this file.
- property types: tuple[type[INodeElement], ...]¶
Supported top-level node element types.
- property unit: PyTranslationUnit¶
The parsed translation unit for this file.
Added in version 0.1.3.
- class zyntex.parsing.SourceModule(dir_path, lazy_parsing=False, use_threading=False, max_workers=None)[source]¶
Container that discovers and parses .zig files under a directory.
Parameters¶
- dir_path:
Directory to search for .zig files.
- lazy_parsing:
Controls whether parsing is deferred. When enabled, constructing a
SourceFileis cheap and actual parsing happens later when the file’s content/unit is accessed. When disabled, parsing is performed eagerly during construction.Added in version 0.2.3.
- use_threading:
Controls whether parsing work is submitted to a thread pool. Using threads can significantly speed up parsing when there are many files, because parsing and native calls can run concurrently.
Added in version 0.2.3.
- max_workers:
Upper bound on the number of worker threads when threading is used. If None, picks a sensible default based on CPU count and number of files.
Added in version 0.2.3.
- property files: list[SourceFile]¶
A list of SourceFile objects for every .zig file under
dir_path.