topos.graphs.uast.mapper_common

UAST Mapper Common

Shared logic for mapping Tree-sitter Concrete Syntax Trees (CSTs) to the normalized UAST representation.

This module provides the core transformation engine that:

  1. Filters Noise: Only “named” nodes from Tree-sitter are mapped; anonymous nodes (punctuation, keywords, whitespace) are ignored.

  2. Standardizes Kinds: Uses language-specific mapping functions to translate native Tree-sitter types into unified UNodeKinds.

  3. Preserves Fidelity: Populates every UASTNode with the original byte spans and a NativeRef containing the parser identity and native node type.

topos.graphs.uast.mapper_common.parser_identity(language, *, native=False)[source]

Return the canonical (parser_name, parser_version) for a language.

native=True selects the language’s native parser identity (currently only CPython’s stdlib ast for Python); otherwise the tree-sitter grammar identity is returned. Unknown languages fall back to (“tree-sitter”, “unknown”).

topos.graphs.uast.mapper_common.map_tree_sitter_to_uast(root, language, map_node_kind, file=None)[source]