Boost logo

Boost-Commit :

From: joel_at_[hidden]
Date: 2008-04-27 04:41:47


Author: djowel
Date: 2008-04-27 04:41:47 EDT (Sun, 27 Apr 2008)
New Revision: 44813
URL: http://svn.boost.org/trac/boost/changeset/44813

Log:
added grammar_class test
Text files modified:
   trunk/libs/spirit/test/qi/grammar.cpp | 25 +++++++++++++++++++++++++
   1 files changed, 25 insertions(+), 0 deletions(-)

Modified: trunk/libs/spirit/test/qi/grammar.cpp
==============================================================================
--- trunk/libs/spirit/test/qi/grammar.cpp (original)
+++ trunk/libs/spirit/test/qi/grammar.cpp 2008-04-27 04:41:47 EDT (Sun, 27 Apr 2008)
@@ -68,6 +68,19 @@
     rule<char const*, grammar<my_skipper> > start, num;
 };
 
+template <typename Iterator, typename Skipper>
+struct num_list3 : grammar_def<Iterator, Skipper>
+{
+ num_list3()
+ {
+ using boost::spirit::int_;
+ num = int_;
+ start = num >> *(',' >> num);
+ }
+
+ rule<Iterator, Skipper> start, num;
+};
+
 int
 main()
 {
@@ -104,6 +117,18 @@
         BOOST_TEST(test_attr("inherited", g(123), n, space)); // using the grammar
         BOOST_TEST(n == 123);
     }
+
+ { // grammar_class test
+
+ grammar_class<num_list3> nlist;
+
+ char const* first = "123, 456, 789";
+ char const* last = first;
+ while (*last)
+ last++;
+ BOOST_TEST(phrase_parse(first, last, nlist, space)
+ && (first == last));
+ }
     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