diff options
author | Kevin Smith <git@kismith.co.uk> | 2013-01-12 18:41:34 (GMT) |
---|---|---|
committer | Swift Review <review@swift.im> | 2013-01-13 10:36:26 (GMT) |
commit | f3bc816af1b0d61452de973963e453bf3b3f95a2 (patch) | |
tree | e895f8afa3580e6cff6f5ad2017d45bf147a17c2 /3rdParty/Boost/src/boost/spirit/home/lex/lexer/action.hpp | |
parent | 188fc285c6555eadd3c9d50ab8a94adcade78d89 (diff) | |
download | swift-f3bc816af1b0d61452de973963e453bf3b3f95a2.zip swift-f3bc816af1b0d61452de973963e453bf3b3f95a2.tar.bz2 |
Adding in the spirit Boost stuff
Change-Id: I4f127ce61667243b64081b0aa309028d5077045f
Diffstat (limited to '3rdParty/Boost/src/boost/spirit/home/lex/lexer/action.hpp')
-rw-r--r-- | 3rdParty/Boost/src/boost/spirit/home/lex/lexer/action.hpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/3rdParty/Boost/src/boost/spirit/home/lex/lexer/action.hpp b/3rdParty/Boost/src/boost/spirit/home/lex/lexer/action.hpp new file mode 100644 index 0000000..8de0c87 --- /dev/null +++ b/3rdParty/Boost/src/boost/spirit/home/lex/lexer/action.hpp @@ -0,0 +1,97 @@ +// Copyright (c) 2001-2011 Hartmut Kaiser +// +// 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_LEX_ACTION_NOV_18_2007_0743PM) +#define SPIRIT_LEX_ACTION_NOV_18_2007_0743PM + +#if defined(_MSC_VER) +#pragma once +#endif + +#include <boost/spirit/home/lex/meta_compiler.hpp> +#include <boost/spirit/home/lex/lexer_type.hpp> +#include <boost/spirit/home/lex/argument.hpp> +#include <boost/spirit/home/lex/lexer/support_functions.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/type_traits/is_same.hpp> + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit { namespace lex +{ + /////////////////////////////////////////////////////////////////////////// + template <typename Subject, typename Action> + struct action : unary_lexer<action<Subject, Action> > + { + action(Subject const& subject, Action f) + : subject(subject), f(f) {} + + template <typename LexerDef, typename String> + void collect(LexerDef& lexdef, String const& state + , String const& targetstate) const + { + // collect the token definition information for the token_def + // this action is attached to + subject.collect(lexdef, state, targetstate); + } + + template <typename LexerDef> + void add_actions(LexerDef& lexdef) const + { + // call to add all actions attached further down the hierarchy + subject.add_actions(lexdef); + + // retrieve the id of the associated token_def and register the + // given semantic action with the lexer instance + lexdef.add_action(subject.unique_id(), subject.state(), f); + } + + Subject subject; + Action f; + + private: + // silence MSVC warning C4512: assignment operator could not be generated + action& operator= (action const&); + }; + +}}} + +/////////////////////////////////////////////////////////////////////////////// +namespace boost { namespace spirit +{ + /////////////////////////////////////////////////////////////////////////// + // Karma action meta-compiler + template <> + struct make_component<lex::domain, tag::action> + { + template <typename Sig> + struct result; + + template <typename This, typename Elements, typename Modifiers> + struct result<This(Elements, Modifiers)> + { + typedef typename + remove_const<typename Elements::car_type>::type + subject_type; + + typedef typename + remove_const<typename Elements::cdr_type::car_type>::type + action_type; + + typedef lex::action<subject_type, action_type> type; + }; + + template <typename Elements> + typename result<make_component(Elements, unused_type)>::type + operator()(Elements const& elements, unused_type) const + { + typename result<make_component(Elements, unused_type)>::type + result(elements.car, elements.cdr.car); + return result; + } + }; +}} + +#endif |