pub struct CompilerExport;Expand description
Export utilities for compiler integration.
Implementations§
Source§impl CompilerExport
impl CompilerExport
Sourcepub fn export_domains(table: &SymbolTable) -> HashMap<String, usize>
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));Sourcepub fn export_predicate_signatures(
table: &SymbolTable,
) -> HashMap<String, Vec<String>>
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()]));Sourcepub fn export_variable_bindings(table: &SymbolTable) -> HashMap<String, String>
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()));Sourcepub fn export_all(table: &SymbolTable) -> CompilerExportBundle
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§
impl Freeze for CompilerExport
impl RefUnwindSafe for CompilerExport
impl Send for CompilerExport
impl Sync for CompilerExport
impl Unpin for CompilerExport
impl UnwindSafe for CompilerExport
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more