Om
translator.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Translator_
16 
18 
19 #else
20 
21  #include "om/language/writer.hpp"
22  #include "om/language/evaluator.hpp"
23 
24 // MARK: - Om::Language::Translator
25 
26  #define Type_ \
27  Om::Language::Translator
28 
29 // MARK: public (non-static)
30 
31 inline void Type_::Evaluate(
32  Om::Source::Source<CodePoint const> & theCodePointSource,
33  Om::Sink::Sink<CodePoint const> & theCodePointSink
34 ) const {
35  Writer theWriter(theCodePointSink);
36  Reader theReader(theCodePointSource);
37  Evaluator(
38  theWriter,
39  *this
40  ).ParseElements(theReader);
41 }
42 
43 inline std::string Type_::Evaluate(
44  char const theCodeUnitIterator[]
45 ) const {
46  assert(theCodeUnitIterator);
47  std::string theString;
48  {
49  Om::Source::CodePointSource<> theCodePointSource(theCodeUnitIterator);
51  std::back_insert_iterator<std::string>
52  > theCodePointSink(
53  std::back_inserter(theString)
54  );
55  this->Evaluate(
56  theCodePointSource,
57  theCodePointSink
58  );
59  }
60  return theString;
61 }
62 
63 inline void Type_::GiveElements(Consumer & theConsumer) const {
64  assert(0);
65  throw std::logic_error("Pure virtual function called.");
66 }
67 
68 inline bool Type_::IsEmpty() const {
69  assert(0);
70  throw std::logic_error("Pure virtual function called.");
71 }
72 
73 inline bool Type_::Translate(
74  Evaluation &,
75  Operator const &
76 ) const {
77  assert(0);
78  throw std::logic_error("Pure virtual function called.");
79 }
80 
81  #undef Type_
82 
83 #endif
A CodePoint Sink that pushes each code unit to the iterator.
Any object that items can be pushed to.
Definition: sink.hpp:31
A CodePoint Source that reads each code unit from the iterator.
Any object that items can be pulled from.
Definition: source.hpp:31
Om header file.
Om header file.
Om header file.