| 1 | // Copyright (c) 2001-2011 Hartmut Kaiser |
| 2 | // Copyright (c) 2001-2011 Joel de Guzman |
| 3 | // Copyright (c) 2009 Carl Barron |
| 4 | // |
| 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 7 | |
| 8 | #if !defined(BOOST_PP_IS_ITERATING) |
| 9 | |
| 10 | #if !defined(BOOST_SPIRIT_LEXER_PARSE_ATTR_MAY_27_2009_0926AM) |
| 11 | #define BOOST_SPIRIT_LEXER_PARSE_ATTR_MAY_27_2009_0926AM |
| 12 | |
| 13 | #include <boost/spirit/home/lex/tokenize_and_parse.hpp> |
| 14 | |
| 15 | #include <boost/fusion/include/vector.hpp> |
| 16 | #include <boost/preprocessor/cat.hpp> |
| 17 | #include <boost/preprocessor/iterate.hpp> |
| 18 | #include <boost/preprocessor/repetition/enum.hpp> |
| 19 | #include <boost/preprocessor/repetition/enum_params.hpp> |
| 20 | #include <boost/preprocessor/repetition/enum_binary_params.hpp> |
| 21 | |
| 22 | #define BOOST_PP_FILENAME_1 <boost/spirit/home/lex/tokenize_and_parse_attr.hpp> |
| 23 | #define BOOST_PP_ITERATION_LIMITS (2, SPIRIT_ARGUMENTS_LIMIT) |
| 24 | #include BOOST_PP_ITERATE() |
| 25 | |
| 26 | #endif |
| 27 | |
| 28 | /////////////////////////////////////////////////////////////////////////////// |
| 29 | // |
| 30 | // Preprocessor vertical repetition code |
| 31 | // |
| 32 | /////////////////////////////////////////////////////////////////////////////// |
| 33 | #else // defined(BOOST_PP_IS_ITERATING) |
| 34 | |
| 35 | #define N BOOST_PP_ITERATION() |
| 36 | #define BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE(z, n, A) BOOST_PP_CAT(A, n)& |
| 37 | |
| 38 | namespace boost { namespace spirit { namespace lex |
| 39 | { |
| 40 | template <typename Iterator, typename Lexer, typename ParserExpr |
| 41 | , BOOST_PP_ENUM_PARAMS(N, typename A)> |
| 42 | inline bool |
| 43 | tokenize_and_parse(Iterator& first, Iterator last, Lexer const& lex |
| 44 | , ParserExpr const& expr, BOOST_PP_ENUM_BINARY_PARAMS(N, A, & attr)) |
| 45 | { |
| 46 | // Report invalid expression error as early as possible. |
| 47 | // If you got an error_invalid_expression error message here, |
| 48 | // then the expression (expr) is not a valid spirit qi expression. |
| 49 | BOOST_SPIRIT_ASSERT_MATCH(qi::domain, ParserExpr); |
| 50 | |
| 51 | typedef fusion::vector< |
| 52 | BOOST_PP_ENUM(N, BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE, A) |
| 53 | > vector_type; |
| 54 | |
| 55 | vector_type attr (BOOST_PP_ENUM_PARAMS(N, attr)); |
| 56 | typename Lexer::iterator_type iter = lex.begin(first, last); |
| 57 | return compile<qi::domain>(expr).parse( |
| 58 | iter, lex.end(), unused, unused, attr); |
| 59 | } |
| 60 | }}} |
| 61 | |
| 62 | #undef BOOST_SPIRIT_QI_ATTRIBUTE_REFERENCE |
| 63 | #undef N |
| 64 | |
| 65 | #endif |
| 66 | |
| 67 | |