15 #ifndef Om_Language_Evaluator_
29 Om::Language::Evaluator
33 inline Type_::~Evaluator() {
38 if (this->thisGaveElementToOutput) {
39 this->thisOutput.TakeElement(
40 Separator::GetLineSeparator()
43 this->GiveElements(this->thisOutput);
48 inline Type_::Evaluator(
50 Translator
const & theTranslator
52 thisOutput(theOutput),
53 thisTranslator(theTranslator),
54 thisIncompleteOperationVector(),
55 thisGaveElementToOutput() {}
57 inline void Type_::Clear() {
58 this->thisIncompleteOperationVector.clear();
62 return this->thisTranslator;
65 inline void Type_::GiveElements(Consumer & theConsumer) {
67 this->thisIncompleteOperationVector.begin(),
68 this->thisIncompleteOperationVector.end(),
74 inline void Type_::GiveElements(Consumer & theConsumer)
const {
76 this->thisIncompleteOperationVector.begin(),
77 this->thisIncompleteOperationVector.end(),
82 inline std::auto_ptr<Om::Language::Program> Type_::GiveProgram() {
83 return this->GiveProgram(*
this);
86 inline std::auto_ptr<Om::Language::Program> Type_::GiveProgram()
const {
87 return this->GiveProgram(*
this);
90 inline bool Type_::IsEmpty()
const {
91 return this->thisIncompleteOperationVector.empty();
94 inline void Type_::ParseElements(Reader & theReader) {
101 inline void Type_::ParseQuotedElements(Reader & theReader) {
102 Evaluation theEvaluation(*
this);
103 this->ParseQuotedElements(
107 this->Evaluate(theEvaluation);
110 inline void Type_::ParseQuotedElements(
111 Evaluation & theEvaluation,
115 this->thisIncompleteOperationVector.empty()
117 this->thisOutput.ParseQuotedElements(theReader);
118 this->thisGaveElementToOutput =
true;
120 std::auto_ptr<Operation::IncompleteOperation> theOperation(
121 this->thisIncompleteOperationVector.pop_back().release()
127 !theOperation->ParseQuotedElements(
132 this->thisIncompleteOperationVector.push_back(theOperation);
137 template <
typename TheOperand>
138 inline void Type_::TakeOperand(TheOperand & theOperand) {
140 !theOperand.IsEmpty()
142 Evaluation theEvaluation(*
this);
147 this->Evaluate(theEvaluation);
150 template <
typename TheOperand>
151 inline void Type_::TakeOperand(
152 Evaluation & theEvaluation,
153 TheOperand & theOperand
156 !theOperand.IsEmpty()
159 this->thisIncompleteOperationVector.empty()
161 this->thisOutput.TakeElement(theOperand);
162 this->thisGaveElementToOutput =
true;
164 std::auto_ptr<Operation::IncompleteOperation> theOperation(
165 this->thisIncompleteOperationVector.pop_back().release()
171 !theOperation->TakeElement(
176 this->thisIncompleteOperationVector.push_back(theOperation);
181 template <
typename TheOperation>
182 inline void Type_::TakeOperation(
183 std::auto_ptr<TheOperation> theOperation
185 this->thisIncompleteOperationVector.push_back(theOperation);
188 template <
typename TheOperator>
189 inline void Type_::TakeOperator(TheOperator & theOperator) {
190 Evaluation theEvaluation(*
this);
195 this->Evaluate(theEvaluation);
198 template <
typename TheOperator>
199 inline void Type_::TakeOperator(
200 Evaluation & theEvaluation,
201 TheOperator & theOperator
204 !theOperator.IsEmpty()
207 !this->thisTranslator.Translate(
211 !this->thisTranslator.Translate(
216 if (this->thisGaveElementToOutput) {
217 this->thisOutput.TakeElement(
218 Separator::GetLineSeparator()
225 this->GiveElements(this->thisOutput);
226 this->thisOutput.TakeElement(
227 Separator::GetLineSeparator()
231 this->thisOutput.TakeElement(theOperator);
232 this->thisGaveElementToOutput =
true;
236 template <
typename TheProducer>
237 inline void Type_::TakeQuotedProducer(TheProducer & theProducer) {
238 Evaluation theEvaluation(*
this);
239 this->TakeQuotedProducer(
243 this->Evaluate(theEvaluation);
246 template <
typename TheProducer>
247 inline void Type_::TakeQuotedProducer(
248 Evaluation & theEvaluation,
249 TheProducer & theProducer
252 this->thisIncompleteOperationVector.empty()
254 this->thisOutput.TakeQuotedElements(theProducer);
255 this->thisGaveElementToOutput =
true;
257 std::auto_ptr<Operation::IncompleteOperation> theOperation(
258 this->thisIncompleteOperationVector.pop_back().release()
264 !theOperation->TakeQuotedElements(
269 this->thisIncompleteOperationVector.push_back(theOperation);
274 template <
typename TheSeparator>
275 inline void Type_::TakeSeparator(TheSeparator &) {}
279 template <
typename TheIterator>
280 inline void Type_::GiveElements(
281 TheIterator theCurrent,
282 TheIterator
const theEnd,
283 Consumer & theConsumer
285 if (theEnd != theCurrent) {
289 theConsumer.TakeElement(
290 Separator::GetLineSeparator()
293 theCurrent->GiveElements(theConsumer);
294 if (theEnd == ++theCurrent) {
301 template <
typename TheEvaluator>
302 inline std::auto_ptr<Om::Language::Program> Type_::GiveProgram(TheEvaluator & theEvaluator) {
303 std::auto_ptr<Program> theExpression(
new Expression);
307 theEvaluator.GiveElements(*theExpression);
308 return theExpression;
313 inline void Type_::Evaluate(Evaluation & theEvaluation) {
315 theEvaluation.GiveTerm(*
this)
An Operator lookup for use by an Evaluator.