|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r67274 - in branches/release: . boost boost/algorithm/string boost/archive boost/archive/impl boost/bimap boost/config boost/detail boost/filesystem boost/functional/hash boost/fusion boost/gil boost/graph boost/integer boost/interprocess boost/intrusive boost/io boost/iostreams boost/math boost/msm boost/numeric/ublas boost/program_options boost/property_tree boost/proto boost/python boost/range boost/regex boost/serialization boost/signals boost/spirit boost/spirit/home boost/spirit/home/classic/core boost/spirit/home/classic/core/composite boost/spirit/home/classic/dynamic boost/spirit/home/classic/phoenix boost/spirit/home/classic/tree boost/spirit/home/karma boost/spirit/home/karma/detail boost/spirit/home/karma/nonterminal boost/spirit/home/lex boost/spirit/home/lex/detail boost/spirit/home/lex/lexer boost/spirit/home/lex/lexer/lexertl boost/spirit/home/lex/qi boost/spirit/home/qi/detail boost/spirit/home/qi/nonterminal boost/spirit/home/support boost/spirit/home/support/detail boost/spirit/home/support/detail/lexer boost/spirit/home/support/detail/lexer/parser boost/spirit/home/support/detail/lexer/parser/tree boost/spirit/home/support/detail/math/detail boost/statechart boost/system boost/thread boost/tr1 boost/type_traits boost/typeof boost/unordered boost/utility boost/uuid boost/variant boost/wave doc libs libs/algorithm/string libs/array/doc libs/array/test libs/bimap libs/config libs/date_time libs/filesystem libs/functional/hash libs/fusion libs/graph_parallel libs/integer libs/interprocess libs/intrusive libs/iostreams libs/math libs/math/doc libs/math/doc/sf_and_dist libs/mpi/build libs/mpl/doc/refmanual libs/mpl/doc/src/refmanual libs/msm libs/numeric/ublas libs/numeric/ublas/doc libs/program_options libs/property_tree libs/python libs/range libs/regex libs/serialization libs/serialization/doc libs/serialization/example libs/serialization/src libs/serialization/test libs/serialization/vc7ide libs/signals libs/spirit libs/spirit/classic/example libs/spirit/classic/example/fundamental libs/spirit/classic/example/fundamental/distinct libs/spirit/classic/example/fundamental/more_calculators libs/spirit/classic/example/intermediate libs/spirit/classic/example/techniques libs/spirit/classic/example/techniques/no_rules libs/spirit/doc libs/spirit/doc/lex libs/spirit/doc/qi libs/spirit/example libs/spirit/example/karma libs/spirit/example/lex libs/spirit/example/qi libs/spirit/example/scheme/output libs/spirit/example/scheme/utree/detail libs/spirit/phoenix libs/spirit/test libs/spirit/test/karma libs/spirit/test/lex libs/spirit/test/qi libs/statechart libs/static_assert libs/system libs/thread libs/timer libs/tr1 libs/type_traits libs/type_traits/doc libs/typeof/doc libs/unordered libs/utility libs/utility/swap/test libs/uuid libs/wave more more/getting_started status tools tools/bcp tools/boostbook tools/build/v2 tools/inspect tools/quickbook tools/regression tools/regression/src tools/release tools/wave
From: hartmut.kaiser_at_[hidden]
Date: 2010-12-16 08:40:10
Author: hkaiser
Date: 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
New Revision: 67274
URL: http://svn.boost.org/trac/boost/changeset/67274
Log:
Spirit: merging from trunk
Added:
branches/release/boost/spirit/home/lex/qi/plain_tokenid.hpp
- copied unchanged from r66780, /trunk/boost/spirit/home/lex/qi/plain_tokenid.hpp
branches/release/libs/spirit/example/lex/lexer_debug_support.cpp
- copied unchanged from r66780, /trunk/libs/spirit/example/lex/lexer_debug_support.cpp
branches/release/libs/spirit/example/lex/print_number_tokenids.cpp
- copied unchanged from r66780, /trunk/libs/spirit/example/lex/print_number_tokenids.cpp
branches/release/libs/spirit/example/qi/unescaped_string.cpp
- copied unchanged from r66560, /trunk/libs/spirit/example/qi/unescaped_string.cpp
branches/release/libs/spirit/test/lex/auto_switch_lexerstate.cpp
- copied, changed from r66796, /trunk/libs/spirit/test/lex/auto_switch_lexerstate.cpp
branches/release/libs/spirit/test/lex/id_type_enum.cpp
- copied unchanged from r66851, /trunk/libs/spirit/test/lex/id_type_enum.cpp
branches/release/libs/spirit/test/lex/regression007.cpp
- copied, changed from r66738, /trunk/libs/spirit/test/lex/regression007.cpp
branches/release/libs/spirit/test/lex/regression008.cpp
- copied, changed from r66738, /trunk/libs/spirit/test/lex/regression008.cpp
branches/release/libs/spirit/test/lex/regression009.cpp
- copied, changed from r66742, /trunk/libs/spirit/test/lex/regression009.cpp
branches/release/libs/spirit/test/lex/regression010.cpp
- copied, changed from r66761, /trunk/libs/spirit/test/lex/regression010.cpp
Properties modified:
branches/release/ (props changed)
branches/release/INSTALL (props changed)
branches/release/Jamroot (props changed)
branches/release/LICENSE_1_0.txt (props changed)
branches/release/boost/ (props changed)
branches/release/boost-build.jam (props changed)
branches/release/boost.css (props changed)
branches/release/boost.png (props changed)
branches/release/boost/algorithm/string/ (props changed)
branches/release/boost/archive/ (props changed)
branches/release/boost/array.hpp (props changed)
branches/release/boost/bimap/ (props changed)
branches/release/boost/config/ (props changed)
branches/release/boost/config.hpp (props changed)
branches/release/boost/detail/ (props changed)
branches/release/boost/detail/endian.hpp (props changed)
branches/release/boost/filesystem/ (props changed)
branches/release/boost/filesystem.hpp (props changed)
branches/release/boost/functional/hash/ (props changed)
branches/release/boost/fusion/ (props changed)
branches/release/boost/gil/ (props changed)
branches/release/boost/graph/ (props changed)
branches/release/boost/integer/ (props changed)
branches/release/boost/interprocess/ (props changed)
branches/release/boost/intrusive/ (props changed)
branches/release/boost/io/ (props changed)
branches/release/boost/iostreams/ (props changed)
branches/release/boost/math/ (props changed)
branches/release/boost/math_fwd.hpp (props changed)
branches/release/boost/msm/ (props changed)
branches/release/boost/numeric/ublas/ (props changed)
branches/release/boost/numeric/ublas/functional.hpp (props changed)
branches/release/boost/program_options/ (props changed)
branches/release/boost/property_tree/ (props changed)
branches/release/boost/python/ (props changed)
branches/release/boost/range/ (props changed)
branches/release/boost/regex/ (props changed)
branches/release/boost/serialization/ (props changed)
branches/release/boost/signals/ (props changed)
branches/release/boost/signals2.hpp (props changed)
branches/release/boost/spirit/ (props changed)
branches/release/boost/spirit/home/ (props changed)
branches/release/boost/spirit/home/karma/ (props changed)
branches/release/boost/spirit/home/support/attributes.hpp (props changed)
branches/release/boost/statechart/ (props changed)
branches/release/boost/system/ (props changed)
branches/release/boost/thread/ (props changed)
branches/release/boost/thread.hpp (props changed)
branches/release/boost/token_functions.hpp (props changed)
branches/release/boost/tr1/ (props changed)
branches/release/boost/type_traits/ (props changed)
branches/release/boost/typeof/message.hpp (props changed)
branches/release/boost/typeof/register_functions.hpp (props changed)
branches/release/boost/typeof/register_functions_iterate.hpp (props changed)
branches/release/boost/typeof/typeof.hpp (props changed)
branches/release/boost/typeof/unsupported.hpp (props changed)
branches/release/boost/unordered/ (props changed)
branches/release/boost/utility/ (props changed)
branches/release/boost/utility/value_init.hpp (props changed)
branches/release/boost/uuid/ (props changed)
branches/release/boost/variant/ (props changed)
branches/release/boost/version.hpp (props changed)
branches/release/boost/wave/ (props changed)
branches/release/bootstrap.bat (props changed)
branches/release/bootstrap.sh (props changed)
branches/release/doc/ (props changed)
branches/release/index.htm (props changed)
branches/release/index.html (props changed)
branches/release/libs/ (props changed)
branches/release/libs/algorithm/string/ (props changed)
branches/release/libs/array/doc/array.xml (props changed)
branches/release/libs/array/test/array0.cpp (props changed)
branches/release/libs/array/test/array2.cpp (props changed)
branches/release/libs/bimap/ (props changed)
branches/release/libs/config/ (props changed)
branches/release/libs/date_time/ (props changed)
branches/release/libs/filesystem/ (props changed)
branches/release/libs/functional/hash/ (props changed)
branches/release/libs/fusion/ (props changed)
branches/release/libs/graph_parallel/ (props changed)
branches/release/libs/integer/ (props changed)
branches/release/libs/interprocess/ (props changed)
branches/release/libs/intrusive/ (props changed)
branches/release/libs/iostreams/ (props changed)
branches/release/libs/math/ (props changed)
branches/release/libs/math/doc/ (props changed)
branches/release/libs/math/doc/sf_and_dist/ (props changed)
branches/release/libs/mpi/build/ (props changed)
branches/release/libs/mpl/doc/refmanual/broken-compiler-workarounds.html (props changed)
branches/release/libs/mpl/doc/refmanual/categorized-index-concepts.html (props changed)
branches/release/libs/mpl/doc/refmanual/cfg-no-preprocessed-headers.html (props changed)
branches/release/libs/mpl/doc/refmanual/composition-and-argument-binding.html (props changed)
branches/release/libs/mpl/doc/refmanual/data-types-concepts.html (props changed)
branches/release/libs/mpl/doc/refmanual/data-types-miscellaneous.html (props changed)
branches/release/libs/mpl/doc/refmanual/extensible-associative-sequence.html (props changed)
branches/release/libs/mpl/doc/refmanual/inserter-class.html (props changed)
branches/release/libs/mpl/doc/refmanual/tag-dispatched-metafunction.html (props changed)
branches/release/libs/mpl/doc/refmanual/trivial-metafunctions-summary.html (props changed)
branches/release/libs/mpl/doc/src/refmanual/Iterators-Iterator.rst (props changed)
branches/release/libs/msm/ (props changed)
branches/release/libs/numeric/ublas/ (props changed)
branches/release/libs/numeric/ublas/doc/ (props changed)
branches/release/libs/program_options/ (props changed)
branches/release/libs/property_tree/ (props changed)
branches/release/libs/python/ (props changed)
branches/release/libs/range/ (props changed)
branches/release/libs/regex/ (props changed)
branches/release/libs/serialization/ (props changed)
branches/release/libs/serialization/doc/ (props changed)
branches/release/libs/serialization/example/ (props changed)
branches/release/libs/serialization/src/ (props changed)
branches/release/libs/serialization/test/test_diamond_complex.cpp (props changed)
branches/release/libs/serialization/vc7ide/ (props changed)
branches/release/libs/signals/ (props changed)
branches/release/libs/spirit/ (props changed)
branches/release/libs/spirit/classic/example/ (props changed)
branches/release/libs/spirit/doc/ (props changed)
branches/release/libs/spirit/example/ (props changed)
branches/release/libs/spirit/phoenix/ (props changed)
branches/release/libs/spirit/test/ (props changed)
branches/release/libs/spirit/test/qi/optional.cpp (props changed)
branches/release/libs/statechart/ (props changed)
branches/release/libs/static_assert/ (props changed)
branches/release/libs/system/ (props changed)
branches/release/libs/thread/ (props changed)
branches/release/libs/timer/ (props changed)
branches/release/libs/tr1/ (props changed)
branches/release/libs/type_traits/ (props changed)
branches/release/libs/type_traits/doc/ (props changed)
branches/release/libs/typeof/doc/typeof.qbk (props changed)
branches/release/libs/unordered/ (props changed)
branches/release/libs/utility/ (props changed)
branches/release/libs/utility/swap.html (props changed)
branches/release/libs/utility/swap/test/std_bitset.cpp (props changed)
branches/release/libs/utility/value_init.htm (props changed)
branches/release/libs/utility/value_init_test.cpp (props changed)
branches/release/libs/uuid/ (props changed)
branches/release/libs/wave/ (props changed)
branches/release/more/ (props changed)
branches/release/more/getting_started/ (props changed)
branches/release/rst.css (props changed)
branches/release/status/ (props changed)
branches/release/status/explicit-failures-markup.xml (props changed)
branches/release/tools/ (props changed)
branches/release/tools/bcp/ (props changed)
branches/release/tools/boostbook/ (props changed)
branches/release/tools/build/v2/ (props changed)
branches/release/tools/inspect/ (props changed)
branches/release/tools/quickbook/ (props changed)
branches/release/tools/regression/ (props changed)
branches/release/tools/regression/src/library_status.cpp (props changed)
branches/release/tools/release/ (props changed)
branches/release/tools/wave/ (props changed)
Text files modified:
branches/release/boost/archive/impl/basic_xml_grammar.hpp | 28 +------
branches/release/boost/proto/debug.hpp | 11 +-
branches/release/boost/spirit/home/classic/core/assert.hpp | 6
branches/release/boost/spirit/home/classic/core/composite/directives.hpp | 2
branches/release/boost/spirit/home/classic/dynamic/rule_alias.hpp | 2
branches/release/boost/spirit/home/classic/phoenix/closures.hpp | 4
branches/release/boost/spirit/home/classic/tree/common.hpp | 5
branches/release/boost/spirit/home/karma/detail/pass_container.hpp | 3
branches/release/boost/spirit/home/karma/nonterminal/rule.hpp | 2
branches/release/boost/spirit/home/lex/detail/sequence_function.hpp | 8 +
branches/release/boost/spirit/home/lex/lexer/action.hpp | 5
branches/release/boost/spirit/home/lex/lexer/char_token_def.hpp | 26 ++++++
branches/release/boost/spirit/home/lex/lexer/lexer.hpp | 31 +++++--
branches/release/boost/spirit/home/lex/lexer/lexertl/functor.hpp | 40 ++++++++--
branches/release/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp | 54 +++++++++----
branches/release/boost/spirit/home/lex/lexer/lexertl/iterator.hpp | 5 +
branches/release/boost/spirit/home/lex/lexer/lexertl/lexer.hpp | 57 ++++++++++++--
branches/release/boost/spirit/home/lex/lexer/lexertl/semantic_action_data.hpp | 8 +-
branches/release/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp | 52 +++++++++----
branches/release/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp | 7 +
branches/release/boost/spirit/home/lex/lexer/lexertl/token.hpp | 150 ++++++++++++++++++++++-----------------
branches/release/boost/spirit/home/lex/lexer/sequence.hpp | 7 +
branches/release/boost/spirit/home/lex/lexer/string_token_def.hpp | 33 +++++++-
branches/release/boost/spirit/home/lex/lexer/support_functions.hpp | 79 ++++++++++++++------
branches/release/boost/spirit/home/lex/lexer/token_def.hpp | 25 ++++-
branches/release/boost/spirit/home/lex/lexer_type.hpp | 10 +-
branches/release/boost/spirit/home/lex/qi.hpp | 1
branches/release/boost/spirit/home/lex/reference.hpp | 5
branches/release/boost/spirit/home/qi/detail/construct.hpp | 22 +++++
branches/release/boost/spirit/home/qi/nonterminal/rule.hpp | 2
branches/release/boost/spirit/home/support/adapt_adt_attributes.hpp | 6
branches/release/boost/spirit/home/support/common_terminals.hpp | 1
branches/release/boost/spirit/home/support/container.hpp | 2
branches/release/boost/spirit/home/support/detail/hold_any.hpp | 6 +
branches/release/boost/spirit/home/support/detail/lexer/parser/parser.hpp | 30 ++++----
branches/release/boost/spirit/home/support/detail/lexer/parser/tree/node.hpp | 4
branches/release/boost/spirit/home/support/detail/lexer/rules.hpp | 20 +++++
branches/release/boost/spirit/home/support/detail/math/detail/fp_traits.hpp | 3
branches/release/libs/serialization/src/basic_xml_grammar.ipp | 16 ++--
branches/release/libs/serialization/src/xml_grammar.cpp | 2
branches/release/libs/serialization/src/xml_wgrammar.cpp | 2
branches/release/libs/spirit/classic/example/fundamental/ast_calc.cpp | 20 ++--
branches/release/libs/spirit/classic/example/fundamental/distinct/distinct_parser.cpp | 8 +-
branches/release/libs/spirit/classic/example/fundamental/distinct/distinct_parser_dynamic.cpp | 8 +-
branches/release/libs/spirit/classic/example/fundamental/error_handling.cpp | 4
branches/release/libs/spirit/classic/example/fundamental/more_calculators/ast_calc2.cpp | 19 ++--
branches/release/libs/spirit/classic/example/fundamental/no_actions.cpp | 6
branches/release/libs/spirit/classic/example/fundamental/parse_tree_calc1.cpp | 13 +-
branches/release/libs/spirit/classic/example/intermediate/lazy_parser.cpp | 6
branches/release/libs/spirit/classic/example/techniques/epsilon.cpp | 6
branches/release/libs/spirit/classic/example/techniques/multiple_scanners.cpp | 3
branches/release/libs/spirit/classic/example/techniques/no_rules/no_rule1.cpp | 3
branches/release/libs/spirit/classic/example/techniques/no_rules/no_rule2.cpp | 3
branches/release/libs/spirit/classic/example/techniques/no_rules/no_rule3.cpp | 3
branches/release/libs/spirit/classic/example/techniques/right_recursion.cpp | 17 ++--
branches/release/libs/spirit/classic/example/techniques/typeof.cpp | 3
branches/release/libs/spirit/doc/lex/concepts.qbk | 11 +-
branches/release/libs/spirit/doc/lex/lexer_primitives.qbk | 2
branches/release/libs/spirit/doc/qi/auto.qbk | 1
branches/release/libs/spirit/doc/spirit2.qbk | 4
branches/release/libs/spirit/doc/what_s_new.qbk | 62 ++++++++++++++++
branches/release/libs/spirit/example/karma/escaped_string.cpp | 2
branches/release/libs/spirit/example/lex/Jamfile | 2
branches/release/libs/spirit/example/qi/Jamfile | 2
branches/release/libs/spirit/example/qi/reference.cpp | 5 +
branches/release/libs/spirit/example/scheme/output/sexpr.hpp | 2
branches/release/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp | 26 ++++++
branches/release/libs/spirit/test/Jamfile | 6 +
branches/release/libs/spirit/test/karma/bool.cpp | 2
branches/release/libs/spirit/test/lex/auto_switch_lexerstate.cpp | 4
branches/release/libs/spirit/test/lex/regression007.cpp | 20 +++--
branches/release/libs/spirit/test/lex/regression008.cpp | 18 ++-
branches/release/libs/spirit/test/lex/regression009.cpp | 4
branches/release/libs/spirit/test/lex/regression010.cpp | 5
branches/release/libs/spirit/test/qi/alternative.cpp | 11 +-
75 files changed, 731 insertions(+), 362 deletions(-)
Modified: branches/release/boost/archive/impl/basic_xml_grammar.hpp
==============================================================================
--- branches/release/boost/archive/impl/basic_xml_grammar.hpp (original)
+++ branches/release/boost/archive/impl/basic_xml_grammar.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -55,26 +55,8 @@
# pragma warning (disable : 4786) // too long name, harmless warning
#endif
-//#define BOOST_SPIRIT_DEBUG
-#include <boost/spirit/core/non_terminal/rule.hpp>
-
-// the following hack is to evade a bogus error generated by using the
-// word "arg" when bind.hpp has been included
-#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
-#define arg xarg
-#endif
-
-// spirit stuff
-#if (defined __BORLANDC__) && (__BORLANDC__ < 0x593) \
- || (defined _MSC_VER) && (_MSC_VER <= 1300)
-#include <boost/spirit/utility/chset.hpp>
-#else
+#include <boost/spirit/include/classic_rule.hpp>
#include <boost/spirit/include/classic_chset.hpp>
-#endif
-
-#if BOOST_WORKAROUND(BOOST_MSVC, <= 1200)
-#undef arg
-#endif
#include <boost/archive/basic_archive.hpp>
#include <boost/serialization/tracking.hpp>
@@ -97,12 +79,12 @@
private:
typedef BOOST_DEDUCED_TYPENAME std::basic_istream<CharType> IStream;
typedef BOOST_DEDUCED_TYPENAME std::basic_string<CharType> StringType;
- typedef BOOST_DEDUCED_TYPENAME boost::spirit::chset<CharType> chset_t;
- typedef BOOST_DEDUCED_TYPENAME boost::spirit::chlit<CharType> chlit_t;
- typedef BOOST_DEDUCED_TYPENAME boost::spirit::scanner<
+ typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::chset<CharType> chset_t;
+ typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::chlit<CharType> chlit_t;
+ typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::scanner<
BOOST_DEDUCED_TYPENAME std::basic_string<CharType>::iterator
> scanner_t;
- typedef BOOST_DEDUCED_TYPENAME boost::spirit::rule<scanner_t> rule_t;
+ typedef BOOST_DEDUCED_TYPENAME boost::spirit::classic::rule<scanner_t> rule_t;
// Start grammar definition
rule_t
Reference,
Modified: branches/release/boost/proto/debug.hpp
==============================================================================
--- branches/release/boost/proto/debug.hpp (original)
+++ branches/release/boost/proto/debug.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -9,9 +9,7 @@
#ifndef BOOST_PROTO_DEBUG_HPP_EAN_12_31_2006
#define BOOST_PROTO_DEBUG_HPP_EAN_12_31_2006
-#include <iomanip>
#include <iostream>
-#include <typeinfo>
#include <boost/preprocessor/stringize.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/proto/proto_fwd.hpp>
@@ -142,7 +140,8 @@
{
using namespace hidden_detail_;
typedef typename tag_of<Expr>::type tag;
- this->sout_ << std::setw(this->depth_) << (this->first_? "" : ", ");
+ this->sout_.width(this->depth_);
+ this->sout_ << (this->first_? "" : ", ");
this->sout_ << tag() << "(" << proto::value(expr) << ")\n";
this->first_ = false;
}
@@ -152,11 +151,13 @@
{
using namespace hidden_detail_;
typedef typename tag_of<Expr>::type tag;
- this->sout_ << std::setw(this->depth_) << (this->first_? "" : ", ");
+ this->sout_.width(this->depth_);
+ this->sout_ << (this->first_? "" : ", ");
this->sout_ << tag() << "(\n";
display_expr display(this->sout_, this->depth_ + 4);
fusion::for_each(expr, display);
- this->sout_ << std::setw(this->depth_) << "" << ")\n";
+ this->sout_.width(this->depth_);
+ this->sout_ << "" << ")\n";
this->first_ = false;
}
Modified: branches/release/boost/spirit/home/classic/core/assert.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/core/assert.hpp (original)
+++ branches/release/boost/spirit/home/classic/core/assert.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -17,7 +17,7 @@
// BOOST_SPIRIT_ASSERT is used throughout the framework. It can be
// overridden by the user. If BOOST_SPIRIT_ASSERT_EXCEPTION is defined,
// then that will be thrown, otherwise, BOOST_SPIRIT_ASSERT simply turns
-// into a plain assert()
+// into a plain BOOST_ASSERT()
//
///////////////////////////////////////////////////////////////////////////////
#if !defined(BOOST_SPIRIT_ASSERT)
@@ -30,8 +30,8 @@
BOOST_SPIRIT_ASSERT_EXCEPTION(f "(" #l "): " #x)); } while(0)
#define BOOST_SPIRIT_ASSERT(x) BOOST_SPIRIT_ASSERT_AUX(__FILE__, __LINE__, x)
#else
- #include <cassert>
- #define BOOST_SPIRIT_ASSERT(x) assert(x)
+ #include <boost/assert.hpp>
+ #define BOOST_SPIRIT_ASSERT(x) BOOST_ASSERT(x)
#endif
#endif // !defined(BOOST_SPIRIT_ASSERT)
Modified: branches/release/boost/spirit/home/classic/core/composite/directives.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/core/composite/directives.hpp (original)
+++ branches/release/boost/spirit/home/classic/core/composite/directives.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -364,7 +364,7 @@
if (l || r)
{
- if (l.length() < r.length() && l || !r)
+ if ((l.length() < r.length() && l) || !r)
{
scan.first = save;
return l;
Modified: branches/release/boost/spirit/home/classic/dynamic/rule_alias.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/dynamic/rule_alias.hpp (original)
+++ branches/release/boost/spirit/home/classic/dynamic/rule_alias.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -60,7 +60,7 @@
ParserT const&
get() const
{
- assert(ptr != 0);
+ BOOST_ASSERT(ptr != 0);
return *ptr;
}
Modified: branches/release/boost/spirit/home/classic/phoenix/closures.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/phoenix/closures.hpp (original)
+++ branches/release/boost/spirit/home/classic/phoenix/closures.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -11,7 +11,7 @@
///////////////////////////////////////////////////////////////////////////////
#include <boost/spirit/home/classic/phoenix/actor.hpp>
-#include <cassert>
+#include <boost/assert.hpp>
#ifdef PHOENIX_THREADSAFE
#include <boost/thread/tss.hpp>
@@ -270,7 +270,7 @@
eval(TupleT const& /*args*/) const
{
using namespace std;
- assert(frame.get() != 0);
+ BOOST_ASSERT(frame.get() != 0);
return (*frame.get())[tuple_index<N>()];
}
Modified: branches/release/boost/spirit/home/classic/tree/common.hpp
==============================================================================
--- branches/release/boost/spirit/home/classic/tree/common.hpp (original)
+++ branches/release/boost/spirit/home/classic/tree/common.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -27,6 +27,7 @@
#include <boost/spirit/home/classic/namespace.hpp>
#include <boost/spirit/home/classic/core.hpp>
#include <boost/detail/iterator.hpp> // for boost::detail::iterator_traits
+#include <boost/assert.hpp>
#if defined(BOOST_SPIRIT_DEBUG) && \
(BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES)
@@ -462,7 +463,7 @@
{
// See docs: reduced_node_d cannot be used with a
// rule inside the [].
- assert(i->children.size() == 0);
+ BOOST_ASSERT(i->children.size() == 0);
c.insert(c.end(), i->value.begin(), i->value.end());
}
return node_t(c.begin(), c.end());
@@ -504,7 +505,7 @@
for (typename ContainerT::const_iterator i = nodes.begin();
i != i_end; ++i)
{
- assert(i->children.size() == 0);
+ BOOST_ASSERT(i->children.size() == 0);
c.insert(c.end(), i->value.begin(), i->value.end());
}
return node_t(c.begin(), c.end());
Modified: branches/release/boost/spirit/home/karma/detail/pass_container.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/detail/pass_container.hpp (original)
+++ branches/release/boost/spirit/home/karma/detail/pass_container.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -88,9 +88,10 @@
return true;
}
+ // This is for the case when the current element expects an attribute
// this is for the case when the current element expects an attribute
// which is a container itself, this element will get the rest of the
- // attribute container
+ // attribute container.
template <typename Component>
bool dispatch_attribute_element(Component const& component, mpl::true_) const
{
Modified: branches/release/boost/spirit/home/karma/nonterminal/rule.hpp
==============================================================================
--- branches/release/boost/spirit/home/karma/nonterminal/rule.hpp (original)
+++ branches/release/boost/spirit/home/karma/nonterminal/rule.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -181,7 +181,7 @@
// from an uninitialized one. Did you mean to refer to the right
// hand side rule instead of assigning from it? In this case you
// should write lhs = rhs.alias();
- BOOST_ASSERT(rhs.f);
+ BOOST_ASSERT(rhs.f && "Did you mean rhs.alias() instead of rhs?");
f = rhs.f;
name_ = rhs.name_;
Modified: branches/release/boost/spirit/home/lex/detail/sequence_function.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/detail/sequence_function.hpp (original)
+++ branches/release/boost/spirit/home/lex/detail/sequence_function.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -18,18 +18,20 @@
template <typename LexerDef, typename String>
struct sequence_collect_function
{
- sequence_collect_function(LexerDef& def_, String const& state_)
- : def(def_), state(state_) {}
+ sequence_collect_function(LexerDef& def_, String const& state_
+ , String const& targetstate_)
+ : def(def_), state(state_), targetstate(targetstate_) {}
template <typename Component>
bool operator()(Component const& component) const
{
- component.collect(def, state);
+ component.collect(def, state, targetstate);
return false; // execute for all sequence elements
}
LexerDef& def;
String const& state;
+ String const& targetstate;
private:
// silence MSVC warning C4512: assignment operator could not be generated
Modified: branches/release/boost/spirit/home/lex/lexer/action.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/action.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/action.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -29,11 +29,12 @@
: subject(subject), f(f) {}
template <typename LexerDef, typename String>
- void collect(LexerDef& lexdef, String const& state) const
+ 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);
+ subject.collect(lexdef, state, targetstate);
}
template <typename LexerDef>
Modified: branches/release/boost/spirit/home/lex/lexer/char_token_def.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/char_token_def.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/char_token_def.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -68,13 +68,31 @@
typedef typename CharEncoding::char_type char_type;
char_token_def(char_type ch)
- : ch(ch), unique_id_(std::size_t(~0)) {}
+ : ch(ch), unique_id_(std::size_t(~0)), token_state_(std::size_t(~0))
+ {}
template <typename LexerDef, typename String>
- void collect(LexerDef& lexdef, String const& state) const
+ void collect(LexerDef& lexdef, String const& state
+ , String const& targetstate) const
{
+ std::size_t state_id = lexdef.add_state(state.c_str());
+
+ // If the following assertion fires you are probably trying to use
+ // a single char_token_def instance in more than one lexer state.
+ // This is not possible. Please create a separate token_def instance
+ // from the same regular expression for each lexer state it needs
+ // to be associated with.
+ BOOST_ASSERT(
+ (std::size_t(~0) == token_state_ || state_id == token_state_) &&
+ "Can't use single char_token_def with more than one lexer state");
+
+ char_type const* target = targetstate.empty() ? 0 : targetstate.c_str();
+ if (target)
+ lexdef.add_state(target);
+
+ token_state_ = state_id;
unique_id_ = lexdef.add_token (state.c_str(), ch
- , static_cast<std::size_t>(ch));
+ , static_cast<std::size_t>(ch), target);
}
template <typename LexerDef>
@@ -82,9 +100,11 @@
std::size_t id() const { return static_cast<std::size_t>(ch); }
std::size_t unique_id() const { return unique_id_; }
+ std::size_t state() const { return token_state_; }
char_type ch;
mutable std::size_t unique_id_;
+ mutable std::size_t token_state_;
};
///////////////////////////////////////////////////////////////////////////
Modified: branches/release/boost/spirit/home/lex/lexer/lexer.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexer.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexer.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -121,7 +121,8 @@
{
if (id_type() == token_id)
token_id = static_cast<id_type>(c);
- def.def.add_token (def.state.c_str(), c, token_id);
+ def.def.add_token (def.state.c_str(), c, token_id
+ , def.targetstate.empty() ? 0 : def.targetstate.c_str());
return *this;
}
@@ -135,7 +136,8 @@
{
if (id_type() == token_id)
token_id = def.def.get_next_id();
- def.def.add_token (def.state.c_str(), s, token_id);
+ def.def.add_token (def.state.c_str(), s, token_id
+ , def.targetstate.empty() ? 0 : def.targetstate.c_str());
return *this;
}
@@ -213,7 +215,7 @@
template <typename TokenExpr>
void compile2pass(TokenExpr const& expr)
{
- expr.collect(def, state);
+ expr.collect(def, state, targetstate);
expr.add_actions(def);
}
@@ -225,9 +227,11 @@
compile2pass(compile<lex::domain>(expr));
}
- lexer_def_(LexerDef& def_, string_type const& state_)
+ lexer_def_(LexerDef& def_, string_type const& state_
+ , string_type const& targetstate_ = string_type())
: proto_base_type(terminal_type::make(alias()))
- , add(this_()), add_pattern(this_()), def(def_), state(state_)
+ , add(this_()), add_pattern(this_()), def(def_)
+ , state(state_), targetstate(targetstate_)
{}
// allow to switch states
@@ -235,9 +239,15 @@
{
return lexer_def_(def, state);
}
- lexer_def_ operator()(string_type const& state) const
+ lexer_def_ operator()(char_type const* state
+ , char_type const* targetstate) const
{
- return lexer_def_(def, state);
+ return lexer_def_(def, state, targetstate);
+ }
+ lexer_def_ operator()(string_type const& state
+ , string_type const& targetstate = string_type()) const
+ {
+ return lexer_def_(def, state, targetstate);
}
// allow to assign a token definition expression
@@ -261,6 +271,7 @@
private:
LexerDef& def;
string_type state;
+ string_type targetstate;
private:
// silence MSVC warning C4512: assignment operator could not be generated
@@ -329,7 +340,7 @@
// avoid warnings about using 'this' in constructor
lexer& this_() { return *this; }
- typename Lexer::id_type next_token_id;
+ std::size_t next_token_id; // has to be an integral type
public:
typedef Lexer lexer_type;
@@ -342,7 +353,7 @@
typedef std::basic_string<char_type> string_type;
lexer(unsigned int flags = match_flags::match_default
- , id_type first_id = min_token_id)
+ , id_type first_id = id_type(min_token_id))
: lexer_type(flags)
, next_token_id(first_id)
, self(this_(), lexer_type::initial_state())
@@ -360,7 +371,7 @@
{ return this->lexer_type::add_state(state); }
// create a unique token id
- id_type get_next_id() { return next_token_id++; }
+ id_type get_next_id() { return id_type(next_token_id++); }
lexer_def self; // allow for easy token definition
};
Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/functor.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/functor.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/functor.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -134,6 +134,8 @@
template <typename MultiPass>
static result_type& get_next(MultiPass& mp, result_type& result)
{
+ typedef typename result_type::id_type id_type;
+
shared& data = mp.shared()->ftor;
for(;;)
{
@@ -147,7 +149,11 @@
data.reset_value();
Iterator end = data.get_first();
std::size_t unique_id = boost::lexer::npos;
- std::size_t id = data.next(end, unique_id);
+ bool prev_bol = false;
+
+ // lexer matching might change state
+ std::size_t state = data.get_state();
+ std::size_t id = data.next(end, unique_id, prev_bol);
if (boost::lexer::npos == id) { // no match
#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
@@ -156,7 +162,7 @@
for (std::size_t i = 0; i < 10 && it != data.get_last(); ++it, ++i)
next += *it;
- std::cerr << "Not matched, in state: " << data.get_state()
+ std::cerr << "Not matched, in state: " << state
<< ", lookahead: >" << next << "<" << std::endl;
#endif
return result = result_type(0);
@@ -177,19 +183,21 @@
next += *it;
std::cerr << "Matched: " << id << ", in state: "
- << data.get_state() << ", string: >"
+ << state << ", string: >"
<< std::basic_string<char_type>(data.get_first(), end) << "<"
<< ", lookahead: >" << next << "<" << std::endl;
+ if (data.get_state() != state) {
+ std::cerr << "Switched to state: "
+ << data.get_state() << std::endl;
+ }
}
#endif
- // invoke_actions might change state, id, data.first_, and/or end
- std::size_t state = data.get_state();
-
// account for a possibly pending lex::more(), i.e. moving
// data.first_ back to the start of the previously matched token.
bool adjusted = data.adjust_start();
- // invoke attached semantic actions, if defined
+ // invoke attached semantic actions, if defined, might change
+ // state, id, data.first_, and/or end
BOOST_SCOPED_ENUM(pass_flags) pass =
data.invoke_actions(state, id, unique_id, end);
@@ -198,23 +206,35 @@
// using data.set_value(), advancing 'data.first_' past the
// matched sequence
assign_on_exit<Iterator> on_exit(data.get_first(), end);
- return result = result_type(id, state, data.get_value());
+ return result = result_type(id_type(id), state, data.get_value());
}
else if (pass_flags::pass_normal == pass) {
// return matched token, advancing 'data.first_' past the
// matched sequence
assign_on_exit<Iterator> on_exit(data.get_first(), end);
- return result = result_type(id, state, data.get_first(), end);
+ return result = result_type(id_type(id), state, data.get_first(), end);
}
else if (pass_flags::pass_fail == pass) {
+#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
+ std::cerr << "Matching forced to fail" << std::endl;
+#endif
// if the data.first_ got adjusted above, revert this adjustment
if (adjusted)
data.revert_adjust_start();
// one of the semantic actions signaled no-match
- return result = result_type(0);
+ data.reset_bol(prev_bol);
+ if (state != data.get_state())
+ continue; // retry matching if state has changed
+
+ // if the state is unchanged repeating the match wouldn't
+ // move the input forward, causing an infinite loop
+ return result = result_type(0);
}
+#if defined(BOOST_SPIRIT_LEXERTL_DEBUG)
+ std::cerr << "Token ignored, continuing matching" << std::endl;
+#endif
// if this token needs to be ignored, just repeat the matching,
// while starting right after the current match
data.get_first() = end;
Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/functor_data.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -25,12 +25,12 @@
///////////////////////////////////////////////////////////////////////
template <typename Iterator, typename HasActors, typename HasState
, typename TokenValue>
- struct data; // no default specialization
+ class data; // no default specialization
///////////////////////////////////////////////////////////////////////
// neither supports state, nor actors
template <typename Iterator, typename TokenValue>
- struct data<Iterator, mpl::false_, mpl::false_, TokenValue>
+ class data<Iterator, mpl::false_, mpl::false_, TokenValue>
{
protected:
typedef typename
@@ -98,7 +98,9 @@
// The following assertion fires most likely because you are
// using lexer semantic actions without using the actor_lexer
// as the base class for your token definition class.
- BOOST_ASSERT(false);
+ BOOST_ASSERT(false &&
+ "Are you using lexer semantic actions without using the "
+ "actor_lexer base?");
return it;
}
@@ -115,7 +117,9 @@
// The following assertion fires most likely because you are
// using lexer semantic actions without using the actor_lexer
// as the base class for your token definition class.
- BOOST_ASSERT(false);
+ BOOST_ASSERT(false &&
+ "Are you using lexer semantic actions without using the "
+ "actor_lexer base?");
}
bool adjust_start() { return false; }
void revert_adjust_start() {}
@@ -127,12 +131,14 @@
//
// This function does nothing as long as no semantic actions are
// used.
- bool lookahead(std::size_t id)
+ bool lookahead(std::size_t id, std::size_t state = std::size_t(~0))
{
// The following assertion fires most likely because you are
// using lexer semantic actions without using the actor_lexer
// as the base class for your token definition class.
- BOOST_ASSERT(false);
+ BOOST_ASSERT(false &&
+ "Are you using lexer semantic actions without using the "
+ "actor_lexer base?");
return false;
}
@@ -141,8 +147,10 @@
// The function next() tries to match the next token from the
// underlying input sequence.
- std::size_t next(Iterator& end, std::size_t& unique_id)
+ std::size_t next(Iterator& end, std::size_t& unique_id, bool& prev_bol)
{
+ prev_bol = bol_;
+
typedef basic_iterator_tokeniser<Iterator> tokenizer;
return tokenizer::next(state_machine_, bol_, end, last_
, unique_id);
@@ -169,6 +177,8 @@
bool has_value() const { return false; }
void reset_value() {}
+ void reset_bol(bool bol) { bol_ = bol; }
+
protected:
Iterator& first_;
Iterator last_;
@@ -184,10 +194,10 @@
};
///////////////////////////////////////////////////////////////////////
- // doesn't support lexer semantic actions
+ // doesn't support lexer semantic actions, but supports state
template <typename Iterator, typename TokenValue>
- struct data<Iterator, mpl::false_, mpl::true_, TokenValue>
- : data<Iterator, mpl::false_, mpl::false_, TokenValue>
+ class data<Iterator, mpl::false_, mpl::true_, TokenValue>
+ : public data<Iterator, mpl::false_, mpl::false_, TokenValue>
{
protected:
typedef data<Iterator, mpl::false_, mpl::false_, TokenValue> base_type;
@@ -236,8 +246,10 @@
// The function next() tries to match the next token from the
// underlying input sequence.
- std::size_t next(Iterator& end, std::size_t& unique_id)
+ std::size_t next(Iterator& end, std::size_t& unique_id, bool& prev_bol)
{
+ prev_bol = this->bol_;
+
typedef basic_iterator_tokeniser<Iterator> tokenizer;
return tokenizer::next(this->state_machine_, state_,
this->bol_, end, this->get_eoi(), unique_id);
@@ -257,8 +269,8 @@
///////////////////////////////////////////////////////////////////////
// does support lexer semantic actions, may support state
template <typename Iterator, typename HasState, typename TokenValue>
- struct data<Iterator, mpl::true_, HasState, TokenValue>
- : data<Iterator, mpl::false_, HasState, TokenValue>
+ class data<Iterator, mpl::true_, HasState, TokenValue>
+ : public data<Iterator, mpl::false_, HasState, TokenValue>
{
public:
typedef semantic_actions<Iterator, HasState, data>
@@ -285,7 +297,7 @@
: base_type(data_, first, last)
, actions_(data_.actions_), hold_()
, value_(iterator_range<Iterator>(first, last))
- , has_hold_(false), has_value_(false) {}
+ , has_value_(false), has_hold_(false) {}
// invoke attached semantic actions, if defined
BOOST_SCOPED_ENUM(pass_flags) invoke_actions(std::size_t state
@@ -323,11 +335,18 @@
// support function lex::lookahead. It can be used to implement
// lookahead for lexer engines not supporting constructs like flex'
// a/b (match a, but only when followed by b)
- bool lookahead(std::size_t id)
+ bool lookahead(std::size_t id, std::size_t state = std::size_t(~0))
{
- Iterator end = this->get_first();
+ Iterator end = end_;
std::size_t unique_id = boost::lexer::npos;
- return id == this->next(end, unique_id);
+ bool bol = this->bol_;
+
+ if (std::size_t(~0) == state)
+ state = this->state_;
+
+ typedef basic_iterator_tokeniser<Iterator> tokenizer;
+ return id == tokenizer::next(this->state_machine_, state,
+ bol, end, this->get_eoi(), unique_id);
}
// The adjust_start() and revert_adjust_start() are helper
@@ -383,7 +402,6 @@
data& operator= (data const&);
};
}
-
}}}}
#endif
Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/iterator.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/iterator.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/iterator.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -89,6 +89,11 @@
// create an end iterator usable for end of range checking
iterator() {}
+ // (wash): < mgaunard> T it; T it2 = ++it; doesn't ocmpile
+ // < mgaunard> this gets fixed by adding
+ iterator(const base_type& base)
+ : base_type(base) { }
+
// set the new required state for the underlying lexer object
std::size_t set_state(std::size_t state)
{
Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/lexer.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/lexer.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/lexer.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -25,6 +25,8 @@
#include <boost/spirit/home/support/detail/lexer/debug.hpp>
#endif
+#include <boost/foreach.hpp>
+
namespace boost { namespace spirit { namespace lex { namespace lexertl
{
///////////////////////////////////////////////////////////////////////////
@@ -145,9 +147,11 @@
class lexer
{
private:
- struct dummy { void true_() {}; };
+ struct dummy { void true_() {} };
typedef void (dummy::*safe_bool)();
+ static std::size_t const all_states_id = static_cast<std::size_t>(-2);
+
public:
operator safe_bool() const
{ return initialized_dfa_ ? &dummy::true_ : 0; }
@@ -156,6 +160,8 @@
char_type;
typedef std::basic_string<char_type> string_type;
+ typedef boost::lexer::basic_rules<char_type> basic_rules_type;
+
// Every lexer type to be used as a lexer for Spirit has to conform to
// a public interface .
typedef Token token_type;
@@ -215,18 +221,32 @@
public:
// interface for token definition management
std::size_t add_token(char_type const* state, char_type tokendef,
- std::size_t token_id)
+ std::size_t token_id, char_type const* targetstate)
{
add_state(state);
initialized_dfa_ = false;
- return rules_.add(state, detail::escape(tokendef), token_id, state);
+ if (state == all_states())
+ return rules_.add(state, detail::escape(tokendef), token_id, rules_.dot());
+
+ if (0 == targetstate)
+ targetstate = state;
+ else
+ add_state(targetstate);
+ return rules_.add(state, detail::escape(tokendef), token_id, targetstate);
}
std::size_t add_token(char_type const* state, string_type const& tokendef,
- std::size_t token_id)
+ std::size_t token_id, char_type const* targetstate)
{
add_state(state);
initialized_dfa_ = false;
- return rules_.add(state, tokendef, token_id, state);
+ if (state == all_states())
+ return rules_.add(state, tokendef, token_id, rules_.dot());
+
+ if (0 == targetstate)
+ targetstate = state;
+ else
+ add_state(targetstate);
+ return rules_.add(state, tokendef, token_id, targetstate);
}
// interface for pattern definition management
@@ -249,6 +269,9 @@
}
std::size_t add_state(char_type const* state)
{
+ if (state == all_states())
+ return all_states_id;
+
std::size_t stateid = rules_.state(state);
if (boost::lexer::npos == stateid) {
stateid = rules_.add_state(state);
@@ -260,20 +283,34 @@
{
return string_type(rules_.initial());
}
+ string_type all_states() const
+ {
+ return string_type(rules_.all_states());
+ }
// Register a semantic action with the given id
template <typename F>
- void add_action(id_type unique_id, std::size_t state, F act)
+ void add_action(std::size_t unique_id, std::size_t state, F act)
{
// If you see an error here stating add_action is not a member of
- // fusion::unused_type the you are probably having semantic actions
+ // fusion::unused_type then you are probably having semantic actions
// attached to at least one token in the lexer definition without
// using the lex::lexertl::actor_lexer<> as its base class.
typedef typename Functor::wrap_action_type wrapper_type;
- actions_.add_action(unique_id, state, wrapper_type::call(act));
+ if (state == all_states_id) {
+ // add the action to all known states
+ typedef typename
+ basic_rules_type::string_size_t_map::value_type
+ state_type;
+ BOOST_FOREACH(state_type const& s, rules_.statemap())
+ actions_.add_action(unique_id, s.second, wrapper_type::call(act));
+ }
+ else {
+ actions_.add_action(unique_id, state, wrapper_type::call(act));
+ }
}
// template <typename F>
-// void add_action(id_type unique_id, char_type const* state, F act)
+// void add_action(std::size_t unique_id, char_type const* state, F act)
// {
// typedef typename Functor::wrap_action_type wrapper_type;
// actions_.add_action(unique_id, add_state(state), wrapper_type::call(act));
@@ -304,7 +341,7 @@
// lexertl specific data
mutable boost::lexer::basic_state_machine<char_type> state_machine_;
boost::lexer::regex_flags flags_;
- boost::lexer::basic_rules<char_type> rules_;
+ basic_rules_type rules_;
typename Functor::semantic_actions_type actions_;
mutable bool initialized_dfa_;
Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/semantic_action_data.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/semantic_action_data.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/semantic_action_data.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -35,8 +35,8 @@
typedef boost::function<functor_type> functor_wrapper_type;
// add a semantic action function object
- template <typename Idtype, typename F>
- void add_action(Idtype unique_id, std::size_t, F act)
+ template <typename F>
+ void add_action(std::size_t unique_id, std::size_t, F act)
{
if (actions_.size() <= unique_id)
actions_.resize(unique_id + 1);
@@ -75,8 +75,8 @@
typedef boost::function<functor_type> functor_wrapper_type;
// add a semantic action function object
- template <typename Idtype, typename F>
- void add_action(Idtype unique_id, std::size_t state, F act)
+ template <typename F>
+ void add_action(std::size_t unique_id, std::size_t state, F act)
{
if (actions_.size() <= state)
actions_.resize(state + 1);
Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/static_functor_data.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -39,12 +39,12 @@
///////////////////////////////////////////////////////////////////////
template <typename Iterator, typename HasActors, typename HasState
, typename TokenValue>
- struct static_data; // no default specialization
+ class static_data; // no default specialization
///////////////////////////////////////////////////////////////////////
// doesn't support no state and no actors
template <typename Iterator, typename TokenValue>
- struct static_data<Iterator, mpl::false_, mpl::false_, TokenValue>
+ class static_data<Iterator, mpl::false_, mpl::false_, TokenValue>
{
protected:
typedef typename
@@ -117,7 +117,9 @@
// The following assertion fires most likely because you are
// using lexer semantic actions without using the actor_lexer
// as the base class for your token definition class.
- BOOST_ASSERT(false);
+ BOOST_ASSERT(false &&
+ "Are you using lexer semantic actions without using the "
+ "actor_lexer base?");
return it;
}
@@ -134,7 +136,9 @@
// The following assertion fires most likely because you are
// using lexer semantic actions without using the actor_lexer
// as the base class for your token definition class.
- BOOST_ASSERT(false);
+ BOOST_ASSERT(false &&
+ "Are you using lexer semantic actions without using the "
+ "actor_lexer base?");
}
bool adjust_start() { return false; }
void revert_adjust_start() {}
@@ -146,12 +150,14 @@
//
// This function does nothing as long as no semantic actions are
// used.
- bool lookahead(std::size_t id)
+ bool lookahead(std::size_t id, std::size_t state = std::size_t(~0))
{
// The following assertion fires most likely because you are
// using lexer semantic actions without using the actor_lexer
// as the base class for your token definition class.
- BOOST_ASSERT(false);
+ BOOST_ASSERT(false &&
+ "Are you using lexer semantic actions without using the "
+ "actor_lexer base?");
return false;
}
@@ -160,9 +166,11 @@
// The function next() tries to match the next token from the
// underlying input sequence.
- std::size_t next(Iterator& end, std::size_t& unique_id)
+ std::size_t next(Iterator& end, std::size_t& unique_id, bool& prev_bol)
{
- std::size_t state;
+ prev_bol = bol_;
+
+ std::size_t state = 0;
return next_token_(state, bol_, end, last_, unique_id);
}
@@ -187,6 +195,8 @@
bool has_value() const { return false; }
void reset_value() {}
+ void reset_bol(bool bol) { bol_ = bol; }
+
protected:
Iterator& first_;
Iterator last_;
@@ -202,10 +212,10 @@
};
///////////////////////////////////////////////////////////////////////
- // doesn't support no actors
+ // doesn't support no actors, but does support states
template <typename Iterator, typename TokenValue>
- struct static_data<Iterator, mpl::false_, mpl::true_, TokenValue>
- : static_data<Iterator, mpl::false_, mpl::false_, TokenValue>
+ class static_data<Iterator, mpl::false_, mpl::true_, TokenValue>
+ : public static_data<Iterator, mpl::false_, mpl::false_, TokenValue>
{
protected:
typedef static_data<Iterator, mpl::false_, mpl::false_, TokenValue> base_type;
@@ -257,8 +267,9 @@
// The function next() tries to match the next token from the
// underlying input sequence.
- std::size_t next(Iterator& end, std::size_t& unique_id)
+ std::size_t next(Iterator& end, std::size_t& unique_id, bool& prev_bol)
{
+ prev_bol = this->bol_;
return this->next_token_(state_, this->bol_, end, this->last_
, unique_id);
}
@@ -278,8 +289,8 @@
///////////////////////////////////////////////////////////////////////
// does support actors, but may have no state
template <typename Iterator, typename HasState, typename TokenValue>
- struct static_data<Iterator, mpl::true_, HasState, TokenValue>
- : static_data<Iterator, mpl::false_, HasState, TokenValue>
+ class static_data<Iterator, mpl::true_, HasState, TokenValue>
+ : public static_data<Iterator, mpl::false_, HasState, TokenValue>
{
public:
typedef semantic_actions<Iterator, HasState, static_data>
@@ -345,11 +356,17 @@
// support function lex::lookahead. It can be used to implement
// lookahead for lexer engines not supporting constructs like flex'
// a/b (match a, but only when followed by b)
- bool lookahead(std::size_t id)
+ bool lookahead(std::size_t id, std::size_t state = std::size_t(~0))
{
- Iterator end = this->first_;
+ Iterator end = end_;
std::size_t unique_id = boost::lexer::npos;
- return id == this->next(end, unique_id);
+ bool bol = this->bol_;
+
+ if (std::size_t(~0) == state)
+ state = this->state_;
+
+ return id == this->next_token_(
+ state, bol, end, this->last_, unique_id);
}
// The adjust_start() and revert_adjust_start() are helper
@@ -405,7 +422,6 @@
static_data& operator= (static_data const&);
};
}
-
}}}}
#endif
Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/static_lexer.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -112,7 +112,7 @@
class static_lexer
{
private:
- struct dummy { void true_() {}; };
+ struct dummy { void true_() {} };
typedef void (dummy::*safe_bool)();
public:
@@ -195,12 +195,13 @@
public:
// interface for token definition management
- std::size_t add_token (char_type const*, char_type, std::size_t)
+ std::size_t add_token (char_type const*, char_type, std::size_t
+ , char_type const*)
{
return unique_id_++;
}
std::size_t add_token (char_type const*, string_type const&
- , std::size_t)
+ , std::size_t, char_type const*)
{
return unique_id_++;
}
Modified: branches/release/boost/spirit/home/lex/lexer/lexertl/token.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/lexertl/token.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/lexertl/token.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -53,6 +53,8 @@
// by this token type.
// HasState A mpl::bool_ indicating, whether this token type
// should support lexer states.
+ // Idtype The type to use for the token id (defaults to
+ // std::size_t).
//
// It is possible to use other token types with the spirit::lex
// framework as well. If you plan to use a different type as your token
@@ -82,7 +84,7 @@
//
// and:
//
- // token(std::size_t id, std::size_t state,
+ // token(Idtype id, std::size_t state,
// iterator_type first, iterator_type last);
//
// where: id: token id
@@ -101,31 +103,33 @@
// Additionally, you will have to implement a couple of helper functions
// in the same namespace as the token type: a comparison operator==() to
// compare your token instances, a token_is_valid() function and different
- // construct() function overloads as described below.
+ // specializations of the Spirit customization point
+ // assign_to_attribute_from_value as shown below.
//
///////////////////////////////////////////////////////////////////////////
template <typename Iterator = char const*
, typename AttributeTypes = mpl::vector0<>
- , typename HasState = mpl::true_>
+ , typename HasState = mpl::true_
+ , typename Idtype = std::size_t>
struct token;
///////////////////////////////////////////////////////////////////////////
// This specialization of the token type doesn't contain any item data and
// doesn't support working with lexer states.
///////////////////////////////////////////////////////////////////////////
- template <typename Iterator>
- struct token<Iterator, lex::omit, mpl::false_>
+ template <typename Iterator, typename Idtype>
+ struct token<Iterator, lex::omit, mpl::false_, Idtype>
{
typedef Iterator iterator_type;
typedef mpl::false_ has_state;
- typedef std::size_t id_type;
+ typedef Idtype id_type;
typedef unused_type token_value_type;
// default constructed tokens correspond to EOI tokens
- token() : id_(boost::lexer::npos) {}
+ token() : id_(id_type(boost::lexer::npos)) {}
// construct an invalid token
- explicit token(int) : id_(0) {}
+ explicit token(int) : id_(id_type(0)) {}
token(id_type id, std::size_t) : id_(id) {}
@@ -135,8 +139,8 @@
#if defined(BOOST_SPIRIT_DEBUG)
token(id_type id, std::size_t, Iterator const& first
, Iterator const& last)
- : id_(id)
- , matched_(first, last)
+ : matched_(first, last)
+ , id_(id)
{}
#else
token(id_type id, std::size_t, Iterator const&, Iterator const&)
@@ -166,34 +170,29 @@
// constructed iterator_range
token& operator= (token const& rhs)
{
+ if (this != &rhs)
+ {
+ id_ = rhs.id_;
+ matched_ = rhs.matched_;
+ }
return *this;
}
#endif
std::pair<Iterator, Iterator> matched_;
#endif
-// works only starting MSVC V8
-#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1400)
- private:
- struct dummy { void true_() {}; };
- typedef void (dummy::*safe_bool)();
-
- public:
- operator safe_bool() const { return is_valid() ? &dummy::true_ : 0; }
-#endif
-
protected:
id_type id_; // token id, 0 if nothing has been matched
};
#if defined(BOOST_SPIRIT_DEBUG)
template <typename Char, typename Traits, typename Iterator
- , typename AttributeTypes, typename HasState>
+ , typename AttributeTypes, typename HasState, typename Idtype>
inline std::basic_ostream<Char, Traits>&
operator<< (std::basic_ostream<Char, Traits>& os
- , token<Iterator, AttributeTypes, HasState> const& t)
+ , token<Iterator, AttributeTypes, HasState, Idtype> const& t)
{
- if (t) {
+ if (t.is_valid()) {
Iterator end = t.matched_.second;
for (Iterator it = t.matched_.first; it != end; ++it)
os << *it;
@@ -209,12 +208,12 @@
// This specialization of the token type doesn't contain any item data but
// supports working with lexer states.
///////////////////////////////////////////////////////////////////////////
- template <typename Iterator>
- struct token<Iterator, lex::omit, mpl::true_>
- : token<Iterator, lex::omit, mpl::false_>
+ template <typename Iterator, typename Idtype>
+ struct token<Iterator, lex::omit, mpl::true_, Idtype>
+ : token<Iterator, lex::omit, mpl::false_, Idtype>
{
private:
- typedef token<Iterator, lex::omit, mpl::false_> base_type;
+ typedef token<Iterator, lex::omit, mpl::false_, Idtype> base_type;
public:
typedef typename base_type::id_type id_type;
@@ -242,6 +241,20 @@
std::size_t state() const { return state_; }
+#if defined(BOOST_SPIRIT_DEBUG) && BOOST_WORKAROUND(BOOST_MSVC, == 1600)
+ // workaround for MSVC10 which has problems copying a default
+ // constructed iterator_range
+ token& operator= (token const& rhs)
+ {
+ if (this != &rhs)
+ {
+ this->base_type::operator=(static_cast<base_type const&>(rhs));
+ state_ = rhs.state_;
+ }
+ return *this;
+ }
+#endif
+
protected:
std::size_t state_; // lexer state this token was matched in
};
@@ -254,7 +267,7 @@
namespace detail
{
///////////////////////////////////////////////////////////////////////
- // Metafunction to calculate the type of the variant data item to be
+ // Meta-function to calculate the type of the variant data item to be
// stored with each token instance.
//
// Note: The iterator pair needs to be the first type in the list of
@@ -305,15 +318,16 @@
{};
}
- template <typename Iterator, typename AttributeTypes, typename HasState>
- struct token : token<Iterator, lex::omit, HasState>
+ template <typename Iterator, typename AttributeTypes, typename HasState
+ , typename Idtype>
+ struct token : token<Iterator, lex::omit, HasState, Idtype>
{
private: // precondition assertions
#if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
BOOST_STATIC_ASSERT((mpl::is_sequence<AttributeTypes>::value ||
is_same<AttributeTypes, lex::omit>::value));
#endif
- typedef token<Iterator, lex::omit, HasState> base_type;
+ typedef token<Iterator, lex::omit, HasState, Idtype> base_type;
protected:
// If no additional token value types are given, the the token will
@@ -374,10 +388,11 @@
///////////////////////////////////////////////////////////////////////////
// tokens are considered equal, if their id's match (these are unique)
- template <typename Iterator, typename AttributeTypes, typename HasState>
+ template <typename Iterator, typename AttributeTypes, typename HasState
+ , typename Idtype>
inline bool
- operator== (token<Iterator, AttributeTypes, HasState> const& lhs,
- token<Iterator, AttributeTypes, HasState> const& rhs)
+ operator== (token<Iterator, AttributeTypes, HasState, Idtype> const& lhs,
+ token<Iterator, AttributeTypes, HasState, Idtype> const& rhs)
{
return lhs.id() == rhs.id();
}
@@ -387,13 +402,13 @@
// validate a token instance. It has to be defined in the same namespace
// as the token class itself to allow ADL to find it.
///////////////////////////////////////////////////////////////////////////
- template <typename Iterator, typename AttributeTypes, typename HasState>
+ template <typename Iterator, typename AttributeTypes, typename HasState
+ , typename Idtype>
inline bool
- token_is_valid(token<Iterator, AttributeTypes, HasState> const& t)
+ token_is_valid(token<Iterator, AttributeTypes, HasState, Idtype> const& t)
{
return t.is_valid();
}
-
}}}}
namespace boost { namespace spirit { namespace traits
@@ -407,12 +422,12 @@
// This is called from the parse function of token_def if the token_def
// has been defined to carry a special attribute type
template <typename Attribute, typename Iterator, typename AttributeTypes
- , typename HasState>
+ , typename HasState, typename Idtype>
struct assign_to_attribute_from_value<Attribute
- , lex::lexertl::token<Iterator, AttributeTypes, HasState> >
+ , lex::lexertl::token<Iterator, AttributeTypes, HasState, Idtype> >
{
static void
- call(lex::lexertl::token<Iterator, AttributeTypes, HasState> const& t
+ call(lex::lexertl::token<Iterator, AttributeTypes, HasState, Idtype> const& t
, Attribute& attr)
{
// The goal of this function is to avoid the conversion of the pair of
@@ -462,7 +477,7 @@
// tokenization.
typedef lex::lexertl::token<
- Iterator, AttributeTypes, HasState> token_type;
+ Iterator, AttributeTypes, HasState, Idtype> token_type;
const_cast<token_type&>(t).value() = attr; // re-assign value
}
else {
@@ -474,12 +489,13 @@
// These are called from the parse function of token_def if the token type
// has no special attribute type assigned
- template <typename Attribute, typename Iterator, typename HasState>
- struct assign_to_attribute_from_value<
- Attribute, lex::lexertl::token<Iterator, mpl::vector0<>, HasState> >
+ template <typename Attribute, typename Iterator, typename HasState
+ , typename Idtype>
+ struct assign_to_attribute_from_value<Attribute
+ , lex::lexertl::token<Iterator, mpl::vector0<>, HasState, Idtype> >
{
static void
- call(lex::lexertl::token<Iterator, mpl::vector0<>, HasState> const& t
+ call(lex::lexertl::token<Iterator, mpl::vector0<>, HasState, Idtype> const& t
, Attribute& attr)
{
// The default type returned by the token_def parser component (if
@@ -490,12 +506,13 @@
};
// same as above but using mpl::vector<> instead of mpl::vector0<>
- template <typename Attribute, typename Iterator, typename HasState>
- struct assign_to_attribute_from_value<
- Attribute, lex::lexertl::token<Iterator, mpl::vector<>, HasState> >
+ template <typename Attribute, typename Iterator, typename HasState
+ , typename Idtype>
+ struct assign_to_attribute_from_value<Attribute
+ , lex::lexertl::token<Iterator, mpl::vector<>, HasState, Idtype> >
{
static void
- call(lex::lexertl::token<Iterator, mpl::vector<>, HasState> const& t
+ call(lex::lexertl::token<Iterator, mpl::vector<>, HasState, Idtype> const& t
, Attribute& attr)
{
// The default type returned by the token_def parser component (if
@@ -509,12 +526,13 @@
// has been explicitly omitted (i.e. no attribute value is used), which
// essentially means that every attribute gets initialized using default
// constructed values.
- template <typename Attribute, typename Iterator, typename HasState>
- struct assign_to_attribute_from_value<
- Attribute, lex::lexertl::token<Iterator, lex::omit, HasState> >
+ template <typename Attribute, typename Iterator, typename HasState
+ , typename Idtype>
+ struct assign_to_attribute_from_value<Attribute
+ , lex::lexertl::token<Iterator, lex::omit, HasState, Idtype> >
{
static void
- call(lex::lexertl::token<Iterator, lex::omit, HasState> const& t
+ call(lex::lexertl::token<Iterator, lex::omit, HasState, Idtype> const& t
, Attribute& attr)
{
// do nothing
@@ -522,20 +540,21 @@
};
// This is called from the parse function of lexer_def_
- template <typename Iterator, typename AttributeTypes, typename HasState>
+ template <typename Iterator, typename AttributeTypes, typename HasState
+ , typename Idtype_, typename Idtype>
struct assign_to_attribute_from_value<
- fusion::vector2<std::size_t, iterator_range<Iterator> >
- , lex::lexertl::token<Iterator, AttributeTypes, HasState> >
+ fusion::vector2<Idtype_, iterator_range<Iterator> >
+ , lex::lexertl::token<Iterator, AttributeTypes, HasState, Idtype> >
{
static void
- call(lex::lexertl::token<Iterator, AttributeTypes, HasState> const& t
- , fusion::vector2<std::size_t, iterator_range<Iterator> >& attr)
+ call(lex::lexertl::token<Iterator, AttributeTypes, HasState, Idtype> const& t
+ , fusion::vector2<Idtype_, iterator_range<Iterator> >& attr)
{
// The type returned by the lexer_def_ parser components is a
// fusion::vector containing the token id of the matched token
// and the pair of iterators to the matched character sequence.
typedef iterator_range<Iterator> iterpair_type;
- typedef fusion::vector2<std::size_t, iterator_range<Iterator> >
+ typedef fusion::vector2<Idtype_, iterator_range<Iterator> >
attribute_type;
iterpair_type const& ip = get<iterpair_type>(t.value());
@@ -546,20 +565,21 @@
///////////////////////////////////////////////////////////////////////////
// Overload debug output for a single token, this integrates lexer tokens
// with Qi's simple_trace debug facilities
- template <typename Iterator, typename Attribute, typename HasState>
- struct token_printer_debug<lex::lexertl::token<Iterator, Attribute, HasState> >
+ template <typename Iterator, typename Attribute, typename HasState
+ , typename Idtype>
+ struct token_printer_debug<
+ lex::lexertl::token<Iterator, Attribute, HasState, Idtype> >
{
- typedef lex::lexertl::token<Iterator, Attribute, HasState> token_type;
+ typedef lex::lexertl::token<Iterator, Attribute, HasState, Idtype> token_type;
template <typename Out>
static void print(Out& out, token_type const& val)
{
- out << '<';
+ out << '[';
spirit::traits::print_token(out, val.value());
- out << '>';
+ out << ']';
}
};
-
}}}
#endif
Modified: branches/release/boost/spirit/home/lex/lexer/sequence.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/sequence.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/sequence.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -40,9 +40,12 @@
: elements(elements) {}
template <typename LexerDef, typename String>
- void collect(LexerDef& lexdef, String const& state) const
+ void collect(LexerDef& lexdef, String const& state
+ , String const& targetstate) const
{
- detail::sequence_collect_function<LexerDef, String> f (lexdef, state);
+ typedef detail::sequence_collect_function<LexerDef, String>
+ collect_function_type;
+ collect_function_type f (lexdef, state, targetstate);
fusion::any(elements, f);
}
Modified: branches/release/boost/spirit/home/lex/lexer/string_token_def.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/string_token_def.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/string_token_def.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -62,15 +62,36 @@
typedef std::basic_string<char_type> string_type;
string_token_def(typename add_reference<String>::type str)
- : str_(str), id_(std::size_t(~0)) {}
-
- template <typename LexerDef, typename State>
- void collect(LexerDef& lexdef, State const& state) const
+ : str_(str), id_(std::size_t(~0)), unique_id_(std::size_t(~0))
+ , token_state_(std::size_t(~0))
+ {}
+
+ template <typename LexerDef, typename String_>
+ void collect(LexerDef& lexdef, String_ const& state
+ , String_ const& targetstate) const
{
+ std::size_t state_id = lexdef.add_state(state.c_str());
+
+ // If the following assertion fires you are probably trying to use
+ // a single string_token_def instance in more than one lexer state.
+ // This is not possible. Please create a separate token_def instance
+ // from the same regular expression for each lexer state it needs
+ // to be associated with.
+ BOOST_ASSERT(
+ (std::size_t(~0) == token_state_ || state_id == token_state_) &&
+ "Can't use single string_token_def with more than one lexer state");
+
+ char_type const* target = targetstate.empty() ? 0 : targetstate.c_str();
+ if (target)
+ lexdef.add_state(target);
+
+ token_state_ = state_id;
+
typedef typename LexerDef::id_type id_type;
if (std::size_t(~0) == id_)
id_ = lexdef.get_next_id();
- unique_id_ = lexdef.add_token (state.c_str(), str_, id_);
+
+ unique_id_ = lexdef.add_token (state.c_str(), str_, id_, target);
}
template <typename LexerDef>
@@ -78,10 +99,12 @@
std::size_t id() const { return id_; }
std::size_t unique_id() const { return unique_id_; }
+ std::size_t state() const { return token_state_; }
string_type str_;
mutable std::size_t id_;
mutable std::size_t unique_id_;
+ mutable std::size_t token_state_;
};
///////////////////////////////////////////////////////////////////////////
Modified: branches/release/boost/spirit/home/lex/lexer/support_functions.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/support_functions.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/support_functions.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -22,12 +22,12 @@
namespace boost { namespace spirit { namespace lex
{
///////////////////////////////////////////////////////////////////////////
- // The function less() is used by the implementation of the support
- // function lex::less(). Its functionality is equivalent to flex' function
- // yyless(): it returns an iterator positioned to the nth input character
- // beyond the current start iterator (i.e. by assigning the return value to
- // the placeholder '_end' it is possible to return all but the first n
- // characters of the current token back to the input stream.
+ // The function object less_type is used by the implementation of the
+ // support function lex::less(). Its functionality is equivalent to flex'
+ // function yyless(): it returns an iterator positioned to the nth input
+ // character beyond the current start iterator (i.e. by assigning the
+ // return value to the placeholder '_end' it is possible to return all but
+ // the first n characters of the current token back to the input stream.
//
// This Phoenix actor is invoked whenever the function lex::less(n) is
// used inside a lexer semantic action:
@@ -82,13 +82,13 @@
}
///////////////////////////////////////////////////////////////////////////
- // The function more() is used by the implemention of the support function
- // lex::more(). Its functionality is equivalent to flex' function yymore():
- // it tells the lexer that the next time it matches a rule, the
- // corresponding token should be appended onto the current token value
- // rather than replacing it.
+ // The function object more_type is used by the implementation of the
+ // support function lex::more(). Its functionality is equivalent to flex'
+ // function yymore(): it tells the lexer that the next time it matches a
+ // rule, the corresponding token should be appended onto the current token
+ // value rather than replacing it.
//
- // This Phoenix actor is invoked whenever the function lex::less(n) is
+ // This Phoenix actor is invoked whenever the function lex::more(n) is
// used inside a lexer semantic action:
//
// lex::token_def<> identifier = "[a-zA-Z_][a-zA-Z0-9_]*";
@@ -122,7 +122,14 @@
}
///////////////////////////////////////////////////////////////////////////
- template <typename Actor>
+ // The function object lookahead_type is used by the implementation of the
+ // support function lex::lookahead(). Its functionality is needed to
+ // emulate the flex' lookahead operator a/b. Use lex::lookahead() inside
+ // of lexer semantic actions to test whether the argument to this function
+ // matches the current look ahead input. lex::lookahead() can be used with
+ // either a token id or a token_def instance as its argument. It returns
+ // a bool indicating whether the look ahead has been matched.
+ template <typename IdActor, typename StateActor>
struct lookahead_type
{
typedef mpl::true_ no_nullary;
@@ -136,32 +143,56 @@
template <typename Env>
bool eval(Env const& env) const
{
- return fusion::at_c<4>(env.args()).lookahead(actor_());
+ return fusion::at_c<4>(env.args()).
+ lookahead(id_actor_(), state_actor_());
}
- lookahead_type(Actor const& actor)
- : actor_(actor) {}
+ lookahead_type(IdActor const& id_actor, StateActor const& state_actor)
+ : id_actor_(id_actor), state_actor_(state_actor) {}
- Actor actor_;
+ IdActor id_actor_;
+ StateActor state_actor_;
};
+ // The function lex::lookahead() is used to create a Phoenix actor
+ // allowing to implement functionality similar to flex' lookahead operator
+ // a/b.
template <typename T>
inline phoenix::actor<
- lookahead_type<typename phoenix::as_actor<T>::type> >
+ lookahead_type<
+ typename phoenix::as_actor<T>::type
+ , typename phoenix::as_actor<std::size_t>::type> >
lookahead(T const& id)
{
- typedef typename phoenix::as_actor<T>::type actor_type;
- return lookahead_type<actor_type>(phoenix::as_actor<T>::convert(id));
+ typedef typename phoenix::as_actor<T>::type id_actor_type;
+ typedef typename phoenix::as_actor<std::size_t>::type state_actor_type;
+
+ return lookahead_type<id_actor_type, state_actor_type>(
+ phoenix::as_actor<T>::convert(id),
+ phoenix::as_actor<std::size_t>::convert(std::size_t(~0)));
}
template <typename Attribute, typename Char, typename Idtype>
inline phoenix::actor<
- lookahead_type<typename phoenix::as_actor<Idtype>::type> >
+ lookahead_type<
+ typename phoenix::as_actor<Idtype>::type
+ , typename phoenix::as_actor<std::size_t>::type> >
lookahead(token_def<Attribute, Char, Idtype> const& tok)
{
- typedef typename phoenix::as_actor<Idtype>::type actor_type;
- return lookahead_type<actor_type>(
- phoenix::as_actor<Idtype>::convert(tok.id()));
+ typedef typename phoenix::as_actor<Idtype>::type id_actor_type;
+ typedef typename phoenix::as_actor<std::size_t>::type state_actor_type;
+
+ std::size_t state = tok.state();
+
+ // The following assertion fires if you pass a token_def instance to
+ // lex::lookahead without first associating this instance with the
+ // lexer.
+ BOOST_ASSERT(std::size_t(~0) != state &&
+ "token_def instance not associated with lexer yet");
+
+ return lookahead_type<id_actor_type, state_actor_type>(
+ phoenix::as_actor<Idtype>::convert(tok.id()),
+ phoenix::as_actor<std::size_t>::convert(state));
}
///////////////////////////////////////////////////////////////////////////
Modified: branches/release/boost/spirit/home/lex/lexer/token_def.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer/token_def.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer/token_def.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -58,8 +58,10 @@
typedef typename proto::terminal<reference_>::type terminal_type;
typedef proto::extends<terminal_type, token_def> proto_base_type;
+ static std::size_t const all_states_id = static_cast<std::size_t>(-2);
+
public:
- // Qi interface: metafunction calculating parser return type
+ // Qi interface: meta-function calculating parser return type
template <typename Context, typename Iterator>
struct attribute
{
@@ -97,7 +99,9 @@
BOOST_ASSERT(std::size_t(~0) != token_state_);
token_type const& t = *first;
- if (token_id_ == t.id() && token_state_ == t.state()) {
+ if (token_id_ == t.id() &&
+ (all_states_id == token_state_ || token_state_ == t.state()))
+ {
spirit::traits::assign_to(t, attr);
++first;
return true;
@@ -119,7 +123,8 @@
// Lex interface: collect token definitions and put it into the
// provided lexer def
template <typename LexerDef, typename String>
- void collect(LexerDef& lexdef, String const& state) const
+ void collect(LexerDef& lexdef, String const& state
+ , String const& targetstate) const
{
std::size_t state_id = lexdef.add_state(state.c_str());
@@ -128,7 +133,13 @@
// is not possible. Please create a separate token_def instance
// from the same regular expression for each lexer state it needs
// to be associated with.
- BOOST_ASSERT(std::size_t(~0) == token_state_ || state_id == token_state_);
+ BOOST_ASSERT(
+ (std::size_t(~0) == token_state_ || state_id == token_state_) &&
+ "Can't use single token_def with more than one lexer state");
+
+ char_type const* target = targetstate.empty() ? 0 : targetstate.c_str();
+ if (target)
+ lexdef.add_state(target);
token_state_ = state_id;
if (0 == token_id_)
@@ -136,11 +147,11 @@
if (0 == def_.which()) {
unique_id_ = lexdef.add_token(state.c_str()
- , get<string_type>(def_), token_id_);
+ , get<string_type>(def_), token_id_, target);
}
else {
unique_id_ = lexdef.add_token(state.c_str()
- , get<char_type>(def_), token_id_);
+ , get<char_type>(def_), token_id_, target);
}
}
@@ -166,7 +177,7 @@
explicit token_def(char_type def_, Idtype id_ = Idtype())
: proto_base_type(terminal_type::make(reference_(*this)))
, def_(def_)
- , token_id_(std::size_t(Idtype() == id_ ? def_ : id_))
+ , token_id_(Idtype() == id_ ? Idtype(def_) : id_)
, unique_id_(std::size_t(~0)), token_state_(std::size_t(~0)) {}
explicit token_def(string_type const& def_, Idtype id_ = Idtype())
Modified: branches/release/boost/spirit/home/lex/lexer_type.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/lexer_type.hpp (original)
+++ branches/release/boost/spirit/home/lex/lexer_type.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -23,11 +23,13 @@
typedef Derived derived_type;
typedef lex::domain domain;
- // Requirement: l.collect(def, state) -> void
+ // Requirement: l.collect(def, state, targetstate) -> void
//
- // l: a lexer component
- // def: token definition container
- // state: lexer state this token definition needs to be added to
+ // l: a lexer component
+ // def: token definition container
+ // state: lexer state this token definition needs to be added to
+ // targetstate: an optional lexer state the lexer should be switched
+ // into after matching this token
Derived const& derived() const
{
Modified: branches/release/boost/spirit/home/lex/qi.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/qi.hpp (original)
+++ branches/release/boost/spirit/home/lex/qi.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -13,5 +13,6 @@
#include <boost/spirit/home/lex/qi/state_switcher.hpp>
#include <boost/spirit/home/lex/qi/in_state.hpp>
#include <boost/spirit/home/lex/qi/plain_token.hpp>
+#include <boost/spirit/home/lex/qi/plain_tokenid.hpp>
#endif
Modified: branches/release/boost/spirit/home/lex/reference.hpp
==============================================================================
--- branches/release/boost/spirit/home/lex/reference.hpp (original)
+++ branches/release/boost/spirit/home/lex/reference.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -35,9 +35,10 @@
: qi::reference<Subject>(subject) {}
template <typename LexerDef, typename String>
- void collect(LexerDef& lexdef, String const& state) const
+ void collect(LexerDef& lexdef, String const& state
+ , String const& targetstate) const
{
- this->ref.get().collect(lexdef, state);
+ this->ref.get().collect(lexdef, state, targetstate);
}
template <typename LexerDef>
Modified: branches/release/boost/spirit/home/qi/detail/construct.hpp
==============================================================================
--- branches/release/boost/spirit/home/qi/detail/construct.hpp (original)
+++ branches/release/boost/spirit/home/qi/detail/construct.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -33,6 +33,26 @@
}
};
+ template <typename Iterator>
+ struct assign_to_attribute_from_iterators<signed char, Iterator>
+ {
+ static void
+ call(Iterator const& first, Iterator const& last, signed char& attr)
+ {
+ attr = *first;
+ }
+ };
+
+ template <typename Iterator>
+ struct assign_to_attribute_from_iterators<unsigned char, Iterator>
+ {
+ static void
+ call(Iterator const& first, Iterator const& last, unsigned char& attr)
+ {
+ attr = *first;
+ }
+ };
+
// wchar_t is intrinsic
template <typename Iterator>
struct assign_to_attribute_from_iterators<wchar_t, Iterator>
@@ -61,7 +81,7 @@
struct assign_to_attribute_from_iterators<bool, Iterator>
{
static void
- call(Iterator const& first, Iterator const& last, char& attr)
+ call(Iterator const& first, Iterator const& last, bool& attr)
{
Iterator first_ = first;
qi::parse(first_, last, bool_, attr);
Modified: branches/release/boost/spirit/home/qi/nonterminal/rule.hpp
==============================================================================
--- branches/release/boost/spirit/home/qi/nonterminal/rule.hpp (original)
+++ branches/release/boost/spirit/home/qi/nonterminal/rule.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -173,7 +173,7 @@
// from an uninitialized one. Did you mean to refer to the right
// hand side rule instead of assigning from it? In this case you
// should write lhs = rhs.alias();
- BOOST_ASSERT(rhs.f);
+ BOOST_ASSERT(rhs.f && "Did you mean rhs.alias() instead of rhs?");
f = rhs.f;
name_ = rhs.name_;
Modified: branches/release/boost/spirit/home/support/adapt_adt_attributes.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/adapt_adt_attributes.hpp (original)
+++ branches/release/boost/spirit/home/support/adapt_adt_attributes.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -30,7 +30,7 @@
template <typename T, int N, bool Const>
struct container_value<fusion::extension::adt_attribute_proxy<T, N, Const> >
: container_value<
- typename fusion::extension::access::adt_attribute_proxy<
+ typename fusion::extension::adt_attribute_proxy<
T, N, Const
>::type
>
@@ -63,7 +63,7 @@
{};
///////////////////////////////////////////////////////////////////////////
- template <typename T, int N, bool Const, typename Val>
+ template <typename T, int N, typename Val>
struct assign_to_attribute_from_value<
fusion::extension::adt_attribute_proxy<T, N, false>
, Val>
@@ -108,7 +108,7 @@
val = attr;
}
static void
- fail(fusion::extension::access::adt_attribute_proxy<T, N, Const>&)
+ fail(fusion::extension::adt_attribute_proxy<T, N, false>&)
{
}
};
Modified: branches/release/boost/spirit/home/support/common_terminals.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/common_terminals.hpp (original)
+++ branches/release/boost/spirit/home/support/common_terminals.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -128,6 +128,7 @@
( set_state )
( in_state )
( token )
+ ( tokenid )
( attr )
( columns )
( auto_ )
Modified: branches/release/boost/spirit/home/support/container.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/container.hpp (original)
+++ branches/release/boost/spirit/home/support/container.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -285,7 +285,7 @@
bool push_back_impl(T_&, mpl::false_) const
{
// this variant doesn't hold a container
- BOOST_ASSERT(false);
+ BOOST_ASSERT(false && "This variant doesn't hold a container");
return false;
}
Modified: branches/release/boost/spirit/home/support/detail/hold_any.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/detail/hold_any.hpp (original)
+++ branches/release/boost/spirit/home/support/detail/hold_any.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -193,7 +193,9 @@
// value of the required type to the hold_any instance you want to
// stream to. This assignment has to be executed before the actual
// call to the operator>>().
- BOOST_ASSERT(false);
+ BOOST_ASSERT(false &&
+ "Tried to insert from a std istream into an empty "
+ "hold_any instance");
return i;
}
@@ -210,7 +212,7 @@
public:
// constructors
template <typename T>
- hold_any(T const& x)
+ explicit hold_any(T const& x)
: table(spirit::detail::get_table<T>::get()), object(0)
{
if (spirit::detail::get_table<T>::is_small::value)
Modified: branches/release/boost/spirit/home/support/detail/lexer/parser/parser.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/detail/lexer/parser/parser.hpp (original)
+++ branches/release/boost/spirit/home/support/detail/lexer/parser/parser.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -6,7 +6,7 @@
#ifndef BOOST_LEXER_PARSER_HPP
#define BOOST_LEXER_PARSER_HPP
-#include <assert.h>
+#include <boost/assert.hpp>
#include "tree/end_node.hpp"
#include "tree/iteration_node.hpp"
#include "tree/leaf_node.hpp"
@@ -101,7 +101,7 @@
throw runtime_error ("Empty rules are not allowed.");
}
- assert (tree_node_stack_.size () == 1);
+ BOOST_ASSERT(tree_node_stack_.size () == 1);
node *lhs_node_ = tree_node_stack_.top ();
@@ -161,7 +161,7 @@
}
} while (!token_stack_.empty () && action_ == '=');
- assert (token_stack_.empty () || action_ == '<');
+ BOOST_ASSERT(token_stack_.empty () || action_ == '<');
switch (rhs_._type)
{
@@ -231,7 +231,7 @@
static void orexp (token_stack &handle_, token_stack &token_stack_,
node_ptr_vector &node_ptr_vector_, tree_node_stack &tree_node_stack_)
{
- assert (handle_.top ()._type == token::OREXP &&
+ BOOST_ASSERT(handle_.top ()._type == token::OREXP &&
(handle_.size () == 1 || handle_.size () == 3));
if (handle_.size () == 1)
@@ -241,9 +241,9 @@
else
{
handle_.pop ();
- assert (handle_.top ()._type == token::OR);
+ BOOST_ASSERT(handle_.top ()._type == token::OR);
handle_.pop ();
- assert (handle_.top ()._type == token::SEQUENCE);
+ BOOST_ASSERT(handle_.top ()._type == token::SEQUENCE);
perform_or (node_ptr_vector_, tree_node_stack_);
token_stack_.push (token::OREXP);
}
@@ -252,7 +252,7 @@
static void sub (token_stack &handle_, token_stack &token_stack_,
node_ptr_vector &node_ptr_vector_, tree_node_stack &tree_node_stack_)
{
- assert (handle_.top ()._type == token::SUB &&
+ BOOST_ASSERT(handle_.top ()._type == token::SUB &&
(handle_.size () == 1 || handle_.size () == 2));
if (handle_.size () == 1)
@@ -262,7 +262,7 @@
else
{
handle_.pop ();
- assert (handle_.top ()._type == token::EXPRESSION);
+ BOOST_ASSERT(handle_.top ()._type == token::EXPRESSION);
// perform join
sequence (node_ptr_vector_, tree_node_stack_);
token_stack_.push (token::SUB);
@@ -271,7 +271,7 @@
static void repeat (token_stack &handle_, token_stack &token_stack_)
{
- assert (handle_.top ()._type == token::REPEAT &&
+ BOOST_ASSERT(handle_.top ()._type == token::REPEAT &&
handle_.size () >= 1 && handle_.size () <= 3);
if (handle_.size () == 1)
@@ -281,7 +281,7 @@
else
{
handle_.pop ();
- assert (handle_.top ()._type == token::DUP);
+ BOOST_ASSERT(handle_.top ()._type == token::DUP);
token_stack_.push (token::REPEAT);
}
}
@@ -289,7 +289,7 @@
static void charset (token_stack &handle_, token_stack &token_stack_,
node_ptr_vector &node_ptr_vector_, tree_node_stack &tree_node_stack_)
{
- assert (handle_.top ()._type == token::CHARSET &&
+ BOOST_ASSERT(handle_.top ()._type == token::CHARSET &&
handle_.size () == 1);
// store charset
node_ptr_vector_->push_back (static_cast<leaf_node *>(0));
@@ -307,7 +307,7 @@
{
token &top_ = handle_.top ();
- assert (top_._type == token::MACRO && handle_.size () == 1);
+ BOOST_ASSERT(top_._type == token::MACRO && handle_.size () == 1);
typename macro_map::const_iterator iter_ =
macromap_.find (top_._macro);
@@ -335,12 +335,12 @@
static void openparen (token_stack &handle_, token_stack &token_stack_)
{
- assert (handle_.top ()._type == token::OPENPAREN &&
+ BOOST_ASSERT(handle_.top ()._type == token::OPENPAREN &&
handle_.size () == 3);
handle_.pop ();
- assert (handle_.top ()._type == token::REGEX);
+ BOOST_ASSERT(handle_.top ()._type == token::REGEX);
handle_.pop ();
- assert (handle_.top ()._type == token::CLOSEPAREN);
+ BOOST_ASSERT(handle_.top ()._type == token::CLOSEPAREN);
token_stack_.push (token::REPEAT);
}
Modified: branches/release/boost/spirit/home/support/detail/lexer/parser/tree/node.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/detail/lexer/parser/tree/node.hpp (original)
+++ branches/release/boost/spirit/home/support/detail/lexer/parser/tree/node.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -6,7 +6,7 @@
#ifndef BOOST_LEXER_NODE_HPP
#define BOOST_LEXER_NODE_HPP
-#include <assert.h>
+#include <boost/assert.hpp>
#include "../../containers/ptr_vector.hpp"
#include "../../runtime_error.hpp"
#include "../../size_t.hpp"
@@ -96,7 +96,7 @@
}
}
- assert (new_node_stack_.size () == 1);
+ BOOST_ASSERT(new_node_stack_.size () == 1);
new_root_ = new_node_stack_.top ();
new_node_stack_.pop ();
return new_root_;
Modified: branches/release/boost/spirit/home/support/detail/lexer/rules.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/detail/lexer/rules.hpp (original)
+++ branches/release/boost/spirit/home/support/detail/lexer/rules.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -39,6 +39,11 @@
{
return ".";
}
+
+ static const char *all_states ()
+ {
+ return "*";
+ }
};
template <>
@@ -53,6 +58,11 @@
{
return L".";
}
+
+ static const wchar_t *all_states ()
+ {
+ return L"*";
+ }
};
}
@@ -526,6 +536,16 @@
return detail::strings<CharT>::initial ();
}
+ static const CharT *all_states ()
+ {
+ return detail::strings<CharT>::all_states ();
+ }
+
+ static const CharT *dot ()
+ {
+ return detail::strings<CharT>::dot ();
+ }
+
private:
string_size_t_map _statemap;
string_pair_deque _macrodeque;
Modified: branches/release/boost/spirit/home/support/detail/math/detail/fp_traits.hpp
==============================================================================
--- branches/release/boost/spirit/home/support/detail/math/detail/fp_traits.hpp (original)
+++ branches/release/boost/spirit/home/support/detail/math/detail/fp_traits.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -193,7 +193,8 @@
// If we do get here, then we have failed to detect the Motorola
// processor at compile time.
- BOOST_ASSERT(false);
+ BOOST_ASSERT(false &&
+ "Failed to detect the Motorola processor at compile time");
return;
case 0x3ffe8000: // IEEE extended double precision format
Modified: branches/release/libs/serialization/src/basic_xml_grammar.ipp
==============================================================================
--- branches/release/libs/serialization/src/basic_xml_grammar.ipp (original)
+++ branches/release/libs/serialization/src/basic_xml_grammar.ipp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -22,9 +22,9 @@
#endif
// spirit stuff
-#include <boost/spirit/core/composite/operators.hpp>
-#include <boost/spirit/core/composite/actions.hpp>
-#include <boost/spirit/core/primitives/numerics.hpp>
+#include <boost/spirit/include/classic_operators.hpp>
+#include <boost/spirit/include/classic_actions.hpp>
+#include <boost/spirit/include/classic_numerics.hpp>
#ifdef BOOST_MSVC
#pragma warning(pop)
@@ -42,7 +42,7 @@
#include <boost/archive/basic_xml_archive.hpp>
#include <boost/archive/iterators/xml_unescape.hpp>
-using namespace boost::spirit;
+using namespace boost::spirit::classic;
namespace boost {
namespace archive {
@@ -207,7 +207,7 @@
// and transaction data logging in the standard way.
parse_info<BOOST_DEDUCED_TYPENAME std::basic_string<CharType>::iterator>
- result = boost::spirit::parse(arg.begin(), arg.end(), rule_);
+ result = boost::spirit::classic::parse(arg.begin(), arg.end(), rule_);
return result.hit;
}
@@ -426,9 +426,9 @@
!S
>> str_p(L"<boost_serialization")
>> S
- >> SignatureAttribute
- >> S
- >> VersionAttribute
+ >> ( (SignatureAttribute >> S >> VersionAttribute)
+ | (VersionAttribute >> S >> SignatureAttribute)
+ )
>> !S
>> L'>'
;
Modified: branches/release/libs/serialization/src/xml_grammar.cpp
==============================================================================
--- branches/release/libs/serialization/src/xml_grammar.cpp (original)
+++ branches/release/libs/serialization/src/xml_grammar.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -15,7 +15,7 @@
#define BOOST_ARCHIVE_SOURCE
#include <boost/archive/impl/basic_xml_grammar.hpp>
-using namespace boost::spirit;
+using namespace boost::spirit::classic;
#include <boost/config.hpp>
Modified: branches/release/libs/serialization/src/xml_wgrammar.cpp
==============================================================================
--- branches/release/libs/serialization/src/xml_wgrammar.cpp (original)
+++ branches/release/libs/serialization/src/xml_wgrammar.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -17,7 +17,7 @@
#define BOOST_WARCHIVE_SOURCE
#include <boost/archive/impl/basic_xml_grammar.hpp>
-using namespace boost::spirit;
+using namespace boost::spirit::classic;
// fixup for RogueWave
#include <boost/config.hpp>
Modified: branches/release/libs/spirit/classic/example/fundamental/ast_calc.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/fundamental/ast_calc.cpp (original)
+++ branches/release/libs/spirit/classic/example/fundamental/ast_calc.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -17,13 +17,13 @@
#include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_ast.hpp>
#include <boost/spirit/include/classic_tree_to_xml.hpp>
+#include <boost/assert.hpp>
#include "tree_calc_grammar.hpp"
#include <iostream>
#include <stack>
#include <functional>
#include <string>
-#include <cassert>
#if defined(BOOST_SPIRIT_DUMP_PARSETREE_AS_XML)
#include <map>
@@ -55,7 +55,7 @@
if (i->value.id() == calculator::integerID)
{
- assert(i->children.size() == 0);
+ BOOST_ASSERT(i->children.size() == 0);
// extract integer (not always delimited by '\0')
string integer(i->value.begin(), i->value.end());
@@ -65,46 +65,46 @@
else if (i->value.id() == calculator::factorID)
{
// factor can only be unary minus
- assert(*i->value.begin() == '-');
+ BOOST_ASSERT(*i->value.begin() == '-');
return - eval_expression(i->children.begin());
}
else if (i->value.id() == calculator::termID)
{
if (*i->value.begin() == '*')
{
- assert(i->children.size() == 2);
+ BOOST_ASSERT(i->children.size() == 2);
return eval_expression(i->children.begin()) *
eval_expression(i->children.begin()+1);
}
else if (*i->value.begin() == '/')
{
- assert(i->children.size() == 2);
+ BOOST_ASSERT(i->children.size() == 2);
return eval_expression(i->children.begin()) /
eval_expression(i->children.begin()+1);
}
else
- assert(0);
+ BOOST_ASSERT(0);
}
else if (i->value.id() == calculator::expressionID)
{
if (*i->value.begin() == '+')
{
- assert(i->children.size() == 2);
+ BOOST_ASSERT(i->children.size() == 2);
return eval_expression(i->children.begin()) +
eval_expression(i->children.begin()+1);
}
else if (*i->value.begin() == '-')
{
- assert(i->children.size() == 2);
+ BOOST_ASSERT(i->children.size() == 2);
return eval_expression(i->children.begin()) -
eval_expression(i->children.begin()+1);
}
else
- assert(0);
+ BOOST_ASSERT(0);
}
else
{
- assert(0); // error
+ BOOST_ASSERT(0); // error
}
return 0;
Modified: branches/release/libs/spirit/classic/example/fundamental/distinct/distinct_parser.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/fundamental/distinct/distinct_parser.cpp (original)
+++ branches/release/libs/spirit/classic/example/fundamental/distinct/distinct_parser.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -6,7 +6,7 @@
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
-#include <cassert>
+#include <boost/assert.hpp>
#include <iostream>
#include <boost/cstdlib.hpp>
#include <boost/spirit/include/classic_core.hpp>
@@ -56,13 +56,13 @@
parse_info<> info;
info = parse("declare ident", gram, space_p);
- assert(info.full); // valid input
+ BOOST_ASSERT(info.full); // valid input
info = parse("declare: ident", gram, space_p);
- assert(info.full); // valid input
+ BOOST_ASSERT(info.full); // valid input
info = parse("declareident", gram, space_p);
- assert(!info.hit); // invalid input
+ BOOST_ASSERT(!info.hit); // invalid input
return exit_success;
}
Modified: branches/release/libs/spirit/classic/example/fundamental/distinct/distinct_parser_dynamic.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/fundamental/distinct/distinct_parser_dynamic.cpp (original)
+++ branches/release/libs/spirit/classic/example/fundamental/distinct/distinct_parser_dynamic.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -6,7 +6,7 @@
License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
=============================================================================*/
-#include <cassert>
+#include <boost/assert.hpp>
#include <iostream>
#include <boost/cstdlib.hpp>
#include <boost/spirit/include/classic_core.hpp>
@@ -52,13 +52,13 @@
parse_info<> info;
info = parse("asn-declare ident", gram, space_p);
- assert(info.full); // valid input
+ BOOST_ASSERT(info.full); // valid input
info = parse("asn-declare--ident", gram, space_p);
- assert(info.full); // valid input
+ BOOST_ASSERT(info.full); // valid input
info = parse("asn-declare-ident", gram, space_p);
- assert(!info.hit); // invalid input
+ BOOST_ASSERT(!info.hit); // invalid input
return exit_success;
}
Modified: branches/release/libs/spirit/classic/example/fundamental/error_handling.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/fundamental/error_handling.cpp (original)
+++ branches/release/libs/spirit/classic/example/fundamental/error_handling.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -15,7 +15,7 @@
#include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_exceptions.hpp>
#include <iostream>
-#include <cassert>
+#include <boost/assert.hpp>
using namespace std;
using namespace BOOST_SPIRIT_CLASSIC_NS;
@@ -49,7 +49,7 @@
bool r = parse("abcx", start).full;
- assert(!r);
+ BOOST_ASSERT(!r);
return 0;
}
Modified: branches/release/libs/spirit/classic/example/fundamental/more_calculators/ast_calc2.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/fundamental/more_calculators/ast_calc2.cpp (original)
+++ branches/release/libs/spirit/classic/example/fundamental/more_calculators/ast_calc2.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -8,6 +8,7 @@
=============================================================================*/
#include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_ast.hpp>
+#include <boost/assert.hpp>
#include <iostream>
#include <stack>
@@ -56,51 +57,51 @@
if (i->value.id() == integer.id())
{
- assert(i->children.size() == 0);
+ BOOST_ASSERT(i->children.size() == 0);
return strtol(i->value.begin(), 0, 10);
}
else if (i->value.id() == factor.id())
{
// factor can only be unary minus
- assert(*i->value.begin() == '-');
+ BOOST_ASSERT(*i->value.begin() == '-');
return - eval_expression(i->children.begin());
}
else if (i->value.id() == term.id())
{
if (*i->value.begin() == '*')
{
- assert(i->children.size() == 2);
+ BOOST_ASSERT(i->children.size() == 2);
return eval_expression(i->children.begin()) *
eval_expression(i->children.begin()+1);
}
else if (*i->value.begin() == '/')
{
- assert(i->children.size() == 2);
+ BOOST_ASSERT(i->children.size() == 2);
return eval_expression(i->children.begin()) /
eval_expression(i->children.begin()+1);
}
else
- assert(0);
+ BOOST_ASSERT(0);
}
else if (i->value.id() == expression.id())
{
if (*i->value.begin() == '+')
{
- assert(i->children.size() == 2);
+ BOOST_ASSERT(i->children.size() == 2);
return eval_expression(i->children.begin()) +
eval_expression(i->children.begin()+1);
}
else if (*i->value.begin() == '-')
{
- assert(i->children.size() == 2);
+ BOOST_ASSERT(i->children.size() == 2);
return eval_expression(i->children.begin()) -
eval_expression(i->children.begin()+1);
}
else
- assert(0);
+ BOOST_ASSERT(0);
}
else
- assert(0); // error
+ BOOST_ASSERT(0); // error
return 0;
}
Modified: branches/release/libs/spirit/classic/example/fundamental/no_actions.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/fundamental/no_actions.cpp (original)
+++ branches/release/libs/spirit/classic/example/fundamental/no_actions.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -15,7 +15,7 @@
//
//-----------------------------------------------------------------------------
-#include <cassert>
+#include <boost/assert.hpp>
#include <iostream>
#include <boost/cstdlib.hpp>
#include <boost/spirit/include/classic_core.hpp>
@@ -46,9 +46,9 @@
]
);
- assert(info.full);
+ BOOST_ASSERT(info.full);
// Check, that the action hasn't been invoked
- assert(i == 0);
+ BOOST_ASSERT(i == 0);
return exit_success;
}
Modified: branches/release/libs/spirit/classic/example/fundamental/parse_tree_calc1.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/fundamental/parse_tree_calc1.cpp (original)
+++ branches/release/libs/spirit/classic/example/fundamental/parse_tree_calc1.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -16,6 +16,7 @@
#include <boost/spirit/include/classic_core.hpp>
#include <boost/spirit/include/classic_parse_tree.hpp>
+#include <boost/assert.hpp>
#include <iostream>
#include <stack>
@@ -63,7 +64,7 @@
long eval_expression(iter_t const& i)
{
parser_id id = i->value.id();
- assert(id == expression.id()); // check the id
+ BOOST_ASSERT(id == expression.id()); // check the id
// first child points to a term, so call eval_term on it
iter_t chi = i->children.begin();
@@ -80,7 +81,7 @@
else if (op == '-')
lhs -= rhs;
else
- assert(0);
+ BOOST_ASSERT(0);
}
return lhs;
}
@@ -88,7 +89,7 @@
long eval_term(iter_t const& i)
{
parser_id id = i->value.id();
- assert(id == term.id());
+ BOOST_ASSERT(id == term.id());
iter_t chi = i->children.begin();
long lhs = eval_factor(chi);
@@ -102,7 +103,7 @@
else if (op == '/')
lhs /= rhs;
else
- assert(0);
+ BOOST_ASSERT(0);
}
return lhs;
}
@@ -110,7 +111,7 @@
long eval_factor(iter_t const& i)
{
parser_id id = i->value.id();
- assert(id == factor.id());
+ BOOST_ASSERT(id == factor.id());
iter_t chi = i->children.begin();
id = chi->value.id();
@@ -128,7 +129,7 @@
}
else
{
- assert(0);
+ BOOST_ASSERT(0);
return 0;
}
}
Modified: branches/release/libs/spirit/classic/example/intermediate/lazy_parser.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/intermediate/lazy_parser.cpp (original)
+++ branches/release/libs/spirit/classic/example/intermediate/lazy_parser.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -30,7 +30,7 @@
// parser to invoke the parser stored in the block.int_rule pointer.
//
//-----------------------------------------------------------------------------
-#include <cassert>
+#include <boost/assert.hpp>
#include <boost/cstdlib.hpp>
#include <boost/spirit/include/phoenix1.hpp>
#include <boost/spirit/include/classic_core.hpp>
@@ -117,8 +117,8 @@
int result;
info = parse("bin{1 dec{1 2 3} 10}", gram[var(result) = arg1], space_p);
- assert(info.full);
- assert(result == 9);
+ BOOST_ASSERT(info.full);
+ BOOST_ASSERT(result == 9);
return exit_success;
}
Modified: branches/release/libs/spirit/classic/example/techniques/epsilon.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/techniques/epsilon.cpp (original)
+++ branches/release/libs/spirit/classic/example/techniques/epsilon.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -24,7 +24,7 @@
//-----------------------------------------------------------------------------
#define BOOST_SPIRIT_RULE_SCANNERTYPE_LIMIT 2
-#include <cassert>
+#include <boost/assert.hpp>
#include <iostream>
#include <boost/cstdlib.hpp>
#include <boost/spirit/include/classic_core.hpp>
@@ -58,9 +58,9 @@
space_p
);
- assert(info.full);
+ BOOST_ASSERT(info.full);
// Check, that the semantic action was invoked only once
- assert(i == 1);
+ BOOST_ASSERT(i == 1);
return exit_success;
}
Modified: branches/release/libs/spirit/classic/example/techniques/multiple_scanners.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/techniques/multiple_scanners.cpp (original)
+++ branches/release/libs/spirit/classic/example/techniques/multiple_scanners.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -15,6 +15,7 @@
#include <iostream>
#include <boost/spirit/include/classic_core.hpp>
+#include <boost/assert.hpp>
using namespace BOOST_SPIRIT_CLASSIC_NS;
@@ -46,7 +47,7 @@
{
my_grammar g;
bool success = parse("abcdef aBc d e f aBc d E f", g, space_p).full;
- assert(success);
+ BOOST_ASSERT(success);
std::cout << "SUCCESS!!!\n";
return 0;
}
Modified: branches/release/libs/spirit/classic/example/techniques/no_rules/no_rule1.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/techniques/no_rules/no_rule1.cpp (original)
+++ branches/release/libs/spirit/classic/example/techniques/no_rules/no_rule1.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -13,6 +13,7 @@
#include <iostream>
#include <boost/spirit/include/classic_core.hpp>
+#include <boost/assert.hpp>
using namespace BOOST_SPIRIT_CLASSIC_NS;
@@ -44,7 +45,7 @@
bool success = parse(
"/*this is a comment*/\n//this is a c++ comment\n\n",
*g).full;
- assert(success);
+ BOOST_ASSERT(success);
std::cout << "SUCCESS!!!\n";
return 0;
}
Modified: branches/release/libs/spirit/classic/example/techniques/no_rules/no_rule2.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/techniques/no_rules/no_rule2.cpp (original)
+++ branches/release/libs/spirit/classic/example/techniques/no_rules/no_rule2.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -13,6 +13,7 @@
#include <iostream>
#include <boost/spirit/include/classic_core.hpp>
+#include <boost/assert.hpp>
using namespace BOOST_SPIRIT_CLASSIC_NS;
@@ -51,7 +52,7 @@
bool success = parse(
"/*this is a comment*/\n//this is a c++ comment\n\n",
*g).full;
- assert(success);
+ BOOST_ASSERT(success);
std::cout << "SUCCESS!!!\n";
return 0;
}
Modified: branches/release/libs/spirit/classic/example/techniques/no_rules/no_rule3.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/techniques/no_rules/no_rule3.cpp (original)
+++ branches/release/libs/spirit/classic/example/techniques/no_rules/no_rule3.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -13,6 +13,7 @@
#include <iostream>
#include <boost/spirit/include/classic_core.hpp>
+#include <boost/assert.hpp>
using namespace BOOST_SPIRIT_CLASSIC_NS;
@@ -79,7 +80,7 @@
bool success = parse(
"/*this is a comment*/\n//this is a c++ comment\n\n",
*g).full;
- assert(success);
+ BOOST_ASSERT(success);
std::cout << "SUCCESS!!!\n";
return 0;
}
Modified: branches/release/libs/spirit/classic/example/techniques/right_recursion.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/techniques/right_recursion.cpp (original)
+++ branches/release/libs/spirit/classic/example/techniques/right_recursion.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -10,6 +10,7 @@
#define BOOST_SPIRIT_DEBUG
#include <boost/spirit/include/classic_core.hpp>
+#include <boost/assert.hpp>
using namespace BOOST_SPIRIT_CLASSIC_NS;
@@ -63,25 +64,25 @@
{
non_greedy_kleene k;
success = parse("3", k).full;
- assert(success);
+ BOOST_ASSERT(success);
success = parse("abcdef3", k).full;
- assert(success);
+ BOOST_ASSERT(success);
success = parse("abc2def3", k).full;
- assert(success);
+ BOOST_ASSERT(success);
success = parse("abc", k).full;
- assert(!success);
+ BOOST_ASSERT(!success);
}
{
non_greedy_plus p;
success = parse("3", p).full;
- assert(!success);
+ BOOST_ASSERT(!success);
success = parse("abcdef3", p).full;
- assert(success);
+ BOOST_ASSERT(success);
success = parse("abc2def3", p).full;
- assert(success);
+ BOOST_ASSERT(success);
success = parse("abc", p).full;
- assert(!success);
+ BOOST_ASSERT(!success);
}
std::cout << "SUCCESS!!!\n";
Modified: branches/release/libs/spirit/classic/example/techniques/typeof.cpp
==============================================================================
--- branches/release/libs/spirit/classic/example/techniques/typeof.cpp (original)
+++ branches/release/libs/spirit/classic/example/techniques/typeof.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -14,6 +14,7 @@
#include <iostream>
#include <boost/spirit/include/classic_core.hpp>
#include <boost/typeof/typeof.hpp>
+#include <boost/assert.hpp>
using namespace BOOST_SPIRIT_CLASSIC_NS;
@@ -33,7 +34,7 @@
bool success = parse(
"/*this is a comment*/\n//this is a c++ comment\n\n",
*skipper).full;
- assert(success);
+ BOOST_ASSERT(success);
std::cout << "SUCCESS!!!\n";
return 0;
}
Modified: branches/release/libs/spirit/doc/lex/concepts.qbk
==============================================================================
--- branches/release/libs/spirit/doc/lex/concepts.qbk (original)
+++ branches/release/libs/spirit/doc/lex/concepts.qbk 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -46,14 +46,17 @@
For any Lexer the following expressions must be valid:
[table
- [[Expression] [Semantics] [Return type]]
- [[`l.collect(def, state)`] [Add all token definitions provided
+ [[Expression] [Semantics] [Return type]]
+ [[`l.collect(def, state, targetstate)`]
+ [Add all token definitions provided
by this Lexer instance to the lexer
state `state` of the token definition
- container `def`.] [`void`]]
+ container `def`. After matching this token, the
+ lexer should be switched into the state
+ `targetstate` (optional)] [`void`]]
[[`l.add_actions(def)`] [Add all semantic actions provided
by this Lexer instance to the token
- definition container `def`.] [`void`]]
+ definition container `def`.] [`void`]]
]
[heading Type Expressions]
Modified: branches/release/libs/spirit/doc/lex/lexer_primitives.qbk
==============================================================================
--- branches/release/libs/spirit/doc/lex/lexer_primitives.qbk (original)
+++ branches/release/libs/spirit/doc/lex/lexer_primitives.qbk 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -11,6 +11,6 @@
[/ Describe the primitive lexer constructs, such as token_def, lexer ]
[/ Describe the primitive lexer constructs usable in parsers, such as
- in_state[], set_state(), token(), etc. ]
+ in_state[], set_state(), token(), tokenid(), etc. ]
[endsect]
Modified: branches/release/libs/spirit/doc/qi/auto.qbk
==============================================================================
--- branches/release/libs/spirit/doc/qi/auto.qbk (original)
+++ branches/release/libs/spirit/doc/qi/auto.qbk 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -60,7 +60,6 @@
[[`unsigned short`, `unsigned int`, `unsigned long`]
[`ushort_`, `uint_`, `ulong_`]]
[[`float`, `double`, `long double`] [`float_`, `double_`, `long_double`]]
- [[`short`, `int`, `long`] [`short_`, `int_`, `long_`]]
[[`long long`, `unsigned long long`]
[`long_long`, `ulong_long`]]
[[`bool`] [`bool_`]]
Modified: branches/release/libs/spirit/doc/spirit2.qbk
==============================================================================
--- branches/release/libs/spirit/doc/spirit2.qbk (original)
+++ branches/release/libs/spirit/doc/spirit2.qbk 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -8,7 +8,7 @@
[article Spirit
[quickbook 1.4]
- [version 2.4.1]
+ [version 2.4.2]
[authors [de Guzman, Joel], [Kaiser, Hartmut]]
[copyright 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 Joel de Guzman, Hartmut Kaiser]
[/ purpose Parser and Generator Library]
@@ -397,7 +397,7 @@
[/ Here we go ]
This is the documentation of the newest version of __spirit__ (currently,
-V2.4.1). If you're looking for the documentation of Spirit's previous version
+V2.4.2). If you're looking for the documentation of Spirit's previous version
(formerly Spirit V1.8), see __classic__.
[include preface.qbk]
Modified: branches/release/libs/spirit/doc/what_s_new.qbk
==============================================================================
--- branches/release/libs/spirit/doc/what_s_new.qbk (original)
+++ branches/release/libs/spirit/doc/what_s_new.qbk 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -9,6 +9,68 @@
[section What's New]
[/////////////////////////////////////////////////////////////////////////////]
+[section:spirit_2_4_2 Spirit V2.4.2]
+
+[heading What's changed in __qi__ and __karma__ from V2.4.1 (Boost V1.45.0) to V2.4.2 (Boost V1.46.0)]
+
+[heading Bug Fixes]
+
+ * Fixed a problem in the Lexer giving problems to assign tokens to all lexer
+ states at once. This is now possible by simply using "*" as the state name.
+ For instance this will add the token int_ to all lexer states:
+``
+ template <typename Lexer>
+ struct lexer : lex::lexer<Lexer>
+ {
+ lexer()
+ {
+ int_ = "[1-9][0-9]*";
+ this->self("*") = int_;
+ }
+ lex::token_def<int> int_;
+ };
+``
+ Note: the `self("*") = ...` must be executed after all lexer states have
+ been introduced to the lexer object.
+ * Fixed lexer lookahead. The lookahead operation is now evaluated using the
+ lexer state the `token_def` instance used as its argument is associated
+ with.
+ * Fixed a problem in the `multi_pass` iterator causing wrong tokens to be
+ returned to the user. This could happen in conjunction with a lexer which
+ performed lexer state changes and was using `pass_fail` in semantic actions
+ to make a token match fail.
+ * Added `qi::tokenid()` primitive parser allowing to match arbitrary lexer
+ tokens based on a given token id. The difference to `qi::token()` is, that it
+ exposes as its attribute the token id of the matched token (instead of the
+ iterator_range of the matched input, as qi::token() does).
+ * Added additional template parameter to the default `lexertl::token<>`
+ definition: the type of the token id. This type defaults to `std::size_t`.
+ Any type used as the id type needs to be (explicitly) convertible from
+ `std::size_t`.
+ * It's now possible to attach lexer semantic actions to token definitions
+ based on `lex::char()` and `lex::string()`.
+ * It's now possible to specify a lexer state the lexer should automatically be
+ switched to after matching certain tokens. For this reason the token
+ definition syntax has been extended:
+``
+ template <typename Lexer>
+ struct lexer : lex::lexer<Lexer>
+ {
+ lexer()
+ {
+ int_ = "[1-9][0-9]*";
+ this->self("INITIAL", "TARGETSTATE") = int_;
+ }
+ lex::token_def<int> int_;
+ };
+``
+ This example lexer will match a `int_` token and will switch the lexer to
+ the state `"TARGETSTATE"` afterwards. If the second argument is not
+ specified the lexer remains in the previous state (as before).
+
+[endsect] [/ spirit_2_4_2]
+
+[/////////////////////////////////////////////////////////////////////////////]
[section:spirit_2_4_1 Spirit V2.4.1]
[heading What's changed in __qi__ and __karma__ from V2.4 (Boost V1.44.0) to V2.4.1 (Boost V1.45.0)]
Modified: branches/release/libs/spirit/example/karma/escaped_string.cpp
==============================================================================
--- branches/release/libs/spirit/example/karma/escaped_string.cpp (original)
+++ branches/release/libs/spirit/example/karma/escaped_string.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -21,7 +21,7 @@
: escaped_string::base_type(esc_str)
{
esc_char.add('\a', "\\a")('\b', "\\b")('\f', "\\f")('\n', "\\n")
- ('\r', "\\r")('\t', "\\t")('\v', "\\v")
+ ('\r', "\\r")('\t', "\\t")('\v', "\\v")('\\', "\\\\")
('\'', "\\\'")('\"', "\\\"")
;
Modified: branches/release/libs/spirit/example/lex/Jamfile
==============================================================================
--- branches/release/libs/spirit/example/lex/Jamfile (original)
+++ branches/release/libs/spirit/example/lex/Jamfile 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -21,6 +21,7 @@
exe example5 : example5.cpp ;
exe example6 : example6.cpp ;
exe print_numbers : print_numbers.cpp ;
+exe print_number_tokenids : print_number_tokenids.cpp ;
exe word_count : word_count.cpp ;
exe word_count_functor : word_count_functor.cpp ;
exe word_count_lexer : word_count_lexer.cpp ;
@@ -29,3 +30,4 @@
exe strip_comments_lexer : strip_comments_lexer.cpp ;
exe custom_token_attribute : custom_token_attribute.cpp ;
+exe lexer_debug_support : lexer_debug_support.cpp ;
Modified: branches/release/libs/spirit/example/qi/Jamfile
==============================================================================
--- branches/release/libs/spirit/example/qi/Jamfile (original)
+++ branches/release/libs/spirit/example/qi/Jamfile 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -37,6 +37,8 @@
exe display_attribute_type : display_attribute_type.cpp ;
exe adapt_template_struct : adapt_template_struct.cpp ;
+exe unescaped_string : unescaped_string.cpp ;
+
exe calculator1 : calc1.cpp ;
exe calculator2 : calc2.cpp ;
exe calculator2_ast : calc2_ast.cpp ;
Modified: branches/release/libs/spirit/example/qi/reference.cpp
==============================================================================
--- branches/release/libs/spirit/example/qi/reference.cpp (original)
+++ branches/release/libs/spirit/example/qi/reference.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -5,6 +5,11 @@
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 is not supposed to be executed, so the asserts are for
+// demonstration purposes only
+// boostinspect:naassert_macro
+
//[reference_includes
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
Modified: branches/release/libs/spirit/example/scheme/output/sexpr.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/output/sexpr.hpp (original)
+++ branches/release/libs/spirit/example/scheme/output/sexpr.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -37,7 +37,7 @@
{
uint_generator<unsigned char, 16> hex2;
- start = double_
+ start %= double_
| int_
| bool_
| string_
Modified: branches/release/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp
==============================================================================
--- branches/release/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp (original)
+++ branches/release/libs/spirit/example/scheme/utree/detail/utree_detail2.hpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -144,7 +144,7 @@
: public boost::iterator_facade<
node_iterator<Value>
, Value
- , boost::bidirectional_traversal_tag
+ , boost::random_access_traversal_tag
>
{
public:
@@ -188,6 +188,17 @@
return node->val;
}
+ void advance (typename node_iterator::difference_type n)
+ {
+ std::advance(*this, n);
+ }
+
+ template<typename Iterator>
+ typename node_iterator::difference_type distance_to(Iterator const& other)
+ const {
+ return std::distance(*this, node_iterator(other));
+ }
+
list::node* node;
list::node* prev;
};
@@ -197,7 +208,7 @@
: public boost::iterator_facade<
node_iterator<boost::reference_wrapper<Value> >
, boost::reference_wrapper<Value>
- , boost::bidirectional_traversal_tag
+ , boost::random_access_traversal_tag
>
{
public:
@@ -243,6 +254,17 @@
return curr;
}
+ void advance (typename node_iterator::difference_type n)
+ {
+ std::advance(*this, n);
+ }
+
+ template<typename Iterator>
+ typename node_iterator::difference_type distance_to(Iterator const& other)
+ const {
+ return std::distance(*this, node_iterator(other));
+ }
+
list::node* node;
list::node* prev;
Modified: branches/release/libs/spirit/test/Jamfile
==============================================================================
--- branches/release/libs/spirit/test/Jamfile (original)
+++ branches/release/libs/spirit/test/Jamfile 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -135,6 +135,8 @@
[ run lex/dedent_handling_phoenix.cpp : : : : ]
[ run lex/set_token_value_phoenix.cpp : : : : ]
[ run lex/semantic_actions.cpp : : : : ]
+ [ run lex/auto_switch_lexerstate.cpp : : : : ]
+ [ run lex/id_type_enum.cpp : : : : ]
# run Lex regression tests
[ run lex/regression001.cpp : : : : lex_regression001 ]
@@ -146,6 +148,10 @@
[ run lex/regression004.cpp : : : : lex_regression004 ]
[ run lex/regression005.cpp : : : : lex_regression005 ]
[ run lex/regression006.cpp : : : : lex_regression006 ]
+ [ run lex/regression007.cpp : : : : lex_regression007 ]
+ [ run lex/regression008.cpp : : : : lex_regression008 ]
+ [ run lex/regression009.cpp : : : : lex_regression009 ]
+ [ run lex/regression010.cpp : : : : lex_regression010 ]
# support tests
[ compile support/multi_pass_regression001.cpp : : support_multi_pass_regression001 ]
Modified: branches/release/libs/spirit/test/karma/bool.cpp
==============================================================================
--- branches/release/libs/spirit/test/karma/bool.cpp (original)
+++ branches/release/libs/spirit/test/karma/bool.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -47,7 +47,7 @@
// we need to provide (safe) convertibility to bool
private:
- struct dummy { void true_() {}; };
+ struct dummy { void true_() {} };
typedef void (dummy::*safe_bool)();
public:
Copied: branches/release/libs/spirit/test/lex/auto_switch_lexerstate.cpp (from r66796, /trunk/libs/spirit/test/lex/auto_switch_lexerstate.cpp)
==============================================================================
--- /trunk/libs/spirit/test/lex/auto_switch_lexerstate.cpp (original)
+++ branches/release/libs/spirit/test/lex/auto_switch_lexerstate.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -82,11 +82,11 @@
token_iterator begin2 = l.begin(begin, end);
token_iterator end2 = l.end();
- int test_data[] = { 2, 1, 2 };
+ std::size_t test_data[] = { 2, 1, 2 };
std::size_t const test_data_size = sizeof(test_data)/sizeof(test_data[0]);
token_iterator it = begin2;
- int i = 0;
+ std::size_t i = 0;
for (/**/; it != end2 && i < test_data_size; ++it, ++i)
{
BOOST_TEST(it->id() == test_data[i]);
Copied: branches/release/libs/spirit/test/lex/regression007.cpp (from r66738, /trunk/libs/spirit/test/lex/regression007.cpp)
==============================================================================
--- /trunk/libs/spirit/test/lex/regression007.cpp (original)
+++ branches/release/libs/spirit/test/lex/regression007.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -4,8 +4,10 @@
// 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/detail/lightweight_test.hpp>
+// #define BOOST_SPIRIT_LEXERTL_DEBUG
+
#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
#include <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
@@ -27,14 +29,14 @@
typedef boost::iterator_range<file_iterator> file_range;
-inline file_iterator make_file_iterator(std::istream& input, const std::string& filename)
+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
- );
+ spirit::multi_pass<std::istreambuf_iterator<char> >(),
+ filename);
}
struct identifier
@@ -90,14 +92,16 @@
token_iterator begin2 = l.begin(begin, end, "ST");
token_iterator end2 = l.end();
- int test_data[] = { 1, 3, 2 };
+ std::size_t test_data[] = { 1, 3, 2 };
std::size_t const test_data_size = sizeof(test_data)/sizeof(test_data[0]);
- int i = 0;
- for (token_iterator it = begin2; it != end2 && i < test_data_size; ++it, ++i)
+ token_iterator it = begin2;
+ std::size_t i = 0;
+ for (/**/; it != end2 && i < test_data_size; ++it, ++i)
{
BOOST_TEST(it->id() == test_data[i]);
}
+ BOOST_TEST(it == end2);
BOOST_TEST(i == test_data_size);
return boost::report_errors();
Copied: branches/release/libs/spirit/test/lex/regression008.cpp (from r66738, /trunk/libs/spirit/test/lex/regression008.cpp)
==============================================================================
--- /trunk/libs/spirit/test/lex/regression008.cpp (original)
+++ branches/release/libs/spirit/test/lex/regression008.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -4,8 +4,10 @@
// 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/detail/lightweight_test.hpp>
+// #define BOOST_SPIRIT_LEXERTL_DEBUG 1
+
#include <boost/config/warning_disable.hpp>
+#include <boost/detail/lightweight_test.hpp>
#include <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
@@ -25,14 +27,14 @@
spirit::multi_pass<std::istreambuf_iterator<char> >
> file_iterator;
-inline file_iterator make_file_iterator(std::istream& input, const std::string& filename)
+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
- );
+ filename);
}
struct identifier
@@ -97,14 +99,16 @@
token_iterator begin2 = l.begin(begin, end, "ST");
token_iterator end2 = l.end();
- int test_data[] = { 1, 3, 2 };
+ std::size_t test_data[] = { 1, 3, 2 };
std::size_t const test_data_size = sizeof(test_data)/sizeof(test_data[0]);
- int i = 0;
- for (token_iterator it = begin2; it != end2; ++it, ++i)
+ token_iterator it = begin2;
+ std::size_t i = 0;
+ for (/**/; it != end2 && i < test_data_size; ++it, ++i)
{
BOOST_TEST(it->id() == test_data[i]);
}
+ BOOST_TEST(it == end2);
BOOST_TEST(i == test_data_size);
return boost::report_errors();
Copied: branches/release/libs/spirit/test/lex/regression009.cpp (from r66742, /trunk/libs/spirit/test/lex/regression009.cpp)
==============================================================================
--- /trunk/libs/spirit/test/lex/regression009.cpp (original)
+++ branches/release/libs/spirit/test/lex/regression009.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -5,6 +5,7 @@
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_SPIRIT_DEBUG 1 // required for token streaming
+// #define BOOST_SPIRIT_LEXERTL_DEBUG 1
#include <boost/config/warning_disable.hpp>
#include <boost/detail/lightweight_test.hpp>
@@ -17,7 +18,6 @@
#include <boost/spirit/home/phoenix/operator.hpp>
#include <boost/spirit/home/phoenix/statement.hpp>
#include <boost/spirit/home/phoenix/object.hpp>
-#include <boost/spirit/home/phoenix/stl.hpp>
#include <sstream>
@@ -89,7 +89,7 @@
std::size_t const test_data_size = sizeof(test_data)/sizeof(test_data[0]);
token_iterator it = begin2;
- int i = 0;
+ std::size_t i = 0;
for (/**/; it != end2 && i < test_data_size; ++it, ++i)
{
std::stringstream ss;
Copied: branches/release/libs/spirit/test/lex/regression010.cpp (from r66761, /trunk/libs/spirit/test/lex/regression010.cpp)
==============================================================================
--- /trunk/libs/spirit/test/lex/regression010.cpp (original)
+++ branches/release/libs/spirit/test/lex/regression010.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -21,7 +21,6 @@
#include <boost/spirit/home/phoenix/operator.hpp>
#include <boost/spirit/home/phoenix/statement.hpp>
#include <boost/spirit/home/phoenix/object.hpp>
-#include <boost/spirit/home/phoenix/stl.hpp>
namespace spirit = boost::spirit;
namespace lex = spirit::lex;
@@ -85,11 +84,11 @@
token_iterator begin2 = l.begin(begin, end);
token_iterator end2 = l.end();
- int test_data[] = { 2, 1, 2 };
+ std::size_t test_data[] = { 2, 1, 2 };
std::size_t const test_data_size = sizeof(test_data)/sizeof(test_data[0]);
token_iterator it = begin2;
- int i = 0;
+ std::size_t i = 0;
for (/**/; it != end2 && i < test_data_size; ++it, ++i)
{
BOOST_TEST(it->id() == test_data[i]);
Modified: branches/release/libs/spirit/test/qi/alternative.cpp
==============================================================================
--- branches/release/libs/spirit/test/qi/alternative.cpp (original)
+++ branches/release/libs/spirit/test/qi/alternative.cpp 2010-12-16 08:39:55 EST (Thu, 16 Dec 2010)
@@ -19,6 +19,7 @@
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/variant.hpp>
+#include <boost/assert.hpp>
#include <string>
#include <iostream>
@@ -169,11 +170,11 @@
std::vector<boost::optional<char> > v;
BOOST_TEST( (test("x,y,z", (*(',' | char_))[phx::ref(v) = _1])) );
- assert(v[0] == 'x');
- assert(!v[1]);
- assert(v[2] == 'y');
- assert(!v[3]);
- assert(v[4] == 'z');
+ BOOST_ASSERT(v[0] == 'x');
+ BOOST_ASSERT(!v[1]);
+ BOOST_ASSERT(v[2] == 'y');
+ BOOST_ASSERT(!v[3]);
+ BOOST_ASSERT(v[4] == 'z');
}
{
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk