Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/boost/spirit/home/lex/reference.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 //  Copyright (c) 2001-2011 Hartmut Kaiser
0002 //  Copyright (c) 2001-2011 Joel de Guzman
0003 // 
0004 //  Distributed under the Boost Software License, Version 1.0. (See accompanying 
0005 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 #if !defined(BOOST_SPIRIT_LEX_REFERENCE_APR_20_2009_0827AM)
0008 #define BOOST_SPIRIT_LEX_REFERENCE_APR_20_2009_0827AM
0009 
0010 #if defined(_MSC_VER)
0011 #pragma once
0012 #endif
0013 
0014 #include <boost/spirit/home/lex/meta_compiler.hpp>
0015 #include <boost/spirit/home/lex/lexer_type.hpp>
0016 #include <boost/spirit/home/qi/reference.hpp>
0017 #include <boost/spirit/home/support/info.hpp>
0018 #include <boost/spirit/home/support/handles_container.hpp>
0019 #include <boost/ref.hpp>
0020 
0021 namespace boost { namespace spirit { namespace lex
0022 {
0023     ///////////////////////////////////////////////////////////////////////////
0024     // reference is a lexer that references another lexer (its Subject)
0025     // all lexer components are at the same time
0026     ///////////////////////////////////////////////////////////////////////////
0027     template <typename Subject, typename IdType = unused_type>
0028     struct reference; 
0029 
0030     template <typename Subject>
0031     struct reference<Subject, unused_type>
0032       : qi::reference<Subject>
0033       , lexer_type<reference<Subject> >
0034     {
0035         reference(Subject& subject)
0036           : qi::reference<Subject>(subject) {}
0037 
0038         template <typename LexerDef, typename String>
0039         void collect(LexerDef& lexdef, String const& state
0040           , String const& targetstate) const
0041         {
0042             this->ref.get().collect(lexdef, state, targetstate);
0043         }
0044 
0045         template <typename LexerDef>
0046         void add_actions(LexerDef& lexdef) const 
0047         {
0048             this->ref.get().add_actions(lexdef);
0049         }
0050     };
0051 
0052     template <typename Subject, typename IdType>
0053     struct reference : reference<Subject>
0054     {
0055         reference(Subject& subject)
0056           : reference<Subject>(subject) {}
0057 
0058         IdType id() const 
0059         { 
0060             return this->ref.get().id(); 
0061         }
0062         std::size_t unique_id() const 
0063         { 
0064             return this->ref.get().unique_id(); 
0065         }
0066         std::size_t state() const 
0067         { 
0068             return this->ref.get().state(); 
0069         }
0070     };
0071 }}}
0072 
0073 namespace boost { namespace spirit { namespace traits
0074 {
0075     ///////////////////////////////////////////////////////////////////////////
0076     template <typename Subject, typename IdType
0077       , typename Attribute, typename Context, typename Iterator>
0078     struct handles_container<lex::reference<Subject, IdType>
0079           , Attribute, Context, Iterator>
0080       : handles_container<
0081             typename remove_const<Subject>::type, Attribute, Context, Iterator> 
0082     {};
0083 }}}
0084 
0085 #endif