/*============================================================================= Copyright (c) 2001-2003 Joel de Guzman http://spirit.sourceforge.net/ Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef BOOST_SPIRIT_SYMBOLS_IPP #define BOOST_SPIRIT_SYMBOLS_IPP /////////////////////////////////////////////////////////////////////////////// #include #include // MSVC: void warning about the use of 'this' pointer in constructors #if defined(BOOST_MSVC) #pragma warning(disable : 4355) #endif /////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { /////////////////////////////////////////////////////////////////////////////// // // symbols class implementation // /////////////////////////////////////////////////////////////////////////////// template inline symbols::symbols() : SetT() , add(*this) { } ////////////////////////////////// template symbols::symbols(symbols const& other) : SetT(other) // Tru64 CXX seems to be confused by the explicit call of the default // constructor and generates wrong code which invalidates the just contructed // first base class in the line above. #if !BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590041)) , parser >() #endif , add(*this) { } ////////////////////////////////// template inline symbols::~symbols() {} ////////////////////////////////// template inline symbols& symbols::operator=(symbols const& other) { SetT::operator=(other); return *this; } ////////////////////////////////// template inline symbol_inserter const& symbols::operator=(CharT const* str) { return add, str; } /////////////////////////////////////////////////////////////////////////////// // // Symbol table utilities // /////////////////////////////////////////////////////////////////////////////// template inline T* find(symbols const& table, CharT const* sym) { CharT const* last = sym; while (*last) last++; scanner scan(sym, last); T* result = table.find(scan); return scan.at_end()? result: 0; } ////////////////////////////////// template inline T* add(symbols& table, CharT const* sym, T const& data) { CharT const* first = sym; CharT const* last = sym; while (*last) last++; scanner scan(first, last); if (table.find(scan) && scan.at_end()) return 0; // symbol already contained in symbol table table.add(sym, last, data); first = sym; return table.find(scan); // refind the inserted symbol } /////////////////////////////////////////////////////////////////////////////// }} // namespace boost::spirit #if defined(BOOST_MSVC) #pragma warning(default : 4355) #endif #endif