Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r68906 - in trunk/libs/spirit/test: . qi
From: joel_at_[hidden]
Date: 2011-02-14 22:20:13


Author: djowel
Date: 2011-02-14 22:20:11 EST (Mon, 14 Feb 2011)
New Revision: 68906
URL: http://svn.boost.org/trac/boost/changeset/68906

Log:
Allow attribute compatibility with semantic actions
Added:
   trunk/libs/spirit/test/qi/actions2.cpp (contents, props changed)
Text files modified:
   trunk/libs/spirit/test/Jamfile | 15 ++++++++-------
   1 files changed, 8 insertions(+), 7 deletions(-)

Modified: trunk/libs/spirit/test/Jamfile
==============================================================================
--- trunk/libs/spirit/test/Jamfile (original)
+++ trunk/libs/spirit/test/Jamfile 2011-02-14 22:20:11 EST (Mon, 14 Feb 2011)
@@ -26,6 +26,7 @@
     test-suite spirit_v2/qi :
 
      [ run qi/actions.cpp : : : : qi_actions ]
+ [ run qi/actions2.cpp : : : : qi_actions2 ]
      [ run qi/alternative.cpp : : : : qi_alternative ]
      [ run qi/attr.cpp : : : : qi_attr ]
      [ run qi/attribute1.cpp : : : : qi_attribute1 ]
@@ -93,10 +94,10 @@
      [ run qi/utree2.cpp : : : : qi_utree2 ]
      [ run qi/utree3.cpp : : : : qi_utree3 ]
      [ run qi/utree4.cpp : : : : qi_utree4 ]
-
+
     ;
-
- ###########################################################################
+
+ ###########################################################################
     test-suite spirit_v2/qi_regressions :
 
      [ compile qi/regression_attr_with_action.cpp : : qi_regression_attr_with_action ]
@@ -188,7 +189,7 @@
 
     ;
 
- ###########################################################################
+ ###########################################################################
     test-suite spirit_v2/karma_regressions :
 
      [ run karma/regression_optional_double.cpp : : : : karma_regression_optional_double ]
@@ -214,7 +215,7 @@
      [ run lex/semantic_actions.cpp : : : : lex_semantic_actions ]
      [ run lex/auto_switch_lexerstate.cpp : : : : lex_auto_switch_lexerstate ]
      [ run lex/id_type_enum.cpp : : : : lex_id_type_enum ]
-
+
     ;
 
     ###########################################################################
@@ -233,7 +234,7 @@
      [ run lex/regression_file_iterator2.cpp : : : : lex_regression_file_iterator2 ]
      [ run lex/regression_file_iterator3.cpp : : : : lex_regression_file_iterator3 ]
      [ run lex/regression_file_iterator4.cpp : : : : lex_regression_file_iterator4 ]
-
+
     ;
 
     ###########################################################################
@@ -244,7 +245,7 @@
 
     ;
 
- ###########################################################################
+ ###########################################################################
     test-suite spirit_v2/support_regressions :
 
      [ compile support/regression_multi_pass_position_iterator.cpp : : support_regression_multi_pass_position_iterator ]

Added: trunk/libs/spirit/test/qi/actions2.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/spirit/test/qi/actions2.cpp 2011-02-14 22:20:11 EST (Mon, 14 Feb 2011)
@@ -0,0 +1,50 @@
+/*=============================================================================
+ Copyright (c) 2001-2011 Joel de Guzman
+
+ 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)
+=============================================================================*/
+
+#if defined(_MSC_VER)
+# pragma warning(disable: 4180) // qualifier applied to function type
+ // has no meaning; ignored
+#endif
+
+// This tests the new behavior allowing attribute compatibility
+// to semantic actions
+
+#define BOOST_SPIRIT_ACTIONS_ALLOW_ATTR_COMPAT
+
+#include <boost/detail/lightweight_test.hpp>
+#include <boost/detail/workaround.hpp>
+#include <boost/spirit/include/qi.hpp>
+#include <boost/spirit/include/phoenix_bind.hpp>
+#include <string>
+#include "test.hpp"
+
+void f(std::string const& s)
+{
+ std::cout << "parsing got: " << s << std::endl;
+}
+
+int main()
+{
+ namespace qi = boost::spirit::qi;
+ namespace phoenix = boost::phoenix;
+ using spirit_test::test_attr;
+
+ {
+ qi::rule<char const*, std::string()> r;
+ r %= (+qi::char_)[phoenix::bind(&f, qi::_1)];
+
+ std::string attr;
+ BOOST_TEST(test_attr("abcdef", r, attr));
+ BOOST_TEST(attr == "abcdef");
+ }
+
+ return boost::report_errors();
+}
+
+
+
+


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