Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r56596 - trunk/libs/spirit/example/qi
From: hartmut.kaiser_at_[hidden]
Date: 2009-10-05 10:48:21


Author: hkaiser
Date: 2009-10-05 10:48:20 EDT (Mon, 05 Oct 2009)
New Revision: 56596
URL: http://svn.boost.org/trac/boost/changeset/56596

Log:
Spirit: more comments in new example
Text files modified:
   trunk/libs/spirit/example/qi/parse_date.cpp | 13 ++++++-------
   1 files changed, 6 insertions(+), 7 deletions(-)

Modified: trunk/libs/spirit/example/qi/parse_date.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/parse_date.cpp (original)
+++ trunk/libs/spirit/example/qi/parse_date.cpp 2009-10-05 10:48:20 EDT (Mon, 05 Oct 2009)
@@ -33,7 +33,7 @@
         typedef fusion::vector<int, int, int> date_parts;
 
         // The embedded typedef 'type' exposes the attribute as it will be
- // passed to the right hand side.
+ // passed to the right hand side of the rule.
         typedef date_parts type;
 
         // The function pre() is called for down-stream conversion of the
@@ -41,7 +41,7 @@
         // right hand side.
         // The supplied attribute might have been pre-initialized by parsers
         // (i.e. semantic actions) higher up the parser hierarchy (in the
- // grammar, in which case we would need to properly initialize the
+ // grammar), in which case we would need to properly initialize the
         // returned value from the argument. In this example this is not
         // required, so we just create a new instance of a date_parts.
         static date_parts pre(boost::gregorian::date)
@@ -51,8 +51,9 @@
 
         // The function post() is called for up-stream conversion of the
         // results returned from parsing the right hand side of the rule.
- // We need to initialize the attribute supplied to the rule with the
- // values taken from the parsing results.
+ // We need to initialize the attribute supplied to the rule (referenced
+ // by the first argument) with the values taken from the parsing
+ // results (referenced by the second argument).
         static void post(boost::gregorian::date& d, date_parts const& v)
         {
             d = boost::gregorian::date(fusion::at_c<0>(v), fusion::at_c<1>(v)
@@ -65,13 +66,11 @@
 namespace client
 {
     namespace qi = boost::spirit::qi;
- namespace fusion = boost::fusion;
-
- typedef fusion::vector<int, int, int> date_parts;
 
     template <typename Iterator>
     bool parse_date(Iterator& first, Iterator last, boost::gregorian::date& d)
     {
+ typedef boost::fusion::vector<int, int, int> date_parts;
         qi::rule<Iterator, date_parts(), qi::space_type> date =
             qi::int_ >> '-' >> qi::int_ >> '-' >> qi::int_;
 


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