Skip to main content

CompilerExport

Struct CompilerExport 

Source
pub struct CompilerExport;
Expand description

Export utilities for compiler integration.

Implementations§

Source§

impl CompilerExport

Source

pub fn export_domains(table: &SymbolTable) -> HashMap<String, usize>

Export domain information as a simple map for compiler consumption.

This returns a HashMap that maps domain names to their cardinalities, suitable for direct use in compiler contexts.

§Example
use tensorlogic_adapters::{SymbolTable, DomainInfo, CompilerExport};

let mut table = SymbolTable::new();
table.add_domain(DomainInfo::new("Person", 100)).unwrap();
table.add_domain(DomainInfo::new("Location", 50)).unwrap();

let domain_map = CompilerExport::export_domains(&table);
assert_eq!(domain_map.get("Person"), Some(&100));
assert_eq!(domain_map.get("Location"), Some(&50));
Source

pub fn export_predicate_signatures( table: &SymbolTable, ) -> HashMap<String, Vec<String>>

Export predicate signatures for type checking.

Returns a HashMap mapping predicate names to their argument domain lists.

§Example
use tensorlogic_adapters::{SymbolTable, DomainInfo, PredicateInfo, CompilerExport};

let mut table = SymbolTable::new();
table.add_domain(DomainInfo::new("Person", 100)).unwrap();
table.add_predicate(PredicateInfo::new(
    "knows",
    vec!["Person".to_string(), "Person".to_string()]
)).unwrap();

let signatures = CompilerExport::export_predicate_signatures(&table);
assert_eq!(signatures.get("knows"), Some(&vec!["Person".to_string(), "Person".to_string()]));
Source

pub fn export_variable_bindings(table: &SymbolTable) -> HashMap<String, String>

Export variable bindings for scope analysis.

Returns a HashMap mapping variable names to their domain types.

§Example
use tensorlogic_adapters::{SymbolTable, DomainInfo, CompilerExport};

let mut table = SymbolTable::new();
table.add_domain(DomainInfo::new("Person", 100)).unwrap();
table.bind_variable("x", "Person").unwrap();
table.bind_variable("y", "Person").unwrap();

let bindings = CompilerExport::export_variable_bindings(&table);
assert_eq!(bindings.get("x"), Some(&"Person".to_string()));
assert_eq!(bindings.get("y"), Some(&"Person".to_string()));
Source

pub fn export_all(table: &SymbolTable) -> CompilerExportBundle

Create a complete export bundle for compiler initialization.

Returns all three maps (domains, signatures, bindings) in a single structure.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.