Om
skip_operation.cpp
Go to the documentation of this file.
1 
15 #ifndef Om_Language_Operation_SkipOperation_
16 
18 
19  #ifdef Om_Macro_Test_
20 
21  #ifndef Om_Macro_Precompilation_
22 
23  #include "boost/test/unit_test.hpp"
24 
25  #endif
26 
27 namespace Om {
28 
29  namespace Language {
30 
31  namespace Operation {
32 
33  BOOST_AUTO_TEST_SUITE(SkipOperationTest)
34 
35  BOOST_AUTO_TEST_CASE(DefinitionTest) {
36  BOOST_CHECK_EQUAL(
37  "{skip}",
38  System::Get().Evaluate("drop find {skip} system")
39  );
40  }
41 
42  BOOST_AUTO_TEST_CASE(GeneralTest) {
43  BOOST_CHECK_EQUAL(
44  "{A}{B}{B}",
45  System::Get().Evaluate("skip{copy}{A}{B}")
46  );
47 
48  BOOST_CHECK_EQUAL(
49  "{A}{}{}",
50  System::Get().Evaluate("skip{copy}{A}{}")
51  );
52 
53  BOOST_CHECK_EQUAL(
54  "{A}{B}",
55  System::Get().Evaluate("skip{}{A}{B}")
56  );
57  }
58 
59  BOOST_AUTO_TEST_SUITE_END()
60 
61  }
62 
63  }
64 
65 }
66 
67  #endif
68 
69 #else
70 
71 // MARK: - Om::Language::Operation::SkipOperation
72 
73  #define Type_ \
74  Om::Language::Operation::SkipOperation
75 
76 // MARK: public (static)
77 
78 inline char const * Type_::GetName() {
80 }
81 
82 template <typename TheSkipOperation>
83 inline void Type_::GiveElements(
84  TheSkipOperation & theSkipOperation,
85  Consumer & theConsumer
86 ) {
87  theConsumer.TakeElement(
88  GetOperator()
89  );
90  if (
91  !theSkipOperation.thisExpression.IsEmpty()
92  ) {
93  theConsumer.TakeQuotedElements(theSkipOperation.thisExpression);
94  }
95 }
96 
97 // MARK: public (non-static)
98 
99 inline Type_::SkipOperation():
100 thisExpression() {}
101 
102 template <typename TheOperand>
103 inline bool Type_::TakeOperand(
104  Evaluation & theEvaluation,
105  TheOperand & theOperand
106 ) {
107  assert(
108  !theOperand.IsEmpty()
109  );
110  return this->TakeQuotedProducer(
111  theEvaluation,
112  *theOperand.GetProgram()
113  );
114 }
115 
116 template <typename TheProducer>
117 inline bool Type_::TakeQuotedProducer(
118  Evaluation & theEvaluation,
119  TheProducer & theProducer
120 ) {
121  if (
122  this->thisExpression.IsEmpty()
123  ) {
124  this->thisExpression.TakeElements(theProducer);
125  return this->thisExpression.IsEmpty();
126  }
127  theEvaluation.TakeProducer(this->thisExpression);
128  theEvaluation.TakeQuotedProducer(theProducer);
129  return true;
130 }
131 
132  #undef Type_
133 
134 #endif
static System & Get()
The Om library.
Definition: code_point.hpp:26
Om header file.
#define Om_Language_Operation_SkipOperation_GetName_()