diff --git a/test/lex/Jamfile b/test/lex/Jamfile index 83e4361e32..626ad5f11e 100644 --- a/test/lex/Jamfile +++ b/test/lex/Jamfile @@ -105,9 +105,9 @@ run regression_matlib_switch.cpp : : : lex_regression_matl run regression_word_count.cpp ; run regression_syntax_error.cpp ; run regression_wide.cpp ; -run regression_file_iterator1.cpp ; -run regression_file_iterator2.cpp ; -run regression_file_iterator3.cpp : : : off ; -run regression_file_iterator4.cpp ; +run state_any_token_semact.cpp ; +run multi_pass.cpp ; +run lookahead.cpp : : : off ; +run bol_reset.cpp ; run regression_static_wide_6253.cpp ; run regression_less_8563.cpp ; diff --git a/test/lex/auto_switch_lexerstate.cpp b/test/lex/auto_switch_lexerstate.cpp index 5d6f9af70a..1d49f0142b 100644 --- a/test/lex/auto_switch_lexerstate.cpp +++ b/test/lex/auto_switch_lexerstate.cpp @@ -12,9 +12,6 @@ #include -#include -#include - #include #include @@ -23,21 +20,8 @@ namespace spirit = boost::spirit; namespace lex = spirit::lex; -typedef spirit::classic::position_iterator2< - spirit::multi_pass > -> file_iterator; - -inline file_iterator -make_file_iterator(std::istream& input, const std::string& filename) -{ - return file_iterator( - spirit::make_default_multi_pass( - std::istreambuf_iterator(input)), - spirit::multi_pass >(), - filename); -} - -typedef lex::lexertl::token token_type; +typedef char const* content_iterator; +typedef lex::lexertl::token token_type; struct lexer : lex::lexer > @@ -66,11 +50,10 @@ typedef lexer::iterator_type token_iterator; int main() { - std::stringstream ss; - ss << "!foo\nbar\n!baz"; + std::string const s = "!foo\nbar\n!baz"; - file_iterator begin = make_file_iterator(ss, "SS"); - file_iterator end; + content_iterator begin = s.data(); + content_iterator end = s.data() + s.size(); lexer l; token_iterator begin2 = l.begin(begin, end); diff --git a/test/lex/regression_file_iterator4.cpp b/test/lex/bol_reset.cpp similarity index 73% rename from test/lex/regression_file_iterator4.cpp rename to test/lex/bol_reset.cpp index 4f30193875..698e2aecf1 100644 --- a/test/lex/regression_file_iterator4.cpp +++ b/test/lex/bol_reset.cpp @@ -8,8 +8,6 @@ // if a token matched at the beginning of a line is discarded using // lex::pass_fail. -#include -#include #include #include @@ -21,21 +19,8 @@ namespace spirit = boost::spirit; namespace lex = spirit::lex; -typedef spirit::classic::position_iterator2< - spirit::multi_pass > -> file_iterator; - -inline file_iterator -make_file_iterator(std::istream& input, const std::string& filename) -{ - return file_iterator( - spirit::make_default_multi_pass( - std::istreambuf_iterator(input)), - spirit::multi_pass >(), - filename); -} - -typedef lex::lexertl::token token_type; +typedef char const* content_iterator; +typedef lex::lexertl::token token_type; struct lexer : lex::lexer > @@ -69,11 +54,10 @@ typedef lexer::iterator_type token_iterator; int main() { - std::stringstream ss; - ss << "!foo\nbar\n!baz"; + std::string const s = "!foo\nbar\n!baz"; - file_iterator begin = make_file_iterator(ss, "SS"); - file_iterator end; + content_iterator begin = s.data(); + content_iterator end = s.data() + s.size(); lexer l; token_iterator begin2 = l.begin(begin, end); diff --git a/test/lex/id_type_enum.cpp b/test/lex/id_type_enum.cpp index a2eccfe49f..b469379962 100644 --- a/test/lex/id_type_enum.cpp +++ b/test/lex/id_type_enum.cpp @@ -5,8 +5,6 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include -#include -#include #include #include @@ -16,19 +14,7 @@ namespace spirit = boost::spirit; namespace lex = spirit::lex; -typedef spirit::classic::position_iterator2< - spirit::multi_pass > -> file_iterator; - -inline file_iterator -make_file_iterator(std::istream& input, const std::string& filename) -{ - return file_iterator( - spirit::make_default_multi_pass( - std::istreambuf_iterator(input)), - spirit::multi_pass >(), - filename); -} +typedef char const* content_iterator; enum token_id { @@ -37,7 +23,7 @@ enum token_id }; typedef lex::lexertl::token< - file_iterator, boost::mpl::vector<>, boost::mpl::true_, token_id + content_iterator, boost::mpl::vector<>, boost::mpl::true_, token_id > token_type; struct lexer @@ -69,11 +55,10 @@ typedef lexer::iterator_type token_iterator; int main() { - std::stringstream ss; - ss << "!foo\nbar\n!baz"; + std::string const s = "!foo\nbar\n!baz"; - file_iterator begin = make_file_iterator(ss, "SS"); - file_iterator end; + content_iterator begin = s.data(); + content_iterator end = s.data() + s.size(); lexer l; token_iterator begin2 = l.begin(begin, end); diff --git a/test/lex/regression_file_iterator3.cpp b/test/lex/lookahead.cpp similarity index 69% rename from test/lex/regression_file_iterator3.cpp rename to test/lex/lookahead.cpp index 6c3a044643..22b262d59d 100644 --- a/test/lex/regression_file_iterator3.cpp +++ b/test/lex/lookahead.cpp @@ -7,8 +7,6 @@ #define BOOST_SPIRIT_DEBUG 1 // required for token streaming // #define BOOST_SPIRIT_LEXERTL_DEBUG 1 -#include -#include #include #include @@ -22,31 +20,17 @@ namespace spirit = boost::spirit; namespace lex = spirit::lex; namespace phoenix = boost::phoenix; -typedef spirit::classic::position_iterator2< - spirit::multi_pass > -> file_iterator; - -typedef boost::iterator_range file_range; - -inline file_iterator -make_file_iterator(std::istream& input, const std::string& filename) -{ - return file_iterator( - spirit::make_default_multi_pass( - std::istreambuf_iterator(input)), - spirit::multi_pass >(), - filename); -} +typedef char const* content_iterator; struct string_literal { - string_literal(file_iterator, file_iterator) + string_literal(content_iterator, content_iterator) { } }; typedef lex::lexertl::token< - file_iterator, boost::mpl::vector + content_iterator, boost::mpl::vector > token_type; struct lexer @@ -72,11 +56,10 @@ typedef lexer::iterator_type token_iterator; int main() { - std::stringstream ss; - ss << "'foo''bar'"; + std::string const s = "'foo''bar'"; - file_iterator begin = make_file_iterator(ss, "SS"); - file_iterator end; + content_iterator begin = s.data(); + content_iterator end = s.data() + s.size(); lexer l; token_iterator begin2 = l.begin(begin, end); diff --git a/test/lex/regression_file_iterator2.cpp b/test/lex/multi_pass.cpp similarity index 72% rename from test/lex/regression_file_iterator2.cpp rename to test/lex/multi_pass.cpp index f859cb22e7..725872701a 100644 --- a/test/lex/regression_file_iterator2.cpp +++ b/test/lex/multi_pass.cpp @@ -4,8 +4,9 @@ // 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) +// problem in multi_pass showing up in conjunction with certain lexer usage patterns + #include -#include #include #include @@ -17,36 +18,24 @@ namespace spirit = boost::spirit; namespace lex = spirit::lex; -typedef spirit::classic::position_iterator2< - spirit::multi_pass > -> file_iterator; - -inline file_iterator -make_file_iterator(std::istream& input, const std::string& filename) -{ - return file_iterator( - spirit::make_default_multi_pass( - std::istreambuf_iterator(input)), - spirit::multi_pass >(), - filename); -} +typedef char const* content_iterator; struct identifier { - identifier(file_iterator, file_iterator) + identifier(content_iterator, content_iterator) { } }; struct string_literal { - string_literal(file_iterator, file_iterator) + string_literal(content_iterator, content_iterator) { } }; typedef lex::lexertl::token< - file_iterator, boost::mpl::vector + content_iterator, boost::mpl::vector > token_type; struct lexer @@ -83,11 +72,10 @@ typedef lexer::iterator_type token_iterator; int main() { - std::stringstream ss; - ss << "foo 'bar'"; + std::string const s = "foo 'bar'"; - file_iterator begin = make_file_iterator(ss, "SS"); - file_iterator end; + content_iterator begin = s.data(); + content_iterator end = s.data() + s.size(); lexer l; token_iterator begin2 = l.begin(begin, end, "ST"); diff --git a/test/lex/regression_file_iterator1.cpp b/test/lex/state_any_token_semact.cpp similarity index 65% rename from test/lex/regression_file_iterator1.cpp rename to test/lex/state_any_token_semact.cpp index 3420732e34..eae69c6913 100644 --- a/test/lex/regression_file_iterator1.cpp +++ b/test/lex/state_any_token_semact.cpp @@ -4,8 +4,8 @@ // 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) -#include -#include +// lexers with semantic actions attached to state '*' tokens + #include #include @@ -16,38 +16,24 @@ namespace spirit = boost::spirit; namespace lex = spirit::lex; -typedef spirit::classic::position_iterator2< - spirit::multi_pass > -> file_iterator; - -typedef boost::iterator_range file_range; - -inline file_iterator -make_file_iterator(std::istream& input, const std::string& filename) -{ - return file_iterator( - spirit::make_default_multi_pass( - std::istreambuf_iterator(input)), - spirit::multi_pass >(), - filename); -} +typedef char const* content_iterator; struct identifier { - identifier(file_iterator, file_iterator) + identifier(content_iterator, content_iterator) { } }; struct string_literal { - string_literal(file_iterator, file_iterator) + string_literal(content_iterator, content_iterator) { } }; typedef lex::lexertl::token< - file_iterator, boost::mpl::vector + content_iterator, boost::mpl::vector > token_type; struct lexer @@ -75,11 +61,10 @@ typedef lexer::iterator_type token_iterator; int main() { - std::stringstream ss; - ss << "foo 'bar'"; + std::string const s = "foo 'bar'"; - file_iterator begin = make_file_iterator(ss, "SS"); - file_iterator end; + content_iterator begin = s.data(); + content_iterator end = s.data() + s.size(); lexer l; token_iterator begin2 = l.begin(begin, end, "ST"); diff --git a/test/support/Jamfile b/test/support/Jamfile index c955dabf2a..45d8c16ce5 100644 --- a/test/support/Jamfile +++ b/test/support/Jamfile @@ -68,4 +68,3 @@ run utree.cpp ; run utree_debug.cpp ; compile multi_pass_functor.cpp ; -compile multi_pass_position_iterator.cpp ; diff --git a/test/support/multi_pass_position_iterator.cpp b/test/support/multi_pass_position_iterator.cpp deleted file mode 100644 index 6df9d2f47c..0000000000 --- a/test/support/multi_pass_position_iterator.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) 2010 Chris Hoeppler -// -// 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) - -// This code below failed to compile with MSVC starting with Boost V1.42 - -#include -#include -#include - -namespace char_enc = boost::spirit::ascii; -namespace qi = boost::spirit::qi; - -int main() -{ - typedef std::vector file_storage; - typedef boost::spirit::classic::position_iterator< - file_storage::const_iterator> iterator_type; - - qi::rule top = - qi::lexeme[+char_enc::alpha]; - - // I do not know what the hell is going under the hood of MSVC 9, - // but the next line fixes compilation error. - // error C3767: '!=': candidate function(s) not accessible - iterator_type first, last; - - return first == last; // just to silence unused variable warnings -} -