/usr/include/boost/spirit/home/qi/auxiliary
Edit: /usr/include/boost/spirit/home/qi/auxiliary/lazy.hpp (10613B)
/*=============================================================================
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_LAZY_MARCH_27_2007_1002AM)
#define BOOST_SPIRIT_LAZY_MARCH_27_2007_1002AM
#if defined(_MSC_VER)
#pragma once
#endif
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace boost { namespace phoenix
{
template
struct actor;
}}
namespace boost { namespace spirit
{
///////////////////////////////////////////////////////////////////////////
// Enablers
///////////////////////////////////////////////////////////////////////////
template
struct use_terminal > // enables phoenix actors
: mpl::true_ {};
// forward declaration
template
struct lazy_terminal;
}}
namespace boost { namespace spirit { namespace qi
{
using spirit::lazy;
typedef modify qi_modify;
namespace detail
{
template
bool lazy_parse_impl(Parser const& p
, Iterator& first, Iterator const& last
, Context& context, Skipper const& skipper
, Attribute& attr, mpl::false_)
{
return p.parse(first, last, context, skipper, attr);
}
template
bool lazy_parse_impl(Parser const& p
, Iterator& first, Iterator const& last
, Context& context, Skipper const& skipper
, Attribute& /*attr*/, mpl::true_)
{
// If DeducedAuto is false (semantic actions is present), the
// component's attribute is unused.
return p.parse(first, last, context, skipper, unused);
}
template
bool lazy_parse_impl_main(Parser const& p
, Iterator& first, Iterator const& last
, Context& context, Skipper const& skipper
, Attribute& attr)
{
// If DeducedAuto is true (no semantic action), we pass the parser's
// attribute on to the component.
typedef typename traits::has_semantic_action::type auto_rule;
return lazy_parse_impl(p, first, last, context, skipper, attr, auto_rule());
}
}
template
struct lazy_parser : parser >
{
template
struct attribute
{
typedef typename
boost::result_of::type
modifier;
typedef typename
remove_reference<
typename boost::result_of::type
>::type
expr_type;
// If you got an error_invalid_expression error message here,
// then the expression (expr_type) is not a valid spirit qi
// expression.
BOOST_SPIRIT_ASSERT_MATCH(qi::domain, expr_type);
typedef typename
result_of::compile::type
parser_type;
typedef typename
traits::attribute_of::type
type;
};
lazy_parser(Function const& function_, Modifiers const& modifiers_)
: function(function_), modifiers(modifiers_) {}
template
bool parse(Iterator& first, Iterator const& last
, Context& context, Skipper const& skipper
, Attribute& attr) const
{
return detail::lazy_parse_impl_main(
compile(function(unused, context)
, qi_modify()(tag::lazy_eval(), modifiers))
, first, last, context, skipper, attr);
}
template
info what(Context& context) const
{
return info("lazy"
, compile(function(unused, context)
, qi_modify()(tag::lazy_eval(), modifiers))
.what(context)
);
}
Function function;
Modifiers modifiers;
};
template
struct lazy_directive
: unary_parser >
{
typedef Subject subject_type;
template
struct attribute
{
typedef typename
boost::result_of::type
modifier;
typedef typename
remove_reference<
typename boost::result_of::type
>::type
directive_expr_type;
typedef typename
proto::result_of::make_expr<
proto::tag::subscript
, directive_expr_type
, Subject
>::type
expr_type;
// If you got an error_invalid_expression error message here,
// then the expression (expr_type) is not a valid spirit qi
// expression.
BOOST_SPIRIT_ASSERT_MATCH(qi::domain, expr_type);
typedef typename
result_of::compile::type
parser_type;
typedef typename
traits::attribute_of::type
type;
};
lazy_directive(
Function const& function_
, Subject const& subject_
, Modifiers const& modifiers_)
: function(function_), subject(subject_), modifiers(modifiers_) {}
template
bool parse(Iterator& first, Iterator const& last
, Context& context, Skipper const& skipper
, Attribute& attr) const
{
return detail::lazy_parse_impl_main(compile(
proto::make_expr(
function(unused, context)
, subject)
, qi_modify()(tag::lazy_eval(), modifiers))
, first, last, context, skipper, attr);
}
template
info what(Context& context) const
{
return info("lazy-directive"
, compile(
proto::make_expr(
function(unused, context)
, subject
), qi_modify()(tag::lazy_eval(), modifiers))
.what(context)
);
}
Function function;
Subject subject;
Modifiers modifiers;
};
///////////////////////////////////////////////////////////////////////////
// Parser generators: make_xxx function (objects)
///////////////////////////////////////////////////////////////////////////
template
struct make_primitive, Modifiers>
{
typedef lazy_parser, Modifiers> result_type;
result_type operator()(phoenix::actor const& f
, Modifiers const& modifiers) const
{
return result_type(f, modifiers);
}
};
template
struct make_primitive, Modifiers>
{
typedef lazy_parser result_type;
result_type operator()(
lazy_terminal const& lt
, Modifiers const& modifiers) const
{
return result_type(lt.actor, modifiers);
}
};
template
struct make_directive, Subject, Modifiers>
{
typedef lazy_directive result_type;
result_type operator()(
lazy_terminal const& lt
, Subject const& subject, Modifiers const& modifiers) const
{
return result_type(lt.actor, subject, modifiers);
}
};
}}}
namespace boost { namespace spirit { namespace traits
{
///////////////////////////////////////////////////////////////////////////
template
struct handles_container<
qi::lazy_parser, Attribute, Context, Iterator>
: handles_container<
typename qi::lazy_parser::template
attribute::parser_type
, Attribute, Context, Iterator>
{};
template
struct handles_container<
qi::lazy_directive, Attribute
, Context, Iterator>
: handles_container<
typename qi::lazy_directive::template
attribute::parser_type
, Attribute, Context, Iterator>
{};
}}}
#endif