diff options
Diffstat (limited to '3rdParty/Boost/src/boost/spirit/home/classic/core/scanner')
5 files changed, 791 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/impl/skipper.ipp b/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/impl/skipper.ipp new file mode 100644 index 0000000..fab74bd --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/impl/skipper.ipp @@ -0,0 +1,181 @@ +/*============================================================================= + Copyright (c) 1998-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + Use, modification and distribution is subject to 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_SKIPPER_IPP) +#define BOOST_SPIRIT_SKIPPER_IPP + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { + +BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN + + struct space_parser; + template <typename BaseT> + struct no_skipper_iteration_policy; + + namespace impl + { + template <typename ST, typename ScannerT, typename BaseT> + inline void + skipper_skip( + ST const& s, + ScannerT const& scan, + skipper_iteration_policy<BaseT> const&) + { + typedef scanner_policies< + no_skipper_iteration_policy< + BOOST_DEDUCED_TYPENAME ScannerT::iteration_policy_t>, + BOOST_DEDUCED_TYPENAME ScannerT::match_policy_t, + BOOST_DEDUCED_TYPENAME ScannerT::action_policy_t + > policies_t; + + scanner<BOOST_DEDUCED_TYPENAME ScannerT::iterator_t, policies_t> + scan2(scan.first, scan.last, policies_t(scan)); + typedef typename ScannerT::iterator_t iterator_t; + + for (;;) + { + iterator_t save = scan.first; + if (!s.parse(scan2)) + { + scan.first = save; + break; + } + } + } + + template <typename ST, typename ScannerT, typename BaseT> + inline void + skipper_skip( + ST const& s, + ScannerT const& scan, + no_skipper_iteration_policy<BaseT> const&) + { + for (;;) + { + typedef typename ScannerT::iterator_t iterator_t; + iterator_t save = scan.first; + if (!s.parse(scan)) + { + scan.first = save; + break; + } + } + } + + template <typename ST, typename ScannerT> + inline void + skipper_skip( + ST const& s, + ScannerT const& scan, + iteration_policy const&) + { + for (;;) + { + typedef typename ScannerT::iterator_t iterator_t; + iterator_t save = scan.first; + if (!s.parse(scan)) + { + scan.first = save; + break; + } + } + } + + template <typename SkipT> + struct phrase_parser + { + template <typename IteratorT, typename ParserT> + static parse_info<IteratorT> + parse( + IteratorT const& first_, + IteratorT const& last, + ParserT const& p, + SkipT const& skip) + { + typedef skip_parser_iteration_policy<SkipT> iter_policy_t; + typedef scanner_policies<iter_policy_t> scanner_policies_t; + typedef scanner<IteratorT, scanner_policies_t> scanner_t; + + iter_policy_t iter_policy(skip); + scanner_policies_t policies(iter_policy); + IteratorT first = first_; + scanner_t scan(first, last, policies); + match<nil_t> hit = p.parse(scan); + return parse_info<IteratorT>( + first, hit, hit && (first == last), + hit.length()); + } + }; + + template <> + struct phrase_parser<space_parser> + { + template <typename IteratorT, typename ParserT> + static parse_info<IteratorT> + parse( + IteratorT const& first_, + IteratorT const& last, + ParserT const& p, + space_parser const&) + { + typedef skipper_iteration_policy<> iter_policy_t; + typedef scanner_policies<iter_policy_t> scanner_policies_t; + typedef scanner<IteratorT, scanner_policies_t> scanner_t; + + IteratorT first = first_; + scanner_t scan(first, last); + match<nil_t> hit = p.parse(scan); + return parse_info<IteratorT>( + first, hit, hit && (first == last), + hit.length()); + } + }; + } + + /////////////////////////////////////////////////////////////////////////// + // + // Free parse functions using the skippers + // + /////////////////////////////////////////////////////////////////////////// + template <typename IteratorT, typename ParserT, typename SkipT> + inline parse_info<IteratorT> + parse( + IteratorT const& first, + IteratorT const& last, + parser<ParserT> const& p, + parser<SkipT> const& skip) + { + return impl::phrase_parser<SkipT>:: + parse(first, last, p.derived(), skip.derived()); + } + + /////////////////////////////////////////////////////////////////////////// + // + // Parse function for null terminated strings using the skippers + // + /////////////////////////////////////////////////////////////////////////// + template <typename CharT, typename ParserT, typename SkipT> + inline parse_info<CharT const*> + parse( + CharT const* str, + parser<ParserT> const& p, + parser<SkipT> const& skip) + { + CharT const* last = str; + while (*last) + last++; + return parse(str, last, p, skip); + } + +BOOST_SPIRIT_CLASSIC_NAMESPACE_END + +}} // namespace boost::spirit + +#endif + diff --git a/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/scanner.hpp b/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/scanner.hpp new file mode 100644 index 0000000..3854877 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/scanner.hpp @@ -0,0 +1,329 @@ +/*============================================================================= + Copyright (c) 1998-2002 Joel de Guzman + http://spirit.sourceforge.net/ + + 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_SCANNER_HPP) +#define BOOST_SPIRIT_SCANNER_HPP + +#include <iterator> +#include <boost/config.hpp> +#include <boost/spirit/home/classic/namespace.hpp> +#include <boost/spirit/home/classic/core/match.hpp> +#include <boost/spirit/home/classic/core/non_terminal/parser_id.hpp> +#include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits + +#include <boost/spirit/home/classic/core/scanner/scanner_fwd.hpp> + +namespace boost { namespace spirit { + +BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN + + /////////////////////////////////////////////////////////////////////////// + // + // iteration_policy class + // + /////////////////////////////////////////////////////////////////////////// + struct iteration_policy + { + template <typename ScannerT> + void + advance(ScannerT const& scan) const + { + ++scan.first; + } + + template <typename ScannerT> + bool at_end(ScannerT const& scan) const + { + return scan.first == scan.last; + } + + template <typename T> + T filter(T ch) const + { + return ch; + } + + template <typename ScannerT> + typename ScannerT::ref_t + get(ScannerT const& scan) const + { + return *scan.first; + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // match_policy class + // + /////////////////////////////////////////////////////////////////////////// + struct match_policy + { + template <typename T> + struct result { typedef match<T> type; }; + + const match<nil_t> + no_match() const + { + return match<nil_t>(); + } + + const match<nil_t> + empty_match() const + { + return match<nil_t>(0, nil_t()); + } + + template <typename AttrT, typename IteratorT> + match<AttrT> + create_match( + std::size_t length, + AttrT const& val, + IteratorT const& /*first*/, + IteratorT const& /*last*/) const + { + return match<AttrT>(length, val); + } + + template <typename MatchT, typename IteratorT> + void group_match( + MatchT& /*m*/, + parser_id const& /*id*/, + IteratorT const& /*first*/, + IteratorT const& /*last*/) const {} + + template <typename Match1T, typename Match2T> + void concat_match(Match1T& l, Match2T const& r) const + { + l.concat(r); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // match_result class + // + /////////////////////////////////////////////////////////////////////////// + template <typename MatchPolicyT, typename T> + struct match_result + { + typedef typename MatchPolicyT::template result<T>::type type; + }; + + /////////////////////////////////////////////////////////////////////////// + // + // action_policy class + // + /////////////////////////////////////////////////////////////////////////// + template <typename AttrT> + struct attributed_action_policy + { + template <typename ActorT, typename IteratorT> + static void + call( + ActorT const& actor, + AttrT& val, + IteratorT const&, + IteratorT const&) + { + actor(val); + } + }; + + ////////////////////////////////// + template <> + struct attributed_action_policy<nil_t> + { + template <typename ActorT, typename IteratorT> + static void + call( + ActorT const& actor, + nil_t, + IteratorT const& first, + IteratorT const& last) + { + actor(first, last); + } + }; + + ////////////////////////////////// + struct action_policy + { + template <typename ActorT, typename AttrT, typename IteratorT> + void + do_action( + ActorT const& actor, + AttrT& val, + IteratorT const& first, + IteratorT const& last) const + { + attributed_action_policy<AttrT>::call(actor, val, first, last); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // scanner_policies class + // + /////////////////////////////////////////////////////////////////////////// + template < + typename IterationPolicyT, + typename MatchPolicyT, + typename ActionPolicyT> + struct scanner_policies : + public IterationPolicyT, + public MatchPolicyT, + public ActionPolicyT + { + typedef IterationPolicyT iteration_policy_t; + typedef MatchPolicyT match_policy_t; + typedef ActionPolicyT action_policy_t; + + scanner_policies( + IterationPolicyT const& i_policy = IterationPolicyT(), + MatchPolicyT const& m_policy = MatchPolicyT(), + ActionPolicyT const& a_policy = ActionPolicyT()) + : IterationPolicyT(i_policy) + , MatchPolicyT(m_policy) + , ActionPolicyT(a_policy) {} + + template <typename ScannerPoliciesT> + scanner_policies(ScannerPoliciesT const& policies) + : IterationPolicyT(policies) + , MatchPolicyT(policies) + , ActionPolicyT(policies) {} + }; + + /////////////////////////////////////////////////////////////////////////// + // + // scanner_policies_base class: the base class of all scanners + // + /////////////////////////////////////////////////////////////////////////// + struct scanner_base {}; + + /////////////////////////////////////////////////////////////////////////// + // + // scanner class + // + /////////////////////////////////////////////////////////////////////////// + template < + typename IteratorT, + typename PoliciesT> + class scanner : public PoliciesT, public scanner_base + { + public: + + typedef IteratorT iterator_t; + typedef PoliciesT policies_t; + + typedef typename boost::detail:: + iterator_traits<IteratorT>::value_type value_t; + typedef typename boost::detail:: + iterator_traits<IteratorT>::reference ref_t; + typedef typename boost:: + call_traits<IteratorT>::param_type iter_param_t; + + scanner( + IteratorT& first_, + iter_param_t last_, + PoliciesT const& policies = PoliciesT()) + : PoliciesT(policies), first(first_), last(last_) + { + at_end(); + } + + scanner(scanner const& other) + : PoliciesT(other), first(other.first), last(other.last) {} + + scanner(scanner const& other, IteratorT& first_) + : PoliciesT(other), first(first_), last(other.last) {} + + template <typename PoliciesT1> + scanner(scanner<IteratorT, PoliciesT1> const& other) + : PoliciesT(other), first(other.first), last(other.last) {} + + bool + at_end() const + { + typedef typename PoliciesT::iteration_policy_t iteration_policy_type; + return iteration_policy_type::at_end(*this); + } + + value_t + operator*() const + { + typedef typename PoliciesT::iteration_policy_t iteration_policy_type; + return iteration_policy_type::filter(iteration_policy_type::get(*this)); + } + + scanner const& + operator++() const + { + typedef typename PoliciesT::iteration_policy_t iteration_policy_type; + iteration_policy_type::advance(*this); + return *this; + } + + template <typename PoliciesT2> + struct rebind_policies + { + typedef scanner<IteratorT, PoliciesT2> type; + }; + + template <typename PoliciesT2> + scanner<IteratorT, PoliciesT2> + change_policies(PoliciesT2 const& policies) const + { + return scanner<IteratorT, PoliciesT2>(first, last, policies); + } + + template <typename IteratorT2> + struct rebind_iterator + { + typedef scanner<IteratorT2, PoliciesT> type; + }; + + template <typename IteratorT2> + scanner<IteratorT2, PoliciesT> + change_iterator(IteratorT2 const& first_, IteratorT2 const &last_) const + { + return scanner<IteratorT2, PoliciesT>(first_, last_, *this); + } + + IteratorT& first; + IteratorT const last; + + private: + + scanner& + operator=(scanner const& other); + }; + + /////////////////////////////////////////////////////////////////////////// + // + // rebind_scanner_policies class + // + /////////////////////////////////////////////////////////////////////////// + template <typename ScannerT, typename PoliciesT> + struct rebind_scanner_policies + { + typedef typename ScannerT::template + rebind_policies<PoliciesT>::type type; + }; + + ////////////////////////////////// + template <typename ScannerT, typename IteratorT> + struct rebind_scanner_iterator + { + typedef typename ScannerT::template + rebind_iterator<IteratorT>::type type; + }; + +BOOST_SPIRIT_CLASSIC_NAMESPACE_END + +}} + +#endif diff --git a/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/scanner_fwd.hpp b/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/scanner_fwd.hpp new file mode 100644 index 0000000..efd78cf --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/scanner_fwd.hpp @@ -0,0 +1,52 @@ +/*============================================================================= + Copyright (c) 2006 Tobias Schwinger + http://spirit.sourceforge.net/ + + 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_SCANNER_FWD_HPP) +#define BOOST_SPIRIT_SCANNER_FWD_HPP + +#include <boost/spirit/home/classic/namespace.hpp> + +namespace boost { namespace spirit { + +BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN + + /////////////////////////////////////////////////////////////////////////// + // + // policy classes + // + /////////////////////////////////////////////////////////////////////////// + struct iteration_policy; + struct action_policy; + struct match_policy; + + /////////////////////////////////////////////////////////////////////////// + // + // scanner_policies class + // + /////////////////////////////////////////////////////////////////////////// + template < + typename IterationPolicyT = iteration_policy, + typename MatchPolicyT = match_policy, + typename ActionPolicyT = action_policy> + struct scanner_policies; + + /////////////////////////////////////////////////////////////////////////// + // + // scanner class + // + /////////////////////////////////////////////////////////////////////////// + template < + typename IteratorT = char const*, + typename PoliciesT = scanner_policies<> > + class scanner; + +BOOST_SPIRIT_CLASSIC_NAMESPACE_END + +}} // namespace BOOST_SPIRIT_CLASSIC_NS + +#endif + diff --git a/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/skipper.hpp b/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/skipper.hpp new file mode 100644 index 0000000..4e655ae --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/skipper.hpp @@ -0,0 +1,197 @@ +/*============================================================================= + Copyright (c) 1998-2003 Joel de Guzman + http://spirit.sourceforge.net/ + + 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_SKIPPER_HPP) +#define BOOST_SPIRIT_SKIPPER_HPP + +/////////////////////////////////////////////////////////////////////////////// +#include <cctype> + +#include <boost/spirit/home/classic/namespace.hpp> +#include <boost/spirit/home/classic/core/scanner/scanner.hpp> +#include <boost/spirit/home/classic/core/primitives/impl/primitives.ipp> + +#include <boost/spirit/home/classic/core/scanner/skipper_fwd.hpp> + +namespace boost { namespace spirit { + +BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN + + /////////////////////////////////////////////////////////////////////////// + // + // skipper_iteration_policy class + // + /////////////////////////////////////////////////////////////////////////// + template <typename BaseT> + struct skipper_iteration_policy : public BaseT + { + typedef BaseT base_t; + + skipper_iteration_policy() + : BaseT() {} + + template <typename PolicyT> + skipper_iteration_policy(PolicyT const& other) + : BaseT(other) {} + + template <typename ScannerT> + void + advance(ScannerT const& scan) const + { + BaseT::advance(scan); + scan.skip(scan); + } + + template <typename ScannerT> + bool + at_end(ScannerT const& scan) const + { + scan.skip(scan); + return BaseT::at_end(scan); + } + + template <typename ScannerT> + void + skip(ScannerT const& scan) const + { + while (!BaseT::at_end(scan) && impl::isspace_(BaseT::get(scan))) + BaseT::advance(scan); + } + }; + + /////////////////////////////////////////////////////////////////////////// + // + // no_skipper_iteration_policy class + // + /////////////////////////////////////////////////////////////////////////// + template <typename BaseT> + struct no_skipper_iteration_policy : public BaseT + { + typedef BaseT base_t; + + no_skipper_iteration_policy() + : BaseT() {} + + template <typename PolicyT> + no_skipper_iteration_policy(PolicyT const& other) + : BaseT(other) {} + + template <typename ScannerT> + void + skip(ScannerT const& /*scan*/) const {} + }; + + /////////////////////////////////////////////////////////////////////////// + // + // skip_parser_iteration_policy class + // + /////////////////////////////////////////////////////////////////////////// + namespace impl + { + template <typename ST, typename ScannerT, typename BaseT> + void + skipper_skip( + ST const& s, + ScannerT const& scan, + skipper_iteration_policy<BaseT> const&); + + template <typename ST, typename ScannerT, typename BaseT> + void + skipper_skip( + ST const& s, + ScannerT const& scan, + no_skipper_iteration_policy<BaseT> const&); + + template <typename ST, typename ScannerT> + void + skipper_skip( + ST const& s, + ScannerT const& scan, + iteration_policy const&); + } + + template <typename ParserT, typename BaseT> + class skip_parser_iteration_policy : public skipper_iteration_policy<BaseT> + { + public: + + typedef skipper_iteration_policy<BaseT> base_t; + + skip_parser_iteration_policy( + ParserT const& skip_parser, + base_t const& base = base_t()) + : base_t(base), subject(skip_parser) {} + + template <typename PolicyT> + skip_parser_iteration_policy(PolicyT const& other) + : base_t(other), subject(other.skipper()) {} + + template <typename ScannerT> + void + skip(ScannerT const& scan) const + { + impl::skipper_skip(subject, scan, scan); + } + + ParserT const& + skipper() const + { + return subject; + } + + private: + + ParserT const& subject; + }; + + /////////////////////////////////////////////////////////////////////////////// + // + // Free parse functions using the skippers + // + /////////////////////////////////////////////////////////////////////////////// + template <typename IteratorT, typename ParserT, typename SkipT> + parse_info<IteratorT> + parse( + IteratorT const& first, + IteratorT const& last, + parser<ParserT> const& p, + parser<SkipT> const& skip); + + /////////////////////////////////////////////////////////////////////////////// + // + // Parse function for null terminated strings using the skippers + // + /////////////////////////////////////////////////////////////////////////////// + template <typename CharT, typename ParserT, typename SkipT> + parse_info<CharT const*> + parse( + CharT const* str, + parser<ParserT> const& p, + parser<SkipT> const& skip); + + /////////////////////////////////////////////////////////////////////////////// + // + // phrase_scanner_t and wide_phrase_scanner_t + // + // The most common scanners. Use these typedefs when you need + // a scanner that skips white spaces. + // + /////////////////////////////////////////////////////////////////////////////// + typedef skipper_iteration_policy<> iter_policy_t; + typedef scanner_policies<iter_policy_t> scanner_policies_t; + typedef scanner<char const*, scanner_policies_t> phrase_scanner_t; + typedef scanner<wchar_t const*, scanner_policies_t> wide_phrase_scanner_t; + + /////////////////////////////////////////////////////////////////////////////// + +BOOST_SPIRIT_CLASSIC_NAMESPACE_END + +}} // namespace BOOST_SPIRIT_CLASSIC_NS + +#include <boost/spirit/home/classic/core/scanner/impl/skipper.ipp> +#endif + diff --git a/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/skipper_fwd.hpp b/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/skipper_fwd.hpp new file mode 100644 index 0000000..228e618 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/classic/core/scanner/skipper_fwd.hpp @@ -0,0 +1,32 @@ +/*============================================================================= + Copyright (c) 2006 Tobias Schwinger + http://spirit.sourceforge.net/ + + 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_SKIPPER_FWD_HPP) +#define BOOST_SPIRIT_SKIPPER_FWD_HPP + +#include <boost/spirit/home/classic/namespace.hpp> +#include <boost/spirit/home/classic/core/scanner/scanner_fwd.hpp> + +namespace boost { namespace spirit { + +BOOST_SPIRIT_CLASSIC_NAMESPACE_BEGIN + + template <typename BaseT = iteration_policy> + struct skipper_iteration_policy; + + template <typename BaseT = iteration_policy> + struct no_skipper_iteration_policy; + + template <typename ParserT, typename BaseT = iteration_policy> + class skip_parser_iteration_policy; + +BOOST_SPIRIT_CLASSIC_NAMESPACE_END + +}} // namespace BOOST_SPIRIT_CLASSIC_NS + +#endif + |