├── .gitignore ├── CMakeLists.txt ├── ChangeLog.markdown ├── License.markdown ├── ReadMe.markdown ├── code ├── om.cpp ├── om.external ├── om.hpp ├── om.internal └── om │ ├── code_point.cpp │ ├── code_point.hpp │ ├── copyable.cpp │ ├── copyable.hpp │ ├── default_copyable.cpp │ ├── default_copyable.hpp │ ├── default_giveable.cpp │ ├── default_giveable.hpp │ ├── default_moveable.cpp │ ├── default_moveable.hpp │ ├── giveable.cpp │ ├── giveable.hpp │ ├── language.cpp │ ├── language.hpp │ ├── language │ ├── atom.cpp │ ├── atom.hpp │ ├── consumer.cpp │ ├── consumer.hpp │ ├── default_atom.cpp │ ├── default_atom.hpp │ ├── default_consumer.cpp │ ├── default_consumer.hpp │ ├── default_element.cpp │ ├── default_element.hpp │ ├── default_program.cpp │ ├── default_program.hpp │ ├── element.cpp │ ├── element.hpp │ ├── environment.cpp │ ├── environment.hpp │ ├── evaluation.cpp │ ├── evaluation.hpp │ ├── evaluator.cpp │ ├── evaluator.hpp │ ├── expression.cpp │ ├── expression.hpp │ ├── form.cpp │ ├── form.hpp │ ├── lexicon.cpp │ ├── lexicon.hpp │ ├── literal.cpp │ ├── literal.hpp │ ├── null.cpp │ ├── null.hpp │ ├── operand.cpp │ ├── operand.hpp │ ├── operation.cpp │ ├── operation.hpp │ ├── operation │ │ ├── back_pull_character_operation.cpp │ │ ├── back_pull_character_operation.hpp │ │ ├── back_pull_code_point_operation.cpp │ │ ├── back_pull_code_point_operation.hpp │ │ ├── back_pull_element_operation.cpp │ │ ├── back_pull_element_operation.hpp │ │ ├── back_pull_form_operation.cpp │ │ ├── back_pull_form_operation.hpp │ │ ├── back_pull_operand_operation.cpp │ │ ├── back_pull_operand_operation.hpp │ │ ├── back_pull_operator_operation.cpp │ │ ├── back_pull_operator_operation.hpp │ │ ├── back_pull_pair_operation.cpp │ │ ├── back_pull_pair_operation.hpp │ │ ├── back_pull_separator_operation.cpp │ │ ├── back_pull_separator_operation.hpp │ │ ├── back_pull_term_operation.cpp │ │ ├── back_pull_term_operation.hpp │ │ ├── choose_operation.cpp │ │ ├── choose_operation.hpp │ │ ├── copy_operation.cpp │ │ ├── copy_operation.hpp │ │ ├── decode_operation.cpp │ │ ├── decode_operation.hpp │ │ ├── default_incomplete_operation.cpp │ │ ├── default_incomplete_operation.hpp │ │ ├── define_operation.cpp │ │ ├── define_operation.hpp │ │ ├── dequote_operation.cpp │ │ ├── dequote_operation.hpp │ │ ├── do_operation.cpp │ │ ├── do_operation.hpp │ │ ├── drop_operation.cpp │ │ ├── drop_operation.hpp │ │ ├── encode_operation.cpp │ │ ├── encode_operation.hpp │ │ ├── environment_operation.cpp │ │ ├── environment_operation.hpp │ │ ├── equals_operation.cpp │ │ ├── equals_operation.hpp │ │ ├── evaluate_operation.cpp │ │ ├── evaluate_operation.hpp │ │ ├── expression_back_push_operation.cpp │ │ ├── expression_back_push_operation.hpp │ │ ├── expression_front_push_operation.cpp │ │ ├── expression_front_push_operation.hpp │ │ ├── expression_operation.cpp │ │ ├── expression_operation.hpp │ │ ├── fill_operation.cpp │ │ ├── fill_operation.hpp │ │ ├── find_operation.cpp │ │ ├── find_operation.hpp │ │ ├── front_pull_character_operation.cpp │ │ ├── front_pull_character_operation.hpp │ │ ├── front_pull_code_point_operation.cpp │ │ ├── front_pull_code_point_operation.hpp │ │ ├── front_pull_element_operation.cpp │ │ ├── front_pull_element_operation.hpp │ │ ├── front_pull_form_operation.cpp │ │ ├── front_pull_form_operation.hpp │ │ ├── front_pull_operand_operation.cpp │ │ ├── front_pull_operand_operation.hpp │ │ ├── front_pull_operator_operation.cpp │ │ ├── front_pull_operator_operation.hpp │ │ ├── front_pull_pair_operation.cpp │ │ ├── front_pull_pair_operation.hpp │ │ ├── front_pull_separator_operation.cpp │ │ ├── front_pull_separator_operation.hpp │ │ ├── front_pull_term_operation.cpp │ │ ├── front_pull_term_operation.hpp │ │ ├── front_push_operation.cpp │ │ ├── front_push_operation.hpp │ │ ├── incomplete_operation.cpp │ │ ├── incomplete_operation.hpp │ │ ├── inject_operation.cpp │ │ ├── inject_operation.hpp │ │ ├── lexicon_back_push_operation.cpp │ │ ├── lexicon_back_push_operation.hpp │ │ ├── lexicon_front_push_operation.cpp │ │ ├── lexicon_front_push_operation.hpp │ │ ├── lexicon_operation.cpp │ │ ├── lexicon_operation.hpp │ │ ├── literal_back_push_operation.cpp │ │ ├── literal_back_push_operation.hpp │ │ ├── literal_front_push_operation.cpp │ │ ├── literal_front_push_operation.hpp │ │ ├── normalize_operation.cpp │ │ ├── normalize_operation.hpp │ │ ├── operand_operation.cpp │ │ ├── operand_operation.hpp │ │ ├── operator_back_push_operation.cpp │ │ ├── operator_back_push_operation.hpp │ │ ├── operator_front_push_operation.cpp │ │ ├── operator_front_push_operation.hpp │ │ ├── operator_operation.cpp │ │ ├── operator_operation.hpp │ │ ├── pair_operation.cpp │ │ ├── pair_operation.hpp │ │ ├── program_operation.cpp │ │ ├── program_operation.hpp │ │ ├── pull_operation.cpp │ │ ├── pull_operation.hpp │ │ ├── quote_operation.cpp │ │ ├── quote_operation.hpp │ │ ├── rearrange_operation.cpp │ │ ├── rearrange_operation.hpp │ │ ├── separator_operation.cpp │ │ ├── separator_operation.hpp │ │ ├── skip_operation.cpp │ │ ├── skip_operation.hpp │ │ ├── substitute_operation.cpp │ │ ├── substitute_operation.hpp │ │ ├── swap_operation.cpp │ │ ├── swap_operation.hpp │ │ ├── system_operation.cpp │ │ ├── system_operation.hpp │ │ ├── translate_operation.cpp │ │ └── translate_operation.hpp │ ├── operator.cpp │ ├── operator.hpp │ ├── pair.cpp │ ├── pair.hpp │ ├── producer.cpp │ ├── producer.hpp │ ├── program.cpp │ ├── program.hpp │ ├── reader.cpp │ ├── reader.hpp │ ├── separator.cpp │ ├── separator.hpp │ ├── symbol.cpp │ ├── symbol.hpp │ ├── symbol │ │ ├── operand_symbol.cpp │ │ ├── operand_symbol.hpp │ │ ├── operator_symbol.cpp │ │ ├── operator_symbol.hpp │ │ ├── separator_symbol.cpp │ │ └── separator_symbol.hpp │ ├── system.cpp │ ├── system.hpp │ ├── translator.cpp │ ├── translator.hpp │ ├── writer.cpp │ └── writer.hpp │ ├── list.cpp │ ├── list.hpp │ ├── macro.cpp │ ├── macro.hpp │ ├── moveable.cpp │ ├── moveable.hpp │ ├── owner.cpp │ ├── owner.hpp │ ├── shareable.cpp │ ├── shareable.hpp │ ├── sink.cpp │ ├── sink.hpp │ ├── sink │ ├── code_point_sink.cpp │ ├── code_point_sink.hpp │ ├── container_back_sink.cpp │ ├── container_back_sink.hpp │ ├── container_front_sink.cpp │ ├── container_front_sink.hpp │ ├── default_sink.cpp │ ├── default_sink.hpp │ ├── iterator_sink.cpp │ ├── iterator_sink.hpp │ ├── sink.cpp │ ├── sink.hpp │ ├── stream_sink.cpp │ └── stream_sink.hpp │ ├── source.cpp │ ├── source.hpp │ ├── source │ ├── code_point_source.cpp │ ├── code_point_source.hpp │ ├── code_point_string_back_source.cpp │ ├── code_point_string_back_source.hpp │ ├── code_point_string_front_source.cpp │ ├── code_point_string_front_source.hpp │ ├── collection_back_source.cpp │ ├── collection_back_source.hpp │ ├── collection_front_source.cpp │ ├── collection_front_source.hpp │ ├── container_back_source.cpp │ ├── container_back_source.hpp │ ├── container_front_source.cpp │ ├── container_front_source.hpp │ ├── default_source.cpp │ ├── default_source.hpp │ ├── empty_source.cpp │ ├── empty_source.hpp │ ├── iterator_pair_source.cpp │ ├── iterator_pair_source.hpp │ ├── iterator_source.cpp │ ├── iterator_source.hpp │ ├── singleton_source.cpp │ ├── singleton_source.hpp │ ├── source.cpp │ ├── source.hpp │ ├── stream_source.cpp │ └── stream_source.hpp │ ├── taker.cpp │ ├── taker.hpp │ ├── utf8.cpp │ └── utf8.hpp ├── dependencies ├── Boost │ └── build.cmake └── Icu4c │ └── build.cmake ├── documentation ├── Doxyfile ├── footer.html ├── header.html └── stylesheet.css ├── generate.bat ├── generate.sh └── images ├── operand.pdf ├── operand.png ├── operator.pdf ├── operator.png ├── program.pdf ├── program.png ├── separator.pdf └── separator.png /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /ReadMe.markdown: -------------------------------------------------------------------------------- 1 | # Om 2 | 3 | Om is an experimental high-level programming language with the goal of maximal simplicity. It is a concatenative, homoiconic, embeddable programming and algorithm notation language, implemented in C++, with minimal syntax (only three elements), prefix notation (whereby functions manipulate the remainder of the program itself), and "panmorphic" typing (allowing programming without data types). 4 | 5 | See the documentation for more information. 6 | -------------------------------------------------------------------------------- /code/om.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_ 16 | 17 | #include "om.hpp" 18 | 19 | #ifdef Om_Macro_Test_ 20 | 21 | #include "boost/test/included/unit_test.hpp" 22 | 23 | bool init_unit_test() { 24 | boost::debug::detect_memory_leaks(false); 25 | Om::Language::System::Get().Initialize("en_US.UTF-8"); 26 | return true; 27 | } 28 | 29 | #else 30 | 31 | /*! 32 | \param theArgumentCount 33 | The argument count; must be greater than 0. 34 | \param theArgumentArray 35 | The argument array contains (in order): 36 | - The program invocation. 37 | - (Optional) A valid UTF-8 locale string; defaults to "en_US.UTF-8". 38 | */ 39 | int main( 40 | int const theArgumentCount, 41 | char const * const theArgumentArray[] 42 | ) { 43 | assert(0 < theArgumentCount); 44 | assert(theArgumentArray); 45 | 46 | Om::Language::System::Get().Initialize( 47 | 1 < theArgumentCount ? 48 | theArgumentArray[1] : 49 | "en_US.UTF-8" 50 | ); 51 | 52 | typedef Om::Source::StreamSource<> CodeUnitSource; 53 | CodeUnitSource theCodeUnitSource(std::cin); 54 | Om::Source::CodePointSource theCodePointSource( 55 | theCodeUnitSource, 56 | CodeUnitSource() 57 | ); 58 | 59 | typedef Om::Sink::StreamSink<> CodeUnitSink; 60 | CodeUnitSink theCodeUnitSink(std::cout); 61 | Om::Sink::CodePointSink theCodePointSink(theCodeUnitSink); 62 | 63 | Om::Language::System::Get().Evaluate( 64 | theCodePointSource, 65 | theCodePointSink 66 | ); 67 | 68 | return EXIT_SUCCESS; 69 | } 70 | 71 | #endif 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /code/om.external: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "boost/array.hpp" 9 | #include "boost/checked_delete.hpp" 10 | #include "boost/integer_traits.hpp" 11 | #include "boost/intrusive_ptr.hpp" 12 | #include "boost/locale/boundary.hpp" 13 | #include "boost/locale/conversion.hpp" 14 | #include "boost/locale/encoding.hpp" 15 | #include "boost/locale/generator.hpp" 16 | #include "boost/locale/utf.hpp" 17 | #include "boost/optional.hpp" 18 | #include "boost/ptr_container/ptr_deque.hpp" 19 | #include "boost/ptr_container/ptr_map.hpp" 20 | #include "boost/ptr_container/ptr_vector.hpp" 21 | #include "boost/ref.hpp" 22 | #include "boost/scoped_ptr.hpp" 23 | #include "boost/swap.hpp" 24 | #include "boost/utility/in_place_factory.hpp" 25 | 26 | #ifdef Om_Macro_Test_ 27 | 28 | #include "boost/test/unit_test.hpp" 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /code/om.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om umbrella header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | Including this header file causes all other header files to be included. 15 | */ 16 | 17 | #ifndef Om_ 18 | 19 | #define Om_ \ 20 | Om 21 | 22 | #include "om.internal" 23 | 24 | /*! 25 | \brief 26 | The Om library. 27 | */ 28 | namespace Om {} 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /code/om/code_point.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_CodePoint_ 16 | 17 | #include "om/code_point.hpp" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /code/om/code_point.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_CodePoint_ 16 | 17 | #define Om_CodePoint_ \ 18 | Om::CodePoint 19 | 20 | #ifndef Om_Macro_Precompilation_ 21 | 22 | #include "boost/locale/utf.hpp" 23 | 24 | #endif 25 | 26 | namespace Om { 27 | 28 | /*! 29 | \brief 30 | A UTF-8 code point. 31 | */ 32 | typedef boost::locale::utf::code_point CodePoint; 33 | 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /code/om/copyable.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Copyable_ 16 | 17 | #include "om/copyable.hpp" 18 | 19 | #else 20 | 21 | #ifndef Om_Macro_Precompilation_ 22 | 23 | #include 24 | #include 25 | 26 | #endif 27 | 28 | // MARK: - Om::Copyable 29 | 30 | #define Type_ \ 31 | Om::Copyable 32 | 33 | // MARK: public (non-static) 34 | 35 | inline Type_::~Copyable() {} 36 | 37 | inline std::auto_ptr Type_::Copy() const { 38 | assert(0); 39 | throw std::logic_error("Pure virtual function called."); 40 | } 41 | 42 | #undef Type_ 43 | 44 | // MARK: - Om:: 45 | 46 | template 47 | inline std::auto_ptr Om::Copy(TheCopyable const & theCopyable) { 48 | return std::auto_ptr( 49 | static_cast( 50 | theCopyable.Copy().release() 51 | ) 52 | ); 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /code/om/copyable.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Copyable_ 16 | 17 | #define Om_Copyable_ \ 18 | Om::Copyable 19 | 20 | #ifndef Om_Macro_Precompilation_ 21 | 22 | #include 23 | 24 | #endif 25 | 26 | namespace Om { 27 | 28 | // MARK: - Om::Copyable 29 | 30 | /*! 31 | \brief 32 | An object that can be passed to #Copy to be copied. 33 | */ 34 | class Copyable { 35 | 36 | template 37 | friend std::auto_ptr Copy(TheCopyable const &); 38 | 39 | public: // MARK: public (non-static) 40 | 41 | virtual ~Copyable() = 0; 42 | 43 | /*! 44 | \return 45 | An owner pointer to a copy. 46 | */ 47 | virtual std::auto_ptr Copy() const = 0; 48 | 49 | private: // MARK: private (non-static) 50 | 51 | Copyable & operator =(Copyable const &); 52 | 53 | }; 54 | 55 | // MARK: - Om:: 56 | 57 | /*! 58 | \return 59 | A polymorphic copy of the object. 60 | */ 61 | template 62 | std::auto_ptr Copy(TheCopyable const &); 63 | 64 | } 65 | 66 | #include "om/copyable.cpp" 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /code/om/default_copyable.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_DefaultCopyable_ 16 | 17 | #include "om/default_copyable.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::DefaultCopyable 22 | 23 | #define Template_ \ 24 | template < \ 25 | typename ThisImplementation, \ 26 | typename ThisInterface \ 27 | > 28 | 29 | #define Type_ \ 30 | Om::DefaultCopyable< \ 31 | ThisImplementation, \ 32 | ThisInterface \ 33 | > 34 | 35 | // MARK: public (non-static) 36 | 37 | Template_ 38 | inline Type_::~DefaultCopyable() {} 39 | 40 | Template_ 41 | inline std::auto_ptr Type_::Copy() const { 42 | assert( 43 | dynamic_cast(this) 44 | ); 45 | return std::auto_ptr( 46 | new ThisImplementation( 47 | static_cast(*this) 48 | ) 49 | ); 50 | } 51 | 52 | #undef Type_ 53 | #undef Template_ 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /code/om/default_copyable.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_DefaultCopyable_ 16 | 17 | #define Om_DefaultCopyable_ \ 18 | Om::DefaultCopyable 19 | 20 | #include "om/copyable.hpp" 21 | 22 | namespace Om { 23 | 24 | // MARK: - Om::DefaultCopyable 25 | 26 | /*! 27 | \brief 28 | A partial implementation of Copyable. 29 | */ 30 | template < 31 | typename ThisImplementation, 32 | typename ThisInterface = Copyable 33 | > 34 | class DefaultCopyable: 35 | public ThisInterface { 36 | 37 | template 38 | friend std::auto_ptr Copy(TheCopyable const &); 39 | 40 | public: // MARK: public (non-static) 41 | 42 | virtual ~DefaultCopyable() = 0; 43 | 44 | /*! 45 | \return 46 | An owner pointer to a copy. 47 | */ 48 | virtual std::auto_ptr Copy() const; 49 | 50 | private: // MARK: private (non-static) 51 | 52 | DefaultCopyable & operator =(DefaultCopyable const &); 53 | 54 | }; 55 | 56 | } 57 | 58 | #include "om/default_copyable.cpp" 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /code/om/default_giveable.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_DefaultGiveable_ 16 | 17 | #include "om/default_giveable.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::DefaultGiveable 22 | 23 | #define Template_ \ 24 | template < \ 25 | typename ThisImplementation, \ 26 | typename ThisInterface \ 27 | > 28 | 29 | #define Type_ \ 30 | Om::DefaultGiveable< \ 31 | ThisImplementation, \ 32 | ThisInterface \ 33 | > 34 | 35 | // MARK: public (non-static) 36 | 37 | Template_ 38 | inline Type_::~DefaultGiveable() {} 39 | 40 | #undef Type_ 41 | #undef Template_ 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /code/om/default_giveable.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_DefaultGiveable_ 16 | 17 | #define Om_DefaultGiveable_ \ 18 | Om::DefaultGiveable 19 | 20 | #include "om/default_copyable.hpp" 21 | #include "om/default_moveable.hpp" 22 | #include "om/giveable.hpp" 23 | 24 | namespace Om { 25 | 26 | // MARK: - Om::DefaultGiveable 27 | 28 | /*! 29 | \brief 30 | A partial implementation of Giveable. 31 | */ 32 | template < 33 | typename ThisImplementation, 34 | typename ThisInterface = Giveable 35 | > 36 | class DefaultGiveable: 37 | public DefaultMoveable< 38 | ThisImplementation, 39 | DefaultCopyable< 40 | ThisImplementation, 41 | ThisInterface 42 | > 43 | > { 44 | 45 | public: // MARK: public (non-static) 46 | 47 | virtual ~DefaultGiveable() = 0; 48 | 49 | private: // MARK: private (non-static) 50 | 51 | DefaultGiveable & operator =(DefaultGiveable const &); 52 | 53 | }; 54 | 55 | } 56 | 57 | #include "om/default_giveable.cpp" 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /code/om/default_moveable.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_DefaultMoveable_ 16 | 17 | #include "om/default_moveable.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::DefaultMoveable 22 | 23 | #define Template_ \ 24 | template < \ 25 | typename ThisImplementation, \ 26 | typename ThisInterface \ 27 | > 28 | 29 | #define Type_ \ 30 | Om::DefaultMoveable< \ 31 | ThisImplementation, \ 32 | ThisInterface \ 33 | > 34 | 35 | // MARK: public (non-static) 36 | 37 | Template_ 38 | inline Type_::~DefaultMoveable() {} 39 | 40 | Template_ 41 | inline std::auto_ptr Type_::Move() { 42 | assert( 43 | dynamic_cast(this) 44 | ); 45 | std::auto_ptr theMoveable(new ThisImplementation); 46 | assert( 47 | theMoveable.get() 48 | ); 49 | theMoveable->Swap( 50 | static_cast(*this) 51 | ); 52 | return std::auto_ptr( 53 | theMoveable.release() 54 | ); 55 | } 56 | 57 | #undef Type_ 58 | #undef Template_ 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /code/om/default_moveable.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_DefaultMoveable_ 16 | 17 | #define Om_DefaultMoveable_ \ 18 | Om::DefaultMoveable 19 | 20 | #include "om/moveable.hpp" 21 | 22 | namespace Om { 23 | 24 | // MARK: - Om::DefaultMoveable 25 | 26 | /*! 27 | \brief 28 | A partial implementation of Moveable. 29 | */ 30 | template < 31 | typename ThisImplementation, 32 | typename ThisInterface = Moveable 33 | > 34 | class DefaultMoveable: 35 | public ThisInterface { 36 | 37 | template 38 | friend std::auto_ptr Move(TheMoveable &); 39 | 40 | public: // MARK: public (non-static) 41 | 42 | virtual ~DefaultMoveable() = 0; 43 | 44 | /*! 45 | \return 46 | An owner pointer to a moved object. 47 | */ 48 | virtual std::auto_ptr Move(); 49 | 50 | private: // MARK: private (non-static) 51 | 52 | DefaultMoveable & operator =(DefaultMoveable const &); 53 | 54 | }; 55 | 56 | } 57 | 58 | #include "om/default_moveable.cpp" 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /code/om/giveable.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Giveable_ 16 | 17 | #include "om/giveable.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::Giveable 22 | 23 | #define Type_ \ 24 | Om::Giveable 25 | 26 | // MARK: public (non-static) 27 | 28 | inline Type_::~Giveable() {} 29 | 30 | #undef Type_ 31 | 32 | // MARK: - Om:: 33 | 34 | template 35 | inline std::auto_ptr Om::Give(TheGiveable & theGiveable) { 36 | return Move(theGiveable); 37 | } 38 | 39 | template 40 | inline std::auto_ptr Om::Give(TheGiveable const & theGiveable) { 41 | return Copy(theGiveable); 42 | } 43 | 44 | template 45 | inline std::auto_ptr Om::Give( 46 | std::auto_ptr & theGiveable 47 | ) { 48 | return theGiveable; 49 | } 50 | 51 | template 52 | inline std::auto_ptr Om::Give( 53 | std::auto_ptr const & theGiveable 54 | ) { 55 | return ( 56 | theGiveable.get() ? 57 | Give(*theGiveable) : 58 | std::auto_ptr() 59 | ); 60 | } 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /code/om/giveable.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Giveable_ 16 | 17 | #define Om_Giveable_ \ 18 | Om::Giveable 19 | 20 | #include "om/copyable.hpp" 21 | #include "om/moveable.hpp" 22 | 23 | namespace Om { 24 | 25 | // MARK: - Om::Giveable 26 | 27 | /*! 28 | \brief 29 | An object that can be copied or moved via #Give. 30 | */ 31 | class Giveable: 32 | public Copyable, 33 | public Moveable { 34 | 35 | public: // MARK: public (non-static) 36 | 37 | virtual ~Giveable() = 0; 38 | 39 | private: // MARK: private (non-static) 40 | 41 | Giveable & operator =(Giveable const &); 42 | 43 | }; 44 | 45 | // MARK: - Om:: 46 | 47 | /*! 48 | \brief 49 | Calls #Move on the object. 50 | \return 51 | The resulting object. 52 | */ 53 | template 54 | std::auto_ptr Give(TheGiveable &); 55 | 56 | /*! 57 | \brief 58 | Calls #Copy on the object. 59 | \return 60 | The resulting object. 61 | */ 62 | template 63 | std::auto_ptr Give(TheGiveable const &); 64 | 65 | /*! 66 | \brief 67 | Transfers pointer ownership. 68 | \return 69 | The resulting object. 70 | */ 71 | template 72 | std::auto_ptr Give( 73 | std::auto_ptr & 74 | ); 75 | 76 | /*! 77 | \brief 78 | Transfers pointer ownership. 79 | \return 80 | The resulting object. 81 | 82 | This is useful in situations where the argument auto_ptr is a member of a const class. 83 | */ 84 | template 85 | std::auto_ptr Give( 86 | std::auto_ptr const & 87 | ); 88 | 89 | } 90 | 91 | #include "om/giveable.cpp" 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /code/om/language.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_ 16 | 17 | #include "om/language.hpp" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /code/om/language/atom.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Atom_ 16 | 17 | #include "om/language/atom.hpp" 18 | 19 | #else 20 | 21 | #include "om/language/null.hpp" 22 | 23 | // MARK: - Om::Language::Atom 24 | 25 | #define Type_ \ 26 | Om::Language::Atom 27 | 28 | // MARK: public (non-static) 29 | 30 | inline Om::Language::Program & Type_::operator *() { 31 | return Null::Get(); 32 | } 33 | 34 | inline Om::Language::Program const & Type_::operator *() const { 35 | return Null::Get(); 36 | } 37 | 38 | #undef Type_ 39 | 40 | // MARK: - Om::Language:: 41 | 42 | inline Om::Language::Atom * Om::Language::new_clone(Atom const & theAtom) { 43 | return Copy(theAtom).release(); 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /code/om/language/atom.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Atom_ 16 | 17 | #define Om_Language_Atom_ \ 18 | Om::Language::Atom 19 | 20 | #include "om/language/element.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Language { 25 | 26 | // MARK: - Om::Language::Atom 27 | 28 | /*! 29 | \brief 30 | An atomic Element defined by a string. 31 | */ 32 | class Atom: 33 | public Element { 34 | 35 | public: // MARK: public (non-static) 36 | 37 | virtual Program & operator *(); 38 | 39 | virtual Program const & operator *() const; 40 | 41 | private: // MARK: private (non-static) 42 | 43 | Atom & operator =(Atom const &); 44 | 45 | }; 46 | 47 | // MARK: - Om::Language:: 48 | 49 | /*! 50 | \return 51 | An owner pointer to a new copy. 52 | \note 53 | Required by boost::ptr_container classes. 54 | */ 55 | Atom * new_clone(Atom const &); 56 | 57 | } 58 | 59 | } 60 | 61 | #include "om/language/atom.cpp" 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /code/om/language/default_consumer.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_DefaultConsumer_ 16 | 17 | #define Om_Language_DefaultConsumer_ \ 18 | Om::Language::DefaultConsumer 19 | 20 | #include "om/language/consumer.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Language { 25 | 26 | // MARK: - Om::Language::DefaultConsumer 27 | 28 | /*! 29 | \brief 30 | A partial implementation of Consumer. 31 | */ 32 | template < 33 | typename ThisImplementation, 34 | typename ThisInterface = Consumer 35 | > 36 | class DefaultConsumer: 37 | public ThisInterface { 38 | 39 | public: // MARK: public (non-static) 40 | 41 | virtual ~DefaultConsumer() = 0; 42 | 43 | virtual void TakeElement(Operand &); 44 | 45 | virtual void TakeElement(Operand const &); 46 | 47 | virtual void TakeElement(Operator &); 48 | 49 | virtual void TakeElement(Operator const &); 50 | 51 | virtual void TakeElement(Separator &); 52 | 53 | virtual void TakeElement(Separator const &); 54 | 55 | virtual void TakeElements(Producer &); 56 | 57 | virtual void TakeElements(Producer const &); 58 | 59 | virtual void TakeQuotedElements(Producer &); 60 | 61 | virtual void TakeQuotedElements(Producer const &); 62 | 63 | private: // MARK: private (non-static) 64 | 65 | DefaultConsumer & operator =(DefaultConsumer const &); 66 | 67 | }; 68 | 69 | } 70 | 71 | } 72 | 73 | #include "om/language/default_consumer.cpp" 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /code/om/language/default_element.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_DefaultElement_ 16 | 17 | #define Om_Language_DefaultElement_ \ 18 | Om::Language::DefaultElement 19 | 20 | #include "om/language/default_program.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Language { 25 | 26 | // MARK: - Om::Language::DefaultElement 27 | 28 | /*! 29 | \brief 30 | A partial implementation of Element. 31 | \internal 32 | The fully-specified Element namespace is required to work around a Doxygen bug that has difficulty inferring inheritance otherwise. 33 | */ 34 | template < 35 | typename ThisImplementation, 36 | typename ThisInterface = Om::Language::Element 37 | > 38 | class DefaultElement: 39 | public DefaultProgram< 40 | ThisImplementation, 41 | ThisInterface 42 | > { 43 | 44 | public: // MARK: public (non-static) 45 | 46 | virtual ~DefaultElement() = 0; 47 | 48 | using DefaultProgram< 49 | ThisImplementation, 50 | ThisInterface 51 | >::Equals; 52 | 53 | virtual bool Equals(Element const &) const; 54 | 55 | /*! 56 | \note 57 | This is a non-virtual declaration that will force a link error if undefined (which could cause infinite recursion in the other form). 58 | */ 59 | bool Equals(ThisImplementation const &) const; 60 | 61 | virtual std::auto_ptr< 62 | Om::Source::Source 63 | > GetElementRange(); 64 | 65 | virtual std::auto_ptr< 66 | Om::Source::Source 67 | > GetElementRange() const; 68 | 69 | virtual void GiveElements(Consumer &); 70 | 71 | virtual void GiveElements(Consumer &) const; 72 | 73 | private: // MARK: private (non-static) 74 | 75 | Element & operator =(Element const &); 76 | 77 | }; 78 | 79 | } 80 | 81 | } 82 | 83 | #include "om/language/default_element.cpp" 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /code/om/language/default_program.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_DefaultProgram_ 16 | 17 | #define Om_Language_DefaultProgram_ \ 18 | Om::Language::DefaultProgram 19 | 20 | #include "om/default_giveable.hpp" 21 | #include "om/language/default_consumer.hpp" 22 | #include "om/language/program.hpp" 23 | #include "om/taker.hpp" 24 | 25 | namespace Om { 26 | 27 | namespace Language { 28 | 29 | // MARK: - Om::Language::DefaultProgram 30 | 31 | /*! 32 | \brief 33 | A partial implementation of Program. 34 | \internal 35 | The fully-specified Program namespace is required to work around a Doxygen bug that has difficulty inferring inheritance otherwise. 36 | */ 37 | template < 38 | typename ThisImplementation, 39 | typename ThisInterface = Om::Language::Program 40 | > 41 | class DefaultProgram: 42 | public DefaultConsumer< 43 | ThisImplementation, 44 | DefaultGiveable< 45 | ThisImplementation, 46 | ThisInterface 47 | > 48 | >, 49 | public Taker { 50 | 51 | public: // MARK: public (non-static) 52 | 53 | virtual ~DefaultProgram() = 0; 54 | 55 | using DefaultConsumer< 56 | ThisImplementation, 57 | DefaultGiveable< 58 | ThisImplementation, 59 | ThisInterface 60 | > 61 | >::Equals; 62 | 63 | virtual bool Equals(Program const &) const; 64 | 65 | virtual void TakeElements(Producer &); 66 | 67 | virtual void TakeElements(Producer const &); 68 | 69 | private: // MARK: private (non-static) 70 | 71 | DefaultProgram & operator =(DefaultProgram const &); 72 | 73 | template < 74 | typename TheCast, 75 | typename TheProducer 76 | > 77 | void TakeProducer(TheProducer &); 78 | 79 | }; 80 | 81 | } 82 | 83 | } 84 | 85 | #include "om/language/default_program.cpp" 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /code/om/language/environment.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Environment_ 16 | 17 | #define Om_Language_Environment_ \ 18 | Om::Language::Environment 19 | 20 | #include "om/language/translator.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Language { 25 | 26 | // MARK: - Om::Language::Environment 27 | 28 | /*! 29 | \brief 30 | An unowned Translator collection for which lookups are done for each Translator, in reverse order, until a match is found. 31 | */ 32 | class Environment: 33 | public Translator { 34 | 35 | public: // MARK: public (non-static) 36 | 37 | Environment(); 38 | 39 | virtual void GiveElements(Consumer &) const; 40 | 41 | virtual bool IsEmpty() const; 42 | 43 | /*! 44 | \brief 45 | Pushes an unowned Translator reference. 46 | 47 | If the given Translator is already the last reference in the Environment, there is no change. 48 | */ 49 | void Push(Translator const &); 50 | 51 | virtual bool Translate( 52 | Evaluation &, 53 | Operator const & 54 | ) const; 55 | 56 | private: // MARK: private (static) 57 | 58 | /*! 59 | \brief 60 | A vector of non-owner Translator pointers. 61 | 62 | When looking up an Operator, the back Translator is used first. This requires the reverse iteration functionality provided by std::vector. 63 | */ 64 | typedef std::vector TranslatorVector; 65 | 66 | private: // MARK: private (non-static) 67 | 68 | TranslatorVector thisTranslatorVector; 69 | 70 | }; 71 | 72 | } 73 | 74 | } 75 | 76 | #include "om/language/environment.cpp" 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /code/om/language/operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_ 16 | 17 | #include "om/language/operation.hpp" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /code/om/language/operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__ Operation 15 | \brief 16 | A function that processes 0 or more \ref om__operand__ "Operands" as data for computation. 17 | \par Implementation 18 | Each \ref om__operation__ is a concrete type in the Om::Language::Operation namespace. 19 | */ 20 | 21 | #ifndef Om_Language_Operation_ 22 | 23 | #define Om_Language_Operation_ \ 24 | Om::Language::Operation 25 | 26 | namespace Om { 27 | 28 | namespace Language { 29 | 30 | /*! 31 | \brief 32 | A namespace for all \ref om__operation__ implementations. 33 | 34 | Each operation implementation requires the following: 35 | - A static char const * GetName() function that returns a null-terminated, NFD-normalized UTF-8 string to be used as a corresponding Operator name. 36 | - A static void Give(Evaluation) function, which gives the implementation of the operation to the Evaluation. 37 | 38 | Including the header for an operation will cause the operation to be added to the System automatically. 39 | 40 | Operations that consume at least one Operand must live in memory while waiting for the Operand. These operations are derived from Operation::IncompleteOperation. 41 | */ 42 | namespace Operation {} 43 | 44 | } 45 | 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /code/om/language/operation/back_pull_character_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__back_pull_character_operation__ [characters]-> 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the last character, quoted. 18 | \par Implementation 19 | Om::Language::Operation::BackPullCharacterOperation 20 | */ 21 | 22 | #ifndef Om_Language_Operation_BackPullCharacterOperation_ 23 | 24 | #define Om_Language_Operation_BackPullCharacterOperation_ \ 25 | Om::Language::Operation::BackPullCharacterOperation 26 | 27 | #include "om/language/system.hpp" 28 | 29 | #define Om_Language_Operation_BackPullCharacterOperation_GetName_() \ 30 | "[characters]->" 31 | 32 | namespace Om { 33 | 34 | namespace Language { 35 | 36 | namespace Operation { 37 | 38 | // MARK: - Om::Language::Operation::BackPullCharacterOperation 39 | 40 | /*! 41 | \brief 42 | The \ref om__operation__back_pull_character_operation__ operation implementation. 43 | */ 44 | class BackPullCharacterOperation { 45 | 46 | public: // MARK: public (static) 47 | 48 | static char const * GetName(); 49 | 50 | static void Give(Evaluation &); 51 | 52 | /*! 53 | \brief 54 | The callback for PullOperation. 55 | */ 56 | template 57 | static void Pull( 58 | Operator &, 59 | TheConsumer & 60 | ); 61 | 62 | }; 63 | 64 | namespace { 65 | 66 | static System::Definition const theBackPullCharacterDefinition; 67 | 68 | } 69 | 70 | } 71 | 72 | } 73 | 74 | } 75 | 76 | #include "om/language/operation/back_pull_character_operation.cpp" 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /code/om/language/operation/back_pull_code_point_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__back_pull_code_point_operation__ [code` points]-> 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the last code point, quoted. 18 | \par Implementation 19 | Om::Language::Operation::BackPullCodePointOperation 20 | */ 21 | 22 | #ifndef Om_Language_Operation_BackPullCodePointOperation_ 23 | 24 | #define Om_Language_Operation_BackPullCodePointOperation_ \ 25 | Om::Language::Operation::BackPullCodePointOperation 26 | 27 | #include "om/language/system.hpp" 28 | 29 | #define Om_Language_Operation_BackPullCodePointOperation_GetName_() \ 30 | "[code points]->" 31 | 32 | namespace Om { 33 | 34 | namespace Language { 35 | 36 | namespace Operation { 37 | 38 | // MARK: - Om::Language::Operation::BackPullCodePointOperation 39 | 40 | /*! 41 | \brief 42 | The \ref om__operation__back_pull_code_point_operation__ operation implementation. 43 | */ 44 | class BackPullCodePointOperation { 45 | 46 | public: // MARK: public (static) 47 | 48 | static char const * GetName(); 49 | 50 | static void Give(Evaluation &); 51 | 52 | /*! 53 | \brief 54 | The callback for PullOperation. 55 | */ 56 | template 57 | static void Pull( 58 | Operator &, 59 | TheConsumer & 60 | ); 61 | 62 | }; 63 | 64 | namespace { 65 | 66 | static System::Definition const theBackPullCodePointDefinition; 67 | 68 | } 69 | 70 | } 71 | 72 | } 73 | 74 | } 75 | 76 | #include "om/language/operation/back_pull_code_point_operation.cpp" 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /code/om/language/operation/back_pull_element_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__back_pull_element_operation__ [...]-> 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the last element, quoted. 18 | \par Input 19 | {A B} 20 | \par Output 21 | {B} {A } 22 | \par Implementation 23 | Om::Language::Operation::BackPullElementOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_BackPullElementOperation_ 27 | 28 | #define Om_Language_Operation_BackPullElementOperation_ \ 29 | Om::Language::Operation::BackPullElementOperation 30 | 31 | #include "om/language/system.hpp" 32 | 33 | #define Om_Language_Operation_BackPullElementOperation_GetName_() \ 34 | "[...]->" 35 | 36 | namespace Om { 37 | 38 | namespace Language { 39 | 40 | //! \cond 41 | class Literal; 42 | //! \endcond 43 | 44 | namespace Operation { 45 | 46 | // MARK: - Om::Language::Operation::BackPullElementOperation 47 | 48 | /*! 49 | \brief 50 | The \ref om__operation__back_pull_element_operation__ operation implementation. 51 | */ 52 | class BackPullElementOperation { 53 | 54 | public: // MARK: public (static) 55 | 56 | static char const * GetName(); 57 | 58 | static void Give(Evaluation &); 59 | 60 | /*! 61 | \brief 62 | The callback for PullOperation. 63 | */ 64 | template 65 | static void Pull( 66 | Literal &, 67 | TheConsumer & 68 | ); 69 | 70 | }; 71 | 72 | namespace { 73 | 74 | static System::Definition const theBackPullElementDefinition; 75 | 76 | } 77 | 78 | } 79 | 80 | } 81 | 82 | } 83 | 84 | #include "om/language/operation/back_pull_element_operation.cpp" 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /code/om/language/operation/back_pull_form_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__back_pull_form_operation__ [forms]-> 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the last form (a non-empty list of zero or one \ref om__operator__ "Operator(s)", followed by zero or more \ref om__operand__ "Operands"), quoted. 18 | \par Implementation 19 | Om::Language::Operation::BackPullFormOperation 20 | */ 21 | 22 | #ifndef Om_Language_Operation_BackPullFormOperation_ 23 | 24 | #define Om_Language_Operation_BackPullFormOperation_ \ 25 | Om::Language::Operation::BackPullFormOperation 26 | 27 | #include "om/language/system.hpp" 28 | 29 | #define Om_Language_Operation_BackPullFormOperation_GetName_() \ 30 | "[forms]->" 31 | 32 | namespace Om { 33 | 34 | namespace Language { 35 | 36 | //! \cond 37 | class Expression; 38 | //! \endcond 39 | 40 | namespace Operation { 41 | 42 | // MARK: - Om::Language::Operation::BackPullFormOperation 43 | 44 | /*! 45 | \brief 46 | The \ref om__operation__back_pull_form_operation__ operation implementation. 47 | */ 48 | class BackPullFormOperation { 49 | 50 | public: // MARK: public (static) 51 | 52 | static char const * GetName(); 53 | 54 | static void Give(Evaluation &); 55 | 56 | /*! 57 | \brief 58 | The callback for PullOperation. 59 | */ 60 | template 61 | static void Pull( 62 | Expression &, 63 | TheConsumer & 64 | ); 65 | 66 | }; 67 | 68 | namespace { 69 | 70 | static System::Definition const theBackPullFormDefinition; 71 | 72 | } 73 | 74 | } 75 | 76 | } 77 | 78 | } 79 | 80 | #include "om/language/operation/back_pull_form_operation.cpp" 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /code/om/language/operation/back_pull_operand_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__back_pull_operand_operation__ [...operand]-> 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the last \ref om__operand__ (if any), quoted. 18 | \par Input 19 | {A {B}} 20 | \par Output 21 | {{B}} {A } 22 | \par Implementation 23 | Om::Language::Operation::BackPullOperandOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_BackPullOperandOperation_ 27 | 28 | #define Om_Language_Operation_BackPullOperandOperation_ \ 29 | Om::Language::Operation::BackPullOperandOperation 30 | 31 | #include "om/language/system.hpp" 32 | 33 | #define Om_Language_Operation_BackPullOperandOperation_GetName_() \ 34 | "[...operand]->" 35 | 36 | namespace Om { 37 | 38 | namespace Language { 39 | 40 | //! \cond 41 | class Literal; 42 | //! \endcond 43 | 44 | namespace Operation { 45 | 46 | // MARK: - Om::Language::Operation::BackPullOperandOperation 47 | 48 | /*! 49 | \brief 50 | The \ref om__operation__back_pull_operand_operation__ operation implementation. 51 | */ 52 | class BackPullOperandOperation { 53 | 54 | public: // MARK: public (static) 55 | 56 | static char const * GetName(); 57 | 58 | static void Give(Evaluation &); 59 | 60 | /*! 61 | \brief 62 | The callback for PullOperation. 63 | */ 64 | template 65 | static void Pull( 66 | Literal &, 67 | TheConsumer & 68 | ); 69 | 70 | }; 71 | 72 | namespace { 73 | 74 | static System::Definition const theBackPullOperandDefinition; 75 | 76 | } 77 | 78 | } 79 | 80 | } 81 | 82 | } 83 | 84 | #include "om/language/operation/back_pull_operand_operation.cpp" 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /code/om/language/operation/back_pull_operator_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__back_pull_operator_operation__ [...operator]-> 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the last \ref om__operator__ (if any), quoted. 18 | \par Input 19 | {A B} 20 | \par Output 21 | {B} {A } 22 | \par Implementation 23 | Om::Language::Operation::BackPullOperatorOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_BackPullOperatorOperation_ 27 | 28 | #define Om_Language_Operation_BackPullOperatorOperation_ \ 29 | Om::Language::Operation::BackPullOperatorOperation 30 | 31 | #include "om/language/system.hpp" 32 | 33 | #define Om_Language_Operation_BackPullOperatorOperation_GetName_() \ 34 | "[...operator]->" 35 | 36 | namespace Om { 37 | 38 | namespace Language { 39 | 40 | //! \cond 41 | class Literal; 42 | //! \endcond 43 | 44 | namespace Operation { 45 | 46 | // MARK: - Om::Language::Operation::BackPullOperatorOperation 47 | 48 | /*! 49 | \brief 50 | The \ref om__operation__back_pull_operator_operation__ operation implementation. 51 | */ 52 | class BackPullOperatorOperation { 53 | 54 | public: // MARK: public (static) 55 | 56 | static char const * GetName(); 57 | 58 | static void Give(Evaluation &); 59 | 60 | /*! 61 | \brief 62 | The callback for PullOperation. 63 | */ 64 | template 65 | static void Pull( 66 | Literal &, 67 | TheConsumer & 68 | ); 69 | 70 | }; 71 | 72 | namespace { 73 | 74 | static System::Definition const theBackPullOperatorDefinition; 75 | 76 | } 77 | 78 | } 79 | 80 | } 81 | 82 | } 83 | 84 | #include "om/language/operation/back_pull_operator_operation.cpp" 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /code/om/language/operation/back_pull_pair_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__back_pull_pair_operation__ [pairs]-> 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the last pair (a non-empty list of zero or one \ref om__operator__ "Operator(s)", followed by zero or one \ref om__operand__ "Operand(s)"), quoted. 18 | \par Implementation 19 | Om::Language::Operation::BackPullPairOperation 20 | */ 21 | 22 | #ifndef Om_Language_Operation_BackPullPairOperation_ 23 | 24 | #define Om_Language_Operation_BackPullPairOperation_ \ 25 | Om::Language::Operation::BackPullPairOperation 26 | 27 | #include "om/language/system.hpp" 28 | 29 | #define Om_Language_Operation_BackPullPairOperation_GetName_() \ 30 | "[pairs]->" 31 | 32 | namespace Om { 33 | 34 | namespace Language { 35 | 36 | //! \cond 37 | class Lexicon; 38 | //! \endcond 39 | 40 | namespace Operation { 41 | 42 | // MARK: - Om::Language::Operation::BackPullPairOperation 43 | 44 | /*! 45 | \brief 46 | The \ref om__operation__back_pull_pair_operation__ operation implementation. 47 | */ 48 | class BackPullPairOperation { 49 | 50 | public: // MARK: public (static) 51 | 52 | static char const * GetName(); 53 | 54 | static void Give(Evaluation &); 55 | 56 | /*! 57 | \brief 58 | The callback for PullOperation. 59 | */ 60 | template 61 | static void Pull( 62 | Lexicon &, 63 | TheConsumer & 64 | ); 65 | 66 | }; 67 | 68 | namespace { 69 | 70 | static System::Definition const theBackPullPairDefinition; 71 | 72 | } 73 | 74 | } 75 | 76 | } 77 | 78 | } 79 | 80 | #include "om/language/operation/back_pull_pair_operation.cpp" 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /code/om/language/operation/back_pull_separator_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__back_pull_separator_operation__ [...separator]-> 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the last \ref om__separator__ (if any), quoted. 18 | \par Input 19 | {A B } 20 | \par Output 21 | { } {A B} 22 | \par Implementation 23 | Om::Language::Operation::BackPullSeparatorOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_BackPullSeparatorOperation_ 27 | 28 | #define Om_Language_Operation_BackPullSeparatorOperation_ \ 29 | Om::Language::Operation::BackPullSeparatorOperation 30 | 31 | #include "om/language/system.hpp" 32 | 33 | #define Om_Language_Operation_BackPullSeparatorOperation_GetName_() \ 34 | "[...separator]->" 35 | 36 | namespace Om { 37 | 38 | namespace Language { 39 | 40 | //! \cond 41 | class Literal; 42 | //! \endcond 43 | 44 | namespace Operation { 45 | 46 | // MARK: - Om::Language::Operation::BackPullSeparatorOperation 47 | 48 | /*! 49 | \brief 50 | The \ref om__operation__back_pull_separator_operation__ operation implementation. 51 | */ 52 | class BackPullSeparatorOperation { 53 | 54 | public: // MARK: public (static) 55 | 56 | static char const * GetName(); 57 | 58 | static void Give(Evaluation &); 59 | 60 | /*! 61 | \brief 62 | The callback for PullOperation. 63 | */ 64 | template 65 | static void Pull( 66 | Literal &, 67 | TheConsumer & 68 | ); 69 | 70 | }; 71 | 72 | namespace { 73 | 74 | static System::Definition const theBackPullSeparatorDefinition; 75 | 76 | } 77 | 78 | } 79 | 80 | } 81 | 82 | } 83 | 84 | #include "om/language/operation/back_pull_separator_operation.cpp" 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /code/om/language/operation/copy_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__copy_operation__ copy 15 | \ingroup om__operation__ 16 | \brief 17 | Copies an \ref om__operand__. 18 | \par Input 19 | {A} 20 | \par Output 21 | {A}{A} 22 | \par Implementation 23 | Om::Language::Operation::CopyOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_CopyOperation_ 27 | 28 | #define Om_Language_Operation_CopyOperation_ \ 29 | Om::Language::Operation::CopyOperation 30 | 31 | #include "om/language/operation/default_incomplete_operation.hpp" 32 | #include "om/language/system.hpp" 33 | 34 | #define Om_Language_Operation_CopyOperation_GetName_() \ 35 | "copy" 36 | 37 | namespace Om { 38 | 39 | namespace Language { 40 | 41 | namespace Operation { 42 | 43 | // MARK: - Om::Language::Operation::CopyOperation 44 | 45 | /*! 46 | \brief 47 | The \ref om__operation__copy_operation__ operation implementation. 48 | */ 49 | class CopyOperation: 50 | public DefaultIncompleteOperation { 51 | 52 | public: // MARK: public (static) 53 | 54 | static char const * GetName(); 55 | 56 | template 57 | static void GiveElements( 58 | TheCopyOperation &, 59 | Consumer & 60 | ); 61 | 62 | public: // MARK: public (non-static) 63 | 64 | template 65 | bool TakeOperand( 66 | Evaluation &, 67 | TheOperand & 68 | ); 69 | 70 | template 71 | bool TakeQuotedProducer( 72 | Evaluation &, 73 | TheProducer & 74 | ); 75 | 76 | }; 77 | 78 | namespace { 79 | 80 | static System::Definition const theCopyDefinition; 81 | 82 | } 83 | 84 | } 85 | 86 | } 87 | 88 | } 89 | 90 | #include "om/language/operation/copy_operation.cpp" 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /code/om/language/operation/dequote_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__dequote_operation__ dequote 15 | \ingroup om__operation__ 16 | \brief 17 | Strips the outer braces from an \ref om__operand__. 18 | \par Input 19 | {A} 20 | \par Output 21 | A 22 | \par Implementation 23 | Om::Language::Operation::DequoteOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_DequoteOperation_ 27 | 28 | #define Om_Language_Operation_DequoteOperation_ \ 29 | Om::Language::Operation::DequoteOperation 30 | 31 | #include "om/language/operation/default_incomplete_operation.hpp" 32 | #include "om/language/system.hpp" 33 | 34 | #define Om_Language_Operation_DequoteOperation_GetName_() \ 35 | "dequote" 36 | 37 | namespace Om { 38 | 39 | namespace Language { 40 | 41 | namespace Operation { 42 | 43 | // MARK: - Om::Language::Operation::DequoteOperation 44 | 45 | /*! 46 | \brief 47 | The \ref om__operation__dequote_operation__ operation implementation. 48 | */ 49 | class DequoteOperation: 50 | public DefaultIncompleteOperation { 51 | 52 | public: // MARK: public (static) 53 | 54 | static char const * GetName(); 55 | 56 | template 57 | static void GiveElements( 58 | TheDequoteOperation &, 59 | Consumer & 60 | ); 61 | 62 | public: // MARK: public (non-static) 63 | 64 | template 65 | bool TakeOperand( 66 | Evaluation &, 67 | TheOperand & 68 | ); 69 | 70 | template 71 | bool TakeQuotedProducer( 72 | Evaluation &, 73 | TheProducer & 74 | ); 75 | 76 | }; 77 | 78 | namespace { 79 | 80 | static System::Definition const theDequoteDefinition; 81 | 82 | } 83 | 84 | } 85 | 86 | } 87 | 88 | } 89 | 90 | #include "om/language/operation/dequote_operation.cpp" 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /code/om/language/operation/do_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_DoOperation_ 16 | 17 | #include "om/language/operation/do_operation.hpp" 18 | 19 | #ifdef Om_Macro_Test_ 20 | 21 | #include "om/language/system.hpp" 22 | 23 | #ifndef Om_Macro_Precompilation_ 24 | 25 | #include "boost/test/unit_test.hpp" 26 | 27 | #endif 28 | 29 | namespace Om { 30 | 31 | namespace Language { 32 | 33 | namespace Operation { 34 | 35 | BOOST_AUTO_TEST_SUITE(DoOperationTest) 36 | 37 | BOOST_AUTO_TEST_CASE(DefinitionTest) { 38 | BOOST_CHECK_EQUAL( 39 | "{do}", 40 | System::Get().Evaluate("drop find {do} system") 41 | ); 42 | } 43 | 44 | BOOST_AUTO_TEST_CASE(SimpleTest) { 45 | BOOST_CHECK_EQUAL( 46 | "{a}{bc}", 47 | System::Get().Evaluate("do {<-[code points]} {abc}") 48 | ); 49 | } 50 | 51 | BOOST_AUTO_TEST_SUITE_END() 52 | 53 | } 54 | 55 | } 56 | 57 | } 58 | 59 | #endif 60 | 61 | #else 62 | 63 | #include "om/language/operation/dequote_operation.hpp" 64 | #include "om/language/operation/operator_operation.hpp" 65 | 66 | // MARK: - Om::Language::Operation::DoOperation 67 | 68 | #define Type_ \ 69 | Om::Language::Operation::DoOperation 70 | 71 | // MARK: public (static) 72 | 73 | inline char const * Type_::GetName() { 74 | return Om_Language_Operation_DoOperation_GetName_(); 75 | } 76 | 77 | inline void Type_::Give(Evaluation & theEvaluation) { 78 | DequoteOperation::Give(theEvaluation); 79 | OperatorOperation::Give(theEvaluation); 80 | } 81 | 82 | #undef Type_ 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /code/om/language/operation/do_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__do_operation__ do 15 | \ingroup om__operation__ 16 | \brief 17 | Converts an \ref om__operand__ to a quoted \ref om__operator__, then \ref om__operation__dequote_operation__ "dequotes". 18 | \par Input 19 | {hello, world!} 20 | \par Output 21 | hello,` world! 22 | \par Implementation 23 | Om::Language::Operation::DoOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_DoOperation_ 27 | 28 | #define Om_Language_Operation_DoOperation_ \ 29 | Om::Language::Operation::DoOperation 30 | 31 | #include "om/language/system.hpp" 32 | 33 | #define Om_Language_Operation_DoOperation_GetName_() \ 34 | "do" 35 | 36 | namespace Om { 37 | 38 | namespace Language { 39 | 40 | namespace Operation { 41 | 42 | // MARK: - Om::Language::Operation::DoOperation 43 | 44 | /*! 45 | \brief 46 | The \ref om__operation__do_operation__ operation implementation. 47 | */ 48 | class DoOperation { 49 | 50 | public: // MARK: public (static) 51 | 52 | static char const * GetName(); 53 | 54 | static void Give(Evaluation &); 55 | 56 | }; 57 | 58 | namespace { 59 | 60 | static System::Definition const theDoDefinition; 61 | 62 | } 63 | 64 | } 65 | 66 | } 67 | 68 | } 69 | 70 | #include "om/language/operation/do_operation.cpp" 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /code/om/language/operation/encode_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__encode_operation__ encode 15 | \ingroup om__operation__ 16 | \brief 17 | Encodes all special characters (non-recursively). 18 | \par Input 19 | {program} 20 | \par Output 21 | {operator} 22 | \par Implementation 23 | Om::Language::Operation::EncodeOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_EncodeOperation_ 27 | 28 | #define Om_Language_Operation_EncodeOperation_ \ 29 | Om::Language::Operation::EncodeOperation 30 | 31 | #include "om/language/operation/default_incomplete_operation.hpp" 32 | #include "om/language/system.hpp" 33 | 34 | #define Om_Language_Operation_EncodeOperation_GetName_() \ 35 | "encode" 36 | 37 | namespace Om { 38 | 39 | namespace Language { 40 | 41 | namespace Operation { 42 | 43 | // MARK: - Om::Language::Operation::EncodeOperation 44 | 45 | /*! 46 | \brief 47 | The \ref om__operation__encode_operation__ operation implementation. 48 | */ 49 | class EncodeOperation: 50 | public DefaultIncompleteOperation { 51 | 52 | public: // MARK: public (static) 53 | 54 | static char const * GetName(); 55 | 56 | template 57 | static void GiveElements( 58 | TheEncodeOperation &, 59 | Consumer & 60 | ); 61 | 62 | public: // MARK: public (non-static) 63 | 64 | template 65 | bool TakeOperand( 66 | Evaluation &, 67 | TheOperand & 68 | ); 69 | 70 | template 71 | bool TakeQuotedProducer( 72 | Evaluation &, 73 | TheProducer & 74 | ); 75 | 76 | }; 77 | 78 | namespace { 79 | 80 | static System::Definition const theEncodeDefinition; 81 | 82 | } 83 | 84 | } 85 | 86 | } 87 | 88 | } 89 | 90 | #include "om/language/operation/encode_operation.cpp" 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /code/om/language/operation/environment_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_EnvironmentOperation_ 16 | 17 | #include "om/language/operation/environment_operation.hpp" 18 | 19 | #ifdef Om_Macro_Test_ 20 | 21 | #include "om/language/system.hpp" 22 | 23 | #ifndef Om_Macro_Precompilation_ 24 | 25 | #include "boost/test/unit_test.hpp" 26 | 27 | #endif 28 | 29 | namespace Om { 30 | 31 | namespace Language { 32 | 33 | namespace Operation { 34 | 35 | BOOST_AUTO_TEST_SUITE(EnvironmentOperationTest) 36 | 37 | BOOST_AUTO_TEST_CASE(DefinitionTest) { 38 | BOOST_CHECK_EQUAL( 39 | "{environment}", 40 | System::Get().Evaluate("drop find {environment} system") 41 | ); 42 | } 43 | 44 | BOOST_AUTO_TEST_CASE(GeneralTest) { 45 | BOOST_CHECK_EQUAL( 46 | "{pass}", 47 | System::Get().Evaluate( 48 | "choose" 49 | " {fail}" 50 | " {pass}" 51 | " = define {a{A}} {environment} [lexicon]<- {a{A}} system" 52 | ) 53 | ); 54 | } 55 | 56 | BOOST_AUTO_TEST_SUITE_END() 57 | 58 | } 59 | 60 | } 61 | 62 | } 63 | 64 | #endif 65 | 66 | #else 67 | 68 | // MARK: - Om::Language::Operation::EnvironmentOperation 69 | 70 | #define Type_ \ 71 | Om::Language::Operation::EnvironmentOperation 72 | 73 | // MARK: public (static) 74 | 75 | inline char const * Type_::GetName() { 76 | return Om_Language_Operation_EnvironmentOperation_GetName_(); 77 | } 78 | 79 | inline void Type_::Give(Evaluation & theEvaluation) { 80 | Lexicon theLexicon; 81 | theEvaluation.GetTranslator().GiveElements(theLexicon); 82 | theEvaluation.TakeQuotedProducer(theLexicon); 83 | } 84 | 85 | #undef Type_ 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /code/om/language/operation/expression_back_push_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_ExpressionBackPushOperation_ 16 | 17 | #include "om/language/operation/expression_back_push_operation.hpp" 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(ExpressionBackPushOperationTest) 34 | 35 | BOOST_AUTO_TEST_CASE(DefinitionTest) { 36 | BOOST_CHECK_EQUAL( 37 | "{[expression]<-}", 38 | System::Get().Evaluate("drop find {[expression]<-} system") 39 | ); 40 | } 41 | 42 | BOOST_AUTO_TEST_SUITE_END() 43 | 44 | } 45 | 46 | } 47 | 48 | } 49 | 50 | #endif 51 | 52 | #else 53 | 54 | #include "om/language/operation/expression_front_push_operation.hpp" 55 | #include "om/language/operation/swap_operation.hpp" 56 | 57 | // MARK: - Om::Language::Operation::ExpressionBackPushOperation 58 | 59 | #define Type_ \ 60 | Om::Language::Operation::ExpressionBackPushOperation 61 | 62 | // MARK: public (static) 63 | 64 | inline char const * Type_::GetName() { 65 | return Om_Language_Operation_ExpressionBackPushOperation_GetName_(); 66 | } 67 | 68 | inline void Type_::Give(Evaluation & theEvaluation) { 69 | ExpressionFrontPushOperation::Give(theEvaluation); 70 | SwapOperation::Give(theEvaluation); 71 | } 72 | 73 | #undef Type_ 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /code/om/language/operation/expression_back_push_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__expression_back_push_operation__ [expression]<- 15 | \ingroup om__operation__ 16 | \brief 17 | Pushes the contents of an \ref om__operand__ onto the back of an \ref om__expression__ (quoted). 18 | \par Input 19 | {A} {B} 20 | \par Output 21 | {B
22 | A}
23 | \par Implementation 24 | Om::Language::Operation::ExpressionBackPushOperation 25 | */ 26 | 27 | #ifndef Om_Language_Operation_ExpressionBackPushOperation_ 28 | 29 | #define Om_Language_Operation_ExpressionBackPushOperation_ \ 30 | Om::Language::Operation::ExpressionBackPushOperation 31 | 32 | #include "om/language/system.hpp" 33 | 34 | #define Om_Language_Operation_ExpressionBackPushOperation_GetName_() \ 35 | "[expression]<-" 36 | 37 | namespace Om { 38 | 39 | namespace Language { 40 | 41 | namespace Operation { 42 | 43 | // MARK: - Om::Language::Operation::ExpressionBackPushOperation 44 | 45 | /*! 46 | \brief 47 | The \ref om__operation__expression_back_push_operation__ operation implementation. 48 | */ 49 | class ExpressionBackPushOperation { 50 | 51 | public: // MARK: public (static) 52 | 53 | static char const * GetName(); 54 | 55 | static void Give(Evaluation &); 56 | 57 | }; 58 | 59 | namespace { 60 | 61 | static System::Definition const theExpressionBackPushDefinition; 62 | 63 | } 64 | 65 | } 66 | 67 | } 68 | 69 | } 70 | 71 | #include "om/language/operation/expression_back_push_operation.cpp" 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /code/om/language/operation/expression_front_push_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__expression_front_push_operation__ ->[expression] 15 | \ingroup om__operation__ 16 | \brief 17 | Pushes the contents of an \ref om__operand__ onto the front of an \ref om__expression__ (quoted). 18 | \par Input 19 | {A} {B} 20 | \par Output 21 | {A
22 | B}
23 | \par Implementation 24 | Om::Language::Operation::ExpressionFrontPushOperation 25 | */ 26 | 27 | #ifndef Om_Language_Operation_ExpressionFrontPushOperation_ 28 | 29 | #define Om_Language_Operation_ExpressionFrontPushOperation_ \ 30 | Om::Language::Operation::ExpressionFrontPushOperation 31 | 32 | #include "om/language/system.hpp" 33 | 34 | #define Om_Language_Operation_ExpressionFrontPushOperation_GetName_() \ 35 | "->[expression]" 36 | 37 | namespace Om { 38 | 39 | namespace Language { 40 | 41 | namespace Operation { 42 | 43 | // MARK: - Om::Language::Operation::ExpressionFrontPushOperation 44 | 45 | /*! 46 | \brief 47 | The \ref om__operation__expression_front_push_operation__ operation implementation. 48 | */ 49 | class ExpressionFrontPushOperation { 50 | 51 | public: // MARK: public (static) 52 | 53 | static char const * GetName(); 54 | 55 | static void Give(Evaluation &); 56 | 57 | }; 58 | 59 | namespace { 60 | 61 | static System::Definition const theExpressionFrontPushDefinition; 62 | 63 | } 64 | 65 | } 66 | 67 | } 68 | 69 | } 70 | 71 | #include "om/language/operation/expression_front_push_operation.cpp" 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /code/om/language/operation/expression_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_ExpressionOperation_ 16 | 17 | #include "om/language/operation/expression_operation.hpp" 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(ExpressionOperationTest) 34 | 35 | BOOST_AUTO_TEST_CASE(DefinitionTest) { 36 | BOOST_CHECK_EQUAL( 37 | "{expression}", 38 | System::Get().Evaluate("drop find {expression} system") 39 | ); 40 | } 41 | 42 | BOOST_AUTO_TEST_CASE(BasicTest) { 43 | BOOST_CHECK_EQUAL( 44 | ( 45 | "{" 46 | "1{2}{5}\n" 47 | "6{7 {8}}" 48 | "}" 49 | ), 50 | System::Get().Evaluate("expression {1{2}{5}6{7 {8}} }") 51 | ); 52 | } 53 | 54 | BOOST_AUTO_TEST_SUITE_END() 55 | 56 | } 57 | 58 | } 59 | 60 | } 61 | 62 | #endif 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /code/om/language/operation/expression_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__expression_operation__ expression 15 | \ingroup om__operation__ 16 | \brief 17 | Normalizes the \ref om__operand__ as a quoted \ref om__expression__. 18 | \par Implementation 19 | Om::Language::Operation::ExpressionOperation 20 | */ 21 | 22 | #ifndef Om_Language_Operation_ExpressionOperation_ 23 | 24 | #define Om_Language_Operation_ExpressionOperation_ \ 25 | Om::Language::Operation::ExpressionOperation 26 | 27 | #include "om/language/expression.hpp" 28 | #include "om/language/operation/program_operation.hpp" 29 | #include "om/language/system.hpp" 30 | 31 | namespace Om { 32 | 33 | namespace Language { 34 | 35 | namespace Operation { 36 | 37 | /*! 38 | \brief 39 | The \ref om__operation__expression_operation__ operation implementation. 40 | */ 41 | typedef ProgramOperation ExpressionOperation; 42 | 43 | namespace { 44 | 45 | static System::Definition const theExpressionDefinition; 46 | 47 | } 48 | 49 | } 50 | 51 | } 52 | 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /code/om/language/operation/front_pull_character_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__front_pull_character_operation__ <-[characters] 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the first character, quoted. 18 | \par Implementation 19 | Om::Language::Operation::FrontPullCharacterOperation 20 | */ 21 | 22 | #ifndef Om_Language_Operation_FrontPullCharacterOperation_ 23 | 24 | #define Om_Language_Operation_FrontPullCharacterOperation_ \ 25 | Om::Language::Operation::FrontPullCharacterOperation 26 | 27 | #include "om/language/system.hpp" 28 | 29 | #define Om_Language_Operation_FrontPullCharacterOperation_GetName_() \ 30 | "<-[characters]" 31 | 32 | namespace Om { 33 | 34 | namespace Language { 35 | 36 | namespace Operation { 37 | 38 | // MARK: - Om::Language::Operation::FrontPullCharacterOperation 39 | 40 | /*! 41 | \brief 42 | The \ref om__operation__front_pull_character_operation__ operation implementation. 43 | */ 44 | class FrontPullCharacterOperation { 45 | 46 | public: // MARK: public (static) 47 | 48 | static char const * GetName(); 49 | 50 | static void Give(Evaluation &); 51 | 52 | /*! 53 | \brief 54 | The callback for PullOperation. 55 | */ 56 | template 57 | static void Pull( 58 | Operator &, 59 | TheConsumer & 60 | ); 61 | 62 | }; 63 | 64 | namespace { 65 | 66 | static System::Definition const theFrontPullCharacterDefinition; 67 | 68 | } 69 | 70 | } 71 | 72 | } 73 | 74 | } 75 | 76 | #include "om/language/operation/front_pull_character_operation.cpp" 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /code/om/language/operation/front_pull_code_point_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__front_pull_code_point_operation__ <-[code` points] 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the first code point, quoted. 18 | \par Implementation 19 | Om::Language::Operation::FrontPullCodePointOperation 20 | */ 21 | 22 | #ifndef Om_Language_Operation_FrontPullCodePointOperation_ 23 | 24 | #define Om_Language_Operation_FrontPullCodePointOperation_ \ 25 | Om::Language::Operation::FrontPullCodePointOperation 26 | 27 | #include "om/language/system.hpp" 28 | 29 | #define Om_Language_Operation_FrontPullCodePointOperation_GetName_() \ 30 | "<-[code points]" 31 | 32 | namespace Om { 33 | 34 | namespace Language { 35 | 36 | namespace Operation { 37 | 38 | // MARK: - Om::Language::Operation::FrontPullCodePointOperation 39 | 40 | /*! 41 | \brief 42 | The \ref om__operation__front_pull_code_point_operation__ operation implementation. 43 | */ 44 | class FrontPullCodePointOperation { 45 | 46 | public: // MARK: public (static) 47 | 48 | static char const * GetName(); 49 | 50 | static void Give(Evaluation &); 51 | 52 | /*! 53 | \brief 54 | The callback for PullOperation. 55 | */ 56 | template 57 | static void Pull( 58 | Operator &, 59 | TheConsumer & 60 | ); 61 | 62 | }; 63 | 64 | namespace { 65 | 66 | static System::Definition const theFrontPullCodePointDefinition; 67 | 68 | } 69 | 70 | } 71 | 72 | } 73 | 74 | } 75 | 76 | #include "om/language/operation/front_pull_code_point_operation.cpp" 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /code/om/language/operation/front_pull_element_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__front_pull_element_operation__ <-[...] 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the first element, quoted. 18 | \par Input 19 | {A B} 20 | \par Output 21 | {A} { B} 22 | \par Implementation 23 | Om::Language::Operation::FrontPullElementOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_FrontPullElementOperation_ 27 | 28 | #define Om_Language_Operation_FrontPullElementOperation_ \ 29 | Om::Language::Operation::FrontPullElementOperation 30 | 31 | #include "om/language/system.hpp" 32 | 33 | #define Om_Language_Operation_FrontPullElementOperation_GetName_() \ 34 | "<-[...]" 35 | 36 | namespace Om { 37 | 38 | namespace Language { 39 | 40 | //! \cond 41 | class Literal; 42 | //! \endcond 43 | 44 | namespace Operation { 45 | 46 | // MARK: - Om::Language::Operation::FrontPullElementOperation 47 | 48 | /*! 49 | \brief 50 | The \ref om__operation__front_pull_element_operation__ operation implementation. 51 | */ 52 | class FrontPullElementOperation { 53 | 54 | public: // MARK: public (static) 55 | 56 | static char const * GetName(); 57 | 58 | static void Give(Evaluation &); 59 | 60 | /*! 61 | \brief 62 | The callback for PullOperation. 63 | */ 64 | template 65 | static void Pull( 66 | Literal &, 67 | TheConsumer & 68 | ); 69 | 70 | }; 71 | 72 | namespace { 73 | 74 | static System::Definition const theFrontPullElementDefinition; 75 | 76 | } 77 | 78 | } 79 | 80 | } 81 | 82 | } 83 | 84 | #include "om/language/operation/front_pull_element_operation.cpp" 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /code/om/language/operation/front_pull_form_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__front_pull_form_operation__ <-[forms] 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the first form (a non-empty list of zero or one \ref om__operator__ "Operator(s)", followed by zero or more \ref om__operand__ "Operands"), quoted. 18 | \par Implementation 19 | Om::Language::Operation::FrontPullFormOperation 20 | */ 21 | 22 | #ifndef Om_Language_Operation_FrontPullFormOperation_ 23 | 24 | #define Om_Language_Operation_FrontPullFormOperation_ \ 25 | Om::Language::Operation::FrontPullFormOperation 26 | 27 | #include "om/language/system.hpp" 28 | 29 | #define Om_Language_Operation_FrontPullFormOperation_GetName_() \ 30 | "<-[forms]" 31 | 32 | namespace Om { 33 | 34 | namespace Language { 35 | 36 | //! \cond 37 | class Expression; 38 | //! \endcond 39 | 40 | namespace Operation { 41 | 42 | // MARK: - Om::Language::Operation::FrontPullFormOperation 43 | 44 | /*! 45 | \brief 46 | The \ref om__operation__front_pull_form_operation__ operation implementation. 47 | */ 48 | class FrontPullFormOperation { 49 | 50 | public: // MARK: public (static) 51 | 52 | static char const * GetName(); 53 | 54 | static void Give(Evaluation &); 55 | 56 | /*! 57 | \brief 58 | The callback for PullOperation. 59 | */ 60 | template 61 | static void Pull( 62 | Expression &, 63 | TheConsumer & 64 | ); 65 | 66 | }; 67 | 68 | namespace { 69 | 70 | static System::Definition const theFrontPullFormDefinition; 71 | 72 | } 73 | 74 | } 75 | 76 | } 77 | 78 | } 79 | 80 | #include "om/language/operation/front_pull_form_operation.cpp" 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /code/om/language/operation/front_pull_operand_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__front_pull_operand_operation__ <-[operand...] 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the first \ref om__operand__ (if any), quoted. 18 | \par Input 19 | {{A} B} 20 | \par Output 21 | {{A}} { B} 22 | \par Implementation 23 | Om::Language::Operation::FrontPullOperandOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_FrontPullOperandOperation_ 27 | 28 | #define Om_Language_Operation_FrontPullOperandOperation_ \ 29 | Om::Language::Operation::FrontPullOperandOperation 30 | 31 | #include "om/language/system.hpp" 32 | 33 | #define Om_Language_Operation_FrontPullOperandOperation_GetName_() \ 34 | "<-[operand...]" 35 | 36 | namespace Om { 37 | 38 | namespace Language { 39 | 40 | //! \cond 41 | class Literal; 42 | //! \endcond 43 | 44 | namespace Operation { 45 | 46 | // MARK: - Om::Language::Operation::FrontPullOperandOperation 47 | 48 | /*! 49 | \brief 50 | The \ref om__operation__front_pull_operand_operation__ operation implementation. 51 | */ 52 | class FrontPullOperandOperation { 53 | 54 | public: // MARK: public (static) 55 | 56 | static char const * GetName(); 57 | 58 | static void Give(Evaluation &); 59 | 60 | /*! 61 | \brief 62 | The callback for PullOperation. 63 | */ 64 | template 65 | static void Pull( 66 | Literal &, 67 | TheConsumer & 68 | ); 69 | 70 | }; 71 | 72 | namespace { 73 | 74 | static System::Definition const theFrontPullOperandDefinition; 75 | 76 | } 77 | 78 | } 79 | 80 | } 81 | 82 | } 83 | 84 | #include "om/language/operation/front_pull_operand_operation.cpp" 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /code/om/language/operation/front_pull_operator_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__front_pull_operator_operation__ <-[operator...] 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the first \ref om__operator__ (if any), quoted. 18 | \par Input 19 | {A B} 20 | \par Output 21 | {A} { B} 22 | \par Implementation 23 | Om::Language::Operation::FrontPullOperatorOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_FrontPullOperatorOperation_ 27 | 28 | #define Om_Language_Operation_FrontPullOperatorOperation_ \ 29 | Om::Language::Operation::FrontPullOperatorOperation 30 | 31 | #include "om/language/system.hpp" 32 | 33 | #define Om_Language_Operation_FrontPullOperatorOperation_GetName_() \ 34 | "<-[operator...]" 35 | 36 | namespace Om { 37 | 38 | namespace Language { 39 | 40 | //! \cond 41 | class Literal; 42 | //! \endcond 43 | 44 | namespace Operation { 45 | 46 | // MARK: - Om::Language::Operation::FrontPullOperatorOperation 47 | 48 | /*! 49 | \brief 50 | The \ref om__operation__front_pull_operator_operation__ operation implementation. 51 | */ 52 | class FrontPullOperatorOperation { 53 | 54 | public: // MARK: public (static) 55 | 56 | static char const * GetName(); 57 | 58 | static void Give(Evaluation &); 59 | 60 | /*! 61 | \brief 62 | The callback for PullOperation. 63 | */ 64 | template 65 | static void Pull( 66 | Literal &, 67 | TheConsumer & 68 | ); 69 | 70 | }; 71 | 72 | namespace { 73 | 74 | static System::Definition const theFrontPullOperatorDefinition; 75 | 76 | } 77 | 78 | } 79 | 80 | } 81 | 82 | } 83 | 84 | #include "om/language/operation/front_pull_operator_operation.cpp" 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /code/om/language/operation/front_pull_pair_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__front_pull_pair_operation__ <-[pairs] 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the first pair (a non-empty list of zero or one \ref om__operator__ "Operator(s)", followed by zero or one \ref om__operand__ "Operand(s)"), quoted. 18 | \par Implementation 19 | Om::Language::Operation::FrontPullPairOperation 20 | */ 21 | 22 | #ifndef Om_Language_Operation_FrontPullPairOperation_ 23 | 24 | #define Om_Language_Operation_FrontPullPairOperation_ \ 25 | Om::Language::Operation::FrontPullPairOperation 26 | 27 | #include "om/language/system.hpp" 28 | 29 | #define Om_Language_Operation_FrontPullPairOperation_GetName_() \ 30 | "<-[pairs]" 31 | 32 | namespace Om { 33 | 34 | namespace Language { 35 | 36 | //! \cond 37 | class Lexicon; 38 | //! \endcond 39 | 40 | namespace Operation { 41 | 42 | // MARK: - Om::Language::Operation::FrontPullPairOperation 43 | 44 | /*! 45 | \brief 46 | The \ref om__operation__front_pull_pair_operation__ operation implementation. 47 | */ 48 | class FrontPullPairOperation { 49 | 50 | public: // MARK: public (static) 51 | 52 | static char const * GetName(); 53 | 54 | static void Give(Evaluation &); 55 | 56 | /*! 57 | \brief 58 | The callback for PullOperation. 59 | */ 60 | template 61 | static void Pull( 62 | Lexicon &, 63 | TheConsumer & 64 | ); 65 | 66 | }; 67 | 68 | namespace { 69 | 70 | static System::Definition const theFrontPullPairDefinition; 71 | 72 | } 73 | 74 | } 75 | 76 | } 77 | 78 | } 79 | 80 | #include "om/language/operation/front_pull_pair_operation.cpp" 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /code/om/language/operation/front_pull_separator_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__front_pull_separator_operation__ <-[separator...] 15 | \ingroup om__operation__ 16 | \brief 17 | Pops the first \ref om__separator__ (if any), quoted. 18 | \par Input 19 | { A B} 20 | \par Output 21 | { } {A B} 22 | \par Implementation 23 | Om::Language::Operation::FrontPullSeparatorOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_FrontPullSeparatorOperation_ 27 | 28 | #define Om_Language_Operation_FrontPullSeparatorOperation_ \ 29 | Om::Language::Operation::FrontPullSeparatorOperation 30 | 31 | #include "om/language/system.hpp" 32 | 33 | #define Om_Language_Operation_FrontPullSeparatorOperation_GetName_() \ 34 | "<-[separator...]" 35 | 36 | namespace Om { 37 | 38 | namespace Language { 39 | 40 | //! \cond 41 | class Literal; 42 | //! \endcond 43 | 44 | namespace Operation { 45 | 46 | // MARK: - Om::Language::Operation::FrontPullSeparatorOperation 47 | 48 | /*! 49 | \brief 50 | The \ref om__operation__front_pull_separator_operation__ operation implementation. 51 | */ 52 | class FrontPullSeparatorOperation { 53 | 54 | public: // MARK: public (static) 55 | 56 | static char const * GetName(); 57 | 58 | static void Give(Evaluation &); 59 | 60 | /*! 61 | \brief 62 | The callback for PullOperation. 63 | */ 64 | template 65 | static void Pull( 66 | Literal &, 67 | TheConsumer & 68 | ); 69 | 70 | }; 71 | 72 | namespace { 73 | 74 | static System::Definition const theFrontPullSeparatorDefinition; 75 | 76 | } 77 | 78 | } 79 | 80 | } 81 | 82 | } 83 | 84 | #include "om/language/operation/front_pull_separator_operation.cpp" 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /code/om/language/operation/front_push_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_FrontPushOperation_ 16 | 17 | #define Om_Language_Operation_FrontPushOperation_ \ 18 | Om::Language::Operation::FrontPushOperation 19 | 20 | #include "om/language/operation/default_incomplete_operation.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Language { 25 | 26 | namespace Operation { 27 | 28 | // MARK: - Om::Language::Operation::FrontPushOperation 29 | 30 | /*! 31 | \brief 32 | An Operation that joins an Operand to the front of a Program. 33 | */ 34 | template < 35 | typename ThisProgram, 36 | typename ThisImplementation 37 | > 38 | class FrontPushOperation: 39 | public DefaultIncompleteOperation< 40 | FrontPushOperation< 41 | ThisProgram, 42 | ThisImplementation 43 | > 44 | > { 45 | 46 | public: // MARK: public (static) 47 | 48 | template 49 | static void GiveElements( 50 | TheFrontPushOperation &, 51 | Consumer & 52 | ); 53 | 54 | public: // MARK: public (non-static) 55 | 56 | FrontPushOperation(); 57 | 58 | template 59 | bool TakeOperand( 60 | Evaluation &, 61 | TheOperand & 62 | ); 63 | 64 | template 65 | bool TakeQuotedProducer( 66 | Evaluation &, 67 | TheProducer & 68 | ); 69 | 70 | private: // MARK: private (static) 71 | 72 | static Operator const & GetOperator(); 73 | 74 | private: // MARK: private (non-static) 75 | 76 | ThisProgram thisProgram; 77 | 78 | }; 79 | 80 | } 81 | 82 | } 83 | 84 | } 85 | 86 | #include "om/language/operation/front_push_operation.cpp" 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /code/om/language/operation/incomplete_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_IncompleteOperation_ 16 | 17 | #include "om/language/operation/incomplete_operation.hpp" 18 | 19 | #else 20 | 21 | #ifndef Om_Macro_Precompilation_ 22 | 23 | #include 24 | #include 25 | 26 | #endif 27 | 28 | // MARK: - Om::Language::Operation::IncompleteOperation 29 | 30 | #define Type_ \ 31 | Om::Language::Operation::IncompleteOperation 32 | 33 | // MARK: public (non-static) 34 | 35 | inline Type_::~IncompleteOperation() {} 36 | 37 | inline void Type_::GiveElements(Consumer &) { 38 | assert(0); 39 | throw std::logic_error("Pure virtual function called."); 40 | } 41 | 42 | inline void Type_::GiveElements(Consumer &) const { 43 | assert(0); 44 | throw std::logic_error("Pure virtual function called."); 45 | } 46 | 47 | inline bool Type_::ParseQuotedElements( 48 | Evaluation &, 49 | Reader & 50 | ) { 51 | assert(0); 52 | throw std::logic_error("Pure virtual function called."); 53 | } 54 | 55 | inline bool Type_::TakeElement( 56 | Evaluation &, 57 | Operand & 58 | ) { 59 | assert(0); 60 | throw std::logic_error("Pure virtual function called."); 61 | } 62 | 63 | inline bool Type_::TakeElement( 64 | Evaluation &, 65 | Operand const & 66 | ) { 67 | assert(0); 68 | throw std::logic_error("Pure virtual function called."); 69 | } 70 | 71 | inline bool Type_::TakeQuotedElements( 72 | Evaluation &, 73 | Producer & 74 | ) { 75 | assert(0); 76 | throw std::logic_error("Pure virtual function called."); 77 | } 78 | 79 | inline bool Type_::TakeQuotedElements( 80 | Evaluation &, 81 | Producer const & 82 | ) { 83 | assert(0); 84 | throw std::logic_error("Pure virtual function called."); 85 | } 86 | 87 | // MARK: protected (non-static) 88 | 89 | inline Type_::IncompleteOperation() {} 90 | 91 | #undef Type_ 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /code/om/language/operation/lexicon_back_push_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_LexiconBackPushOperation_ 16 | 17 | #include "om/language/operation/lexicon_back_push_operation.hpp" 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(LexiconBackPushOperationTest) 34 | 35 | BOOST_AUTO_TEST_CASE(DefinitionTest) { 36 | BOOST_CHECK_EQUAL( 37 | "{[lexicon]<-}", 38 | System::Get().Evaluate("drop find {[lexicon]<-} system") 39 | ); 40 | } 41 | 42 | BOOST_AUTO_TEST_SUITE_END() 43 | 44 | } 45 | 46 | } 47 | 48 | } 49 | 50 | #endif 51 | 52 | #else 53 | 54 | #include "om/language/operation/lexicon_front_push_operation.hpp" 55 | #include "om/language/operation/swap_operation.hpp" 56 | 57 | // MARK: - Om::Language::Operation::LexiconBackPushOperation 58 | 59 | #define Type_ \ 60 | Om::Language::Operation::LexiconBackPushOperation 61 | 62 | // MARK: public (static) 63 | 64 | inline char const * Type_::GetName() { 65 | return Om_Language_Operation_LexiconBackPushOperation_GetName_(); 66 | } 67 | 68 | inline void Type_::Give(Evaluation & theEvaluation) { 69 | LexiconFrontPushOperation::Give(theEvaluation); 70 | SwapOperation::Give(theEvaluation); 71 | } 72 | 73 | #undef Type_ 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /code/om/language/operation/lexicon_back_push_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__lexicon_back_push_operation__ [lexicon]<- 15 | \ingroup om__operation__ 16 | \brief 17 | Pushes the contents of an \ref om__operand__ onto the back of a \ref om__lexicon__ (quoted). 18 | \par Input 19 | {A} {B} 20 | \par Output 21 | {B
22 | A}
23 | \par Implementation 24 | Om::Language::Operation::LexiconBackPushOperation 25 | */ 26 | 27 | #ifndef Om_Language_Operation_LexiconBackPushOperation_ 28 | 29 | #define Om_Language_Operation_LexiconBackPushOperation_ \ 30 | Om::Language::Operation::LexiconBackPushOperation 31 | 32 | #include "om/language/system.hpp" 33 | 34 | #define Om_Language_Operation_LexiconBackPushOperation_GetName_() \ 35 | "[lexicon]<-" 36 | 37 | namespace Om { 38 | 39 | namespace Language { 40 | 41 | namespace Operation { 42 | 43 | // MARK: - Om::Language::Operation::LexiconBackPushOperation 44 | 45 | /*! 46 | \brief 47 | The \ref om__operation__lexicon_back_push_operation__ operation implementation. 48 | */ 49 | class LexiconBackPushOperation { 50 | 51 | public: // MARK: public (static) 52 | 53 | static char const * GetName(); 54 | 55 | static void Give(Evaluation &); 56 | 57 | }; 58 | 59 | namespace { 60 | 61 | static System::Definition const theLexiconBackPushDefinition; 62 | 63 | } 64 | 65 | } 66 | 67 | } 68 | 69 | } 70 | 71 | #include "om/language/operation/lexicon_back_push_operation.cpp" 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /code/om/language/operation/lexicon_front_push_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__lexicon_front_push_operation__ ->[lexicon] 15 | \ingroup om__operation__ 16 | \brief 17 | Pushes the contents of an \ref om__operand__ onto the front of a \ref om__lexicon__ (quoted). 18 | \par Input 19 | {A} {B} 20 | \par Output 21 | {A
22 | B}
23 | \par Implementation 24 | Om::Language::Operation::LexiconFrontPushOperation 25 | */ 26 | 27 | #ifndef Om_Language_Operation_LexiconFrontPushOperation_ 28 | 29 | #define Om_Language_Operation_LexiconFrontPushOperation_ \ 30 | Om::Language::Operation::LexiconFrontPushOperation 31 | 32 | #include "om/language/system.hpp" 33 | 34 | #define Om_Language_Operation_LexiconFrontPushOperation_GetName_() \ 35 | "->[lexicon]" 36 | 37 | namespace Om { 38 | 39 | namespace Language { 40 | 41 | namespace Operation { 42 | 43 | // MARK: - Om::Language::Operation::LexiconFrontPushOperation 44 | 45 | /*! 46 | \brief 47 | The \ref om__operation__lexicon_front_push_operation__ operation implementation. 48 | */ 49 | class LexiconFrontPushOperation { 50 | 51 | public: // MARK: public (static) 52 | 53 | static char const * GetName(); 54 | 55 | static void Give(Evaluation &); 56 | 57 | }; 58 | 59 | namespace { 60 | 61 | static System::Definition const theLexiconFrontPushDefinition; 62 | 63 | } 64 | 65 | } 66 | 67 | } 68 | 69 | } 70 | 71 | #include "om/language/operation/lexicon_front_push_operation.cpp" 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /code/om/language/operation/lexicon_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_LexiconOperation_ 16 | 17 | #include "om/language/operation/lexicon_operation.hpp" 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(LexiconOperationTest) 34 | 35 | BOOST_AUTO_TEST_CASE(DefinitionTest) { 36 | BOOST_CHECK_EQUAL( 37 | "{lexicon}", 38 | System::Get().Evaluate("drop find {lexicon} system") 39 | ); 40 | } 41 | 42 | BOOST_AUTO_TEST_SUITE_END() 43 | 44 | } 45 | 46 | } 47 | 48 | } 49 | 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /code/om/language/operation/lexicon_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__lexicon_operation__ lexicon 15 | \ingroup om__operation__ 16 | \brief 17 | Normalizes the \ref om__operand__ as a quoted \ref om__lexicon__. 18 | \par Implementation 19 | Om::Language::Operation::LexiconOperation 20 | 21 | A \ref om__program__ is interpreted as a \ref om__lexicon__ as follows: 22 | - Each \ref om__operator__ is a key, indexing to the \ref om__operand__ to its right. 23 | - In the case of duplicate \ref om__operator__ "Operators", the prior is removed. 24 | - An \ref om__operator__ without an \ref om__operand__ indicates that the system mapping for the \ref om__operator__ is to be explicitly included. 25 | - An \ref om__operand__ without an \ref om__operator__ indicates the default mapping, which is used for any \ref om__operator__ not found in the \ref om__lexicon__. 26 | */ 27 | 28 | #ifndef Om_Language_Operation_LexiconOperation_ 29 | 30 | #define Om_Language_Operation_LexiconOperation_ \ 31 | Om::Language::Operation::LexiconOperation 32 | 33 | #include "om/language/lexicon.hpp" 34 | #include "om/language/operation/program_operation.hpp" 35 | #include "om/language/system.hpp" 36 | 37 | namespace Om { 38 | 39 | namespace Language { 40 | 41 | namespace Operation { 42 | 43 | /*! 44 | \brief 45 | The \ref om__operation__lexicon_operation__ operation implementation. 46 | */ 47 | typedef ProgramOperation LexiconOperation; 48 | 49 | namespace { 50 | 51 | static System::Definition const theLexiconDefinition; 52 | 53 | } 54 | 55 | } 56 | 57 | } 58 | 59 | } 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /code/om/language/operation/literal_back_push_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_LiteralBackPushOperation_ 16 | 17 | #include "om/language/operation/literal_back_push_operation.hpp" 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(LiteralBackPushOperationTest) 34 | 35 | BOOST_AUTO_TEST_CASE(DefinitionTest) { 36 | BOOST_CHECK_EQUAL( 37 | "{[literal]<-}", 38 | System::Get().Evaluate("drop find {[literal]<-} system") 39 | ); 40 | } 41 | 42 | BOOST_AUTO_TEST_SUITE_END() 43 | 44 | } 45 | 46 | } 47 | 48 | } 49 | 50 | #endif 51 | 52 | #else 53 | 54 | #include "om/language/operation/literal_front_push_operation.hpp" 55 | #include "om/language/operation/swap_operation.hpp" 56 | 57 | // MARK: - Om::Language::Operation::LiteralBackPushOperation 58 | 59 | #define Type_ \ 60 | Om::Language::Operation::LiteralBackPushOperation 61 | 62 | // MARK: public (static) 63 | 64 | inline char const * Type_::GetName() { 65 | return Om_Language_Operation_LiteralBackPushOperation_GetName_(); 66 | } 67 | 68 | inline void Type_::Give(Evaluation & theEvaluation) { 69 | LiteralFrontPushOperation::Give(theEvaluation); 70 | SwapOperation::Give(theEvaluation); 71 | } 72 | 73 | #undef Type_ 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /code/om/language/operation/literal_back_push_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__literal_back_push_operation__ [literal]<- 15 | \ingroup om__operation__ 16 | \brief 17 | Pushes the contents of an \ref om__operand__ onto the back of a \ref om__literal__ (quoted). 18 | \par Input 19 | {A} {B} 20 | \par Output 21 | {BA} 22 | \par Implementation 23 | Om::Language::Operation::LiteralBackPushOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_LiteralBackPushOperation_ 27 | 28 | #define Om_Language_Operation_LiteralBackPushOperation_ \ 29 | Om::Language::Operation::LiteralBackPushOperation 30 | 31 | #include "om/language/system.hpp" 32 | 33 | #define Om_Language_Operation_LiteralBackPushOperation_GetName_() \ 34 | "[literal]<-" 35 | 36 | namespace Om { 37 | 38 | namespace Language { 39 | 40 | namespace Operation { 41 | 42 | // MARK: - Om::Language::Operation::LiteralBackPushOperation 43 | 44 | /*! 45 | \brief 46 | The \ref om__operation__literal_back_push_operation__ operation implementation. 47 | */ 48 | class LiteralBackPushOperation { 49 | 50 | public: // MARK: public (static) 51 | 52 | static char const * GetName(); 53 | 54 | static void Give(Evaluation &); 55 | 56 | }; 57 | 58 | namespace { 59 | 60 | static System::Definition const theLiteralBackPushDefinition; 61 | 62 | } 63 | 64 | } 65 | 66 | } 67 | 68 | } 69 | 70 | #include "om/language/operation/literal_back_push_operation.cpp" 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /code/om/language/operation/literal_front_push_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__literal_front_push_operation__ ->[literal] 15 | \ingroup om__operation__ 16 | \brief 17 | Pushes the contents of an \ref om__operand__ onto the front of a \ref om__literal__ (quoted). 18 | \par Input 19 | {A} {B} 20 | \par Output 21 | {AB} 22 | \par Implementation 23 | Om::Language::Operation::LiteralFrontPushOperation 24 | 25 | Normalization to a \ref om__literal__ only happens if an append occurs (i.e. the first \ref om__operand__ is non-empty); otherwise, it is left unchanged. However, since everything represents as a \ref om__literal__, this doesn't make an observable difference. 26 | */ 27 | 28 | #ifndef Om_Language_Operation_LiteralFrontPushOperation_ 29 | 30 | #define Om_Language_Operation_LiteralFrontPushOperation_ \ 31 | Om::Language::Operation::LiteralFrontPushOperation 32 | 33 | #include "om/language/system.hpp" 34 | 35 | #define Om_Language_Operation_LiteralFrontPushOperation_GetName_() \ 36 | "->[literal]" 37 | 38 | namespace Om { 39 | 40 | namespace Language { 41 | 42 | namespace Operation { 43 | 44 | // MARK: - Om::Language::Operation::LiteralFrontPushOperation 45 | 46 | /*! 47 | \brief 48 | The \ref om__operation__literal_front_push_operation__ operation implementation. 49 | */ 50 | class LiteralFrontPushOperation { 51 | 52 | public: // MARK: public (static) 53 | 54 | static char const * GetName(); 55 | 56 | static void Give(Evaluation &); 57 | 58 | }; 59 | 60 | namespace { 61 | 62 | static System::Definition const theLiteralFrontPushDefinition; 63 | 64 | } 65 | 66 | } 67 | 68 | } 69 | 70 | } 71 | 72 | #include "om/language/operation/literal_front_push_operation.cpp" 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /code/om/language/operation/operand_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_OperandOperation_ 16 | 17 | #include "om/language/operation/operand_operation.hpp" 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(OperandOperationTest) 34 | 35 | BOOST_AUTO_TEST_CASE(DefinitionTest) { 36 | BOOST_CHECK_EQUAL( 37 | "{operand}", 38 | System::Get().Evaluate("drop find {operand} system") 39 | ); 40 | } 41 | 42 | BOOST_AUTO_TEST_CASE(GeneralTest) { 43 | BOOST_CHECK_EQUAL( 44 | "{}", 45 | System::Get().Evaluate("operand{}") 46 | ); 47 | 48 | BOOST_CHECK_EQUAL( 49 | "{{}}", 50 | System::Get().Evaluate("operand{{}}") 51 | ); 52 | 53 | BOOST_CHECK_EQUAL( 54 | "{{b}}", 55 | System::Get().Evaluate("operand{ a {b} {c} d }") 56 | ); 57 | 58 | BOOST_CHECK_EQUAL( 59 | "{{b}}", 60 | System::Get().Evaluate("drop swap operand copy{ a {b} {c} d }") 61 | ); 62 | } 63 | 64 | BOOST_AUTO_TEST_SUITE_END() 65 | 66 | } 67 | 68 | } 69 | 70 | } 71 | 72 | #endif 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /code/om/language/operation/operand_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__operand_operation__ operand 15 | \ingroup om__operation__ 16 | \brief 17 | Normalizes the \ref om__operand__ as a quoted \ref om__operand__. 18 | \par Implementation 19 | Om::Language::Operation::OperandOperation 20 | */ 21 | 22 | #ifndef Om_Language_Operation_OperandOperation_ 23 | 24 | #define Om_Language_Operation_OperandOperation_ \ 25 | Om::Language::Operation::OperandOperation 26 | 27 | #include "om/language/operation/program_operation.hpp" 28 | #include "om/language/system.hpp" 29 | 30 | namespace Om { 31 | 32 | namespace Language { 33 | 34 | namespace Operation { 35 | 36 | /*! 37 | \brief 38 | The \ref om__operation__operand_operation__ operation implementation. 39 | */ 40 | typedef ProgramOperation OperandOperation; 41 | 42 | namespace { 43 | 44 | static System::Definition const theOperandDefinition; 45 | 46 | } 47 | 48 | } 49 | 50 | } 51 | 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /code/om/language/operation/operator_back_push_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_OperatorBackPushOperation_ 16 | 17 | #include "om/language/operation/operator_back_push_operation.hpp" 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(OperatorBackPushOperationTest) 34 | 35 | BOOST_AUTO_TEST_CASE(DefinitionTest) { 36 | BOOST_CHECK_EQUAL( 37 | "{[operator]<-}", 38 | System::Get().Evaluate("drop find {[operator]<-} system") 39 | ); 40 | } 41 | 42 | BOOST_AUTO_TEST_SUITE_END() 43 | 44 | } 45 | 46 | } 47 | 48 | } 49 | 50 | #endif 51 | 52 | #else 53 | 54 | #include "om/language/operation/operator_front_push_operation.hpp" 55 | #include "om/language/operation/swap_operation.hpp" 56 | 57 | // MARK: - Om::Language::Operation::OperatorBackPushOperation 58 | 59 | #define Type_ \ 60 | Om::Language::Operation::OperatorBackPushOperation 61 | 62 | // MARK: public (static) 63 | 64 | inline char const * Type_::GetName() { 65 | return Om_Language_Operation_OperatorBackPushOperation_GetName_(); 66 | } 67 | 68 | inline void Type_::Give(Evaluation & theEvaluation) { 69 | OperatorFrontPushOperation::Give(theEvaluation); 70 | SwapOperation::Give(theEvaluation); 71 | } 72 | 73 | #undef Type_ 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /code/om/language/operation/operator_back_push_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__operator_back_push_operation__ [operator]<- 15 | \ingroup om__operation__ 16 | \brief 17 | Pushes the contents of an \ref om__operand__ onto the back of an \ref om__operator__ (quoted). 18 | \par Input 19 | {A} {B} 20 | \par Output 21 | {BA} 22 | \par Implementation 23 | Om::Language::Operation::OperatorBackPushOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_OperatorBackPushOperation_ 27 | 28 | #define Om_Language_Operation_OperatorBackPushOperation_ \ 29 | Om::Language::Operation::OperatorBackPushOperation 30 | 31 | #include "om/language/system.hpp" 32 | 33 | #define Om_Language_Operation_OperatorBackPushOperation_GetName_() \ 34 | "[operator]<-" 35 | 36 | namespace Om { 37 | 38 | namespace Language { 39 | 40 | namespace Operation { 41 | 42 | // MARK: - Om::Language::Operation::OperatorBackPushOperation 43 | 44 | /*! 45 | \brief 46 | The \ref om__operation__operator_back_push_operation__ operation implementation. 47 | */ 48 | class OperatorBackPushOperation { 49 | 50 | public: // MARK: public (static) 51 | 52 | static char const * GetName(); 53 | 54 | static void Give(Evaluation &); 55 | 56 | }; 57 | 58 | namespace { 59 | 60 | static System::Definition const theOperatorBackPushDefinition; 61 | 62 | } 63 | 64 | } 65 | 66 | } 67 | 68 | } 69 | 70 | #include "om/language/operation/operator_back_push_operation.cpp" 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /code/om/language/operation/operator_front_push_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_OperatorFrontPushOperation_ 16 | 17 | #include "om/language/operation/operator_front_push_operation.hpp" 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(OperatorFrontPushOperationTest) 34 | 35 | BOOST_AUTO_TEST_CASE(DefinitionTest) { 36 | BOOST_CHECK_EQUAL( 37 | "{->[operator]}", 38 | System::Get().Evaluate("drop find {->[operator]} system") 39 | ); 40 | } 41 | 42 | BOOST_AUTO_TEST_SUITE_END() 43 | 44 | } 45 | 46 | } 47 | 48 | } 49 | 50 | #endif 51 | 52 | #else 53 | 54 | #include "om/language/operation/front_push_operation.hpp" 55 | 56 | // MARK: - Om::Language::Operation::OperatorFrontPushOperation 57 | 58 | #define Type_ \ 59 | Om::Language::Operation::OperatorFrontPushOperation 60 | 61 | // MARK: public (static) 62 | 63 | inline char const * Type_::GetName() { 64 | return Om_Language_Operation_OperatorFrontPushOperation_GetName_(); 65 | } 66 | 67 | inline void Type_::Give(Evaluation & theEvaluation) { 68 | theEvaluation.TakeOperation( 69 | std::auto_ptr( 70 | new FrontPushOperation< 71 | Operator, 72 | OperatorFrontPushOperation 73 | > 74 | ) 75 | ); 76 | } 77 | 78 | #undef Type_ 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /code/om/language/operation/operator_front_push_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__operator_front_push_operation__ ->[operator] 15 | \ingroup om__operation__ 16 | \brief 17 | Pushes the contents of an \ref om__operand__ onto the front of an \ref om__operator__ (quoted). 18 | \par Input 19 | {A} {B} 20 | \par Output 21 | {AB} 22 | \par Implementation 23 | Om::Language::Operation::OperatorFrontPushOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_OperatorFrontPushOperation_ 27 | 28 | #define Om_Language_Operation_OperatorFrontPushOperation_ \ 29 | Om::Language::Operation::OperatorFrontPushOperation 30 | 31 | #include "om/language/system.hpp" 32 | 33 | #define Om_Language_Operation_OperatorFrontPushOperation_GetName_() \ 34 | "->[operator]" 35 | 36 | namespace Om { 37 | 38 | namespace Language { 39 | 40 | namespace Operation { 41 | 42 | // MARK: - Om::Language::Operation::OperatorFrontPushOperation 43 | 44 | /*! 45 | \brief 46 | The \ref om__operation__operator_front_push_operation__ operation implementation. 47 | */ 48 | class OperatorFrontPushOperation { 49 | 50 | public: // MARK: public (static) 51 | 52 | static char const * GetName(); 53 | 54 | static void Give(Evaluation &); 55 | 56 | }; 57 | 58 | namespace { 59 | 60 | static System::Definition const theOperatorFrontPushDefinition; 61 | 62 | } 63 | 64 | } 65 | 66 | } 67 | 68 | } 69 | 70 | #include "om/language/operation/operator_front_push_operation.cpp" 71 | 72 | #endif 73 | -------------------------------------------------------------------------------- /code/om/language/operation/operator_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_OperatorOperation_ 16 | 17 | #include "om/language/operation/operator_operation.hpp" 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(OperatorOperationTest) 34 | 35 | BOOST_AUTO_TEST_CASE(DefinitionTest) { 36 | BOOST_CHECK_EQUAL( 37 | "{operator}", 38 | System::Get().Evaluate("drop find {operator} system") 39 | ); 40 | } 41 | 42 | BOOST_AUTO_TEST_SUITE_END() 43 | 44 | } 45 | 46 | } 47 | 48 | } 49 | 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /code/om/language/operation/operator_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__operator_operation__ operator 15 | \ingroup om__operation__ 16 | \brief 17 | Normalizes the \ref om__operand__ as a quoted \ref om__operator__. 18 | \par Implementation 19 | Om::Language::Operation::OperatorOperation 20 | */ 21 | 22 | #ifndef Om_Language_Operation_OperatorOperation_ 23 | 24 | #define Om_Language_Operation_OperatorOperation_ \ 25 | Om::Language::Operation::OperatorOperation 26 | 27 | #include "om/language/operation/program_operation.hpp" 28 | #include "om/language/system.hpp" 29 | 30 | namespace Om { 31 | 32 | namespace Language { 33 | 34 | namespace Operation { 35 | 36 | /*! 37 | \brief 38 | The \ref om__operation__operator_operation__ operation implementation. 39 | */ 40 | typedef ProgramOperation OperatorOperation; 41 | 42 | namespace { 43 | 44 | static System::Definition const theOperatorDefinition; 45 | 46 | } 47 | 48 | } 49 | 50 | } 51 | 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /code/om/language/operation/program_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_ProgramOperation_ 16 | 17 | #include "om/language/operation/program_operation.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::Language::Operation::ProgramOperation 22 | 23 | #define Template_ \ 24 | template 25 | 26 | #define Type_ \ 27 | Om::Language::Operation::ProgramOperation 28 | 29 | // MARK: public (static) 30 | 31 | Template_ 32 | inline char const * Type_::GetName() { 33 | return ThisProgram::GetName(); 34 | } 35 | 36 | Template_ 37 | template 38 | inline void Type_::GiveElements( 39 | TheProgramOperation &, 40 | Consumer & theConsumer 41 | ) { 42 | theConsumer.TakeElement( 43 | DefaultIncompleteOperation< 44 | ProgramOperation 45 | >::GetOperator() 46 | ); 47 | } 48 | 49 | // MARK: public (non-static) 50 | 51 | Template_ 52 | inline bool Type_::ParseQuotedElements( 53 | Evaluation & theEvaluation, 54 | Reader & theReader 55 | ) { 56 | ThisProgram theProgram; 57 | theProgram.ParseElements(theReader); 58 | theEvaluation.TakeQuotedProducer(theProgram); 59 | return true; 60 | } 61 | 62 | Template_ 63 | template 64 | inline bool Type_::TakeOperand( 65 | Evaluation & theEvaluation, 66 | TheOperand & theOperand 67 | ) { 68 | assert( 69 | !theOperand.IsEmpty() 70 | ); 71 | return this->TakeQuotedProducer( 72 | theEvaluation, 73 | *theOperand.GetProgram() 74 | ); 75 | } 76 | 77 | Template_ 78 | template 79 | inline bool Type_::TakeQuotedProducer( 80 | Evaluation & theEvaluation, 81 | TheProducer & theProducer 82 | ) { 83 | ThisProgram theProgram; 84 | theProgram.TakeElements(theProducer); 85 | theEvaluation.TakeQuotedProducer(theProgram); 86 | return true; 87 | } 88 | 89 | #undef Type_ 90 | #undef Template_ 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /code/om/language/operation/program_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_ProgramOperation_ 16 | 17 | #define Om_Language_Operation_ProgramOperation_ \ 18 | Om::Language::Operation::ProgramOperation 19 | 20 | #include "om/language/operation/default_incomplete_operation.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Language { 25 | 26 | namespace Operation { 27 | 28 | // MARK: - Om::Language::Operation::ProgramOperation 29 | 30 | /*! 31 | \brief 32 | An Operation that normalizes a Program to a specific type. 33 | */ 34 | template 35 | class ProgramOperation: 36 | public DefaultIncompleteOperation< 37 | ProgramOperation 38 | > { 39 | 40 | public: // MARK: public (static) 41 | 42 | static char const * GetName(); 43 | 44 | template 45 | static void GiveElements( 46 | TheProgramOperation &, 47 | Consumer & 48 | ); 49 | 50 | public: // MARK: public (non-static) 51 | 52 | virtual bool ParseQuotedElements( 53 | Evaluation &, 54 | Reader & 55 | ); 56 | 57 | template 58 | bool TakeOperand( 59 | Evaluation &, 60 | TheOperand & 61 | ); 62 | 63 | template 64 | bool TakeQuotedProducer( 65 | Evaluation &, 66 | TheProducer & 67 | ); 68 | 69 | }; 70 | 71 | } 72 | 73 | } 74 | 75 | } 76 | 77 | #include "om/language/operation/program_operation.cpp" 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /code/om/language/operation/pull_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_PullOperation_ 16 | 17 | #define Om_Language_Operation_PullOperation_ \ 18 | Om::Language::Operation::PullOperation 19 | 20 | #include "om/language/operation/default_incomplete_operation.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Language { 25 | 26 | namespace Operation { 27 | 28 | // MARK: - Om::Language::Operation::PullOperation 29 | 30 | /*! 31 | \brief 32 | An Operation that pulls part of a Program. 33 | */ 34 | template < 35 | typename ThisProgram, 36 | typename ThisImplementation 37 | > 38 | class PullOperation: 39 | public DefaultIncompleteOperation< 40 | PullOperation< 41 | ThisProgram, 42 | ThisImplementation 43 | > 44 | > { 45 | 46 | public: // MARK: public (static) 47 | 48 | template 49 | static void GiveElements( 50 | ThePullOperation &, 51 | Consumer & 52 | ); 53 | 54 | public: // MARK: public (non-static) 55 | 56 | virtual bool ParseQuotedElements( 57 | Evaluation &, 58 | Reader & 59 | ); 60 | 61 | template 62 | bool TakeOperand( 63 | Evaluation &, 64 | TheOperand & 65 | ); 66 | 67 | template 68 | bool TakeQuotedProducer( 69 | Evaluation &, 70 | TheProducer & 71 | ); 72 | 73 | private: // MARK: private (static) 74 | 75 | static Operator const & GetOperator(); 76 | 77 | }; 78 | 79 | } 80 | 81 | } 82 | 83 | } 84 | 85 | #include "om/language/operation/pull_operation.cpp" 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /code/om/language/operation/quote_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__quote_operation__ quote 15 | \ingroup om__operation__ 16 | \brief 17 | Encloses an \ref om__operand__ in braces. 18 | \par Input 19 | {A} 20 | \par Output 21 | {{A}} 22 | \par Implementation 23 | Om::Language::Operation::QuoteOperation 24 | */ 25 | 26 | #ifndef Om_Language_Operation_QuoteOperation_ 27 | 28 | #define Om_Language_Operation_QuoteOperation_ \ 29 | Om::Language::Operation::QuoteOperation 30 | 31 | #include "om/language/operation/default_incomplete_operation.hpp" 32 | #include "om/language/system.hpp" 33 | 34 | #define Om_Language_Operation_QuoteOperation_GetName_() \ 35 | "quote" 36 | 37 | namespace Om { 38 | 39 | namespace Language { 40 | 41 | namespace Operation { 42 | 43 | // MARK: - Om::Language::Operation::QuoteOperation 44 | 45 | /*! 46 | \brief 47 | The \ref om__operation__quote_operation__ operation implementation. 48 | */ 49 | class QuoteOperation: 50 | public DefaultIncompleteOperation { 51 | 52 | public: // MARK: public (static) 53 | 54 | static char const * GetName(); 55 | 56 | template 57 | static void GiveElements( 58 | TheQuoteOperation &, 59 | Consumer & 60 | ); 61 | 62 | public: // MARK: public (non-static) 63 | 64 | template 65 | bool TakeOperand( 66 | Evaluation &, 67 | TheOperand & 68 | ); 69 | 70 | template 71 | bool TakeQuotedProducer( 72 | Evaluation &, 73 | TheProducer & 74 | ); 75 | 76 | }; 77 | 78 | namespace { 79 | 80 | static System::Definition const theQuoteDefinition; 81 | 82 | } 83 | 84 | } 85 | 86 | } 87 | 88 | } 89 | 90 | #include "om/language/operation/quote_operation.cpp" 91 | 92 | #endif 93 | 94 | -------------------------------------------------------------------------------- /code/om/language/operation/separator_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_SeparatorOperation_ 16 | 17 | #include "om/language/operation/separator_operation.hpp" 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(SeparatorOperationTest) 34 | 35 | BOOST_AUTO_TEST_CASE(DefinitionTest) { 36 | BOOST_CHECK_EQUAL( 37 | "{separator}", 38 | System::Get().Evaluate("drop find {separator} system") 39 | ); 40 | } 41 | 42 | BOOST_AUTO_TEST_CASE(GeneralTest) { 43 | BOOST_CHECK_EQUAL( 44 | "{}", 45 | System::Get().Evaluate("separator{}") 46 | ); 47 | 48 | BOOST_CHECK_EQUAL( 49 | "{ \n\t }", 50 | System::Get().Evaluate("separator{ \n\t }") 51 | ); 52 | 53 | BOOST_CHECK_EQUAL( 54 | "{ \n\t }", 55 | System::Get().Evaluate("separator{ a {b} \n\t {c} d }") 56 | ); 57 | 58 | BOOST_CHECK_EQUAL( 59 | "{ \n\t }", 60 | System::Get().Evaluate("drop swap separator copy{ a {b} \n\t {c} d }") 61 | ); 62 | } 63 | 64 | BOOST_AUTO_TEST_SUITE_END() 65 | 66 | } 67 | 68 | } 69 | 70 | } 71 | 72 | #endif 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /code/om/language/operation/separator_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__separator_operation__ separator 15 | \ingroup om__operation__ 16 | \brief 17 | Normalizes the \ref om__operand__ as a quoted \ref om__separator__. 18 | \par Implementation 19 | Om::Language::Operation::SeparatorOperation 20 | */ 21 | 22 | #ifndef Om_Language_Operation_SeparatorOperation_ 23 | 24 | #define Om_Language_Operation_SeparatorOperation_ \ 25 | Om::Language::Operation::SeparatorOperation 26 | 27 | #include "om/language/operation/program_operation.hpp" 28 | #include "om/language/system.hpp" 29 | 30 | namespace Om { 31 | 32 | namespace Language { 33 | 34 | namespace Operation { 35 | 36 | /*! 37 | \brief 38 | The \ref om__operation__separator_operation__ operation implementation. 39 | */ 40 | typedef ProgramOperation SeparatorOperation; 41 | 42 | namespace { 43 | 44 | static System::Definition const theSeparatorDefinition; 45 | 46 | } 47 | 48 | } 49 | 50 | } 51 | 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /code/om/language/operation/system_operation.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_SystemOperation_ 16 | 17 | #include "om/language/operation/system_operation.hpp" 18 | 19 | #ifdef Om_Macro_Test_ 20 | 21 | #include "om/language/system.hpp" 22 | 23 | #ifndef Om_Macro_Precompilation_ 24 | 25 | #include "boost/test/unit_test.hpp" 26 | 27 | #endif 28 | 29 | namespace Om { 30 | 31 | namespace Language { 32 | 33 | namespace Operation { 34 | 35 | BOOST_AUTO_TEST_SUITE(SystemOperationTest) 36 | 37 | BOOST_AUTO_TEST_CASE(DefinitionTest) { 38 | BOOST_CHECK_EQUAL( 39 | "{system}", 40 | System::Get().Evaluate("drop find {system} system") 41 | ); 42 | } 43 | 44 | BOOST_AUTO_TEST_SUITE_END() 45 | 46 | } 47 | 48 | } 49 | 50 | } 51 | 52 | #endif 53 | 54 | #else 55 | 56 | // MARK: - Om::Language::Operation::SystemOperation 57 | 58 | #define Type_ \ 59 | Om::Language::Operation::SystemOperation 60 | 61 | // MARK: public (static) 62 | 63 | inline char const * Type_::GetName() { 64 | return Om_Language_Operation_SystemOperation_GetName_(); 65 | } 66 | 67 | inline void Type_::Give(Evaluation & theEvaluation) { 68 | theEvaluation.TakeQuotedProducer( 69 | System::Get().GetLexicon() 70 | ); 71 | } 72 | 73 | #undef Type_ 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /code/om/language/operation/system_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | 14 | \defgroup om__operation__system_operation__ system 15 | \ingroup om__operation__ 16 | \brief 17 | Produces the system \ref om__lexicon__. 18 | \par Details 19 | The system \ref om__lexicon__ contains each \ref om__operator__ defined by the system. Each \ref om__operator__ is without an \ref om__operand__ mapping to indicate that the native system operation is to be used. 20 | \par Implementation 21 | Om::Language::Operation::SystemOperation 22 | */ 23 | 24 | #ifndef Om_Language_Operation_SystemOperation_ 25 | 26 | #define Om_Language_Operation_SystemOperation_ \ 27 | Om::Language::Operation::SystemOperation 28 | 29 | #include "om/language/system.hpp" 30 | 31 | #define Om_Language_Operation_SystemOperation_GetName_() \ 32 | "system" 33 | 34 | namespace Om { 35 | 36 | namespace Language { 37 | 38 | namespace Operation { 39 | 40 | // MARK: - Om::Language::Operation::SystemOperation 41 | 42 | /*! 43 | \brief 44 | The \ref om__operation__system_operation__ operation implementation. 45 | */ 46 | class SystemOperation { 47 | 48 | public: // MARK: public (static) 49 | 50 | static char const * GetName(); 51 | 52 | static void Give(Evaluation &); 53 | 54 | }; 55 | 56 | namespace { 57 | 58 | static System::Definition const theSystemDefinition; 59 | 60 | } 61 | 62 | } 63 | 64 | } 65 | 66 | } 67 | 68 | #include "om/language/operation/system_operation.cpp" 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /code/om/language/operation/translate_operation.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Operation_TranslateOperation_ 16 | 17 | #define Om_Language_Operation_TranslateOperation_ \ 18 | Om::Language::Operation::TranslateOperation 19 | 20 | #include "om/language/lexicon.hpp" 21 | #include "om/language/operation/default_incomplete_operation.hpp" 22 | 23 | namespace Om { 24 | 25 | namespace Language { 26 | 27 | namespace Operation { 28 | 29 | // MARK: - Om::Language::Operation::TranslateOperation 30 | 31 | /*! 32 | \brief 33 | An Operation that applies each Translator to a Program. 34 | */ 35 | template 36 | class TranslateOperation: 37 | public DefaultIncompleteOperation { 38 | 39 | public: // MARK: public (static) 40 | 41 | template 42 | static void GiveElements( 43 | TheTranslateOperation &, 44 | Consumer & 45 | ); 46 | 47 | public: // MARK: public (non-static) 48 | 49 | virtual ~TranslateOperation() = 0; 50 | 51 | template 52 | bool TakeOperand( 53 | Evaluation &, 54 | TheOperand & 55 | ); 56 | 57 | template 58 | bool TakeQuotedProducer( 59 | Evaluation &, 60 | TheProducer & 61 | ); 62 | 63 | protected: // MARK: protected (non-static) 64 | 65 | TranslateOperation(); 66 | 67 | boost::optional thisLexicon; 68 | 69 | }; 70 | 71 | } 72 | 73 | } 74 | 75 | } 76 | 77 | #include "om/language/operation/translate_operation.cpp" 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /code/om/language/pair.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Pair_ 16 | 17 | #define Om_Language_Pair_ \ 18 | Om::Language::Pair 19 | 20 | #include "om/language/operator.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Language { 25 | 26 | // MARK: - Om::Language::Pair 27 | 28 | /*! 29 | \brief 30 | An Operator and an Operand. 31 | */ 32 | class Pair { 33 | 34 | public: // MARK: public (static) 35 | 36 | static Pair const & GetEmpty(); 37 | 38 | public: // MARK: public (non-static) 39 | 40 | virtual ~Pair(); 41 | 42 | Pair(); 43 | 44 | void ClearOperand(); 45 | 46 | Operand const & GetOperand() const; 47 | 48 | Operator const & GetOperator() const; 49 | 50 | void GiveElements(Consumer &); 51 | 52 | void GiveElements(Consumer &) const; 53 | 54 | bool IsEmpty() const; 55 | 56 | template 57 | void TakeOperand(TheOperand &); 58 | 59 | /*! 60 | \brief 61 | Replaces the Operator. 62 | */ 63 | template 64 | void TakeOperator(TheOperator &); 65 | 66 | template 67 | void TakeQuotedProducer(TheProducer &); 68 | 69 | private: // MARK: private (static) 70 | 71 | template 72 | static void GiveElements( 73 | ThePair &, 74 | Consumer & 75 | ); 76 | 77 | private: // MARK: private (non-static) 78 | 79 | Operator thisOperator; 80 | 81 | Operand thisOperand; 82 | 83 | }; 84 | 85 | } 86 | 87 | } 88 | 89 | #include "om/language/pair.cpp" 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /code/om/language/producer.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Producer_ 16 | 17 | #include "om/language/producer.hpp" 18 | 19 | #else 20 | 21 | #ifndef Om_Macro_Precompilation_ 22 | 23 | #include 24 | #include 25 | 26 | #endif 27 | 28 | // MARK: - Om::Language::Producer 29 | 30 | #define Type_ \ 31 | Om::Language::Producer 32 | 33 | // MARK: public (non-static) 34 | 35 | inline Type_::~Producer() {} 36 | 37 | inline void Type_::GiveElements(Consumer &) { 38 | assert(0); 39 | throw std::logic_error("Pure virtual function called."); 40 | } 41 | 42 | inline void Type_::GiveElements(Consumer &) const { 43 | assert(0); 44 | throw std::logic_error("Pure virtual function called."); 45 | } 46 | 47 | inline std::auto_ptr Type_::GiveProgram() { 48 | assert(0); 49 | throw std::logic_error("Pure virtual function called."); 50 | } 51 | 52 | inline std::auto_ptr Type_::GiveProgram() const { 53 | assert(0); 54 | throw std::logic_error("Pure virtual function called."); 55 | } 56 | 57 | #undef Type_ 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /code/om/language/producer.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Producer_ 16 | 17 | #define Om_Language_Producer_ \ 18 | Om::Language::Producer 19 | 20 | #ifndef Om_Macro_Precompilation_ 21 | 22 | #include 23 | 24 | #endif 25 | 26 | namespace Om { 27 | 28 | namespace Language { 29 | 30 | //! \cond 31 | class Consumer; 32 | 33 | class Program; 34 | //! \endcond 35 | 36 | /*! 37 | \brief 38 | An Element giver; gives from the front. 39 | */ 40 | class Producer { 41 | 42 | public: // MARK: public (non-static) 43 | 44 | virtual ~Producer() = 0; 45 | 46 | /*! 47 | \brief 48 | Gives each contained Element to the argument. 49 | \post 50 | IsEmpty() == true 51 | \remarks 52 | Giving every Element is more efficient than giving a subset and managing incremental state, which is never necessary. 53 | */ 54 | virtual void GiveElements(Consumer &) = 0; 55 | 56 | /*! 57 | \brief 58 | \overload 59 | */ 60 | virtual void GiveElements(Consumer &) const = 0; 61 | 62 | /*! 63 | \brief 64 | Returns a new Program populated with the contents of this. 65 | */ 66 | virtual std::auto_ptr GiveProgram() = 0; 67 | 68 | /*! 69 | \brief 70 | \overload 71 | */ 72 | virtual std::auto_ptr GiveProgram() const = 0; 73 | 74 | private: // MARK: private (non-static) 75 | 76 | Producer & operator =(Producer const &); 77 | 78 | }; 79 | 80 | } 81 | 82 | } 83 | 84 | #include "om/language/producer.cpp" 85 | 86 | #endif 87 | -------------------------------------------------------------------------------- /code/om/language/program.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Program_ 16 | 17 | #include "om/language/program.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::Language::Program 22 | 23 | #define Type_ \ 24 | Om::Language::Program 25 | 26 | // MARK: public (non-static) 27 | 28 | inline Type_::~Program() {} 29 | 30 | inline void Type_::Clear() { 31 | assert(0); 32 | throw std::logic_error("Pure virtual function called."); 33 | } 34 | 35 | inline bool Type_::Equals(Program const &) const { 36 | assert(0); 37 | throw std::logic_error("Pure virtual function called."); 38 | } 39 | 40 | inline std::auto_ptr< 41 | Om::Source::Source 42 | > Type_::GetElementRange() const { 43 | assert(0); 44 | throw std::logic_error("Pure virtual function called."); 45 | } 46 | 47 | inline std::auto_ptr Type_::GiveProgram() { 48 | return Give(*this); 49 | } 50 | 51 | inline std::auto_ptr Type_::GiveProgram() const { 52 | return Give(*this); 53 | } 54 | 55 | inline bool Type_::IsEmpty() const { 56 | assert(0); 57 | throw std::logic_error("Pure virtual function called."); 58 | } 59 | 60 | // MARK: - Om::Language:: 61 | 62 | inline bool Om::Language::operator ==( 63 | Type_ const & theFirst, 64 | Type_ const & theSecond 65 | ) { 66 | return theFirst.Equals(theSecond); 67 | } 68 | 69 | inline bool Om::Language::operator !=( 70 | Type_ const & theFirst, 71 | Type_ const & theSecond 72 | ) { 73 | return !theFirst.Equals(theSecond); 74 | } 75 | 76 | #undef Type_ 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /code/om/language/reader.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Reader_ 16 | 17 | #define Om_Language_Reader_ \ 18 | Om::Language::Reader 19 | 20 | #include "om/code_point.hpp" 21 | #include "om/source/default_source.hpp" 22 | 23 | namespace Om { 24 | 25 | namespace Language { 26 | 27 | // MARK: - Om::Language::Reader 28 | 29 | /*! 30 | \brief 31 | Produces each #CodePoint until the end of the Source. 32 | */ 33 | class Reader: 34 | public Om::Source::DefaultSource< 35 | CodePoint const, 36 | Reader 37 | > { 38 | 39 | public: // MARK: public (non-static) 40 | 41 | explicit Reader( 42 | Om::Source::Source & 43 | ); 44 | 45 | virtual CodePoint const & operator *() const; 46 | 47 | virtual bool operator !() const; 48 | 49 | using Om::Source::DefaultSource< 50 | CodePoint const, 51 | Reader 52 | >::Equals; 53 | 54 | bool Equals(Reader const &) const; 55 | 56 | virtual void Pop(); 57 | 58 | private: // MARK: private (non-static) 59 | 60 | Reader(Reader const &); 61 | 62 | Reader const & operator =(Reader const &); 63 | 64 | Om::Source::Source & thisCodePointSource; 65 | 66 | size_t thisDepth; 67 | 68 | bool thisIsEncoded; 69 | 70 | }; 71 | 72 | // MARK: - Om::Language:: 73 | 74 | bool operator ==( 75 | Reader const &, 76 | Reader const & 77 | ); 78 | 79 | bool operator !=( 80 | Reader const &, 81 | Reader const & 82 | ); 83 | 84 | } 85 | 86 | } 87 | 88 | #include "om/language/reader.cpp" 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /code/om/language/symbol.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Symbol_ 16 | 17 | #include "om/language/symbol.hpp" 18 | 19 | #ifdef Om_Macro_Test_ 20 | 21 | #include "om/language/symbol/operand_symbol.hpp" 22 | #include "om/language/symbol/operator_symbol.hpp" 23 | #include "om/language/symbol/separator_symbol.hpp" 24 | 25 | #ifndef Om_Macro_Precompilation_ 26 | 27 | #include "boost/test/unit_test.hpp" 28 | 29 | #endif 30 | 31 | namespace Om { 32 | 33 | namespace Language { 34 | 35 | BOOST_AUTO_TEST_SUITE(SymbolTest) 36 | 37 | BOOST_AUTO_TEST_CASE(StringizationTest) { 38 | BOOST_CHECK_EQUAL( 39 | "{test}` \t\n", 40 | ( 41 | Om_Language_Symbol_OperandSymbol_GetStartString_() 42 | "test" 43 | Om_Language_Symbol_OperandSymbol_GetEndString_() 44 | Om_Language_Symbol_OperatorSymbol_GetEncodeString_() 45 | Om_Language_Symbol_SeparatorSymbol_GetSpaceString_() 46 | Om_Language_Symbol_SeparatorSymbol_GetTabString_() 47 | Om_Language_Symbol_SeparatorSymbol_GetLineString_() 48 | ) 49 | ); 50 | } 51 | 52 | BOOST_AUTO_TEST_SUITE_END() 53 | 54 | } 55 | 56 | } 57 | 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /code/om/language/symbol.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Symbol_ 16 | 17 | #define Om_Language_Symbol_ \ 18 | Om::Language::Symbol 19 | 20 | namespace Om { 21 | 22 | namespace Language { 23 | 24 | /*! 25 | \brief 26 | A namespace for ASCII #CodePoint symbol enumerations. 27 | 28 | Every Unicode #CodePoint has an interpretation in code. Each symbol #CodePoint has a specified interpretation, and each other is interpreted as an Operator #CodePoint. 29 | */ 30 | namespace Symbol {} 31 | 32 | } 33 | 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /code/om/language/symbol/operand_symbol.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Symbol_OperandSymbol_ 16 | 17 | #include "om/language/symbol/operand_symbol.hpp" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /code/om/language/symbol/operand_symbol.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Symbol_OperandSymbol_ 16 | 17 | #define Om_Language_Symbol_OperandSymbol_ \ 18 | Om::Language::Symbol::OperandSymbol 19 | 20 | #include "om/macro.hpp" 21 | 22 | /*! 23 | \brief 24 | Generates switch cases for each Om::Language::Symbol::OperandSymbol. 25 | */ 26 | #define Om_Language_Symbol_OperandSymbol_GetCases_() \ 27 | case Symbol::theStartOperandSymbol: \ 28 | case Symbol::theEndOperandSymbol 29 | 30 | /*! 31 | \brief 32 | Gets the bare hexadecimal code for Om::Language::Symbol::theStartOperandSymbol. 33 | */ 34 | #define Om_Language_Symbol_OperandSymbol_GetStartHex_() \ 35 | 7B 36 | 37 | /*! 38 | \brief 39 | Gets the bare hexadecimal code for Om::Language::Symbol::theEndOperandSymbol. 40 | */ 41 | #define Om_Language_Symbol_OperandSymbol_GetEndHex_() \ 42 | 7D 43 | 44 | /*! 45 | \brief 46 | A string literal representation of Om::Language::Symbol::theStartOperandSymbol. 47 | */ 48 | #define Om_Language_Symbol_OperandSymbol_GetStartString_() \ 49 | Om_Macro_GetString_( \ 50 | Om_Language_Symbol_OperandSymbol_GetStartHex_() \ 51 | ) 52 | 53 | /*! 54 | \brief 55 | A string literal representation of Om::Language::Symbol::theEndOperandSymbol. 56 | */ 57 | #define Om_Language_Symbol_OperandSymbol_GetEndString_() \ 58 | Om_Macro_GetString_( \ 59 | Om_Language_Symbol_OperandSymbol_GetEndHex_() \ 60 | ) 61 | 62 | namespace Om { 63 | 64 | namespace Language { 65 | 66 | namespace Symbol { 67 | 68 | /*! 69 | \brief 70 | An Operand symbol. 71 | */ 72 | enum OperandSymbol { 73 | 74 | theStartOperandSymbol = Om_Macro_GetNumber_( 75 | Om_Language_Symbol_OperandSymbol_GetStartHex_() 76 | ), 77 | 78 | theEndOperandSymbol = Om_Macro_GetNumber_( 79 | Om_Language_Symbol_OperandSymbol_GetEndHex_() 80 | ) 81 | 82 | }; 83 | 84 | } 85 | 86 | } 87 | 88 | } 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /code/om/language/symbol/operator_symbol.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Symbol_OperatorSymbol_ 16 | 17 | #include "om/language/symbol/operator_symbol.hpp" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /code/om/language/symbol/operator_symbol.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Symbol_OperatorSymbol_ 16 | 17 | #define Om_Language_Symbol_OperatorSymbol_ \ 18 | Om::Language::Symbol::OperatorSymbol 19 | 20 | #include "om/macro.hpp" 21 | 22 | /*! 23 | \brief 24 | Gets the bare hexadecimal code for Om::Language::Symbol::theEncodeOperatorSymbol. 25 | */ 26 | #define Om_Language_Symbol_OperatorSymbol_GetEncodeHex_() \ 27 | 60 28 | 29 | /*! 30 | \brief 31 | A string literal representation of Om::Language::Symbol::theEncodeOperatorSymbol. 32 | */ 33 | #define Om_Language_Symbol_OperatorSymbol_GetEncodeString_() \ 34 | Om_Macro_GetString_( \ 35 | Om_Language_Symbol_OperatorSymbol_GetEncodeHex_() \ 36 | ) 37 | 38 | namespace Om { 39 | 40 | namespace Language { 41 | 42 | namespace Symbol { 43 | 44 | /*! 45 | \brief 46 | An Operator symbol. 47 | */ 48 | enum OperatorSymbol { 49 | 50 | /*! 51 | Encodes the next #CodePoint as an Operator #CodePoint. Redundant when followed by a non-symbol #CodePoint. 52 | */ 53 | theEncodeOperatorSymbol = Om_Macro_GetNumber_( 54 | Om_Language_Symbol_OperatorSymbol_GetEncodeHex_() 55 | ) 56 | 57 | }; 58 | 59 | } 60 | 61 | } 62 | 63 | } 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /code/om/language/symbol/separator_symbol.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Symbol_SeparatorSymbol_ 16 | 17 | #include "om/language/symbol/separator_symbol.hpp" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /code/om/language/translator.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Language_Translator_ 16 | 17 | #include "om/language/translator.hpp" 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 & theCodePointSource, 33 | Om::Sink::Sink & 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); 50 | Om::Sink::CodePointSink< 51 | std::back_insert_iterator 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 84 | -------------------------------------------------------------------------------- /code/om/language/writer.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb - Initial API, implementation, and documentation. 13 | */ 14 | 15 | #ifndef Om_Language_Writer_ 16 | 17 | #define Om_Language_Writer_ \ 18 | Om::Language::Writer 19 | 20 | #include "om/code_point.hpp" 21 | #include "om/language/default_consumer.hpp" 22 | 23 | namespace Om { 24 | 25 | //! \cond 26 | namespace Sink { 27 | 28 | template 29 | class Sink; 30 | 31 | } 32 | //! \endcond 33 | 34 | namespace Language { 35 | 36 | // MARK: - Om::Language::Writer 37 | 38 | /*! 39 | \brief 40 | A Consumer that pushes each Element to a #CodePoint Sink upon receipt. 41 | */ 42 | class Writer: 43 | public DefaultConsumer { 44 | 45 | public: // MARK: public (non-static) 46 | 47 | explicit Writer( 48 | Om::Sink::Sink & 49 | ); 50 | 51 | virtual void ParseElements(Reader &); 52 | 53 | virtual void ParseQuotedElements(Reader &); 54 | 55 | template 56 | void TakeOperand(TheOperand &); 57 | 58 | template 59 | void TakeOperator(TheOperator &); 60 | 61 | template 62 | void TakeQuotedProducer(TheProducer &); 63 | 64 | template 65 | void TakeSeparator(TheSeparator &); 66 | 67 | private: // MARK: private (non-static) 68 | 69 | Writer(Writer const &); 70 | 71 | Writer const & operator =(Writer const &); 72 | 73 | /*! 74 | \brief 75 | The output #CodePoint Sink. 76 | */ 77 | Om::Sink::Sink & thisCodePointSink; 78 | 79 | }; 80 | 81 | } 82 | 83 | } 84 | 85 | #include "om/language/writer.cpp" 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /code/om/macro.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Macro_ 16 | 17 | #include "om/macro.hpp" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /code/om/macro.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Macro_ 16 | 17 | #ifndef Om_Macro_Precompilation_ 18 | 19 | #include "boost/preprocessor/stringize.hpp" 20 | 21 | #endif 22 | 23 | /*! 24 | \brief 25 | Defines a namespace for all global macros, aside from include guards. 26 | 27 | All global preprocessor definitions (excluding include guards) should use this namespace to avoid clashes, regardless of where they are physically defined. 28 | */ 29 | #define Om_Macro_ \ 30 | Om::Macro 31 | 32 | /*! 33 | \brief 34 | Prepends 0x. 35 | */ 36 | #define Om_Macro_PrependZeroX_(theArgument) \ 37 | 0x ##theArgument 38 | 39 | /*! 40 | \brief 41 | Prepends \\x and converts the result to a string literal. 42 | */ 43 | #define Om_Macro_PrependSlashXAndStringize_(theArgument) \ 44 | BOOST_PP_STRINGIZE(\x ##theArgument) 45 | 46 | /*! 47 | \brief 48 | Converts a bare hexadecimal to a numeric literal. 49 | */ 50 | #define Om_Macro_GetNumber_(theHex) \ 51 | Om_Macro_PrependZeroX_(theHex) 52 | 53 | /*! 54 | \brief 55 | Converts a bare hexadecimal to a string literal. 56 | */ 57 | #define Om_Macro_GetString_(theHex) \ 58 | Om_Macro_PrependSlashXAndStringize_(theHex) 59 | 60 | namespace Om { 61 | 62 | /*! 63 | \brief 64 | A namespace for all code used to implement global macros. 65 | */ 66 | namespace Macro {} 67 | 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /code/om/moveable.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Moveable_ 16 | 17 | #include "om/moveable.hpp" 18 | 19 | #else 20 | 21 | #ifndef Om_Macro_Precompilation_ 22 | 23 | #include 24 | #include 25 | 26 | #endif 27 | 28 | // MARK: - Om::Moveable 29 | 30 | #define Type_ \ 31 | Om::Moveable 32 | 33 | // MARK: public (non-static) 34 | 35 | inline Type_::~Moveable() {} 36 | 37 | inline std::auto_ptr Type_::Move() { 38 | assert(0); 39 | throw std::logic_error("Pure virtual function called."); 40 | } 41 | 42 | #undef Type_ 43 | 44 | // MARK: - Om:: 45 | 46 | template 47 | inline std::auto_ptr Om::Move(TheMoveable & theMoveable) { 48 | return std::auto_ptr( 49 | static_cast( 50 | theMoveable.Move().release() 51 | ) 52 | ); 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /code/om/moveable.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Moveable_ 16 | 17 | #define Om_Moveable_ \ 18 | Om::Moveable 19 | 20 | #ifndef Om_Macro_Precompilation_ 21 | 22 | #include 23 | 24 | #endif 25 | 26 | namespace Om { 27 | 28 | // MARK: - Om::Moveable 29 | 30 | /*! 31 | \brief 32 | An object that can be passed to #Move to be moved. 33 | */ 34 | class Moveable { 35 | 36 | template 37 | friend std::auto_ptr Move(TheMoveable &); 38 | 39 | public: // MARK: public (non-static) 40 | 41 | virtual ~Moveable() = 0; 42 | 43 | /*! 44 | \return 45 | An owner pointer to a moved object. 46 | */ 47 | virtual std::auto_ptr Move() = 0; 48 | 49 | private: // MARK: private (non-static) 50 | 51 | Moveable & operator =(Moveable const &); 52 | 53 | }; 54 | 55 | // MARK: - Om:: 56 | 57 | /*! 58 | \return 59 | A polymorphic move of the object. 60 | */ 61 | template 62 | std::auto_ptr Move(TheMoveable &); 63 | 64 | } 65 | 66 | #include "om/moveable.cpp" 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /code/om/sink.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_ 16 | 17 | #include "om/sink.hpp" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /code/om/sink.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_ 16 | 17 | #define Om_Sink_ \ 18 | Om::Sink 19 | 20 | namespace Om { 21 | 22 | /*! 23 | \brief 24 | A namespace for all sinks. 25 | */ 26 | namespace Sink {} 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /code/om/sink/code_point_sink.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_CodePointSink_ 16 | 17 | #define Om_Sink_CodePointSink_ \ 18 | Om::Sink::CodePointSink 19 | 20 | #include "om/code_point.hpp" 21 | #include "om/sink/default_sink.hpp" 22 | 23 | namespace Om { 24 | 25 | namespace Sink { 26 | 27 | // MARK: - Om::Sink::CodePointSink 28 | 29 | /*! 30 | \brief 31 | A #CodePoint Sink that pushes each code unit to the iterator. 32 | */ 33 | template 34 | class CodePointSink: 35 | public DefaultSink< 36 | CodePoint const, 37 | CodePointSink 38 | > { 39 | 40 | public: // MARK: public (non-static) 41 | 42 | explicit CodePointSink(ThisCodeUnitIterator); 43 | 44 | CodePointSink & operator =(CodePointSink); 45 | 46 | virtual void Push(CodePoint const &); 47 | 48 | void Swap(CodePointSink &); 49 | 50 | private: // MARK: private (non-static) 51 | 52 | /*! 53 | \brief 54 | The output code unit iterator. 55 | */ 56 | ThisCodeUnitIterator thisCodeUnitIterator; 57 | 58 | }; 59 | 60 | } 61 | 62 | } 63 | 64 | namespace boost { 65 | 66 | // MARK: - boost:: 67 | 68 | template 69 | void swap( 70 | Om::Sink::CodePointSink &, 71 | Om::Sink::CodePointSink & 72 | ); 73 | 74 | } 75 | 76 | #include "om/sink/code_point_sink.cpp" 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /code/om/sink/container_back_sink.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_ContainerBackSink_ 16 | 17 | #define Om_Sink_ContainerBackSink_ \ 18 | Om::Sink::ContainerBackSink 19 | 20 | #include "om/sink/default_sink.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Sink { 25 | 26 | // MARK: - Om::Sink::ContainerBackSink 27 | 28 | /*! 29 | \brief 30 | A Sink adapter for a container; pushes items into the back. 31 | */ 32 | template < 33 | typename ThisItem, 34 | typename ThisContainer 35 | > 36 | class ContainerBackSink: 37 | public DefaultSink< 38 | ThisItem, 39 | ContainerBackSink< 40 | ThisItem, 41 | ThisContainer 42 | > 43 | > { 44 | 45 | public: // MARK: public (non-static) 46 | 47 | explicit ContainerBackSink(ThisContainer &); 48 | 49 | ContainerBackSink & operator =(ContainerBackSink); 50 | 51 | virtual void Push(ThisItem &); 52 | 53 | void Swap(ContainerBackSink &); 54 | 55 | private: // MARK: private (non-static) 56 | 57 | /*! 58 | \brief 59 | The container to push into. 60 | */ 61 | ThisContainer & thisContainer; 62 | 63 | }; 64 | 65 | } 66 | 67 | } 68 | 69 | namespace boost { 70 | 71 | // MARK: - boost:: 72 | 73 | template < 74 | typename TheItem, 75 | typename TheContainer 76 | > 77 | void swap( 78 | Om::Sink::ContainerBackSink< 79 | TheItem, 80 | TheContainer 81 | > &, 82 | Om::Sink::ContainerBackSink< 83 | TheItem, 84 | TheContainer 85 | > & 86 | ); 87 | 88 | } 89 | 90 | #include "om/sink/container_back_sink.cpp" 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /code/om/sink/container_front_sink.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_ContainerFrontSink_ 16 | 17 | #include "om/sink/container_front_sink.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::Sink::ContainerFrontSink 22 | 23 | #define Template_ \ 24 | template < \ 25 | typename ThisItem, \ 26 | typename ThisContainer \ 27 | > 28 | 29 | #define Type_ \ 30 | Om::Sink::ContainerFrontSink< \ 31 | ThisItem, \ 32 | ThisContainer \ 33 | > 34 | 35 | // MARK: public (non-static) 36 | 37 | Template_ 38 | inline Type_::ContainerFrontSink(ThisContainer & theContainer): 39 | thisContainer(theContainer) {} 40 | 41 | Template_ 42 | inline Type_ & Type_::operator =(ContainerFrontSink theContainerFrontSink) { 43 | this->Swap(theContainerFrontSink); 44 | return *this; 45 | } 46 | 47 | Template_ 48 | inline void Type_::Push(ThisItem & thisItem) { 49 | this->thisContainer.push_front(thisItem); 50 | } 51 | 52 | Template_ 53 | inline void Type_::Swap(ContainerFrontSink & theContainerFrontSink) { 54 | boost::swap( 55 | this->thisContainer, 56 | theContainerFrontSink.thisContainer 57 | ); 58 | } 59 | 60 | #undef Type_ 61 | #undef Template_ 62 | 63 | // MARK: - boost:: 64 | 65 | template < 66 | typename TheItem, 67 | typename TheContainer 68 | > 69 | inline void boost::swap( 70 | Om::Sink::ContainerFrontSink< 71 | TheItem, 72 | TheContainer 73 | > & theFirst, 74 | Om::Sink::ContainerFrontSink< 75 | TheItem, 76 | TheContainer 77 | > & theSecond 78 | ) { 79 | theFirst.Swap(theSecond); 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /code/om/sink/container_front_sink.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_ContainerFrontSink_ 16 | 17 | #define Om_Sink_ContainerFrontSink_ \ 18 | Om::Sink::ContainerFrontSink 19 | 20 | #include "om/sink/default_sink.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Sink { 25 | 26 | // MARK: - Om::Sink::ContainerFrontSink 27 | 28 | /*! 29 | \brief 30 | A Sink adapter for a container; pushes items into the front. 31 | */ 32 | template < 33 | typename ThisItem, 34 | typename ThisContainer 35 | > 36 | class ContainerFrontSink: 37 | public DefaultSink< 38 | ThisItem, 39 | ContainerFrontSink< 40 | ThisItem, 41 | ThisContainer 42 | > 43 | > { 44 | 45 | public: // MARK: public (non-static) 46 | 47 | explicit ContainerFrontSink(ThisContainer &); 48 | 49 | ContainerFrontSink & operator =(ContainerFrontSink); 50 | 51 | virtual void Push(ThisItem &); 52 | 53 | void Swap(ContainerFrontSink &); 54 | 55 | private: // MARK: private (non-static) 56 | 57 | /*! 58 | \brief 59 | The container to push into. 60 | */ 61 | ThisContainer & thisContainer; 62 | 63 | }; 64 | 65 | } 66 | 67 | } 68 | 69 | namespace boost { 70 | 71 | // MARK: - boost:: 72 | 73 | template < 74 | typename TheItem, 75 | typename TheContainer 76 | > 77 | void swap( 78 | Om::Sink::ContainerFrontSink< 79 | TheItem, 80 | TheContainer 81 | > &, 82 | Om::Sink::ContainerFrontSink< 83 | TheItem, 84 | TheContainer 85 | > & 86 | ); 87 | 88 | } 89 | 90 | #include "om/sink/container_front_sink.cpp" 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /code/om/sink/default_sink.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_DefaultSink_ 16 | 17 | #include "om/sink/default_sink.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::Sink::DefaultSink 22 | 23 | #define Template_ \ 24 | template < \ 25 | typename ThisItem, \ 26 | typename ThisImplementation \ 27 | > 28 | 29 | #define Type_ \ 30 | Om::Sink::DefaultSink< \ 31 | ThisItem, \ 32 | ThisImplementation \ 33 | > 34 | 35 | // MARK: public (non-static) 36 | 37 | Template_ 38 | inline Type_::~DefaultSink() {} 39 | 40 | Template_ 41 | inline ThisImplementation & Type_::operator ++() { 42 | assert( 43 | dynamic_cast(this) 44 | ); 45 | return static_cast(*this); 46 | } 47 | 48 | Template_ 49 | inline ThisImplementation Type_::operator ++(int) { 50 | assert( 51 | dynamic_cast(this) 52 | ); 53 | return static_cast(*this); 54 | } 55 | 56 | #undef Type_ 57 | #undef Template_ 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /code/om/sink/default_sink.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_DefaultSink_ 16 | 17 | #define Om_Sink_DefaultSink_ \ 18 | Om::Sink::DefaultSink 19 | 20 | #include "om/sink/sink.hpp" 21 | 22 | #ifndef Om_Macro_Precompilation_ 23 | 24 | #include 25 | 26 | #endif 27 | 28 | namespace Om { 29 | 30 | namespace Sink { 31 | 32 | // MARK: - Om::Sink::DefaultSink 33 | 34 | /*! 35 | \brief 36 | A partial Sink implementation. 37 | */ 38 | template < 39 | typename ThisItem, 40 | typename ThisImplementation 41 | > 42 | class DefaultSink: 43 | public Sink, 44 | public std::iterator< 45 | std::output_iterator_tag, 46 | ThisItem 47 | > { 48 | 49 | public: // MARK: public (non-static) 50 | 51 | virtual ~DefaultSink() = 0; 52 | 53 | ThisImplementation & operator ++(); 54 | 55 | ThisImplementation operator ++(int); 56 | 57 | private: // MARK: private (non-static) 58 | 59 | DefaultSink & operator =(DefaultSink const &); 60 | 61 | }; 62 | 63 | } 64 | 65 | } 66 | 67 | #include "om/sink/default_sink.cpp" 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /code/om/sink/iterator_sink.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_IteratorSink_ 16 | 17 | #include "om/sink/iterator_sink.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::Sink::IteratorSink 22 | 23 | #define Template_ \ 24 | template < \ 25 | typename ThisItem, \ 26 | typename ThisIterator \ 27 | > 28 | 29 | #define Type_ \ 30 | Om::Sink::IteratorSink< \ 31 | ThisItem, \ 32 | ThisIterator \ 33 | > 34 | 35 | // MARK: public (non-static) 36 | 37 | Template_ 38 | inline Type_::IteratorSink(ThisIterator theIterator): 39 | thisIterator(theIterator) {} 40 | 41 | Template_ 42 | inline Type_ & Type_::operator =(IteratorSink theIteratorSink) { 43 | this->Swap(theIteratorSink); 44 | return *this; 45 | } 46 | 47 | Template_ 48 | inline void Type_::Push(ThisItem & theItem) { 49 | *this->thisIterator++ = theItem; 50 | } 51 | 52 | Template_ 53 | inline void Type_::Swap(IteratorSink & theIteratorSink) { 54 | boost::swap( 55 | this->thisIterator, 56 | theIteratorSink.thisIterator 57 | ); 58 | } 59 | 60 | #undef Type_ 61 | #undef Template_ 62 | 63 | // MARK: - boost:: 64 | 65 | template < 66 | typename TheItem, 67 | typename TheIterator 68 | > 69 | inline void boost::swap( 70 | Om::Sink::IteratorSink< 71 | TheItem, 72 | TheIterator 73 | > & theFirst, 74 | Om::Sink::IteratorSink< 75 | TheItem, 76 | TheIterator 77 | > & theSecond 78 | ) { 79 | theFirst.Swap(theSecond); 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /code/om/sink/iterator_sink.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_IteratorSink_ 16 | 17 | #define Om_Sink_IteratorSink_ \ 18 | Om::Sink::IteratorSink 19 | 20 | #include "om/sink/default_sink.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Sink { 25 | 26 | // MARK: - Om::Sink::IteratorSink 27 | 28 | /*! 29 | \brief 30 | A Sink adapter for an output iterator. 31 | */ 32 | template < 33 | typename ThisItem, 34 | typename ThisIterator 35 | > 36 | class IteratorSink: 37 | public DefaultSink< 38 | ThisItem, 39 | IteratorSink< 40 | ThisItem, 41 | ThisIterator 42 | > 43 | > { 44 | 45 | public: // MARK: public (non-static) 46 | 47 | explicit IteratorSink(ThisIterator); 48 | 49 | IteratorSink & operator =(IteratorSink); 50 | 51 | virtual void Push(ThisItem &); 52 | 53 | void Swap(IteratorSink &); 54 | 55 | private: // MARK: private (non-static) 56 | 57 | /*! 58 | \brief 59 | The output iterator. 60 | */ 61 | ThisIterator thisIterator; 62 | 63 | }; 64 | 65 | } 66 | 67 | } 68 | 69 | namespace boost { 70 | 71 | // MARK: - boost:: 72 | 73 | template < 74 | typename TheItem, 75 | typename TheIterator 76 | > 77 | void swap( 78 | Om::Sink::IteratorSink< 79 | TheItem, 80 | TheIterator 81 | > &, 82 | Om::Sink::IteratorSink< 83 | TheItem, 84 | TheIterator 85 | > & 86 | ); 87 | 88 | } 89 | 90 | #include "om/sink/iterator_sink.cpp" 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /code/om/sink/sink.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_Sink_ 16 | 17 | #include "om/sink/sink.hpp" 18 | 19 | #else 20 | 21 | #ifndef Om_Macro_Precompilation_ 22 | 23 | #include 24 | #include 25 | 26 | #endif 27 | 28 | // MARK: - Om::Sink::Sink 29 | 30 | #define Template_ \ 31 | template 32 | 33 | #define Type_ \ 34 | Om::Sink::Sink 35 | 36 | // MARK: public (non-static) 37 | 38 | Template_ 39 | inline Type_::~Sink() {} 40 | 41 | Template_ 42 | inline Type_ & Type_::operator =(ThisItem & theItem) { 43 | this->Push(theItem); 44 | return *this; 45 | } 46 | 47 | Template_ 48 | inline Type_ & Type_::operator *() { 49 | return *this; 50 | } 51 | 52 | Template_ 53 | inline Type_ * Type_::operator ->() { 54 | return this; 55 | } 56 | 57 | Template_ 58 | inline void Type_::Push(ThisItem &) { 59 | assert(0); 60 | throw std::logic_error("Pure virtual function called."); 61 | } 62 | 63 | #undef Type_ 64 | #undef Template_ 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /code/om/sink/sink.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_Sink_ 16 | 17 | #define Om_Sink_Sink_ \ 18 | Om::Sink::Sink 19 | 20 | namespace Om { 21 | 22 | namespace Sink { 23 | 24 | // MARK: - Om::Sink::Sink 25 | 26 | /*! 27 | \brief 28 | Any object that items can be pushed to. 29 | */ 30 | template 31 | class Sink { 32 | 33 | public: // MARK: public (non-static) 34 | 35 | virtual ~Sink() = 0; 36 | 37 | /*! 38 | \brief 39 | Pushes to the Sink. 40 | \return 41 | \c *this 42 | */ 43 | Sink & operator =(ThisItem &); 44 | 45 | /*! 46 | \return 47 | \c *this 48 | */ 49 | Sink & operator *(); 50 | 51 | /*! 52 | \return 53 | \c this 54 | */ 55 | Sink * operator ->(); 56 | 57 | /*! 58 | \brief 59 | Pushes an item. 60 | */ 61 | virtual void Push(ThisItem &) = 0; 62 | 63 | private: // MARK: private (non-static) 64 | 65 | Sink & operator =(Sink const &); 66 | 67 | }; 68 | 69 | } 70 | 71 | } 72 | 73 | #include "om/sink/sink.cpp" 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /code/om/sink/stream_sink.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_StreamSink_ 16 | 17 | #include "om/sink/stream_sink.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::Sink::StreamSink 22 | 23 | #define Template_ \ 24 | template 25 | 26 | #define Type_ \ 27 | Om::Sink::StreamSink 28 | 29 | // MARK: public (non-static) 30 | 31 | Template_ 32 | inline Type_::StreamSink(std::ostream & theStream): 33 | IteratorSink< 34 | ThisItem const, 35 | std::ostreambuf_iterator 36 | >(theStream) {} 37 | 38 | #undef Type_ 39 | #undef Template_ 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /code/om/sink/stream_sink.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Sink_StreamSink_ 16 | 17 | #define Om_Sink_StreamSink_ \ 18 | Om::Sink::StreamSink 19 | 20 | #include "om/sink/iterator_sink.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Sink { 25 | 26 | // MARK: - Om::Sink::StreamSink 27 | 28 | /*! 29 | \brief 30 | A Sink adapter for an output stream. 31 | */ 32 | template 33 | class StreamSink: 34 | public IteratorSink< 35 | ThisItem const, 36 | std::ostreambuf_iterator 37 | > { 38 | 39 | public: // MARK: public (non-static) 40 | 41 | explicit StreamSink(std::ostream &); 42 | 43 | }; 44 | 45 | } 46 | 47 | } 48 | 49 | #include "om/sink/stream_sink.cpp" 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /code/om/source.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Source_ 16 | 17 | #include "om/source.hpp" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /code/om/source.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Source_ 16 | 17 | #define Om_Source_ \ 18 | Om::Source 19 | 20 | namespace Om { 21 | 22 | /*! 23 | \brief 24 | A namespace for all sources. 25 | */ 26 | namespace Source {} 27 | 28 | } 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /code/om/source/collection_back_source.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Source_CollectionBackSource_ 16 | 17 | #include "om/source/collection_back_source.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::Source::CollectionBackSource 22 | 23 | #define Template_ \ 24 | template < \ 25 | typename ThisItem, \ 26 | typename ThisIterator \ 27 | > 28 | 29 | #define Type_ \ 30 | Om::Source::CollectionBackSource< \ 31 | ThisItem, \ 32 | ThisIterator \ 33 | > 34 | 35 | // MARK: public (non-static) 36 | 37 | Template_ 38 | template 39 | inline Type_::CollectionBackSource(TheCollection & theCollection): 40 | IteratorPairSource< 41 | ThisItem, 42 | ThisIterator 43 | >( 44 | theCollection.rbegin(), 45 | theCollection.rend() 46 | ) {} 47 | 48 | #undef Type_ 49 | #undef Template_ 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /code/om/source/collection_back_source.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Source_CollectionBackSource_ 16 | 17 | #define Om_Source_CollectionBackSource_ \ 18 | Om::Source::CollectionBackSource 19 | 20 | #include "om/source/iterator_pair_source.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Source { 25 | 26 | // MARK: - Om::Source::CollectionBackSource 27 | 28 | /*! 29 | \brief 30 | A range over a collection, starting from the back. 31 | */ 32 | template < 33 | typename ThisItem, 34 | typename ThisIterator 35 | > 36 | class CollectionBackSource: 37 | public IteratorPairSource< 38 | ThisItem, 39 | ThisIterator 40 | > { 41 | 42 | public: // MARK: public (non-static) 43 | 44 | template 45 | explicit CollectionBackSource(TheCollection &); 46 | 47 | }; 48 | 49 | } 50 | 51 | } 52 | 53 | #include "om/source/collection_back_source.cpp" 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /code/om/source/collection_front_source.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Source_CollectionFrontSource_ 16 | 17 | #include "om/source/collection_front_source.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::Source::CollectionFrontSource 22 | 23 | #define Template_ \ 24 | template < \ 25 | typename ThisItem, \ 26 | typename ThisIterator \ 27 | > 28 | 29 | #define Type_ \ 30 | Om::Source::CollectionFrontSource< \ 31 | ThisItem, \ 32 | ThisIterator \ 33 | > 34 | 35 | // MARK: public (non-static) 36 | 37 | Template_ 38 | template 39 | inline Type_::CollectionFrontSource(TheCollection & theCollection): 40 | IteratorPairSource< 41 | ThisItem, 42 | ThisIterator 43 | >( 44 | theCollection.begin(), 45 | theCollection.end() 46 | ) {} 47 | 48 | #undef Type_ 49 | #undef Template_ 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /code/om/source/collection_front_source.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Source_CollectionFrontSource_ 16 | 17 | #define Om_Source_CollectionFrontSource_ \ 18 | Om::Source::CollectionFrontSource 19 | 20 | #include "om/source/iterator_pair_source.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Source { 25 | 26 | // MARK: - Om::Source::CollectionFrontSource 27 | 28 | /*! 29 | \brief 30 | A range over a collection, starting from the front. 31 | */ 32 | template < 33 | typename ThisItem, 34 | typename ThisIterator 35 | > 36 | class CollectionFrontSource: 37 | public IteratorPairSource< 38 | ThisItem, 39 | ThisIterator 40 | > { 41 | 42 | public: // MARK: public (non-static) 43 | 44 | template 45 | explicit CollectionFrontSource(TheCollection &); 46 | 47 | }; 48 | 49 | } 50 | 51 | } 52 | 53 | #include "om/source/collection_front_source.cpp" 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /code/om/source/default_source.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Source_DefaultSource_ 16 | 17 | #include "om/source/default_source.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::Source::DefaultSource 22 | 23 | #define Template_ \ 24 | template < \ 25 | typename ThisItem, \ 26 | typename ThisImplementation \ 27 | > 28 | 29 | #define Type_ \ 30 | Om::Source::DefaultSource< \ 31 | ThisItem, \ 32 | ThisImplementation \ 33 | > 34 | 35 | // MARK: public (non-static) 36 | 37 | Template_ 38 | inline Type_::~DefaultSource() {} 39 | 40 | Template_ 41 | inline ThisImplementation & Type_::operator ++() { 42 | assert( 43 | dynamic_cast(this) 44 | ); 45 | assert(*this); 46 | this->Pop(); 47 | return static_cast(*this); 48 | } 49 | 50 | Template_ 51 | inline ThisImplementation Type_::operator ++(int) { 52 | assert( 53 | dynamic_cast(this) 54 | ); 55 | ThisImplementation theSource( 56 | static_cast(*this) 57 | ); 58 | ++*this; 59 | return theSource; 60 | } 61 | 62 | Template_ 63 | inline bool Type_::Equals( 64 | Source const & theSource 65 | ) const { 66 | assert( 67 | dynamic_cast(this) 68 | ); 69 | ThisImplementation const * const theImplementation = dynamic_cast(&theSource); 70 | return ( 71 | theImplementation && 72 | theImplementation->Equals( 73 | static_cast(*this) 74 | ) 75 | ); 76 | } 77 | 78 | #undef Type_ 79 | #undef Template_ 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /code/om/source/empty_source.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Source_EmptySource_ 16 | 17 | #define Om_Source_EmptySource_ \ 18 | Om::Source::EmptySource 19 | 20 | #include "om/source/default_source.hpp" 21 | 22 | namespace Om { 23 | 24 | namespace Source { 25 | 26 | // MARK: - Om::Source::EmptySource 27 | 28 | /*! 29 | \brief 30 | An empty Source. 31 | */ 32 | template 33 | class EmptySource: 34 | public DefaultSource< 35 | ThisItem, 36 | EmptySource 37 | > { 38 | 39 | public: // MARK: public (static) 40 | 41 | static EmptySource & Get(); 42 | 43 | public: // MARK: public (non-static) 44 | 45 | EmptySource(); 46 | 47 | EmptySource & operator =(EmptySource); 48 | 49 | virtual bool operator !() const; 50 | 51 | virtual ThisItem & operator *() const; 52 | 53 | using DefaultSource< 54 | ThisItem, 55 | EmptySource 56 | >::Equals; 57 | 58 | bool Equals(EmptySource const &) const; 59 | 60 | virtual void Pop(); 61 | 62 | void Swap(EmptySource &); 63 | 64 | }; 65 | 66 | // MARK: - Om::Source:: 67 | 68 | template 69 | bool operator ==( 70 | EmptySource const &, 71 | EmptySource const & 72 | ); 73 | 74 | template 75 | bool operator !=( 76 | EmptySource const &, 77 | EmptySource const & 78 | ); 79 | 80 | } 81 | 82 | } 83 | 84 | namespace boost { 85 | 86 | // MARK: - boost:: 87 | 88 | template 89 | void swap( 90 | Om::Source::EmptySource &, 91 | Om::Source::EmptySource & 92 | ); 93 | 94 | } 95 | 96 | #include "om/source/empty_source.cpp" 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /code/om/taker.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Taker_ 16 | 17 | #include "om/taker.hpp" 18 | 19 | #else 20 | 21 | // MARK: - Om::Taker 22 | 23 | #define Template_ \ 24 | template 25 | 26 | #define Type_ \ 27 | Om::Taker 28 | 29 | // MARK: public (non-static) 30 | 31 | Template_ 32 | inline Type_::~Taker() {} 33 | 34 | Template_ 35 | inline void Type_::Take(ThisImplementation & theTaker) { 36 | assert( 37 | dynamic_cast(this) 38 | ); 39 | static_cast(*this).Swap(theTaker); 40 | } 41 | 42 | Template_ 43 | inline void Type_::Take(ThisImplementation const & theTaker) { 44 | assert( 45 | dynamic_cast(this) 46 | ); 47 | static_cast(*this) = theTaker; 48 | } 49 | 50 | #undef Type_ 51 | #undef Template_ 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /code/om/taker.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Taker_ 16 | 17 | #define Om_Taker_ \ 18 | Om::Taker 19 | 20 | namespace Om { 21 | 22 | // MARK: - Om::Taker 23 | 24 | /*! 25 | \brief 26 | An object that can take (copy or swap) another of the same type. 27 | */ 28 | template 29 | class Taker { 30 | 31 | public: // MARK: public (non-static) 32 | 33 | virtual ~Taker() = 0; 34 | 35 | /*! 36 | \brief 37 | Swaps. 38 | */ 39 | void Take(ThisImplementation &); 40 | 41 | /*! 42 | \brief 43 | Assigns. 44 | */ 45 | void Take(ThisImplementation const &); 46 | 47 | private: // MARK: private (non-static) 48 | 49 | Taker & operator =(Taker const &); 50 | 51 | }; 52 | 53 | } 54 | 55 | #include "om/taker.cpp" 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /code/om/utf8.cpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om source file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Utf8_ 16 | 17 | #include "om/utf8.hpp" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /code/om/utf8.hpp: -------------------------------------------------------------------------------- 1 | /*! 2 | \file 3 | \brief 4 | Om header file. 5 | \version 6 | 0.1.3 7 | \date 8 | 2012-2014 9 | \copyright 10 | Copyright (c) Sparist. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License, Version 1.0, which accompanies this distribution. 11 | \author 12 | Jason Erb 13 | */ 14 | 15 | #ifndef Om_Utf8_ 16 | 17 | #define Om_Utf8_ \ 18 | Om::Utf8 19 | 20 | #ifndef Om_Macro_Precompilation_ 21 | 22 | #include "boost/locale/utf.hpp" 23 | 24 | #endif 25 | 26 | namespace Om { 27 | 28 | /*! 29 | \brief 30 | The UTF-8 traits type. 31 | */ 32 | typedef boost::locale::utf::utf_traits Utf8; 33 | 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /documentation/footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /documentation/header.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | $projectname: $title 10 | $title 11 | 12 | 13 | 14 | $treeview 15 | $search 16 | $mathjax 17 | 18 | $extrastylesheet 19 | 20 | 21 |
22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 38 | 39 | 40 | 41 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 |
33 |
$projectname 34 |  $projectnumber 35 |
36 |
$projectbrief
37 |
42 |
$projectbrief
43 |
$searchbox
54 |
55 | 56 | 57 | -------------------------------------------------------------------------------- /documentation/stylesheet.css: -------------------------------------------------------------------------------- 1 | /* 2 | Override tabs.css 3 | */ 4 | 5 | /* Remove background images from top tabs, which look bad in landscape mode on phone. */ 6 | .sm-dox { 7 | background-image: inherit; 8 | } 9 | .sm-dox a, 10 | .sm-dox a:focus, 11 | .sm-dox a:active, 12 | .sm-dox a:hover, 13 | .sm-dox a.highlighted { 14 | background-image: inherit; 15 | background-repeat: inherit; 16 | } 17 | .sm-dox a:hover { 18 | color: inherit; 19 | text-shadow: inherit; 20 | text-decoration: underline; 21 | } 22 | .sm-dox ul a:hover { 23 | background-image: inherit; 24 | background-repeat: inherit; 25 | color: inherit; 26 | text-shadow: inherit; 27 | text-decoration: underline; 28 | } 29 | .sm-dox.sm-vertical a.disabled { 30 | background-image: inherit; 31 | } 32 | 33 | /* Add a top border to the top-level menu items only. */ 34 | .sm-dox li { 35 | border-top: 1px solid #AABED2; 36 | } 37 | .sm-dox li ul li { 38 | border-top: none; 39 | } 40 | 41 | /* Add a bottom border to the tabs. This matches the bottom page header border. */ 42 | .sm-dox { 43 | border-bottom: 1px solid #AABED2; 44 | } 45 | 46 | /* 47 | Override doxygen.css 48 | */ 49 | 50 | /* Clean up heading borders and backgrounds. */ 51 | #titlearea { 52 | border-bottom: none; 53 | } 54 | div.header { 55 | background-image: inherit; 56 | display: inline-block; 57 | min-width: 100%; 58 | } 59 | 60 | /* Use consistent fonts. */ 61 | div.toc li { 62 | font: 12px/1.2 Roboto, sans-serif; 63 | } 64 | div.toc h3 { 65 | font: bold 12px/1.2 Roboto, sans-serif; 66 | } 67 | #projectname { 68 | font: 600% Roboto, sans-serif; 69 | } 70 | #projectbrief { 71 | font: 120% Roboto, sans-serif; 72 | } 73 | #projectnumber { 74 | font: 50% Roboto, sans-serif; 75 | } 76 | 77 | /* Underline links; they are too hard to see otherwise. */ 78 | a { 79 | text-decoration: underline; 80 | } 81 | 82 | /* Prevent text from being truncated. */ 83 | ul, p, div.title { 84 | overflow: visible; 85 | } 86 | 87 | /* Prevent rendering issues on phone. */ 88 | code { 89 | display: inline; 90 | } 91 | -------------------------------------------------------------------------------- /generate.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | setLocal enableExtensions 3 | 4 | set argC=0 5 | for %%x in (%*) do set /A argC+=1 6 | if %argC% lss 1 ( 7 | echo Usage: %0 "Project name" [CMake arguments...] 8 | exit /b 1 9 | ) 10 | 11 | set BuildsDirectory=%CD% 12 | set BuildDirectory=%BuildsDirectory%\Om 13 | 14 | set SourceDirectory=%~dp0 15 | if %SourceDirectory:~-1%==\ set SourceDirectory=%SourceDirectory:~0,-1% 16 | 17 | set ProjectDirectory=%BuildDirectory%\projects\%~1 18 | if not exist "%ProjectDirectory%" mkdir "%ProjectDirectory%" 19 | cd "%ProjectDirectory%" 20 | cmake --no-warn-unused-cli -D BuildsDirectory="%BuildsDirectory%" -D BuildDirectory="%BuildDirectory%" -D ProjectDirectory=%* "%SourceDirectory%" 21 | 22 | cd "%BuildsDirectory%" 23 | -------------------------------------------------------------------------------- /generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | if [ $# -lt 1 ] 5 | then 6 | echo Usage: $0 \"Project name\" [CMake arguments...] 7 | exit 1 8 | fi 9 | 10 | BuildsDirectory=`pwd -P` 11 | BuildDirectory="$BuildsDirectory/Om" 12 | 13 | cd `dirname "$0"` 14 | SourceDirectory=`pwd -P` 15 | 16 | ProjectDirectory="$BuildDirectory/projects/$1" 17 | mkdir -p "$ProjectDirectory" 18 | cd "$ProjectDirectory" 19 | cmake --no-warn-unused-cli -D BuildsDirectory="$BuildsDirectory" -D BuildDirectory="$BuildDirectory" -D ProjectDirectory="$@" "$SourceDirectory" 20 | -------------------------------------------------------------------------------- /images/operand.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparist/Om/09d53458b4abb721f5b5c6064b4ab912eede16be/images/operand.pdf -------------------------------------------------------------------------------- /images/operand.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparist/Om/09d53458b4abb721f5b5c6064b4ab912eede16be/images/operand.png -------------------------------------------------------------------------------- /images/operator.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparist/Om/09d53458b4abb721f5b5c6064b4ab912eede16be/images/operator.pdf -------------------------------------------------------------------------------- /images/operator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparist/Om/09d53458b4abb721f5b5c6064b4ab912eede16be/images/operator.png -------------------------------------------------------------------------------- /images/program.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparist/Om/09d53458b4abb721f5b5c6064b4ab912eede16be/images/program.pdf -------------------------------------------------------------------------------- /images/program.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparist/Om/09d53458b4abb721f5b5c6064b4ab912eede16be/images/program.png -------------------------------------------------------------------------------- /images/separator.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparist/Om/09d53458b4abb721f5b5c6064b4ab912eede16be/images/separator.pdf -------------------------------------------------------------------------------- /images/separator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparist/Om/09d53458b4abb721f5b5c6064b4ab912eede16be/images/separator.png --------------------------------------------------------------------------------