Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r75359 - branches/quickbook-dev/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-11-06 17:22:13


Author: danieljames
Date: 2011-11-06 17:22:12 EST (Sun, 06 Nov 2011)
New Revision: 75359
URL: http://svn.boost.org/trac/boost/changeset/75359

Log:
Quickbook: Make the version checker a parser.
Text files modified:
   branches/quickbook-dev/tools/quickbook/src/actions.hpp | 25 ++++++++++++++++---------
   branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp | 10 +++++-----
   branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp | 18 ++++++++----------
   branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp | 4 ++--
   4 files changed, 31 insertions(+), 26 deletions(-)

Modified: branches/quickbook-dev/tools/quickbook/src/actions.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions.hpp 2011-11-06 17:22:12 EST (Sun, 06 Nov 2011)
@@ -18,23 +18,30 @@
 #include "values.hpp"
 #include "scoped.hpp"
 #include "symbols.hpp"
+#include <boost/spirit/include/classic_parser.hpp>
 
 namespace quickbook
 {
+ namespace cl = boost::spirit::classic;
+
     extern unsigned qbk_version_n; // qbk_major_version * 100 + qbk_minor_version
 
- struct quickbook_range {
- template <typename Arg>
- struct result
- {
- typedef bool type;
- };
-
+ struct quickbook_range : cl::parser<quickbook_range> {
         quickbook_range(unsigned min_, unsigned max_)
             : min_(min_), max_(max_) {}
         
- bool operator()() const {
- return qbk_version_n >= min_ && qbk_version_n < max_;
+ template <typename ScannerT>
+ typename cl::parser_result<quickbook_range, ScannerT>::type
+ parse(ScannerT const& scan) const
+ {
+ if (qbk_version_n >= min_ && qbk_version_n < max_)
+ {
+ return scan.empty_match();
+ }
+ else
+ {
+ return scan.no_match();
+ }
         }
 
         unsigned min_, max_;

Modified: branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp 2011-11-06 17:22:12 EST (Sun, 06 Nov 2011)
@@ -45,7 +45,7 @@
 
         local.element_id =
             !( ':'
- >> ( !(cl::eps_p(qbk_since(105u)) >> space)
+ >> ( !(qbk_since(105u) >> space)
>> (+(cl::alnum_p | '_')) [actions.values.entry(ph::arg1, ph::arg2, general_tags::element_id)]
                 | cl::eps_p [actions.element_id_warning]
                 )
@@ -53,10 +53,10 @@
             ;
         
         local.element_id_1_5 =
- !(cl::eps_p(qbk_since(105u)) >> local.element_id);
+ !(qbk_since(105u) >> local.element_id);
 
         local.element_id_1_6 =
- !(cl::eps_p(qbk_since(106u)) >> local.element_id);
+ !(qbk_since(106u) >> local.element_id);
 
         elements.add
             ("section", element_info(element_info::block, &local.begin_section, block_tags::begin_section))
@@ -233,10 +233,10 @@
             ;
 
         local.table_title =
- cl::eps_p(qbk_before(106))
+ qbk_before(106)
>> (*(cl::anychar_p - eol)) [actions.values.entry(ph::arg1, ph::arg2, table_tags::title)]
>> (+eol)
- | cl::eps_p(qbk_since(106))
+ | qbk_since(106)
>> actions.to_value(table_tags::title)
                 [
                     *(escape

Modified: branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp 2011-11-06 17:22:12 EST (Sun, 06 Nov 2011)
@@ -256,9 +256,9 @@
         local.hr =
                 cl::str_p("----")
>> actions.values.list(block_tags::hr)
- [ ( cl::eps_p(qbk_since(106u))
+ [ ( qbk_since(106u)
>> *(line_comment | (cl::anychar_p - (cl::eol_p | '[' | ']')))
- | cl::eps_p(qbk_before(106u))
+ | qbk_before(106u)
>> *(line_comment | (cl::anychar_p - (cl::eol_p | "[/")))
                     )
>> *eol
@@ -333,7 +333,7 @@
             | local.simple_markup
             | escape
             | comment
- | cl::eps_p(qbk_since(106u)) >> local.square_brackets
+ | qbk_since(106u) >> local.square_brackets
             | cl::space_p [actions.space_char]
             | cl::anychar_p [actions.plain_char]
             ;
@@ -374,10 +374,8 @@
             ;
 
         local.template_args =
- cl::eps_p(qbk_since(105u))
- >> local.template_args_1_5
- | cl::eps_p(qbk_before(105u))
- >> local.template_args_1_4
+ qbk_since(105u) >> local.template_args_1_5
+ | qbk_before(105u) >> local.template_args_1_4
             ;
 
         local.template_args_1_4 = local.template_arg_1_4 >> *(".." >> local.template_arg_1_4);
@@ -545,7 +543,7 @@
             ;
 
         local.command_line_macro_identifier =
- cl::eps_p(qbk_since(106u))
+ qbk_since(106u)
>> +(cl::anychar_p - (cl::space_p | '[' | '\\' | ']' | '='))
             | +(cl::anychar_p - (cl::space_p | ']' | '='))
             ;
@@ -595,9 +593,9 @@
 
         // TODO: Prevent an old macro from being used in a 1.6 file.
         macro_identifier =
- cl::eps_p(qbk_since(106u))
+ qbk_since(106u)
>> +(cl::anychar_p - (cl::space_p | '[' | '\\' | ']'))
- | cl::eps_p(qbk_before(106u))
+ | qbk_before(106u)
>> +(cl::anychar_p - (cl::space_p | ']'))
             ;
     }

Modified: branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp 2011-11-06 17:22:12 EST (Sun, 06 Nov 2011)
@@ -52,7 +52,7 @@
             ;
 
         local.image =
- cl::eps_p(qbk_since(105u))
+ qbk_since(105u)
>> blank
>> (+(
                     *cl::space_p
@@ -70,7 +70,7 @@
>> space
                 ]
>> cl::eps_p(']')
- | cl::eps_p(qbk_before(105u))
+ | qbk_before(105u)
>> blank
>> (*(cl::anychar_p - phrase_end)) [actions.values.entry(ph::arg1, ph::arg2)]
>> cl::eps_p(']')


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