Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59305 - in branches/quickbook-1.5-spirit2: . detail
From: daniel_james_at_[hidden]
Date: 2010-01-27 17:02:58


Author: danieljames
Date: 2010-01-27 17:02:57 EST (Wed, 27 Jan 2010)
New Revision: 59305
URL: http://svn.boost.org/trac/boost/changeset/59305

Log:
Attributize macros.
Text files modified:
   branches/quickbook-1.5-spirit2/block.cpp | 22 ++++++++++++++++------
   branches/quickbook-1.5-spirit2/block.hpp | 7 +++++++
   branches/quickbook-1.5-spirit2/block_actions.cpp | 9 +++++++++
   branches/quickbook-1.5-spirit2/detail/actions.cpp | 15 ---------------
   branches/quickbook-1.5-spirit2/detail/actions.hpp | 24 ------------------------
   branches/quickbook-1.5-spirit2/detail/actions_class.cpp | 3 ---
   branches/quickbook-1.5-spirit2/detail/actions_class.hpp | 3 ---
   7 files changed, 32 insertions(+), 51 deletions(-)

Modified: branches/quickbook-1.5-spirit2/block.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block.cpp (original)
+++ branches/quickbook-1.5-spirit2/block.cpp 2010-01-27 17:02:57 EST (Wed, 27 Jan 2010)
@@ -67,6 +67,12 @@
 )
 
 BOOST_FUSION_ADAPT_STRUCT(
+ quickbook::def_macro,
+ (std::string, macro_identifier)
+ (std::string, content)
+)
+
+BOOST_FUSION_ADAPT_STRUCT(
     quickbook::variablelist,
     (std::string, title)
     (std::vector<quickbook::varlistentry>, entries)
@@ -94,8 +100,7 @@
         qi::rule<iterator>
                         start_, blocks, block_markup, code, code_line,
                         space, blank, comment,
- phrase, phrase_end, ordered_list, def_macro,
- macro_identifier,
+ phrase, phrase_end, ordered_list,
                         xinclude, include, hard_space, eol, paragraph_end,
                         template_, template_id, template_formal_arg,
                         template_body, identifier, dummy_block, import;
@@ -125,6 +130,9 @@
         qi::symbols<char, quickbook::markup> paragraph_blocks;
         qi::rule<iterator, quickbook::formatted()> paragraph_block, blockquote, preformatted;
 
+ qi::rule<iterator, std::string()> macro_identifier;
+ qi::rule<iterator, quickbook::def_macro()> def_macro;
+
         qi::rule<iterator, quickbook::variablelist()> variablelist;
         qi::rule<iterator, quickbook::varlistentry()> varlistentry;
         qi::rule<iterator, quickbook::formatted()>
@@ -214,7 +222,7 @@
                 | paragraph_block [actions.process][actions.output]
                 | blockquote [actions.process][actions.output]
                 | preformatted [actions.process][actions.output]
- | def_macro
+ | def_macro [actions.process][actions.output]
                 | table [actions.process][actions.output]
                 | variablelist [actions.process][actions.output]
                 | xinclude
@@ -319,9 +327,11 @@
             ;
 
         def_macro =
- "def" >> hard_space
- >> qi::raw[macro_identifier] [actions.macro_identifier]
- >> blank >> phrase [actions.macro_definition]
+ "def"
+ >> hard_space
+ >> macro_identifier
+ >> blank
+ >> phrase_attr
             ;
 
         identifier =

Modified: branches/quickbook-1.5-spirit2/block.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block.hpp (original)
+++ branches/quickbook-1.5-spirit2/block.hpp 2010-01-27 17:02:57 EST (Wed, 27 Jan 2010)
@@ -63,6 +63,12 @@
         title content;
     };
 
+ struct def_macro
+ {
+ std::string macro_identifier;
+ std::string content;
+ };
+
     typedef std::vector<quickbook::formatted> varlistentry;
 
     struct variablelist
@@ -87,6 +93,7 @@
     void process(quickbook::actions&, begin_section const&);
     void process(quickbook::actions&, end_section const&);
     void process(quickbook::actions&, heading const&);
+ void process(quickbook::actions&, def_macro const&);
     void process(quickbook::actions&, variablelist const&);
     void process(quickbook::actions&, table const&);
 }

Modified: branches/quickbook-1.5-spirit2/block_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_actions.cpp 2010-01-27 17:02:57 EST (Wed, 27 Jan 2010)
@@ -166,6 +166,15 @@
         }
     }
 
+ void process(quickbook::actions& actions, def_macro const& x)
+ {
+ actions.macro.add(
+ x.macro_identifier.begin()
+ , x.macro_identifier.end()
+ , quickbook::macro(x.content));
+
+ }
+
     void process(quickbook::actions& actions, variablelist const& x)
     {
         actions.phrase << "<variablelist>\n";

Modified: branches/quickbook-1.5-spirit2/detail/actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/detail/actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/detail/actions.cpp 2010-01-27 17:02:57 EST (Wed, 27 Jan 2010)
@@ -216,21 +216,6 @@
         detail::print_char(*x.begin(), phrase.get());
     }
 
- void macro_identifier_action::operator()(iterator_range x, unused_type, unused_type) const
- {
- actions.macro_id.assign(x.begin(), x.end());
- actions.phrase.push(); // save the phrase
- }
-
- void macro_definition_action::operator()(unused_type, unused_type, unused_type) const
- {
- actions.macro.add(
- actions.macro_id.begin()
- , actions.macro_id.end()
- , quickbook::macro(actions.phrase.str()));
- actions.phrase.pop(); // restore the phrase
- }
-
     void template_body_action::operator()(iterator_range x, unused_type, unused_type) const
     {
         BOOST_ASSERT(actions.template_info.size());

Modified: branches/quickbook-1.5-spirit2/detail/actions.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/detail/actions.hpp (original)
+++ branches/quickbook-1.5-spirit2/detail/actions.hpp 2010-01-27 17:02:57 EST (Wed, 27 Jan 2010)
@@ -303,30 +303,6 @@
         syntax_highlight& syntax_p;
     };
 
- struct macro_identifier_action
- {
- // Handles macro identifiers
-
- macro_identifier_action(quickbook::actions& actions)
- : actions(actions) {}
-
- void operator()(iterator_range, unused_type, unused_type) const;
-
- quickbook::actions& actions;
- };
-
- struct macro_definition_action
- {
- // Handles macro definitions
-
- macro_definition_action(quickbook::actions& actions)
- : actions(actions) {}
-
- void operator()(unused_type, unused_type, unused_type) const;
-
- quickbook::actions& actions;
- };
-
     struct template_body_action
     {
         // Handles template definitions

Modified: branches/quickbook-1.5-spirit2/detail/actions_class.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/detail/actions_class.cpp (original)
+++ branches/quickbook-1.5-spirit2/detail/actions_class.cpp 2010-01-27 17:02:57 EST (Wed, 27 Jan 2010)
@@ -50,7 +50,6 @@
         , source_mode("c++")
 
     // temporary or global state
- , macro_id()
         , template_info()
         , template_depth(0)
         , templates()
@@ -71,8 +70,6 @@
         , plain_char(phrase)
         , raw_char(phrase)
 
- , macro_identifier(*this)
- , macro_definition(*this)
         , template_body(*this)
         , url_pre(url_pre_)
         , url_post(url_post_)

Modified: branches/quickbook-1.5-spirit2/detail/actions_class.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/detail/actions_class.hpp (original)
+++ branches/quickbook-1.5-spirit2/detail/actions_class.hpp 2010-01-27 17:02:57 EST (Wed, 27 Jan 2010)
@@ -76,7 +76,6 @@
         std::stack<state_tuple> state_stack;
 
     // temporary or global state
- std::string macro_id;
         string_list template_info;
         int template_depth;
         template_stack templates;
@@ -103,8 +102,6 @@
         plain_char_action plain_char;
         raw_char_action raw_char;
 
- macro_identifier_action macro_identifier;
- macro_definition_action macro_definition;
         template_body_action template_body;
         char const* url_pre;
         char const* url_post;


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