Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 10:02:05

0001 /*=============================================================================
0002     Copyright (c) 2001-2003 Joel de Guzman
0003     http://spirit.sourceforge.net/
0004 
0005     Use, modification and distribution is subject to the Boost Software
0006     License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0007     http://www.boost.org/LICENSE_1_0.txt)
0008 =============================================================================*/
0009 #ifndef BOOST_SPIRIT_SYMBOLS_IPP
0010 #define BOOST_SPIRIT_SYMBOLS_IPP
0011 
0012 ///////////////////////////////////////////////////////////////////////////////
0013 #include <boost/spirit/home/classic/symbols/impl/tst.ipp>
0014 #include <boost/detail/workaround.hpp>
0015 
0016 // MSVC: void warning about the use of 'this' pointer in constructors
0017 #if defined(BOOST_MSVC)
0018 #pragma warning(push)
0019 #pragma warning(disable : 4355)
0020 #endif
0021 
0022 ///////////////////////////////////////////////////////////////////////////////
0023 namespace boost { namespace spirit {
0024 
0025 BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN
0026 
0027 ///////////////////////////////////////////////////////////////////////////////
0028 //
0029 //  symbols class implementation
0030 //
0031 ///////////////////////////////////////////////////////////////////////////////
0032 template <typename T, typename CharT, typename SetT>
0033 inline symbols<T, CharT, SetT>::symbols()
0034 : SetT()
0035 , add(*this)
0036 {
0037 }
0038 
0039 //////////////////////////////////
0040 template <typename T, typename CharT, typename SetT>
0041 symbols<T, CharT, SetT>::symbols(symbols const& other)
0042 : SetT(other)
0043 // Tru64 CXX seems to be confused by the explicit call of the default
0044 // constructor and generates wrong code which invalidates the just contructed
0045 // first base class in the line above.
0046 #if !BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590041))
0047 , parser<symbols<T, CharT, SetT> >()
0048 #endif
0049 , add(*this)
0050 {
0051 }
0052 
0053 //////////////////////////////////
0054 template <typename T, typename CharT, typename SetT>
0055 inline symbols<T, CharT, SetT>::~symbols()
0056 {}
0057 
0058 //////////////////////////////////
0059 template <typename T, typename CharT, typename SetT>
0060 inline symbols<T, CharT, SetT>&
0061 symbols<T, CharT, SetT>::operator=(symbols const& other)
0062 {
0063     SetT::operator=(other);
0064     return *this;
0065 }
0066 
0067 //////////////////////////////////
0068 template <typename T, typename CharT, typename SetT>
0069 inline symbol_inserter<T, SetT> const&
0070 symbols<T, CharT, SetT>::operator=(CharT const* str)
0071 {
0072     return add, str;
0073 }
0074 
0075 ///////////////////////////////////////////////////////////////////////////////
0076 //
0077 //  Symbol table utilities
0078 //
0079 ///////////////////////////////////////////////////////////////////////////////
0080 template <typename T, typename CharT, typename SetT>
0081 inline T*
0082 find(symbols<T, CharT, SetT> const& table, CharT const* sym)
0083 {
0084     CharT const* last = sym;
0085     while (*last)
0086         last++;
0087     scanner<CharT const *> scan(sym, last);
0088     T* result = table.find(scan);
0089     return scan.at_end()? result: 0;
0090 }
0091 
0092 //////////////////////////////////
0093 template <typename T, typename CharT, typename SetT>
0094 inline T*
0095 add(symbols<T, CharT, SetT>& table, CharT const* sym, T const& data)
0096 {
0097     CharT const* first = sym;
0098     CharT const* last = sym;
0099     while (*last)
0100         last++;
0101     scanner<CharT const *> scan(first, last);
0102     if (table.find(scan) && scan.at_end())
0103         return 0;               // symbol already contained in symbol table
0104     table.add(sym, last, data);
0105     first = sym;
0106     return table.find(scan);    // refind the inserted symbol
0107 }
0108 
0109 ///////////////////////////////////////////////////////////////////////////////
0110 BOOST_SPIRIT_CLASSIC_NAMESPACE_END
0111 
0112 }} // namespace boost::spirit
0113 
0114 #if defined(BOOST_MSVC)
0115 #pragma warning(pop)
0116 #endif
0117 
0118 #endif