Om
form.hpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Form_
16 
17  #define Om_Language_Form_ \
18  Om::Language::Form
19 
20  #include "om/language/operator.hpp"
22 
23 namespace Om {
24 
25  namespace Language {
26 
27  // MARK: - Om::Language::Form
28 
33  class Form {
34 
35  public: // MARK: public (static)
36 
37  class ElementRange;
38 
43  template <typename ThisOperand>
44  class OperandRange;
45 
46  public: // MARK: public (non-static)
47 
48  Form();
49 
55 
60  bool BackPopTerm();
61 
62  template <typename TheOperand>
63  void BackTakeOperand(TheOperand &);
64 
65  template <typename TheProducer>
66  void BackTakeQuotedProducer(TheProducer &);
67 
73 
78  bool FrontPopTerm();
79 
80  template <typename TheOperand>
81  void FrontTakeOperand(TheOperand &);
82 
83  template <typename TheProducer>
84  void FrontTakeQuotedProducer(TheProducer &);
85 
86  Operator const & GetOperator() const;
87 
89 
90  void GiveElements(Consumer &) const;
91 
92  bool IsEmpty() const;
93 
94  void Swap(Form &);
95 
100  template <typename TheOperator>
101  void TakeOperator(TheOperator &);
102 
103  private: // MARK: private (static)
104 
105  typedef std::deque<Operand> OperandDeque;
106 
107  template <
108  typename TheOperandIterator,
109  typename TheForm
110  >
111  static void GiveElements(
112  TheForm &,
113  Consumer &
114  );
115 
116  private: // MARK: private (non-static)
117 
119 
121 
122  };
123 
124  // MARK: - Om::Language::Form::ElementRange
125 
132  Element const,
133  ElementRange
134  > {
135 
136  public: // MARK: public (non-static)
137 
138  explicit ElementRange(Form const &);
139 
140  virtual bool operator !() const;
141 
142  virtual Element const & operator *() const;
143 
145  Element const,
147  >::Equals;
148 
149  bool Equals(ElementRange const &) const;
150 
151  void End();
152 
153  virtual void Pop();
154 
155  private: // MARK: private (non-static)
156 
157  OperandDeque::const_iterator thisOperandIterator;
158 
159  OperandDeque::const_iterator thisOperandEnd;
160 
162 
163  };
164 
165  // MARK: - Om::Language::
166 
168  Form::ElementRange const &,
169  Form::ElementRange const &
170  );
171 
173  Form::ElementRange const &,
174  Form::ElementRange const &
175  );
176 
177  // MARK: - Om::Language::Form::OperandRange<Operand>
178 
183  template <>
186  Operand,
187  OperandDeque::iterator
188  > {
189 
190  public: // MARK: public (non-static)
191 
192  explicit OperandRange(Form &);
193 
194  };
195 
196  // MARK: - Om::Language::Form::OperandRange<Operand const>
197 
202  template <>
205  Operand const,
206  OperandDeque::const_iterator
207  > {
208 
209  public: // MARK: public (non-static)
210 
211  explicit OperandRange(Form const &);
212 
213  };
214 
215  }
216 
217 }
218 
219 namespace boost {
220 
221  // MARK: - boost::
222 
223  template <>
224  void swap(
227  );
228 
229 }
230 
231  #include "om/language/form.cpp"
232 
233 #endif
An Element taker; takes at the back.
Definition: consumer.hpp:42
A Program that contains a single elemental item (or none, when IsEmpty() returns true).
Definition: element.hpp:33
A Form Element range.
Definition: form.hpp:134
virtual Element const & operator*() const
OperandDeque::const_iterator thisOperandEnd
Definition: form.hpp:159
OperandDeque::const_iterator thisOperandIterator
Definition: form.hpp:157
Element const * thisElement
Definition: form.hpp:161
virtual void Pop()
Pops the current item.
bool Equals(ElementRange const &) const
virtual bool operator!() const
A Form Operand range.
Definition: form.hpp:44
An Operator (which may be empty), followed by zero or more Operand instances.
Definition: form.hpp:33
Operator thisOperator
Definition: form.hpp:118
void GiveElements(Consumer &)
void BackTakeOperand(TheOperand &)
std::deque< Operand > OperandDeque
Definition: form.hpp:105
bool FrontGiveTerm(Consumer &)
void Swap(Form &)
Operator const & GetOperator() const
void FrontTakeQuotedProducer(TheProducer &)
bool BackGiveTerm(Consumer &)
void BackTakeQuotedProducer(TheProducer &)
static void GiveElements(TheForm &, Consumer &)
OperandDeque thisOperandDeque
Definition: form.hpp:120
bool IsEmpty() const
void FrontTakeOperand(TheOperand &)
void GiveElements(Consumer &) const
void TakeOperator(TheOperator &)
Replaces the Form Operator.
The Operand implementation.
Definition: operand.hpp:56
The Operator implementation.
Definition: operator.hpp:60
A range over a collection, starting from the front.
A partial implementation of Source.
Om source file.
bool operator!=(DefaultAtom< TheImplementation > const &, DefaultAtom< TheImplementation > const &)
bool operator==(DefaultAtom< TheImplementation > const &, DefaultAtom< TheImplementation > const &)
The Om library.
Definition: code_point.hpp:26
void swap(Om::Language::Expression &, Om::Language::Expression &)
Om header file.