/////////////////////////////////////////////////////////////////////////////// // grammar.hpp // // Copyright 2008 Eric Niebler. 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) #ifndef BOOST_XPRESSIVE_DETAIL_STATIC_GRAMMAR_HPP_EAN_11_12_2006 #define BOOST_XPRESSIVE_DETAIL_STATIC_GRAMMAR_HPP_EAN_11_12_2006 // MS compatible compilers support #pragma once #if defined(_MSC_VER) && (_MSC_VER >= 1020) # pragma once #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define BOOST_XPRESSIVE_CHECK_REGEX(Expr, Char)\ BOOST_MPL_ASSERT\ ((\ typename boost::mpl::if_c<\ boost::xpressive::is_valid_regex::value\ , boost::mpl::true_\ , boost::xpressive::INVALID_REGULAR_EXPRESSION\ >::type\ )); ////////////////////////////////////////////////////////////////////////// //**********************************************************************// //* << NOTE! >> *// //* *// //* Whenever you change this grammar, you MUST also make corresponding *// //* changes to width_of.hpp and is_pure.hpp. *// //* *// //**********************************************************************// ////////////////////////////////////////////////////////////////////////// namespace boost { namespace xpressive { template struct Grammar; template struct ActionableGrammar; namespace grammar_detail { /////////////////////////////////////////////////////////////////////////// // CharLiteral template struct CharLiteral; /////////////////////////////////////////////////////////////////////////// // ListSet template struct ListSet; /////////////////////////////////////////////////////////////////////////// // as_repeat template struct as_repeat : if_< make > , as_simple_quantifier , as_default_quantifier > {}; /////////////////////////////////////////////////////////////////////////// // NonGreedyRepeatCases template struct NonGreedyRepeatCases { template struct case_ : not_<_> {}; template struct case_ : dereference {}; template struct case_ : unary_plus {}; template struct case_ : logical_not {}; template struct case_, Dummy> : unary_expr, Gram> {}; }; /////////////////////////////////////////////////////////////////////////// // InvertibleCases template struct InvertibleCases { template struct case_ : not_<_> {}; template struct case_ : when, as_list_set_matcher > {}; template struct case_ : when, as_list_set_matcher > {}; template struct case_ : when, call(_right)> > {}; template struct case_ : when< unary_expr , as_lookahead > {}; template struct case_ : when< unary_expr , as_lookbehind > {}; template struct case_ : when< or_< CharLiteral , terminal , terminal > , terminal , terminal > > > , as_matcher > {}; }; /////////////////////////////////////////////////////////////////////////// // Cases template struct Cases { template struct case_ : not_<_> {}; template struct case_ : when< _ , in_sequence > {}; template struct case_ : when< shift_right , reverse_fold<_, _state, Gram> > {}; template struct case_ : when< bitwise_or , in_sequence< as_alternate_matcher< reverse_fold_tree<_, make, in_alternate_list > > > > {}; template struct case_ , Dummy> : when< unary_expr, Gram> , in_sequence(_child)> > > {}; template struct case_ : when< dereference , call)> > {}; template struct case_ : when< unary_plus , call)> > {}; template struct case_ : when< logical_not , call)> > {}; template struct case_, Dummy> : when< unary_expr, Gram> , call)> > {}; template struct case_ : when< negate > > , call(_child)>)> > {}; template struct case_ : when< complement > > , in_sequence >(_child)>)> > > {}; template struct case_ : when, as_modifier > {}; template struct case_ : when< unary_expr , in_sequence > > {}; template struct case_ : when< unary_expr , in_sequence > > {}; template struct case_ : when< unary_expr , in_sequence > > {}; template struct case_ : when, in_sequence > > {}; template struct case_ : or_< when, call > , when, in_sequence > > > {}; template struct case_ : or_< when, in_sequence(_right)> > > , when, _>, call(as_action)> > > {}; }; /////////////////////////////////////////////////////////////////////////// // ActionableCases template struct ActionableCases { template struct case_ : Cases::template case_ {}; // Only in sub-expressions with actions attached do we allow attribute assignements template struct case_ : or_< typename Cases::template case_ , when >, _>, in_sequence > > {}; }; } // namespace detail /////////////////////////////////////////////////////////////////////////// // Grammar template struct Grammar : proto::switch_ > > {}; template struct ActionableGrammar : proto::switch_ > > {}; /////////////////////////////////////////////////////////////////////////// // INVALID_REGULAR_EXPRESSION struct INVALID_REGULAR_EXPRESSION : mpl::false_ {}; /////////////////////////////////////////////////////////////////////////// // is_valid_regex template struct is_valid_regex : proto::matches > {}; }} // namespace boost::xpressive #endif