2
0
mirror of https://github.com/boostorg/spirit.git synced 2026-01-19 04:42:11 +00:00
This commit is contained in:
djowel
2022-06-01 10:22:27 +08:00
parent 1451c2eb3e
commit da9968dbdf
4 changed files with 32 additions and 32 deletions

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2009 Carl Barron
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
//
// 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/lex.hpp>
@@ -33,7 +33,7 @@ struct multi_tokens : lex::lexer<Lexer>
a = "A";
b = "B";
c = "C";
this->self =
this->self =
a [ ++phoenix::ref(level) ]
| b
| c [(
@@ -44,12 +44,12 @@ struct multi_tokens : lex::lexer<Lexer>
;
d = ".";
this->self("in_dedenting") =
d [
if_(--phoenix::ref(level)) [
_end = _start
this->self("in_dedenting") =
d [
if_(--phoenix::ref(level)) [
_end = _start
]
.else_ [
.else_ [
_state = "INITIAL"
]
]
@@ -75,7 +75,7 @@ struct dumper
std::stringstream& strm;
// silence MSVC warning C4512: assignment operator could not be generated
BOOST_DELETED_FUNCTION(dumper& operator= (dumper const&));
BOOST_DELETED_FUNCTION(dumper& operator= (dumper const&))
};
///////////////////////////////////////////////////////////////////////////////

View File

@@ -1,7 +1,7 @@
// Copyright (c) 2001-2009 Hartmut Kaiser
// Copyright (c) 2009 Carl Barron
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
//
// 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)
#ifndef MATLIB_H_05102009
@@ -37,7 +37,7 @@ struct store_double
}
// silence MSVC warning C4512: assignment operator could not be generated
BOOST_DELETED_FUNCTION(store_double& operator= (store_double const&));
BOOST_DELETED_FUNCTION(store_double& operator= (store_double const&))
};
struct add_row
@@ -58,7 +58,7 @@ struct add_row
}
// silence MSVC warning C4512: assignment operator could not be generated
BOOST_DELETED_FUNCTION(add_row& operator= (add_row const&));
BOOST_DELETED_FUNCTION(add_row& operator= (add_row const&))
};
template <class Lexer>
@@ -74,17 +74,17 @@ struct matlib_tokens : boost::spirit::lex::lexer<Lexer>
number = "[-+]?({REAL1}|{REAL2})([eE][-+]?[0-9]+)?";
this->self
this->self
= token_def_('[') [set_lexer_state("A")]
;
this->self("A")
this->self("A")
= token_def_('[') [set_lexer_state("B")]
| ','
| token_def_(']') [set_lexer_state("INITIAL")]
;
this->self("B")
this->self("B")
= number [store_double(row)]
| ','
| token_def_(']') [add_row(matrix,row)]

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2001-2011 Hartmut Kaiser
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
//
// 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/lex_lexertl.hpp>
@@ -14,7 +14,7 @@
using namespace boost::spirit;
///////////////////////////////////////////////////////////////////////////////
// semantic action analyzing leading whitespace
// semantic action analyzing leading whitespace
enum tokenids
{
ID_INDENT = 1000,
@@ -54,7 +54,7 @@ struct handle_whitespace
}
template <typename Iterator>
bool is_dedent(Iterator& start, Iterator& end, unsigned int& level)
bool is_dedent(Iterator& start, Iterator& end, unsigned int& level)
{
unsigned int newindent = get_indent(start, end);
while (!indents_.empty() && newindent < indents_.top()) {
@@ -66,11 +66,11 @@ struct handle_whitespace
// Handle additional indentation
template <typename Iterator>
bool is_indent(Iterator& start, Iterator& end, unsigned int& level)
bool is_indent(Iterator& start, Iterator& end, unsigned int& level)
{
unsigned int newindent = get_indent(start, end);
if (indents_.empty() || newindent > indents_.top()) {
level = 1; // indent one more level
level = 1; // indent one more level
indents_.push(newindent);
return true;
}
@@ -80,7 +80,7 @@ struct handle_whitespace
std::stack<unsigned int>& indents_;
// silence MSVC warning C4512: assignment operator could not be generated
BOOST_DELETED_FUNCTION(handle_whitespace& operator= (handle_whitespace const&));
BOOST_DELETED_FUNCTION(handle_whitespace& operator= (handle_whitespace const&))
};
///////////////////////////////////////////////////////////////////////////////
@@ -113,7 +113,7 @@ struct token_data
};
template <typename Token>
inline
inline
bool test_tokens(token_data const* d, std::vector<Token> const& tokens)
{
for (std::size_t i = 0, len = tokens.size(); i < len; ++i)
@@ -124,7 +124,7 @@ bool test_tokens(token_data const* d, std::vector<Token> const& tokens)
typename Token::token_value_type const& value (tokens[i].value());
if (tokens[i].id() != static_cast<std::size_t>(d->id)) // token id must match
return false;
if (value.which() != 1) // must have an integer value
if (value.which() != 1) // must have an integer value
return false;
if (boost::get<unsigned int>(value) != d->value) // value must match
return false;
@@ -134,7 +134,7 @@ bool test_tokens(token_data const* d, std::vector<Token> const& tokens)
return (d->id == -1) ? true : false;
}
inline
inline
bool test_indents(int *i, std::stack<unsigned int>& indents)
{
while (!indents.empty())
@@ -196,7 +196,7 @@ int main()
int i[] = { 8, 4, -1 };
BOOST_TEST(test_indents(i, lexer.indents));
token_data d[] = {
token_data d[] = {
{ ID_INDENT, 1 }, { ID_INDENT, 1 }
, { -1, 0 } };
BOOST_TEST(test_tokens(d, tokens));
@@ -219,7 +219,7 @@ int main()
int i[] = { 4, -1 };
BOOST_TEST(test_indents(i, lexer.indents));
token_data d[] = {
token_data d[] = {
{ ID_INDENT, 1 }, { ID_INDENT, 1 }
, { ID_DEDENT, 1 }
, { -1, 0 } };
@@ -244,7 +244,7 @@ int main()
int i[] = { 4, -1 };
BOOST_TEST(test_indents(i, lexer.indents));
token_data d[] = {
token_data d[] = {
{ ID_INDENT, 1 }, { ID_INDENT, 1 }, { ID_INDENT, 1 }
, { ID_DEDENT, 2 }
, { -1, 0 } };

View File

@@ -69,7 +69,7 @@ namespace testns
const T1 t1;
// silence MSVC warning C4512: assignment operator could not be generated
BOOST_DELETED_FUNCTION(ops_1_parser& operator= (ops_1_parser const&));
BOOST_DELETED_FUNCTION(ops_1_parser& operator= (ops_1_parser const&))
};
template <typename T1, typename T2>
@@ -121,7 +121,7 @@ namespace testns
const T2 t2;
// silence MSVC warning C4512: assignment operator could not be generated
BOOST_DELETED_FUNCTION(ops_2_parser& operator= (ops_2_parser const&));
BOOST_DELETED_FUNCTION(ops_2_parser& operator= (ops_2_parser const&))
};
template <typename T1, typename T2, typename T3>
@@ -178,7 +178,7 @@ namespace testns
const T3 t3;
// silence MSVC warning C4512: assignment operator could not be generated
BOOST_DELETED_FUNCTION(ops_3_parser& operator= (ops_3_parser const&));
BOOST_DELETED_FUNCTION(ops_3_parser& operator= (ops_3_parser const&))
};
}