Skip to main content

IrMapping

Trait IrMapping 

Source
pub trait IrMapping {
    // Required method
    fn classify(&self, node: &Node<'_>) -> Mapping;

    // Provided methods
    fn node_name<'s>(&self, node: &Node<'_>, source: &'s str) -> Option<&'s str> { ... }
    fn token_kind(&self, kind: &str, is_named: bool, text: &str) -> TokenKind { ... }
}
Expand description

The per-language part of a C-family structural frontend.

The shared walker owns tokenisation, error recovery and IR assembly; an implementation of this trait supplies the language’s node-mapping table. The provided methods cover the whole C family — the C++-only grammar kinds they mention never occur in C trees — so implementations rarely override them.

Required Methods§

Source

fn classify(&self, node: &Node<'_>) -> Mapping

Decide how one CST node maps onto the IR. This table is the granularity contract of a frontend; changing it changes fingerprint input, which invalidates every result recorded under the old table. Before the first release that is settled by rescanning rather than by raising the frontend version, which stays at v1.

Provided Methods§

Source

fn node_name<'s>(&self, node: &Node<'_>, source: &'s str) -> Option<&'s str>

Recover the declared name of a node that emits a named shape.

Source

fn token_kind(&self, kind: &str, is_named: bool, text: &str) -> TokenKind

Map one CST leaf onto the shared TokenKind vocabulary.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§