Om
consumer.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Consumer_
16 
17  #include "om/language/consumer.hpp"
18 
19 #else
20 
21  #include "om/language/reader.hpp"
22 
23  #ifndef Om_Macro_Precompilation_
24 
25  #include <cassert>
26  #include <stdexcept>
27 
28  #endif
29 
30 // MARK: - Om::Language::Consumer
31 
32  #define Type_ \
33  Om::Language::Consumer
34 
35 // MARK: public (non-static)
36 
37 inline Type_::~Consumer() {}
38 
39 template<
40  typename TheOperator,
41  typename TheSeparator
42 >
43 inline void Type_::Parse(Reader & theReader) {
44  while (theReader) {
45  assert(Symbol::theEndOperandSymbol != *theReader);
46  switch (*theReader) {
48  theReader.Pop();
49  {
50  // Ensure that this does not resolve to the copy constructor.
51  Om::Source::Source<CodePoint const> & theCodePointSource = theReader;
52 
53  Reader theOperandReader(theCodePointSource);
54  this->ParseQuotedElements(theOperandReader);
55  }
56  if (!theReader) {
57  return;
58  }
59  assert(Symbol::theEndOperandSymbol == *theReader);
60  theReader.Pop();
61  continue;
63  {
64  TheSeparator theSeparator(theReader);
65  this->TakeElement(theSeparator);
66  }
67  continue;
68  default:
69  {
70  TheOperator theOperator(theReader);
71  this->TakeElement(theOperator);
72  }
73  // Fall through.
74  }
75  }
76 }
77 
78 inline void Type_::ParseElements(Reader &) {
79  assert(0);
80  throw std::logic_error("Pure virtual function called.");
81 }
82 
83 inline void Type_::ParseQuotedElements(Reader &) {
84  assert(0);
85  throw std::logic_error("Pure virtual function called.");
86 }
87 
88 inline void Type_::TakeElement(Operand &) {
89  assert(0);
90  throw std::logic_error("Pure virtual function called.");
91 }
92 
93 inline void Type_::TakeElement(Null &) {}
94 
95 inline void Type_::TakeElement(Null const &) {}
96 
97 inline void Type_::TakeElement(Operand const &) {
98  assert(0);
99  throw std::logic_error("Pure virtual function called.");
100 }
101 
102 inline void Type_::TakeElement(Operator &) {
103  assert(0);
104  throw std::logic_error("Pure virtual function called.");
105 }
106 
107 inline void Type_::TakeElement(Operator const &) {
108  assert(0);
109  throw std::logic_error("Pure virtual function called.");
110 }
111 
112 inline void Type_::TakeElement(Separator &) {
113  assert(0);
114  throw std::logic_error("Pure virtual function called.");
115 }
116 
117 inline void Type_::TakeElement(Separator const &) {
118  assert(0);
119  throw std::logic_error("Pure virtual function called.");
120 }
121 
122 inline void Type_::TakeElements(Producer &) {
123  assert(0);
124  throw std::logic_error("Pure virtual function called.");
125 }
126 
127 inline void Type_::TakeElements(Producer const &) {
128  assert(0);
129  throw std::logic_error("Pure virtual function called.");
130 }
131 
132 inline void Type_::TakeQuotedElements(Producer &) {
133  assert(0);
134  throw std::logic_error("Pure virtual function called.");
135 }
136 
137 inline void Type_::TakeQuotedElements(Producer const &) {
138  assert(0);
139  throw std::logic_error("Pure virtual function called.");
140 }
141 
142  #undef Type_
143 
144 #endif
Any object that items can be pulled from.
Definition: source.hpp:31
Om header file.
Om header file.
#define Om_Language_Symbol_SeparatorSymbol_GetCases_()
Generates switch cases for each Om::Language::Symbol::SeparatorSymbol.