Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r85115 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2013-07-22 15:33:38


Author: danieljames
Date: 2013-07-22 15:33:38 EDT (Mon, 22 Jul 2013)
New Revision: 85115
URL: http://svn.boost.org/trac/boost/changeset/85115

Log:
Better element handling in `syntactic_block_item`.

Now all elements are handled within local.common.

Text files modified:
   trunk/tools/quickbook/src/grammar_impl.hpp | 9 +++----
   trunk/tools/quickbook/src/main_grammar.cpp | 43 ++++++++++++++++++++++++++-------------
   2 files changed, 32 insertions(+), 20 deletions(-)

Modified: trunk/tools/quickbook/src/grammar_impl.hpp
==============================================================================
--- trunk/tools/quickbook/src/grammar_impl.hpp Mon Jul 22 15:33:21 2013 (r85114)
+++ trunk/tools/quickbook/src/grammar_impl.hpp 2013-07-22 15:33:38 EDT (Mon, 22 Jul 2013) (r85115)
@@ -34,19 +34,18 @@
         enum context {
             // At the top level we allow everything.
             in_top_level = phrase | maybe_block | nested_block | conditional_or_block | section_block,
- // In conditional phrases we everything but section elements.
+ // In conditional phrases and list blocks we everything but section elements.
             in_conditional = phrase | maybe_block | nested_block | conditional_or_block,
+ in_list_block = phrase | maybe_block | nested_block | conditional_or_block,
             // In nested blocks we allow a much more limited range of elements.
             in_nested_block = phrase | maybe_block | nested_block,
             // In a phrase we only allow phrase elements, ('maybe_block'
             // elements are treated as phrase elements in this context)
             in_phrase = phrase | maybe_block,
             // At the start of a block these are all block elements.
- only_contextual_block = maybe_block | nested_block | conditional_or_block | section_block,
+ is_contextual_block = maybe_block | nested_block | conditional_or_block | section_block,
             // These are all block elements in all other contexts.
- only_block = nested_block | conditional_or_block | section_block,
- // Block elements that are allowed in a list item
- only_list_block = nested_block | conditional_or_block
+ is_block = nested_block | conditional_or_block | section_block,
         };
 
         element_info()

Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp Mon Jul 22 15:33:21 2013 (r85114)
+++ trunk/tools/quickbook/src/main_grammar.cpp 2013-07-22 15:33:38 EDT (Mon, 22 Jul 2013) (r85115)
@@ -112,11 +112,17 @@
                         skip_escape
                         ;
 
+ struct block_context_closure : cl::closure<block_context_closure,
+ element_info::context>
+ {
+ member1 is_block;
+ };
+
         cl::rule<scanner> simple_markup, simple_markup_end;
 
         cl::rule<scanner> paragraph;
         cl::rule<scanner> list;
- cl::rule<scanner> syntactic_block_item;
+ cl::rule<scanner, block_context_closure::context_t> syntactic_block_item;
         cl::rule<scanner> common;
         cl::rule<scanner> element;
 
@@ -402,10 +408,10 @@
         local.paragraph =
             scoped_still_in_block(true)
             [
- scoped_context(element_info::only_contextual_block)
- [ local.syntactic_block_item [ph::var(local.context) = element_info::only_block]
+ scoped_context(element_info::in_top_level)
+ [ local.syntactic_block_item(element_info::is_contextual_block)
>> *( cl::eps_p(ph::var(local.still_in_block))
- >> local.syntactic_block_item
+ >> local.syntactic_block_item(element_info::is_block)
                     )
                 ]
             ] [paragraph_action]
@@ -416,30 +422,37 @@
>> (cl::ch_p('*') | '#')
>> (*cl::blank_p)
>> scoped_still_in_block(true)
- [ qbk_ver(107u) >> scoped_context(element_info::only_block)
+ [ qbk_ver(107u) >> scoped_context(element_info::in_top_level)
                     [ *( cl::eps_p(ph::var(local.still_in_block))
- >> local.syntactic_block_item
+ >> local.syntactic_block_item(element_info::is_block)
                         )
                     ]
- | qbk_ver(0, 107u) >> scoped_context(element_info::only_list_block)
+ | qbk_ver(0, 107u) >> scoped_context(element_info::in_list_block)
                     [ *( cl::eps_p(ph::var(local.still_in_block))
- >> local.syntactic_block_item
+ >> local.syntactic_block_item(element_info::is_block)
                         )
                     ]
- ] [list_item_action]
+ ] [list_item_action]
                 // TODO: `list_item_action` is sometimes called in the wrong
                 // place. Currently harmless.
             ;
 
         local.syntactic_block_item =
- local.element
+ local.paragraph_separator [ph::var(local.still_in_block) = false]
+ | cl::eps_p [ph::var(local.element_type) = element_info::nothing]
+ >> local.common
+ // If the element is a block, then a newline will end the
+ // current syntactic block.
                 // Note that we don't do this for lists in 1.6 to avoid messing
                 // up on nested block elements.
- >> !( cl::eps_p(in_list) >> eol
- | qbk_ver(0, 106u) >> eol
- ) [ph::var(local.still_in_block) = false]
- | local.paragraph_separator [ph::var(local.still_in_block) = false]
- | scoped_context(element_info::in_phrase) [ local.common ]
+ >> !( cl::eps_p(in_list) >> qbk_ver(106u)
+ | cl::eps_p
+ (
+ ph::static_cast_<int>(local.syntactic_block_item.is_block) &
+ ph::static_cast_<int>(ph::var(local.element_type))
+ )
+ >> eol [ph::var(local.still_in_block) = false]
+ )
             ;
 
         local.paragraph_separator =


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