Plot Script
Public Types | Public Member Functions | List of all members
Expression Class Reference

An expression is a tree of Atoms. More...

#include <expression.hpp>

Public Types

typedef std::vector< Expression >::const_iterator ConstIteratorType
 

Public Member Functions

 Expression ()
 Default construct and Expression, whose type in NoneType. More...
 
 Expression (const Atom &a)
 
 Expression (const Expression &a)
 deep-copy construct an expression (recursive) More...
 
Expressionoperator= (const Expression &a)
 deep-copy assign an expression (recursive) More...
 
Atomhead ()
 return a reference to the head Atom More...
 
const Atomhead () const
 return a const-reference to the head Atom More...
 
void append (const Atom &a)
 append Atom to tail of the expression More...
 
Expressiontail ()
 return a pointer to the last expression in the tail, or nullptr More...
 
ConstIteratorType tailConstBegin () const noexcept
 return a const-iterator to the beginning of tail More...
 
ConstIteratorType tailConstEnd () const noexcept
 return a const-iterator to the tail end More...
 
bool isHeadNumber () const noexcept
 convienience member to determine if head atom is a number More...
 
bool isHeadSymbol () const noexcept
 convienience member to determine if head atom is a symbol More...
 
Expression eval (Environment &env)
 Evaluate expression using a post-order traversal (recursive) More...
 
bool operator== (const Expression &exp) const noexcept
 equality comparison for two expressions (recursive) More...
 

Detailed Description

An expression is a tree of Atoms.

An expression is an atom called the head followed by a (possibly empty) list of expressions called the tail.

Member Typedef Documentation

◆ ConstIteratorType

typedef std::vector<Expression>::const_iterator Expression::ConstIteratorType

Constructor & Destructor Documentation

◆ Expression() [1/3]

Expression::Expression ( )

Default construct and Expression, whose type in NoneType.

◆ Expression() [2/3]

Expression::Expression ( const Atom a)

Construct an Expression with given Atom as head an empty tail

Parameters
atomthe atom to make the head

◆ Expression() [3/3]

Expression::Expression ( const Expression a)

deep-copy construct an expression (recursive)

Member Function Documentation

◆ append()

void Expression::append ( const Atom a)

append Atom to tail of the expression

◆ eval()

Expression Expression::eval ( Environment env)

Evaluate expression using a post-order traversal (recursive)

◆ head() [1/2]

Atom & Expression::head ( )

return a reference to the head Atom

◆ head() [2/2]

const Atom & Expression::head ( ) const

return a const-reference to the head Atom

◆ isHeadNumber()

bool Expression::isHeadNumber ( ) const
noexcept

convienience member to determine if head atom is a number

◆ isHeadSymbol()

bool Expression::isHeadSymbol ( ) const
noexcept

convienience member to determine if head atom is a symbol

◆ operator=()

Expression & Expression::operator= ( const Expression a)

deep-copy assign an expression (recursive)

◆ operator==()

bool Expression::operator== ( const Expression exp) const
noexcept

equality comparison for two expressions (recursive)

◆ tail()

Expression * Expression::tail ( )

return a pointer to the last expression in the tail, or nullptr

◆ tailConstBegin()

Expression::ConstIteratorType Expression::tailConstBegin ( ) const
noexcept

return a const-iterator to the beginning of tail

◆ tailConstEnd()

Expression::ConstIteratorType Expression::tailConstEnd ( ) const
noexcept

return a const-iterator to the tail end


The documentation for this class was generated from the following files: