/*============================================================================= Copyright (c) 2001-2011 Hartmut Kaiser Copyright (c) 2001-2011 Joel de Guzman Distributed under 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) ==============================================================================*/ #if !defined(BOOST_SPIRIT_ATTR_JUL_23_2008_0956AM) #define BOOST_SPIRIT_ATTR_JUL_23_2008_0956AM #if defined(_MSC_VER) #pragma once #endif #include #include #include #include #include #include #include #include #include #include namespace boost { namespace spirit { /////////////////////////////////////////////////////////////////////////// // Enablers /////////////////////////////////////////////////////////////////////////// template // enables attr() struct use_terminal< qi::domain, terminal_ex > > : mpl::true_ {}; template <> // enables *lazy* attr() struct use_lazy_terminal : mpl::true_ {}; }} namespace boost { namespace spirit { namespace qi { #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS using spirit::attr; #endif using spirit::attr_type; template struct attr_parser : primitive_parser > { template struct attribute : remove_const {}; attr_parser(typename add_reference::type value) : value_(value) {} template bool parse(Iterator& /*first*/, Iterator const& /*last*/ , Context& /*context*/, Skipper const& /*skipper*/ , Attribute& attr_) const { spirit::traits::assign_to(value_, attr_); return true; // never consume any input, succeed always } template info what(Context& /*context*/) const { return info("attr"); } Value value_; // silence MSVC warning C4512: assignment operator could not be generated BOOST_DELETED_FUNCTION(attr_parser& operator= (attr_parser const&)) }; /////////////////////////////////////////////////////////////////////////// // Parser generators: make_xxx function (objects) /////////////////////////////////////////////////////////////////////////// template struct make_primitive< terminal_ex > , Modifiers> { typedef typename add_const::type const_value; typedef attr_parser result_type; template result_type operator()(Terminal const& term, unused_type) const { return result_type(fusion::at_c<0>(term.args)); } }; }}} namespace boost { namespace spirit { namespace traits { /////////////////////////////////////////////////////////////////////////// template struct handles_container, Attr, Context, Iterator> : traits::is_container {}; }}} #endif