/*============================================================================= 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_EPS_MARCH_23_2007_0454PM) #define BOOST_SPIRIT_EPS_MARCH_23_2007_0454PM #if defined(_MSC_VER) #pragma once #endif #include #include #include #include #include #include #include #include namespace boost { namespace spirit { /////////////////////////////////////////////////////////////////////////// // Enablers /////////////////////////////////////////////////////////////////////////// template <> struct use_terminal // enables eps : mpl::true_ {}; template struct use_terminal > // enables eps(bool-condition) > : is_convertible {}; template <> // enables eps(f) struct use_lazy_terminal< qi::domain, tag::eps, 1 /*arity*/ > : mpl::true_ {}; }} namespace boost { namespace spirit { namespace qi { #ifndef BOOST_SPIRIT_NO_PREDEFINED_TERMINALS using spirit::eps; #endif using spirit::eps_type; struct eps_parser : primitive_parser { template struct attribute { typedef unused_type type; }; template bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper , Attribute& /*attr*/) const { qi::skip_over(first, last, skipper); return true; } template info what(Context& /*context*/) const { return info("eps"); } }; struct semantic_predicate : primitive_parser { template struct attribute { typedef unused_type type; }; semantic_predicate(bool predicate_) : predicate(predicate_) {} template bool parse(Iterator& first, Iterator const& last , Context& /*context*/, Skipper const& skipper , Attribute& /*attr*/) const { qi::skip_over(first, last, skipper); return predicate; } template info what(Context& /*context*/) const { return info("semantic-predicate"); } bool predicate; }; /////////////////////////////////////////////////////////////////////////// // Parser generators: make_xxx function (objects) /////////////////////////////////////////////////////////////////////////// template struct make_primitive { typedef eps_parser result_type; result_type operator()(unused_type, unused_type) const { return result_type(); } }; template struct make_primitive< terminal_ex > , Modifiers> { typedef semantic_predicate result_type; template result_type operator()(Terminal const& term, unused_type) const { return result_type(fusion::at_c<0>(term.args) ? true : false); } }; }}} #endif