pub enum PrologTerm {
Atom(String),
Integer(i64),
Float(f64),
Variable(String),
Compound(String, Vec<PrologTerm>),
List(Vec<PrologTerm>, Option<Box<PrologTerm>>),
Nil,
DcgPhrase(Box<PrologTerm>, Box<PrologTerm>),
Op(String, Box<PrologTerm>, Box<PrologTerm>),
PrefixOp(String, Box<PrologTerm>),
Cut,
Anon,
}Expand description
A Prolog term (the universal data structure in Prolog).
Variants§
Atom(String)
An atom: lowercase identifier or quoted string, e.g. foo, 'hello world'
Integer(i64)
An integer literal, e.g. 42, -7
Float(f64)
A float literal, e.g. 3.14
Variable(String)
A variable: uppercase-starting or _-prefixed name, e.g. X, _Acc
Compound(String, Vec<PrologTerm>)
A compound term: functor(arg1, arg2, ...), e.g. f(a, b), +(1, 2)
List(Vec<PrologTerm>, Option<Box<PrologTerm>>)
A proper or partial list: [H|T], [1,2,3]
Nil
The empty list []
DcgPhrase(Box<PrologTerm>, Box<PrologTerm>)
A DCG rule term: phrase(Rule, List)
Op(String, Box<PrologTerm>, Box<PrologTerm>)
An operator term written in infix notation, e.g. X is Y + 1
PrefixOp(String, Box<PrologTerm>)
A prefix operator term, e.g. \+(X)
Cut
A cut !
Anon
Anonymous variable _
Implementations§
Source§impl PrologTerm
impl PrologTerm
Sourcepub fn compound(functor: impl Into<String>, args: Vec<PrologTerm>) -> Self
pub fn compound(functor: impl Into<String>, args: Vec<PrologTerm>) -> Self
Create a compound term.
Sourcepub fn list(elems: Vec<PrologTerm>) -> Self
pub fn list(elems: Vec<PrologTerm>) -> Self
Create a proper list from elements.
Sourcepub fn list_partial(elems: Vec<PrologTerm>, tail: PrologTerm) -> Self
pub fn list_partial(elems: Vec<PrologTerm>, tail: PrologTerm) -> Self
Create a partial list [H1,H2,...|T].
Sourcepub fn op(op: impl Into<String>, lhs: PrologTerm, rhs: PrologTerm) -> Self
pub fn op(op: impl Into<String>, lhs: PrologTerm, rhs: PrologTerm) -> Self
Create an infix operator term.
Sourcepub fn prefix_op(op: impl Into<String>, arg: PrologTerm) -> Self
pub fn prefix_op(op: impl Into<String>, arg: PrologTerm) -> Self
Create a prefix operator term.
Sourcepub fn functor_arity(&self) -> usize
pub fn functor_arity(&self) -> usize
Arity of this term as a functor (0 for atoms, variables, etc.)
Trait Implementations§
Source§impl Clone for PrologTerm
impl Clone for PrologTerm
Source§fn clone(&self) -> PrologTerm
fn clone(&self) -> PrologTerm
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PrologTerm
impl Debug for PrologTerm
Source§impl Display for PrologTerm
impl Display for PrologTerm
Source§impl PartialEq for PrologTerm
impl PartialEq for PrologTerm
impl StructuralPartialEq for PrologTerm
Auto Trait Implementations§
impl Freeze for PrologTerm
impl RefUnwindSafe for PrologTerm
impl Send for PrologTerm
impl Sync for PrologTerm
impl Unpin for PrologTerm
impl UnsafeUnpin for PrologTerm
impl UnwindSafe for PrologTerm
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