diff options
author | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
commit | 08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch) | |
tree | 7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/spirit/repository/home/qi | |
parent | bb4dd8289b351fae6b55e303f189127a394a1edd (diff) | |
download | boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2 boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip |
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/spirit/repository/home/qi')
4 files changed, 222 insertions, 221 deletions
diff --git a/boost/spirit/repository/home/qi/directive/kwd.hpp b/boost/spirit/repository/home/qi/directive/kwd.hpp index bba1a78448..18020804bd 100644 --- a/boost/spirit/repository/home/qi/directive/kwd.hpp +++ b/boost/spirit/repository/home/qi/directive/kwd.hpp @@ -30,25 +30,25 @@ namespace boost { namespace spirit /////////////////////////////////////////////////////////////////////////// // Enablers /////////////////////////////////////////////////////////////////////////// - + template < typename T> struct use_directive<qi::domain , terminal_ex<repository::tag::kwd // enables kwd(key)[p] , fusion::vector1<T > > > : mpl::true_ {}; - + template < typename T> struct use_directive<qi::domain , terminal_ex<repository::tag::ikwd // enables ikwd(key)[p] , fusion::vector1<T > > > : mpl::true_ {}; - + template < typename T> struct use_directive<qi::domain , terminal_ex<repository::tag::dkwd // enables dkwd(key)[p] , fusion::vector1<T > > > : mpl::true_ {}; - + template < typename T> struct use_directive<qi::domain , terminal_ex<repository::tag::idkwd // enables idkwd(key)[p] @@ -109,7 +109,7 @@ namespace boost { namespace spirit , terminal_ex<repository::tag::kwd // enables kwd(min, inf)[p] , fusion::vector3<T1, T2, inf_type > > > : mpl::true_ {}; - + template < typename T1, typename T2> struct use_directive<qi::domain , terminal_ex<repository::tag::ikwd // enables ikwd(min, inf)[p] @@ -164,7 +164,7 @@ template <typename T> flag=true; return true; } - + private: // silence MSVC warning C4512: assignment operator could not be generated @@ -193,7 +193,7 @@ template <typename T> } else return flag=false; - + } T const exact; @@ -254,42 +254,42 @@ template <typename T> kwd_infinite_iterator& operator= (kwd_infinite_iterator const&); }; - // This class enables the transportation of parameters needed to call + // This class enables the transportation of parameters needed to call // the occurence constraint checker from higher level calls - // It also serves to select the correct parse function call + // It also serves to select the correct parse function call // of the keyword parser. The implementation changes depending if it is // called form a keyword parsing loop or not. template <typename Skipper, typename NoCasePass> struct skipper_keyword_marker { typedef NoCasePass no_case_pass; - - skipper_keyword_marker(Skipper const &skipper,bool &flag,int &counter) : + + skipper_keyword_marker(Skipper const &skipper,bool &flag,int &counter) : skipper(skipper) , flag(flag) - , counter(counter) + , counter(counter) {} - + const Skipper &skipper; bool &flag; int &counter; }; - + template <typename Subject, typename KeywordType, typename LoopIter , typename NoCase, typename Distinct > struct kwd_parser : spirit::qi::unary_parser<kwd_parser<Subject, KeywordType, LoopIter , NoCase, Distinct > > { struct kwd_parser_id; - + typedef Subject subject_type; typedef NoCase no_case_keyword; typedef Distinct distinct; - + typedef typename remove_const<typename traits::char_type_of<KeywordType>::type>::type char_type; - + typedef std::basic_string<char_type> keyword_type; - + template <typename Context, typename Iterator> struct attribute { @@ -300,13 +300,13 @@ template <typename T> >::type type; }; - + kwd_parser(Subject const& subject , typename add_reference<KeywordType>::type keyword , LoopIter const& iter) - : subject(subject), iter(iter), keyword(keyword) {} - + : subject(subject), iter(iter), keyword(keyword) {} + template<typename CharEncoding> kwd_parser(Subject const& subject , typename add_reference<KeywordType>::type keyword @@ -323,15 +323,15 @@ template <typename T> { return subject.parse(first,last,context,skipper,attr); } - + // Call the subject parser on a container attribute template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse_impl(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper , Attribute& attr,mpl::true_) const - { - + { + // synthesized attribute needs to be default constructed typename traits::container_value<Attribute>::type val = typename traits::container_value<Attribute>::type(); @@ -347,23 +347,23 @@ template <typename T> } return r; } - + template <typename Iterator, typename Context , typename Skipper, typename Attribute,typename NoCasePass> bool parse(Iterator& first, Iterator const& last , Context& context, skipper_keyword_marker<Skipper,NoCasePass> const& skipper , Attribute &attr) const { - + typedef typename traits::attribute_of< Subject, Context, Iterator>::type subject_attribute; - + typedef typename mpl::and_< traits::is_container<Attribute> , mpl::not_< traits::is_weak_substitute< subject_attribute,Attribute > > >::type predicate; - + if((no_case_keyword::value && NoCasePass::value) || !NoCasePass::value) { if(parse_impl(first,last,context,skipper.skipper,attr, predicate())) @@ -371,7 +371,7 @@ template <typename T> } return false; } - + template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse(Iterator& first, Iterator const& last @@ -381,12 +381,12 @@ template <typename T> typedef typename traits::attribute_of< Subject, Context, Iterator>::type subject_attribute; - + typedef typename mpl::and_< traits::is_container<Attribute> , mpl::not_< traits::is_weak_substitute< subject_attribute,Attribute > > >::type predicate; - + // Parse the keyword bool flag = iter.flag_init(); @@ -395,24 +395,24 @@ template <typename T> spirit::qi::skip_over(first, last, skipper); if(keyword.parse(first,last,context,skipper,unused)){ if((!distinct::value) || skipper.parse(first,last,unused,unused,unused)){ - // Followed by the subject parser - spirit::qi::skip_over(first, last, skipper); - if(parse_impl(first,last,context,skipper,attr, predicate())) - { - return iter.register_successful_parse(flag,counter); + // Followed by the subject parser + spirit::qi::skip_over(first, last, skipper); + if(parse_impl(first,last,context,skipper,attr, predicate())) + { + return iter.register_successful_parse(flag,counter); + } } } - } - first = save; - return flag; + first = save; + return flag; } - - + + template <typename Context> - info what(Context& context) const - { + info what(Context& context) const + { if(distinct::value){ - if(no_case_keyword::value) + if(no_case_keyword::value) return info("idkwd", subject.what(context)); else return info("dkwd", subject.what(context)); @@ -421,14 +421,14 @@ template <typename T> { if(no_case_keyword::value) return info("ikwd", subject.what(context)); - else + else return info("kwd", subject.what(context)); - } + } } Subject subject; - LoopIter iter; - + LoopIter iter; + typedef typename mpl::if_< no_case_keyword, spirit::qi::no_case_literal_string< KeywordType, true>, @@ -604,7 +604,7 @@ namespace boost { namespace spirit { namespace qi /////////////////////////////////////////////////////////////////////////// // Parser generators: make_xxx function (objects) /////////////////////////////////////////////////////////////////////////// - + template <typename T1, typename T2, typename Subject, typename Modifiers, typename Distinct, typename MakeDirectiveHelper> struct make_directive_internal_2_args { @@ -784,12 +784,12 @@ namespace boost { namespace spirit { namespace qi { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_pass_iterator<int> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::false_ > result_type; - + template <typename Terminal> result_type operator()( - Terminal const& term, Subject const& subject, unused_type) const + Terminal const& term, Subject const& subject, unused_type) const { typename spirit::detail::get_encoding<Modifiers, spirit::char_encoding::standard>::type encoding; @@ -801,14 +801,14 @@ namespace boost { namespace spirit { namespace qi ); } }; - + template <typename T1, typename Subject, typename Modifiers> struct make_directive< terminal_ex<repository::tag::idkwd, fusion::vector1<T1> >, Subject, Modifiers> { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_pass_iterator<int> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::true_ > result_type; template <typename Terminal> @@ -817,15 +817,15 @@ namespace boost { namespace spirit { namespace qi { typename spirit::detail::get_encoding<Modifiers, spirit::char_encoding::standard>::type encoding; - + return result_type(subject ,fusion::at_c<0>(term.args) - ,iterator_type() + ,iterator_type() ,encoding ); } }; - + // Directive kwd(key,exact)[p] template <typename T> struct make_exact_helper @@ -891,7 +891,7 @@ namespace boost { namespace spirit { namespace qi { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_exact_iterator<T2> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::false_ > result_type; template <typename Terminal> @@ -901,8 +901,8 @@ namespace boost { namespace spirit { namespace qi typename spirit::detail::get_encoding<Modifiers, spirit::char_encoding::standard>::type encoding; return result_type(subject - ,fusion::at_c<0>(term.args) - ,fusion::at_c<1>(term.args) + , fusion::at_c<0>(term.args) + , fusion::at_c<1>(term.args) , encoding ); } @@ -914,13 +914,13 @@ namespace boost { namespace spirit { namespace qi { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_exact_iterator<T2> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::true_ > result_type; - + template <typename Terminal> result_type operator()( Terminal const& term, Subject const& subject, Modifiers const& modifiers) const - { + { typename spirit::detail::get_encoding<Modifiers, spirit::char_encoding::standard>::type encoding; return result_type(subject @@ -930,7 +930,7 @@ namespace boost { namespace spirit { namespace qi ); } }; - + // Directive kwd(min, max)[p] @@ -946,9 +946,9 @@ namespace boost { namespace spirit { namespace qi }; - template <typename T1, typename T2, typename Subject, typename Modifiers> + template <typename T1, typename T2, typename Subject, typename Modifiers> struct make_directive< - terminal_ex<repository::tag::kwd, fusion::vector3< T1, T2, T2> >, Subject, Modifiers> + terminal_ex<repository::tag::kwd, fusion::vector3<T1,T2,T2> >, Subject, Modifiers> { typedef make_directive_internal_2_args< T1 , T2 @@ -1001,7 +1001,7 @@ namespace boost { namespace spirit { namespace qi { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_finite_iterator<T2> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::false_ > result_type; template <typename Terminal> @@ -1027,14 +1027,14 @@ namespace boost { namespace spirit { namespace qi { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_finite_iterator<T2> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::true_ > result_type; template <typename Terminal> result_type operator()( Terminal const& term, Subject const& subject, unused_type) const { - + typename spirit::detail::get_encoding<Modifiers, spirit::char_encoding::standard>::type encoding; return result_type(subject, fusion::at_c<0>(term.args), @@ -1046,7 +1046,7 @@ namespace boost { namespace spirit { namespace qi ); } }; - + // Directive kwd(min, inf)[p] @@ -1063,7 +1063,7 @@ namespace boost { namespace spirit { namespace qi }; - template <typename T1, typename T2, typename Subject, typename Modifiers> + template <typename T1, typename T2, typename Subject, typename Modifiers> struct make_directive< terminal_ex<repository::tag::kwd, fusion::vector3<T1,T2,inf_type> >, Subject, Modifiers> { @@ -1118,7 +1118,7 @@ namespace boost { namespace spirit { namespace qi { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_infinite_iterator<T2> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::false_ > result_type; template <typename Terminal> @@ -1135,15 +1135,15 @@ namespace boost { namespace spirit { namespace qi ); } }; - - template <typename T1, typename T2, typename Subject, typename Modifiers> + + template <typename T1, typename T2, typename Subject, typename Modifiers> struct make_directive< terminal_ex<repository::tag::idkwd , fusion::vector3<T1, T2, inf_type> >, Subject, Modifiers> { typedef typename add_const<T1>::type const_keyword; typedef repository::qi::kwd_infinite_iterator<T2> iterator_type; - + typedef repository::qi::kwd_parser<Subject, const_keyword, iterator_type, mpl::true_, mpl::true_ > result_type; template <typename Terminal> @@ -1152,7 +1152,7 @@ namespace boost { namespace spirit { namespace qi { typename spirit::detail::get_encoding<Modifiers, spirit::char_encoding::standard>::type encoding; - + return result_type(subject , fusion::at_c<0>(term.args) , fusion::at_c<1>(term.args) @@ -1160,15 +1160,15 @@ namespace boost { namespace spirit { namespace qi ); } }; - - + + }}} namespace boost { namespace spirit { namespace traits { template <typename Subject, typename KeywordType , typename LoopIter, typename NoCase , typename Distinct> - struct has_semantic_action< + struct has_semantic_action< repository::qi::kwd_parser< Subject, KeywordType, LoopIter, NoCase, Distinct > > : unary_has_semantic_action<Subject> {}; diff --git a/boost/spirit/repository/home/qi/nonterminal/subrule.hpp b/boost/spirit/repository/home/qi/nonterminal/subrule.hpp index a2db38496b..170367b71c 100644 --- a/boost/spirit/repository/home/qi/nonterminal/subrule.hpp +++ b/boost/spirit/repository/home/qi/nonterminal/subrule.hpp @@ -529,7 +529,7 @@ namespace boost { namespace spirit { namespace repository { namespace qi { // If you are seeing a compilation error here, you are trying // to use a subrule as a parser outside of a subrule group. - BOOST_SPIRIT_ASSERT_MSG(false + BOOST_SPIRIT_ASSERT_FAIL(Iterator , subrule_used_outside_subrule_group, (id_type)); return false; @@ -558,7 +558,7 @@ namespace boost { namespace spirit { namespace repository { namespace qi { // If you are seeing a compilation error here, you are trying // to use a subrule as a parser outside of a subrule group. - BOOST_SPIRIT_ASSERT_MSG(false + BOOST_SPIRIT_ASSERT_FAIL(Iterator , subrule_used_outside_subrule_group, (id_type)); return false; diff --git a/boost/spirit/repository/home/qi/operator/detail/keywords.hpp b/boost/spirit/repository/home/qi/operator/detail/keywords.hpp index 06836f7746..43aa133468 100644 --- a/boost/spirit/repository/home/qi/operator/detail/keywords.hpp +++ b/boost/spirit/repository/home/qi/operator/detail/keywords.hpp @@ -1,9 +1,9 @@ /*============================================================================= Copyright (c) 2011-2012 Thomas Bernard - 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) -=============================================================================*/ + 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(SPIRIT_KEYWORDS_DETAIL_MARCH_13_2007_1145PM) #define SPIRIT_KEYWORDS_DETAIL_MARCH_13_2007_1145PM @@ -14,11 +14,11 @@ #include <boost/spirit/home/qi/string/lit.hpp> #include <boost/fusion/include/at.hpp> namespace boost { namespace spirit { namespace repository { namespace qi { namespace detail { - // Variant visitor class which handles dispatching the parsing to the selected parser - // This also handles passing the correct attributes and flags/counters to the subject parsers + // Variant visitor class which handles dispatching the parsing to the selected parser + // This also handles passing the correct attributes and flags/counters to the subject parsers template<typename T> struct is_distinct : T::distinct { }; - + template<typename T, typename Action> struct is_distinct< spirit::qi::action<T,Action> > : T::distinct { }; @@ -27,10 +27,10 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names - template < typename Elements, typename Iterator ,typename Context ,typename Skipper - ,typename Flags ,typename Counters ,typename Attribute, typename NoCasePass> + template < typename Elements, typename Iterator ,typename Context ,typename Skipper + ,typename Flags ,typename Counters ,typename Attribute, typename NoCasePass> struct parse_dispatcher - : public boost::static_visitor<bool> + : public boost::static_visitor<bool> { typedef Iterator iterator_type; @@ -38,60 +38,60 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names typedef Skipper skipper_type; typedef Elements elements_type; - typedef typename add_reference<Attribute>::type attr_reference; + typedef typename add_reference<Attribute>::type attr_reference; public: parse_dispatcher(const Elements &elements,Iterator& first, Iterator const& last - , Context& context, Skipper const& skipper - , Flags &flags, Counters &counters, attr_reference attr) : - elements(elements), first(first), last(last) - , context(context), skipper(skipper) - , flags(flags),counters(counters), attr(attr) + , Context& context, Skipper const& skipper + , Flags &flags, Counters &counters, attr_reference attr) : + elements(elements), first(first), last(last) + , context(context), skipper(skipper) + , flags(flags),counters(counters), attr(attr) {} - + template<typename T> bool operator()(T& idx) const - { + { return call(idx,typename traits::not_is_unused<Attribute>::type()); } - - template <typename Subject,typename Index> - bool call_subject_unused( - Subject const &subject, Iterator &first, Iterator const &last - , Context& context, Skipper const& skipper - , Index& idx ) const - { - Iterator save = first; + + template <typename Subject,typename Index> + bool call_subject_unused( + Subject const &subject, Iterator &first, Iterator const &last + , Context& context, Skipper const& skipper + , Index& idx ) const + { + Iterator save = first; skipper_keyword_marker<Skipper,NoCasePass> marked_skipper(skipper,flags[Index::value],counters[Index::value]); - - if(subject.parse(first,last,context,marked_skipper,unused)) - { + + if(subject.parse(first,last,context,marked_skipper,unused)) + { return true; + } + save = save; + return false; } - save = save; - return false; - } - - - template <typename Subject,typename Index> - bool call_subject( - Subject const &subject, Iterator &first, Iterator const &last - , Context& context, Skipper const& skipper - , Index& idx ) const - { - - Iterator save = first; + + + template <typename Subject,typename Index> + bool call_subject( + Subject const &subject, Iterator &first, Iterator const &last + , Context& context, Skipper const& skipper + , Index& idx ) const + { + + Iterator save = first; skipper_keyword_marker<Skipper,NoCasePass> marked_skipper(skipper,flags[Index::value],counters[Index::value]); - if(subject.parse(first,last,context,marked_skipper,fusion::at_c<Index::value>(attr))) - { + if(subject.parse(first,last,context,marked_skipper,fusion::at_c<Index::value>(attr))) + { return true; + } + save = save; + return false; } - save = save; - return false; - } // Handle unused attributes - template <typename T> bool call(T &idx, mpl::false_) const{ + template <typename T> bool call(T &idx, mpl::false_) const{ typedef typename mpl::at<Elements,T>::type ElementType; if( @@ -99,8 +99,8 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names || skipper.parse(first,last,unused,unused,unused) ){ spirit::qi::skip_over(first, last, skipper); - return call_subject_unused(fusion::at_c<T::value>(elements), first, last, context, skipper, idx ); - } + return call_subject_unused(fusion::at_c<T::value>(elements), first, last, context, skipper, idx ); + } return false; } // Handle normal attributes @@ -110,11 +110,11 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names (!is_distinct<ElementType>::value) || skipper.parse(first,last,unused,unused,unused) ){ - return call_subject(fusion::at_c<T::value>(elements), first, last, context, skipper, idx); - } + return call_subject(fusion::at_c<T::value>(elements), first, last, context, skipper, idx); + } return false; } - + const Elements &elements; Iterator &first; const Iterator &last; @@ -132,7 +132,7 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names typedef typename spirit::detail::as_variant< IndexList >::type parser_index_type; - + /////////////////////////////////////////////////////////////////////////// // build_char_type_sequence // @@ -369,8 +369,8 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names // Make the keyword/parse index entry in the tst parser lookup->add( - traits::get_begin<char_type>(parser.subject.keyword.str), - traits::get_end<char_type>(parser.subject.keyword.str), + traits::get_begin<char_type>(get_string(parser.subject.keyword)), + traits::get_end<char_type>(get_string(parser.subject.keyword)), position ); // Get the initial state of the flags array and store it in the flags initializer @@ -397,8 +397,8 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names { // Make the keyword/parse index entry in the tst parser lookup->add( - traits::get_begin<char_type>(parser.subject.keyword.str), - traits::get_end<char_type>(parser.subject.keyword.str), + traits::get_begin<char_type>(get_string(parser.subject.keyword)), + traits::get_end<char_type>(get_string(parser.subject.keyword)), position ); // Get the initial state of the flags array and store it in the flags initializer @@ -406,19 +406,20 @@ namespace boost { namespace spirit { namespace repository { namespace qi { names return 0; } + template <typename String, bool no_attribute> - const String & get_string(const boost::spirit::qi::literal_string<String,no_attribute> &parser) const + const String get_string(const boost::spirit::qi::literal_string<String,no_attribute> &parser) const { return parser.str; } - template <typename String, bool no_attribute> + template <typename String, bool no_attribute> const typename boost::spirit::qi::no_case_literal_string<String,no_attribute>::string_type & get_string(const boost::spirit::qi::no_case_literal_string<String,no_attribute> &parser) const { return parser.str_lo; } - + shared_ptr<keywords_type> lookup; diff --git a/boost/spirit/repository/home/qi/operator/keywords.hpp b/boost/spirit/repository/home/qi/operator/keywords.hpp index f0382371fa..4933f91104 100644 --- a/boost/spirit/repository/home/qi/operator/keywords.hpp +++ b/boost/spirit/repository/home/qi/operator/keywords.hpp @@ -66,12 +66,12 @@ namespace boost { namespace spirit { namespace repository { namespace qi // kwd directive parser type identification namespace detail { - BOOST_MPL_HAS_XXX_TRAIT_DEF(kwd_parser_id) + BOOST_MPL_HAS_XXX_TRAIT_DEF(kwd_parser_id) BOOST_MPL_HAS_XXX_TRAIT_DEF(complex_kwd_parser_id) - + } - + // kwd directive type query template <typename T> struct is_kwd_parser : detail::has_kwd_parser_id<T> {}; @@ -112,35 +112,35 @@ namespace boost { namespace spirit { namespace repository { namespace qi traits::build_fusion_vector<all_attributes>::type type; }; - + /// Make sure that all subjects are of the kwd type - typedef typename mpl::count_if< - Elements, - mpl::not_< + typedef typename mpl::count_if< + Elements, + mpl::not_< mpl::or_< - is_kwd_parser< - mpl::_1 + is_kwd_parser< + mpl::_1 > , is_complex_kwd_parser< mpl::_1 - > - > + > + > > > non_kwd_subject_count; - - /// If the assertion fails here then you probably forgot to wrap a + + /// If the assertion fails here then you probably forgot to wrap a /// subject of the / operator in a kwd directive BOOST_MPL_ASSERT_RELATION( non_kwd_subject_count::value, ==, 0 ); - + /////////////////////////////////////////////////////////////////////////// // build_parser_tags // - // Builds a boost::variant from an mpl::range_c in order to "mark" every + // Builds a boost::variant from an mpl::range_c in order to "mark" every // parser of the fusion sequence. The integer constant is used in the parser // dispatcher functor in order to use the parser corresponding to the recognised // keyword. /////////////////////////////////////////////////////////////////////////// - + template <typename Sequence> struct build_parser_tags { @@ -149,14 +149,14 @@ namespace boost { namespace spirit { namespace repository { namespace qi // Create an integer_c constant for every parser in the sequence typedef typename mpl::range_c<int, 0, sequence_size::value>::type int_range; - + // Transform the range_c to an mpl vector in order to be able to transform it into a variant typedef typename mpl::copy<int_range, mpl::back_inserter<mpl::vector<> > >::type type; - + }; // Build an index mpl vector typedef typename build_parser_tags< Elements >::type parser_index_vector; - + template <typename idx> struct is_complex_kwd_parser_filter : is_complex_kwd_parser< typename mpl::at<Elements, idx>::type > {}; @@ -166,8 +166,8 @@ namespace boost { namespace spirit { namespace repository { namespace qi {}; // filter out the string kwd directives - typedef typename mpl::filter_view< Elements, is_kwd_parser<mpl_::_> >::type string_keywords; - + typedef typename mpl::filter_view< Elements, is_kwd_parser<mpl::_> >::type string_keywords; + typedef typename mpl::filter_view< parser_index_vector , is_kwd_parser_filter< mpl::_ > >::type string_keyword_indexes; @@ -183,13 +183,13 @@ namespace boost { namespace spirit { namespace repository { namespace qi detail::empty_keywords_list, detail::complex_keywords< complex_keywords_indexes > >::type complex_keywords_type; - - // build a bool array and an integer array which will be used to - // check that the repetition constraints of the kwd parsers are + + // build a bool array and an integer array which will be used to + // check that the repetition constraints of the kwd parsers are // met and bail out a soon as possible typedef boost::array<bool, fusion::result_of::size<Elements>::value> flags_type; typedef boost::array<int, fusion::result_of::size<Elements>::value> counters_type; - + typedef typename mpl::if_< typename mpl::empty<string_keyword_indexes>::type, detail::empty_keywords_list, @@ -200,13 +200,13 @@ namespace boost { namespace spirit { namespace repository { namespace qi flags_type, Modifiers> >::type string_keywords_type; - + keywords(Elements const& elements_) : elements(elements_) , string_keywords_inst(elements,flags_init) , complex_keywords_inst(elements,flags_init) { - } + } template <typename Iterator, typename Context , typename Skipper, typename Attribute> @@ -214,30 +214,30 @@ namespace boost { namespace spirit { namespace repository { namespace qi , Context& context, Skipper const& skipper , Attribute& attr_) const { - // Select which parse function to call + // Select which parse function to call // We need to handle the case where kwd / ikwd directives have been mixed // This is where we decide which function should be called. return parse_impl(first, last, context, skipper, attr_, typename string_keywords_type::requires_one_pass() ); } - + template <typename Iterator, typename Context , typename Skipper, typename Attribute> bool parse_impl(Iterator& first, Iterator const& last , Context& context, Skipper const& skipper , Attribute& attr_,mpl::true_ /* one pass */) const { - + // wrap the attribute in a tuple if it is not a tuple typename traits::wrap_if_not_tuple<Attribute>::type attr(attr_); flags_type flags(flags_init); //flags.assign(false); - + counters_type counters; counters.assign(0); - + typedef repository::qi::detail::parse_dispatcher<Elements,Iterator, Context, Skipper , flags_type, counters_type , typename traits::wrap_if_not_tuple<Attribute>::type @@ -246,7 +246,7 @@ namespace boost { namespace spirit { namespace repository { namespace qi parser_visitor_type parse_visitor(elements, first, last , context, skipper, flags , counters, attr); - + typedef repository::qi::detail::complex_kwd_function< parser_visitor_type > complex_kwd_function_type; complex_kwd_function_type @@ -255,16 +255,16 @@ namespace boost { namespace spirit { namespace repository { namespace qi // We have a bool array 'flags' with one flag for each parser as well as a 'counter' // array. // The kwd directive sets and increments the counter when a successeful parse occured - // as well as the slot of the corresponding parser to true in the flags array as soon - // the minimum repetition requirement is met and keeps that value to true as long as - // the maximum repetition requirement is met. + // as well as the slot of the corresponding parser to true in the flags array as soon + // the minimum repetition requirement is met and keeps that value to true as long as + // the maximum repetition requirement is met. // The parsing takes place here in two steps: // 1) parse a keyword and fetch the parser index associated with that keyword // 2) call the associated parser and store the parsed value in the matching attribute. while(true) { - + spirit::qi::skip_over(first, last, skipper); Iterator save = first; if (string_keywords_inst.parse(first, last,parse_visitor,skipper)) @@ -272,28 +272,28 @@ namespace boost { namespace spirit { namespace repository { namespace qi save = first; } else { - // restore the position to the last successful keyword parse - first = save; - if(!complex_keywords_inst.parse(complex_function)) - { - first = save; + // restore the position to the last successful keyword parse + first = save; + if(!complex_keywords_inst.parse(complex_function)) + { + first = save; // Check that we are leaving the keywords parser in a successfull state BOOST_FOREACH(bool &valid,flags) { - if(!valid) - { - return false; - } + if(!valid) + { + return false; + } } return true; + } + else + save = first; } - else - save = first; - } } return false; - } - + } + // Handle the mixed kwd and ikwd case template <typename Iterator, typename Context , typename Skipper, typename Attribute> @@ -301,32 +301,32 @@ namespace boost { namespace spirit { namespace repository { namespace qi , Context& context, Skipper const& skipper , Attribute& attr_,mpl::false_ /* two passes */) const { - + // wrap the attribute in a tuple if it is not a tuple typename traits::wrap_if_not_tuple<Attribute>::type attr(attr_); flags_type flags(flags_init); //flags.assign(false); - + counters_type counters; counters.assign(0); - + typedef detail::parse_dispatcher<Elements, Iterator, Context, Skipper , flags_type, counters_type - , typename traits::wrap_if_not_tuple<Attribute>::type + , typename traits::wrap_if_not_tuple<Attribute>::type , mpl::false_> parser_visitor_type; - + typedef detail::parse_dispatcher<Elements, Iterator, Context, Skipper , flags_type, counters_type - , typename traits::wrap_if_not_tuple<Attribute>::type + , typename traits::wrap_if_not_tuple<Attribute>::type , mpl::true_> no_case_parser_visitor_type; - + parser_visitor_type parse_visitor(elements,first,last ,context,skipper,flags,counters,attr); no_case_parser_visitor_type no_case_parse_visitor(elements,first,last - ,context,skipper,flags,counters,attr); - + ,context,skipper,flags,counters,attr); + typedef repository::qi::detail::complex_kwd_function< parser_visitor_type > complex_kwd_function_type; complex_kwd_function_type @@ -336,9 +336,9 @@ namespace boost { namespace spirit { namespace repository { namespace qi // We have a bool array 'flags' with one flag for each parser as well as a 'counter' // array. // The kwd directive sets and increments the counter when a successeful parse occured - // as well as the slot of the corresponding parser to true in the flags array as soon - // the minimum repetition requirement is met and keeps that value to true as long as - // the maximum repetition requirement is met. + // as well as the slot of the corresponding parser to true in the flags array as soon + // the minimum repetition requirement is met and keeps that value to true as long as + // the maximum repetition requirement is met. // The parsing takes place here in two steps: // 1) parse a keyword and fetch the parser index associated with that keyword // 2) call the associated parser and store the parsed value in the matching attribute. @@ -353,29 +353,29 @@ namespace boost { namespace spirit { namespace repository { namespace qi save = first; } else { - first = save; + first = save; - if(!complex_keywords_inst.parse(complex_function)) - { - first = save; + if(!complex_keywords_inst.parse(complex_function)) + { + first = save; // Check that we are leaving the keywords parser in a successfull state BOOST_FOREACH(bool &valid,flags) { - if(!valid) - { - return false; - } + if(!valid) + { + return false; + } } return true; - } - else - { - save = first; - } + } + else + { + save = first; + } } } return false; - } + } template <typename Context> info what(Context& context) const @@ -389,7 +389,7 @@ namespace boost { namespace spirit { namespace repository { namespace qi Elements elements; string_keywords_type string_keywords_inst; complex_keywords_type complex_keywords_inst; - + }; }}}} @@ -406,8 +406,8 @@ namespace boost { namespace spirit { namespace qi { return result_type(ref); } }; - - + + }}} namespace boost { namespace spirit { namespace traits |