15 #ifndef Om_Language_Separator_
23 #ifndef Om_Macro_Precompilation_
25 #include "boost/test/unit_test.hpp"
33 BOOST_AUTO_TEST_SUITE(SeparatorTest)
35 BOOST_AUTO_TEST_CASE(DereferenceTest) {
37 Separator theMutableSeparator;
38 Atom & theMutableAtom = theMutableSeparator;
39 Program & theMutableDereference = *theMutableAtom;
41 typeid(theMutableDereference) ==
typeid(Null)
46 Separator
const theImmutableSeparator;
47 Atom
const & theImmutableAtom = theImmutableSeparator;
48 Program
const & theImmutableDereference = *theImmutableAtom;
50 typeid(theImmutableDereference) ==
typeid(Null)
55 BOOST_AUTO_TEST_CASE(ReadTest) {
56 char const theCode[] =
"0\n\t {1\n\t {2\n\t } 3\n\t } {4\n\t} 5\n";
57 std::string theResult;
60 std::back_insert_iterator<std::string>
62 std::back_inserter(theResult)
64 Writer theWriter(theCodePointSink);
67 Reader theReader(theCodePointSource);
68 Separator theSeparator;
69 theSeparator.ParseElements(theReader);
70 theSeparator.GiveElements(theWriter);
78 BOOST_AUTO_TEST_SUITE_END()
91 Om::Language::Separator
95 inline Type_
const & Type_::GetLineSeparator() {
100 inline char const * Type_::GetName() {
106 inline Type_::Separator() {}
108 inline Type_::Separator(
114 theCodePointSource.
Pop()
116 switch (*theCodePointSource) {
120 this->thisString.push_back(
121 static_cast<char>(*theCodePointSource)
129 DefaultAtom<Separator>(
130 static_cast<char>(theSeparatorSymbol)
139 inline Type_ & Type_::operator =(Separator theSeparator) {
140 this->Swap(theSeparator);
144 inline void Type_::ParseElements(Reader & theReader) {
151 switch (*theReader) {
158 Reader theOperandReader(theCodePointSource);
159 this->ParseQuotedElements(theOperandReader);
167 this->thisString.push_back(
168 static_cast<char>(*theReader)
175 inline void Type_::ParseQuotedElements(Reader & theReader) {
183 template <
typename TheOperand>
184 inline void Type_::TakeOperand(TheOperand &) {}
186 template <
typename TheOperator>
187 inline void Type_::TakeOperator(TheOperator &) {}
189 template <
typename TheProducer>
190 inline void Type_::TakeQuotedProducer(TheProducer &) {}
192 template <
typename TheSeparator>
193 inline void Type_::TakeSeparator(TheSeparator & theSeparator) {
195 !theSeparator.IsEmpty()
197 this->thisString.append(theSeparator.thisString);
200 inline void Type_::TakeSeparatorSymbol(
203 this->thisString.push_back(
204 static_cast<char>(theSymbol)
217 theFirst.
Swap(theSecond);
void Swap(ThisImplementation &)
The Separator implementation.
A CodePoint Sink that pushes each code unit to the iterator.
A CodePoint Source that reads each code unit from the iterator.
Any object that items can be pulled from.
virtual void Pop()=0
Pops the current item.
SeparatorSymbol
A Separator symbol.
@ theSpaceSeparatorSymbol
void swap(Om::Language::Expression &, Om::Language::Expression &)
#define Om_Language_Separator_GetName_()
#define Om_Language_Symbol_SeparatorSymbol_GetCases_()
Generates switch cases for each Om::Language::Symbol::SeparatorSymbol.