Om
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Om::Language::Evaluator Class Reference

A Consumer that evaluates Program instances. More...

#include "evaluator.hpp"

+ Inheritance diagram for Om::Language::Evaluator:
+ Collaboration diagram for Om::Language::Evaluator:

Public Member Functions

virtual ~Evaluator ()
 Flushes the contents. More...
 
 Evaluator (Consumer &theOutput, Translator const &theTranslator)
 
virtual void Clear ()
 
Translator const & GetTranslator () const
 
virtual void GiveElements (Consumer &)
 Gives to the argument each Element currently contained in the Evaluator. More...
 
virtual void GiveElements (Consumer &) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
virtual std::auto_ptr< ProgramGiveProgram ()
 Returns a new Program populated with the contents of this. More...
 
virtual std::auto_ptr< ProgramGiveProgram () const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
virtual bool IsEmpty () const
 
virtual void ParseElements (Reader &)
 
virtual void ParseQuotedElements (Reader &)
 
void ParseQuotedElements (Evaluation &, Reader &)
 
template<typename TheOperand >
void TakeOperand (TheOperand &)
 
template<typename TheOperand >
void TakeOperand (Evaluation &, TheOperand &)
 
template<typename TheOperation >
void TakeOperation (std::auto_ptr< TheOperation >)
 
template<typename TheOperator >
void TakeOperator (TheOperator &)
 
template<typename TheOperator >
void TakeOperator (Evaluation &, TheOperator &)
 
template<typename TheProducer >
void TakeQuotedProducer (TheProducer &)
 
template<typename TheProducer >
void TakeQuotedProducer (Evaluation &, TheProducer &)
 
template<typename TheSeparator >
void TakeSeparator (TheSeparator &)
 
- Public Member Functions inherited from Om::Language::DefaultConsumer< Evaluator >
virtual ~DefaultConsumer ()=0
 
virtual void TakeElement (Operand &)
 
virtual void TakeElement (Operand const &)
 
virtual void TakeElement (Operator &)
 
virtual void TakeElement (Operator const &)
 
virtual void TakeElement (Separator &)
 
virtual void TakeElement (Separator const &)
 
virtual void TakeElements (Producer &)
 
virtual void TakeElements (Producer const &)
 
virtual void TakeQuotedElements (Producer &)
 
virtual void TakeQuotedElements (Producer const &)
 
- Public Member Functions inherited from Om::Language::Consumer
virtual ~Consumer ()=0
 
template<typename TheOperator , typename TheSeparator >
void Parse (Reader &)
 
void TakeElement (Null &)
 Takes a Null Element, which is disregarded. More...
 
void TakeElement (Null const &)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
- Public Member Functions inherited from Om::Language::Producer
virtual ~Producer ()=0
 

Private Types

typedef boost::ptr_vector< Operation::IncompleteOperationIncompleteOperationVector
 An IncompleteOperation vector. More...
 

Private Member Functions

 Evaluator (Evaluator const &)
 
Evaluator const & operator= (Evaluator const &)
 
void Evaluate (Evaluation &)
 

Static Private Member Functions

template<typename TheIterator >
static void GiveElements (TheIterator, TheIterator const, Consumer &)
 
template<typename TheEvaluator >
static std::auto_ptr< ProgramGiveProgram (TheEvaluator &)
 

Private Attributes

ConsumerthisOutput
 The output Consumer. More...
 
Translator const & thisTranslator
 The Translator used for resolving Operator to Operation. More...
 
IncompleteOperationVector thisIncompleteOperationVector
 A vector of IncompleteOperation with the most current at the back. More...
 
bool thisGaveElementToOutput
 True if an Element has been given to the output Consumer. More...
 

Detailed Description

The Evaluator interprets each Element as follows:

The program output by the Evaluator is an Expression. Note that if each line in the Expression was terminated by Symbol::theLineSeparatorSymbol, more than one Evaluator could not be connected in sequence without each contributing Symbol::theLineSeparatorSymbol to the final output.

Definition at line 58 of file evaluator.hpp.

Member Typedef Documentation

◆ IncompleteOperationVector

Definition at line 161 of file evaluator.hpp.

Constructor & Destructor Documentation

◆ ~Evaluator()

virtual Om::Language::Evaluator::~Evaluator ( )
virtual

If an exception is thrown, it will be caught and ignored, and each Element may not be flushed. This would only occur in an extreme situation such as insufficient memory.

◆ Evaluator() [1/2]

Om::Language::Evaluator::Evaluator ( Consumer theOutput,
Translator const &  theTranslator 
)
explicit
Parameters
theOutputThe output Consumer.
theTranslatorThe Translator, which must remain in scope for the life of the Evaluator and is expected to not change.

◆ Evaluator() [2/2]

Om::Language::Evaluator::Evaluator ( Evaluator const &  )
private

Member Function Documentation

◆ Clear()

virtual void Om::Language::Evaluator::Clear ( )
virtual

◆ GetTranslator()

Translator const& Om::Language::Evaluator::GetTranslator ( ) const

◆ GiveElements() [1/3]

virtual void Om::Language::Evaluator::GiveElements ( Consumer )
virtual

◆ GiveElements() [2/3]

virtual void Om::Language::Evaluator::GiveElements ( Consumer ) const
virtual

◆ GiveProgram() [1/3]

virtual std::auto_ptr<Program> Om::Language::Evaluator::GiveProgram ( )
virtual

◆ GiveProgram() [2/3]

virtual std::auto_ptr<Program> Om::Language::Evaluator::GiveProgram ( ) const
virtual

◆ IsEmpty()

virtual bool Om::Language::Evaluator::IsEmpty ( ) const
virtual

◆ ParseElements()

virtual void Om::Language::Evaluator::ParseElements ( Reader )
virtual

◆ ParseQuotedElements() [1/2]

virtual void Om::Language::Evaluator::ParseQuotedElements ( Reader )
virtual

◆ ParseQuotedElements() [2/2]

void Om::Language::Evaluator::ParseQuotedElements ( Evaluation ,
Reader  
)

◆ TakeOperand() [1/2]

template<typename TheOperand >
void Om::Language::Evaluator::TakeOperand ( TheOperand &  )

◆ TakeOperand() [2/2]

template<typename TheOperand >
void Om::Language::Evaluator::TakeOperand ( Evaluation ,
TheOperand &   
)

◆ TakeOperation()

template<typename TheOperation >
void Om::Language::Evaluator::TakeOperation ( std::auto_ptr< TheOperation >  )

◆ TakeOperator() [1/2]

template<typename TheOperator >
void Om::Language::Evaluator::TakeOperator ( TheOperator &  )

Evaluates the Operator in the following order:

  • Attempts to evaluate the Operator in each Translator, in order.
  • Attempts to evaluate the empty Operator (for the default definition) in each Translator, in order. If it was not done in this way, there would be no point in nesting if there was a default definition in the first Translator attempted.

◆ TakeOperator() [2/2]

template<typename TheOperator >
void Om::Language::Evaluator::TakeOperator ( Evaluation ,
TheOperator &   
)

◆ TakeQuotedProducer() [1/2]

template<typename TheProducer >
void Om::Language::Evaluator::TakeQuotedProducer ( TheProducer &  )

◆ TakeQuotedProducer() [2/2]

template<typename TheProducer >
void Om::Language::Evaluator::TakeQuotedProducer ( Evaluation ,
TheProducer &   
)

◆ TakeSeparator()

template<typename TheSeparator >
void Om::Language::Evaluator::TakeSeparator ( TheSeparator &  )

◆ GiveElements() [3/3]

template<typename TheIterator >
static void Om::Language::Evaluator::GiveElements ( TheIterator  ,
TheIterator const  ,
Consumer  
)
staticprivate

◆ GiveProgram() [3/3]

template<typename TheEvaluator >
static std::auto_ptr<Program> Om::Language::Evaluator::GiveProgram ( TheEvaluator &  )
staticprivate

◆ operator=()

Evaluator const& Om::Language::Evaluator::operator= ( Evaluator const &  )
private

◆ Evaluate()

void Om::Language::Evaluator::Evaluate ( Evaluation )
private

Member Data Documentation

◆ thisOutput

Consumer& Om::Language::Evaluator::thisOutput
private

Definition at line 185 of file evaluator.hpp.

◆ thisTranslator

Translator const& Om::Language::Evaluator::thisTranslator
private

Definition at line 191 of file evaluator.hpp.

◆ thisIncompleteOperationVector

IncompleteOperationVector Om::Language::Evaluator::thisIncompleteOperationVector
private

Definition at line 197 of file evaluator.hpp.

◆ thisGaveElementToOutput

bool Om::Language::Evaluator::thisGaveElementToOutput
private

Definition at line 203 of file evaluator.hpp.


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