OperDefs

Struct OperDefs 

Source
pub struct OperDefs { /* private fields */ }
Expand description

Central registry of all operator definitions.

OperDefs maps operator names to a table of definitions by fixity. Provides fast lookup of operator behavior and metadata.

Implementations§

Source§

impl OperDefs

Source

pub fn new() -> Self

Creates an empty OperDefs registry.

Initializes an operator definition map with no entries.

Source

pub fn try_from_ops(arena: &Arena, ops: Term) -> Result<Self>

Builds an OperDefs table from a parsed term representation.

This helper reads operator specifications encoded as arena_terms::Term values and populates the operator definition registry accordingly.

§Parameters
  • arena: The Arena used to allocate or access term data.
  • ops: The root Term containing operator definitions.
§Errors

Returns an error if operator parsing or validation fails.

Source

pub fn len(&self) -> usize

Returns the total number of operator entries in this registry.

Source

pub fn lookup(&self, name: &str) -> Option<usize>

Looks up an operator by name and returns its index, if defined.

§Parameters
  • name: The operator name to query.
§Returns

The operator’s internal index if found, or None if not present.

Source

pub fn get(&self, index: Option<usize>) -> &OperDefTab

Retrieves an operator definition table by index.

Returns a reference to the corresponding OperDefTab, or [EMPTY_OPER_DEF_TAB] if the index is None or out of bounds.

Source

pub fn define_oper(&mut self, arena: &Arena, op: Term) -> Result<()>

Defines a single operator entry from a parsed arena_terms::Term structure.

This function ingests a Prolog-style operator definition term of the form:

op(
    oper: atom | func(arg: atom | '='(name: atom, default: term)), ...,
    type: 'fun' | 'prefix' | 'infix' | 'postfix',
    prec: 0..1200,          % must be 0 for fixity = 'fun'
    assoc: 'none' | 'left' | 'right',
    rename_to: 'none' | some(new_name: atom),
    embed_type: 'false' | 'true'
).

Each op/1 term specifies one operator, including its name, fixity, precedence, associativity, optional renaming target, and embedding behavior.

§Parameters
  • arena: The Arena providing term access and allocation.
  • op: The Term describing the operator declaration.
§Returns
  • Ok(()) if the operator was successfully parsed and registered.
§Errors

Returns an error if the operator definition is invalid, malformed, or violates fixity/precedence/associativity constraints.

Source

pub fn define_opers(&mut self, arena: &Arena, term: Term) -> Result<()>

Defines one or more operators from a parsed arena_terms::Term structure.

This method accepts either:

  • A list of operator terms (each of which is passed to [define_oper]), or
  • A single operator term (op(...)) to be defined directly.

Each term is ingested and registered according to its fixity, precedence, associativity, and optional metadata.

§Parameters
  • arena: The Arena providing term access and allocation.
  • term: Either a list of operator definitions or a single operator term.
§Returns
  • Ok(()) if all operator definitions were successfully processed.
§Errors

Returns an error if any individual operator definition is invalid, malformed, or violates fixity/precedence/associativity constraints.

Trait Implementations§

Source§

impl Clone for OperDefs

Source§

fn clone(&self) -> OperDefs

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OperDefs

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OperDefs

Source§

fn default() -> OperDefs

Returns the “default value” for a type. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V