2
0
mirror of https://github.com/boostorg/spirit.git synced 2026-01-19 04:42:11 +00:00

V2.Tests: Revise poorly named tests

Looking by the commit history they should not have been using classic iterators
This commit is contained in:
Nikita Kniazev
2022-09-03 02:07:20 +03:00
parent 94f4704f40
commit 32fb6f6899
9 changed files with 43 additions and 167 deletions

View File

@@ -105,9 +105,9 @@ run regression_matlib_switch.cpp : : : <dependency>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 : : : <pch>off ;
run regression_file_iterator4.cpp ;
run state_any_token_semact.cpp ;
run multi_pass.cpp ;
run lookahead.cpp : : : <pch>off ;
run bol_reset.cpp ;
run regression_static_wide_6253.cpp ;
run regression_less_8563.cpp ;

View File

@@ -12,9 +12,6 @@
#include <boost/spirit/include/lex_lexertl.hpp>
#include <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/phoenix/operator/self.hpp>
@@ -23,21 +20,8 @@
namespace spirit = boost::spirit;
namespace lex = spirit::lex;
typedef spirit::classic::position_iterator2<
spirit::multi_pass<std::istreambuf_iterator<char> >
> 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<char>(input)),
spirit::multi_pass<std::istreambuf_iterator<char> >(),
filename);
}
typedef lex::lexertl::token<file_iterator> token_type;
typedef char const* content_iterator;
typedef lex::lexertl::token<content_iterator> token_type;
struct lexer
: lex::lexer<lex::lexertl::actor_lexer<token_type> >
@@ -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);

View File

@@ -8,8 +8,6 @@
// if a token matched at the beginning of a line is discarded using
// lex::pass_fail.
#include <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
#include <boost/spirit/include/lex_lexertl.hpp>
#include <boost/core/lightweight_test.hpp>
@@ -21,21 +19,8 @@
namespace spirit = boost::spirit;
namespace lex = spirit::lex;
typedef spirit::classic::position_iterator2<
spirit::multi_pass<std::istreambuf_iterator<char> >
> 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<char>(input)),
spirit::multi_pass<std::istreambuf_iterator<char> >(),
filename);
}
typedef lex::lexertl::token<file_iterator> token_type;
typedef char const* content_iterator;
typedef lex::lexertl::token<content_iterator> token_type;
struct lexer
: lex::lexer<lex::lexertl::actor_lexer<token_type> >
@@ -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);

View File

@@ -5,8 +5,6 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <boost/spirit/include/lex_lexertl.hpp>
#include <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/phoenix/operator/self.hpp>
@@ -16,19 +14,7 @@
namespace spirit = boost::spirit;
namespace lex = spirit::lex;
typedef spirit::classic::position_iterator2<
spirit::multi_pass<std::istreambuf_iterator<char> >
> 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<char>(input)),
spirit::multi_pass<std::istreambuf_iterator<char> >(),
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);

View File

@@ -7,8 +7,6 @@
#define BOOST_SPIRIT_DEBUG 1 // required for token streaming
// #define BOOST_SPIRIT_LEXERTL_DEBUG 1
#include <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
#include <boost/spirit/include/lex_lexertl.hpp>
#include <boost/core/lightweight_test.hpp>
@@ -22,31 +20,17 @@ namespace spirit = boost::spirit;
namespace lex = spirit::lex;
namespace phoenix = boost::phoenix;
typedef spirit::classic::position_iterator2<
spirit::multi_pass<std::istreambuf_iterator<char> >
> file_iterator;
typedef boost::iterator_range<file_iterator> 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<char>(input)),
spirit::multi_pass<std::istreambuf_iterator<char> >(),
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<string_literal>
content_iterator, boost::mpl::vector<string_literal>
> 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);

View File

@@ -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 <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
#include <boost/spirit/include/lex_lexertl.hpp>
#include <boost/core/lightweight_test.hpp>
@@ -17,36 +18,24 @@
namespace spirit = boost::spirit;
namespace lex = spirit::lex;
typedef spirit::classic::position_iterator2<
spirit::multi_pass<std::istreambuf_iterator<char> >
> 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<char>(input)),
spirit::multi_pass<std::istreambuf_iterator<char> >(),
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<identifier, string_literal>
content_iterator, boost::mpl::vector<identifier, string_literal>
> 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");

View File

@@ -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 <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
// lexers with semantic actions attached to state '*' tokens
#include <boost/spirit/include/lex_lexertl.hpp>
#include <boost/core/lightweight_test.hpp>
@@ -16,38 +16,24 @@
namespace spirit = boost::spirit;
namespace lex = spirit::lex;
typedef spirit::classic::position_iterator2<
spirit::multi_pass<std::istreambuf_iterator<char> >
> file_iterator;
typedef boost::iterator_range<file_iterator> 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<char>(input)),
spirit::multi_pass<std::istreambuf_iterator<char> >(),
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<identifier, string_literal>
content_iterator, boost::mpl::vector<identifier, string_literal>
> 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");

View File

@@ -68,4 +68,3 @@ run utree.cpp ;
run utree_debug.cpp ;
compile multi_pass_functor.cpp ;
compile multi_pass_position_iterator.cpp ;

View File

@@ -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 <vector>
#include <boost/spirit/include/classic_position_iterator.hpp>
#include <boost/spirit/include/qi.hpp>
namespace char_enc = boost::spirit::ascii;
namespace qi = boost::spirit::qi;
int main()
{
typedef std::vector<char> file_storage;
typedef boost::spirit::classic::position_iterator<
file_storage::const_iterator> iterator_type;
qi::rule<iterator_type, std::string(), qi::blank_type> 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
}