Registries¶
Registry for source-language parsers and reverse code generators.
- class crosstl.translator.source_registry.SourceRegistry[source]¶
Bases:
objectLookup table for source parsers by name, alias, and extension.
- extensions()[source]¶
Return registered source file extensions in sorted order.
- Return type:
Sequence[str]
- get(name)[source]¶
Return the source spec registered for a name or alias.
- Return type:
Optional[SourceSpec]
- get_by_extension(path_or_ext)[source]¶
Return the source spec registered for a file path or extension.
- Return type:
Optional[SourceSpec]
- names()[source]¶
Return registered canonical source names in sorted order.
- Return type:
Sequence[str]
- class crosstl.translator.source_registry.SourceSpec(name, extensions, load_lexer_parser, reverse_codegen_factory=None, aliases=())[source]¶
Bases:
objectDescriptor for a source language frontend.
A source spec connects file extensions and aliases to a lazily imported lexer/parser pair. Specs can also provide a reverse code generator factory when the source language can be converted back into CrossGL.
- crosstl.translator.source_registry.register_default_sources()[source]¶
Register the built-in CrossGL and native source frontends.
- Return type:
None
Backend registry and alias resolution for CrossGL code generators.
- class crosstl.translator.codegen.registry.BackendRegistry[source]¶
Bases:
objectLookup table for target code generators by backend name and alias.
- all()[source]¶
Return all registered backend specs.
- Return type:
Iterable[BackendSpec]
- get(name)[source]¶
Return the backend spec registered for a name or alias.
- Return type:
Optional[BackendSpec]
- names()[source]¶
Return registered canonical backend names in sorted order.
- Return type:
Sequence[str]
- class crosstl.translator.codegen.registry.BackendSpec(name, codegen_class, aliases=(), file_extensions=(), format_backend=None)[source]¶
Bases:
objectDescriptor for a target code generator backend.
- crosstl.translator.codegen.registry.backend_names()[source]¶
Return registered backend names from the global registry.
- Return type:
Sequence[str]
- crosstl.translator.codegen.registry.get_backend(name)[source]¶
Return a backend spec from the global registry.
- Return type:
Optional[BackendSpec]
- crosstl.translator.codegen.registry.get_backend_extension(name)[source]¶
Return the preferred output extension for a backend, if known.
- Return type:
Optional[str]
- crosstl.translator.codegen.registry.get_codegen(name)[source]¶
Instantiate the code generator class for a registered backend.
- crosstl.translator.codegen.registry.normalize_backend_name(name)[source]¶
Resolve a backend name or alias through the global registry.
- Return type:
Optional[str]
- crosstl.translator.codegen.registry.register_backend(spec, *, overwrite=False)[source]¶
Register a target backend in the global backend registry.
- Return type:
Plugin discovery helpers for external CrossGL Translator backends.
- crosstl.translator.plugin_loader.discover_backend_plugins(force=False)[source]¶
Discover backend plugin specs under
crosstl.backend.Discovery imports optional
backend_specandsource_specmodules from backend packages. Those modules can expose spec constants or aregisterfunction to attach additional source parsers and target code generators.- Return type:
None