Crate oxur_smap

Crate oxur_smap 

Source
Expand description

Source mapping for Oxur language

This crate provides source mapping capabilities for tracking code transformations through the Oxur compilation pipeline. It enables rustc compiler errors to be translated back to the original Oxur source code positions.

§Architecture

The source map tracks three transformation stages:

  1. Surface FormsCore Forms (macro expansion)
  2. Core FormsRust AST (lowering)
  3. Rust errorsOriginal Source (backward lookup)

§Example

use oxur_smap::{SourceMap, new_node_id, SourcePos, Span};

let mut map = SourceMap::new();

// Parser creates surface node with span
let surface = new_node_id();
let span = Span::repl(1, 1, 1, 10);
// Convert span to SourcePos for recording
let pos: SourcePos = (&span).into();
map.record_surface_node(surface, pos);

// Expander creates core node
let core = new_node_id();
map.record_expansion(surface, core);

// Lowering creates rust node
let rust = new_node_id();
map.record_lowering(core, rust);

// Error translator looks up original position
let original = map.lookup(&rust).unwrap();
assert_eq!(original.line, 1);
assert_eq!(original.column, 1);

Structs§

LookupStats
Performance statistics for lookup operations
NodeId
Unique identifier for AST nodes across all compilation stages
NodeIdGenerator
Global NodeId generator using atomic counter
SourceMap
Tracks AST transformations for error reporting
SourceMapStats
Statistics about a SourceMap
SourcePos
Source position in original Oxur code
Span
A span representing a range in source code

Functions§

new_node_id
Generate a new unique NodeId