Om
evaluator.hpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Evaluator_
16 
17  #define Om_Language_Evaluator_ \
18  Om::Language::Evaluator
19 
21  #include "om/language/producer.hpp"
22 
23  #ifndef Om_Macro_Precompilation_
24 
25  #include "boost/ptr_container/ptr_vector.hpp"
26 
27  #endif
28 
29 namespace Om {
30 
31  namespace Language {
32 
34  class Evaluation;
35 
36  namespace Operation {
37 
38  class IncompleteOperation;
39 
40  }
41 
42  class Translator;
44 
45  // MARK: - Om::Language::Evaluator
46 
58  class Evaluator:
59  public DefaultConsumer<Evaluator>,
60  public Producer {
61 
62  public: // MARK: public (non-static)
63 
70  virtual ~Evaluator();
71 
78  explicit Evaluator(
79  Consumer & theOutput,
80  Translator const & theTranslator
81  );
82 
83  virtual void Clear();
84 
85  Translator const & GetTranslator() const;
86 
91  virtual void GiveElements(Consumer &);
92 
97  virtual void GiveElements(Consumer &) const;
98 
99  virtual std::auto_ptr<Program> GiveProgram();
100 
101  virtual std::auto_ptr<Program> GiveProgram() const;
102 
103  virtual bool IsEmpty() const;
104 
105  virtual void ParseElements(Reader &);
106 
107  virtual void ParseQuotedElements(Reader &);
108 
110  Evaluation &,
111  Reader &
112  );
113 
114  template <typename TheOperand>
115  void TakeOperand(TheOperand &);
116 
117  template <typename TheOperand>
119  Evaluation &,
120  TheOperand &
121  );
122 
123  template <typename TheOperation>
125  std::auto_ptr<TheOperation>
126  );
127 
134  template <typename TheOperator>
135  void TakeOperator(TheOperator &);
136 
137  template <typename TheOperator>
139  Evaluation &,
140  TheOperator &
141  );
142 
143  template <typename TheProducer>
144  void TakeQuotedProducer(TheProducer &);
145 
146  template <typename TheProducer>
148  Evaluation &,
149  TheProducer &
150  );
151 
152  template <typename TheSeparator>
153  void TakeSeparator(TheSeparator &);
154 
155  private: // MARK: private (static)
156 
161  typedef boost::ptr_vector<Operation::IncompleteOperation> IncompleteOperationVector;
162 
163  template <typename TheIterator>
164  static void GiveElements(
165  TheIterator,
166  TheIterator const,
167  Consumer &
168  );
169 
170  template <typename TheEvaluator>
171  static std::auto_ptr<Program> GiveProgram(TheEvaluator &);
172 
173  private: // MARK: private (non-static)
174 
176 
177  Evaluator const & operator =(Evaluator const &);
178 
180 
186 
192 
198 
204 
205  };
206 
207  }
208 
209 }
210 
211  #include "om/language/evaluator.cpp"
212 
213 #endif
An Element taker; takes at the back.
Definition: consumer.hpp:42
A partial implementation of Consumer.
The current evaluation.
Definition: evaluation.hpp:42
A Consumer that evaluates Program instances.
Definition: evaluator.hpp:60
Consumer & thisOutput
The output Consumer.
Definition: evaluator.hpp:185
static void GiveElements(TheIterator, TheIterator const, Consumer &)
virtual void GiveElements(Consumer &)
Gives to the argument each Element currently contained in the Evaluator.
void TakeOperator(TheOperator &)
void Evaluate(Evaluation &)
virtual bool IsEmpty() const
boost::ptr_vector< Operation::IncompleteOperation > IncompleteOperationVector
An IncompleteOperation vector.
Definition: evaluator.hpp:161
virtual std::auto_ptr< Program > GiveProgram() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual void GiveElements(Consumer &) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void TakeQuotedProducer(Evaluation &, TheProducer &)
void TakeOperation(std::auto_ptr< TheOperation >)
virtual ~Evaluator()
Flushes the contents.
static std::auto_ptr< Program > GiveProgram(TheEvaluator &)
Evaluator const & operator=(Evaluator const &)
void TakeOperand(TheOperand &)
void TakeQuotedProducer(TheProducer &)
bool thisGaveElementToOutput
True if an Element has been given to the output Consumer.
Definition: evaluator.hpp:203
virtual void ParseElements(Reader &)
virtual std::auto_ptr< Program > GiveProgram()
Returns a new Program populated with the contents of this.
Evaluator(Evaluator const &)
IncompleteOperationVector thisIncompleteOperationVector
A vector of IncompleteOperation with the most current at the back.
Definition: evaluator.hpp:197
void TakeOperator(Evaluation &, TheOperator &)
virtual void ParseQuotedElements(Reader &)
Translator const & thisTranslator
The Translator used for resolving Operator to Operation.
Definition: evaluator.hpp:191
void ParseQuotedElements(Evaluation &, Reader &)
virtual void Clear()
void TakeOperand(Evaluation &, TheOperand &)
Evaluator(Consumer &theOutput, Translator const &theTranslator)
void TakeSeparator(TheSeparator &)
Translator const & GetTranslator() const
An Element giver; gives from the front.
Definition: producer.hpp:40
Produces each CodePoint until the end of the Source.
Definition: reader.hpp:37
An Operator lookup for use by an Evaluator.
Definition: translator.hpp:62
Om header file.
Om source file.
The Om library.
Definition: code_point.hpp:26
Om header file.