Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59289 - branches/quickbook-1.5-spirit2
From: daniel_james_at_[hidden]
Date: 2010-01-27 16:59:35


Author: danieljames
Date: 2010-01-27 16:59:34 EST (Wed, 27 Jan 2010)
New Revision: 59289
URL: http://svn.boost.org/trac/boost/changeset/59289

Log:
Use a parameterized rule for simple_markup.
Text files modified:
   branches/quickbook-1.5-spirit2/phrase.hpp | 83 +++++++++++++++------------------------
   1 files changed, 33 insertions(+), 50 deletions(-)

Modified: branches/quickbook-1.5-spirit2/phrase.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase.hpp (original)
+++ branches/quickbook-1.5-spirit2/phrase.hpp 2010-01-27 16:59:34 EST (Wed, 27 Jan 2010)
@@ -30,41 +30,7 @@
 {
     namespace qi = boost::spirit::qi;
     namespace ph = boost::phoenix;
-
- template <typename Rule, typename Action>
- inline void
- simple_markup(
- Rule& simple
- , char mark
- , Action const& action
- , Rule const& close
- )
- {
- simple =
- mark >>
- qi::raw[
- (
- qi::graph // A single char. e.g. *c*
- >> &(mark
- >> (qi::space | qi::punct | qi::eoi))
- // space, punct or end
- ) // must follow mark
- |
- ( qi::graph >> // qi::graph must follow mark
- *(qi::char_ -
- ( (qi::graph >> mark) // Make sure that we don't go
- | close // past a single block
- )
- ) >> qi::graph // qi::graph must precede mark
- >> &(mark
- >> (qi::space | qi::punct | qi::eoi))
- // space, punct or end
- ) // must follow mark
- ] [action]
- >> mark
- ;
- }
-
+
     template <typename Iterator, typename Actions>
     struct phrase_grammar<Iterator, Actions>::rules
     {
@@ -79,8 +45,7 @@
                         strikethrough, escape, url, common, funcref, classref,
                         memberref, enumref, macroref, headerref, conceptref, globalref,
                         anchor, link, hard_space, eol, inline_code, simple_format,
- simple_bold, simple_italic, simple_underline,
- simple_teletype, source_mode, template_,
+ source_mode, template_,
                         quote, code_block, footnote, replaceable, macro,
                         dummy_block, cond_phrase, macro_identifier,
                         brackets_1_4, template_inner_arg_1_5, brackets_1_5
@@ -93,6 +58,8 @@
         qi::rule<Iterator, std::string()> image_filename, image_attribute_key, image_attribute_value;
         qi::rule<Iterator, std::multimap<std::string, std::string>()> image_attributes;
         qi::rule<Iterator, std::pair<std::string, std::string>()> image_attribute;
+
+ qi::rule<Iterator, boost::iterator_range<Iterator>(char)> simple_markup;
     };
 
     template <typename Iterator, typename Actions>
@@ -226,21 +193,37 @@
                 )
             ;
 
- simple_format =
- simple_bold
- | simple_italic
- | simple_underline
- | simple_teletype
+ simple_markup =
+ qi::omit[qi::char_(qi::_r1)] >>
+ qi::raw[
+ (
+ qi::graph // A single char. e.g. *c*
+ >> &(qi::char_(qi::_r1)
+ >> (qi::space | qi::punct | qi::eoi))
+ // space, punct or end
+ ) // must follow qi::char_(qi::_r1)
+ |
+ ( qi::graph >> // qi::graph must follow qi::char_(qi::_r1)
+ *(qi::char_ -
+ ( (qi::graph >> qi::char_(qi::_r1)) // Make sure that we don't go
+ | phrase_end // past a single block
+ )
+ ) >> qi::graph // qi::graph must precede qi::char_(qi::_r1)
+ >> &(qi::char_(qi::_r1)
+ >> (qi::space | qi::punct | qi::eoi))
+ // space, punct or end
+ ) // must follow qi::char_(qi::_r1)
+ ]
+ >> qi::omit[qi::char_(qi::_r1)]
             ;
 
- simple_markup(simple_bold,
- '*', actions.simple_bold, phrase_end);
- simple_markup(simple_italic,
- '/', actions.simple_italic, phrase_end);
- simple_markup(simple_underline,
- '_', actions.simple_underline, phrase_end);
- simple_markup(simple_teletype,
- '=', actions.simple_teletype, phrase_end);
+
+ simple_format =
+ simple_markup('*') [actions.simple_bold]
+ | simple_markup('/') [actions.simple_italic]
+ | simple_markup('_') [actions.simple_underline]
+ | simple_markup('=') [actions.simple_teletype]
+ ;
 
         phrase =
            *( common


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