/usr/include/boost/metaparse/v1
Edit: /usr/include/boost/metaparse/v1/grammar.hpp (11007B)
#ifndef BOOST_METAPARSE_V1_GRAMMAR_HPP
#define BOOST_METAPARSE_V1_GRAMMAR_HPP
// Copyright Abel Sinkovics (abel@sinkovics.hu) 2012.
// 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)
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
/*
* The grammar
*
* rule_definition ::= name_token define_token expression
* expression ::= seq_expression (or_token seq_expression)*
* seq_expression ::= repeated_expression+
* repeated_expression ::= name_expression (repeated_token | repeated1_token)*
* name_expression ::= char_token | name_token | bracket_expression
* bracket_expression ::= open_bracket_token expression close_bracket_token
*/
namespace boost
{
namespace metaparse
{
namespace v1
{
namespace grammar_util
{
template
struct repeated_apply_impl
{
typedef repeated_apply_impl type;
template
struct apply :
repeated::type>
{};
};
template
struct repeated_apply_impl<'+', FState>
{
typedef repeated_apply_impl type;
template
struct apply :
repeated1::type>
{};
};
struct build_repeated
{
typedef build_repeated type;
template
struct apply : repeated_apply_impl {};
};
struct build_sequence
{
typedef build_sequence type;
template
struct apply_impl
{
typedef apply_impl type;
template
struct apply :
sequence<
typename FState::template apply::type,
typename FP::template apply::type
>
{};
};
template
struct apply : apply_impl {};
};
struct build_selection
{
typedef build_selection type;
template
struct apply_impl
{
typedef apply_impl type;
template
struct apply :
one_of<
typename FState::template apply::type,
typename FP::template apply::type
>
{};
};
template
struct apply : apply_impl {};
};
template
struct get_parser
{
typedef
typename boost::mpl::at::type
::template apply
p;
template
struct impl : transform {};
typedef
typename boost::mpl::eval_if<
typename boost::mpl::has_key::type,
impl >,
p
>::type
type;
};
struct build_name
{
typedef build_name type;
template
struct apply_impl
{
typedef apply_impl type;
template
struct apply : get_parser {};
};
template
struct apply : apply_impl {};
};
struct build_char
{
typedef build_char type;
template
struct apply_impl
{
typedef apply_impl type;
template
struct apply : lit {};
};
template
struct apply : apply_impl {};
};
typedef token > repeated_token;
typedef token > repeated1_token;
typedef token > or_token;
typedef token > open_bracket_token;
typedef token > close_bracket_token;
typedef token > > define_token;
typedef
middle_of<
lit_c<'\''>,
one_of<
last_of<
lit_c<'\\'>,
one_of<
always, boost::mpl::char_<'\n'> >,
always, boost::mpl::char_<'\r'> >,
always, boost::mpl::char_<'\t'> >,
lit_c<'\\'>,
lit_c<'\''>
>
>,
one_char_except_c<'\''>
>,
token >
>
char_token;
typedef
token<
foldr1<
one_of >,
string<>,
impl::front_inserter
>
>
name_token;
struct expression;
typedef
middle_of
bracket_expression;
typedef
one_of<
transform,
transform,
bracket_expression
>
name_expression;
typedef
foldl_start_with_parser<
one_of,
name_expression,
build_repeated
>
repeated_expression;
typedef
foldl_start_with_parser<
repeated_expression,
repeated_expression,
build_sequence
>
seq_expression;
struct expression :
foldl_start_with_parser<
last_of,
seq_expression,
build_selection
>
{};
typedef sequence rule_definition;
typedef build_parser > parser_parser;
template
struct build_native_parser
{
typedef build_native_parser type;
template
struct apply
{
typedef P type;
};
};
template
struct build_parsed_parser
{
typedef typename parser_parser::apply::type p;
typedef typename boost::mpl::front::type name;
typedef typename boost::mpl::back
::type exp;
struct the_parser
{
typedef the_parser type;
template
struct apply : exp::template apply {};
};
typedef boost::mpl::pair type;
};
typedef build_parser name_parser;
template
struct rebuild : name_parser::template apply {};
struct no_action;
template
struct add_rule;
template
struct add_import;
template
struct grammar_builder
{
typedef grammar_builder type;
typedef Rules rules;
typedef Actions actions;
// Make it a parser
template
struct apply :
get_parser<
grammar_builder,
typename rebuild::type
>::type::template apply
{};
template
struct import :
add_import::type, P>
{};
template
struct rule :
add_rule, Action>
{};
};
template
struct add_rule, P, no_action> :
grammar_builder<
Start,
typename boost::mpl::insert::type,
Actions
>
{};
template
struct add_rule, P, F> :
grammar_builder<
Start,
typename boost::mpl::insert::type,
typename boost::mpl::insert<
Actions,
boost::mpl::pair<
typename P::name,
typename boost::mpl::lambda::type
>
>
::type
>
{};
template
struct add_import, Name, P> :
grammar_builder<
Start,
typename boost::mpl::insert<
Rules,
boost::mpl::pair >
>::type,
Actions
>
{};
}
template >
struct grammar :
grammar_util::grammar_builder<
Start,
boost::mpl::map<>,
boost::mpl::map<>
>
{};
}
}
}
#endif