Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r86684 - in trunk/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2013-11-13 16:47:59


Author: danieljames
Date: 2013-11-13 16:47:59 EST (Wed, 13 Nov 2013)
New Revision: 86684
URL: http://svn.boost.org/trac/boost/changeset/86684

Log:
New parser for attribute value template calls. Refs #2035.

Text files modified:
   trunk/tools/quickbook/src/actions.cpp | 22 ++++++++++++++--------
   trunk/tools/quickbook/src/grammar.cpp | 2 ++
   trunk/tools/quickbook/src/grammar.hpp | 1 +
   trunk/tools/quickbook/src/grammar_impl.hpp | 1 +
   trunk/tools/quickbook/src/main_grammar.cpp | 24 ++++++++++++++++++++++++
   trunk/tools/quickbook/test/link-1_7.gold | 4 ++++
   trunk/tools/quickbook/test/link-1_7.quickbook | 5 +++++
   7 files changed, 51 insertions(+), 8 deletions(-)

Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp Wed Nov 13 16:47:28 2013 (r86683)
+++ trunk/tools/quickbook/src/actions.cpp 2013-11-13 16:47:59 EST (Wed, 13 Nov 2013) (r86684)
@@ -553,7 +553,8 @@
 
     namespace
     {
- bool parse_template(value const&, quickbook::state& state);
+ bool parse_template(value const&, quickbook::state& state,
+ bool is_attribute_template = false);
     }
 
     void state::start_callouts()
@@ -1209,6 +1210,7 @@
         bool parse_template(
             value const& content
           , quickbook::state& state
+ , bool is_attribute_template
         )
         {
             file_ptr saved_current_file = state.current_file;
@@ -1220,6 +1222,8 @@
             parse_iterator last(source.end());
 
             bool r = cl::parse(first, last,
+ is_attribute_template ?
+ state.grammar().attribute_template_body :
                     content.get_tag() == template_tags::phrase ?
                         state.grammar().inline_phrase :
                         state.grammar().block_start
@@ -1234,9 +1238,12 @@
     void call_template(quickbook::state& state,
             template_symbol const* symbol,
             std::vector<value> const& args,
- string_iterator first)
+ string_iterator first,
+ bool is_attribute_template = false)
     {
         bool is_block = symbol->content.get_tag() != template_tags::phrase;
+ assert(!(is_attribute_template && is_block));
+
         quickbook::paragraph_action paragraph_action(state);
 
         // Finish off any existing paragraphs.
@@ -1300,16 +1307,15 @@
                 state.phrase.swap(save_phrase);
             }
 
- if (!parse_template(symbol->content, state))
+ if (!parse_template(symbol->content, state, is_attribute_template))
             {
                 detail::outerr(state.current_file, first)
                     << "Expanding "
                     << (is_block ? "block" : "phrase")
- << " template: " << symbol->identifier << std::endl
- << std::endl
- << "------------------begin------------------" << std::endl
+ << " template: " << symbol->identifier << "\n\n"
+ << "------------------begin------------------\n"
                     << symbol->content.get_quickbook()
- << "------------------end--------------------" << std::endl
+ << "------------------end--------------------\n"
                     << std::endl;
                 ++state.error_count;
                 return;
@@ -1471,7 +1477,7 @@
                 return;
             }
 
- call_template(state, symbol, args, first);
+ call_template(state, symbol, args, first, is_attribute_template);
             break;
 
         case template_tags::snippet:

Modified: trunk/tools/quickbook/src/grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/grammar.cpp Wed Nov 13 16:47:28 2013 (r86683)
+++ trunk/tools/quickbook/src/grammar.cpp 2013-11-13 16:47:59 EST (Wed, 13 Nov 2013) (r86684)
@@ -19,6 +19,8 @@
         , inline_phrase(impl_->inline_phrase, "inline_phrase")
         , phrase_start(impl_->phrase_start, "phrase")
         , block_start(impl_->block_start, "block")
+ , attribute_template_body(impl_->attribute_template_body,
+ "attribute_template_body")
         , doc_info(impl_->doc_info_details, "doc_info")
     {
     }

Modified: trunk/tools/quickbook/src/grammar.hpp
==============================================================================
--- trunk/tools/quickbook/src/grammar.hpp Wed Nov 13 16:47:28 2013 (r86683)
+++ trunk/tools/quickbook/src/grammar.hpp 2013-11-13 16:47:59 EST (Wed, 13 Nov 2013) (r86684)
@@ -60,6 +60,7 @@
         grammar inline_phrase;
         grammar phrase_start;
         grammar block_start;
+ grammar attribute_template_body;
         grammar doc_info;
 
         quickbook_grammar(quickbook::state&);

Modified: trunk/tools/quickbook/src/grammar_impl.hpp
==============================================================================
--- trunk/tools/quickbook/src/grammar_impl.hpp Wed Nov 13 16:47:28 2013 (r86683)
+++ trunk/tools/quickbook/src/grammar_impl.hpp 2013-11-13 16:47:59 EST (Wed, 13 Nov 2013) (r86684)
@@ -129,6 +129,7 @@
         cl::rule<scanner> inside_preformatted;
         cl::rule<scanner> inside_paragraph;
         cl::rule<scanner> command_line;
+ cl::rule<scanner> attribute_template_body;
         cl::rule<scanner> attribute_value_1_7;
         cl::rule<scanner> escape;
         cl::rule<scanner> raw_escape;

Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp Wed Nov 13 16:47:28 2013 (r86683)
+++ trunk/tools/quickbook/src/main_grammar.cpp 2013-11-13 16:47:59 EST (Wed, 13 Nov 2013) (r86684)
@@ -947,6 +947,30 @@
                 )
             ;
 
+ attribute_template_body =
+ space
+ >> *( ~cl::eps_p(space >> cl::end_p | comment)
+ >> ( cl::eps_p
+ ( cl::ch_p('[')
+ >> space
+ >> ( cl::eps_p(cl::punct_p)
+ >> elements
+ | elements
+ >> (cl::eps_p - (cl::alnum_p | '_'))
+ )
+ ) [error("Elements not allowed in attribute values.")]
+ >> local.square_brackets
+ | local.attribute_template
+ | cl::eps_p(cl::ch_p('[')) [error("Unmatched template in attribute value.")]
+ >> local.square_brackets
+ | raw_escape
+ | cl::anychar_p [raw_char]
+ )
+ )
+ >> space
+ ;
+
+
         attribute_value_1_7 =
             *( ~cl::eps_p(']' | cl::space_p | comment)
>> ( cl::eps_p

Modified: trunk/tools/quickbook/test/link-1_7.gold
==============================================================================
--- trunk/tools/quickbook/test/link-1_7.gold Wed Nov 13 16:47:28 2013 (r86683)
+++ trunk/tools/quickbook/test/link-1_7.gold 2013-11-13 16:47:59 EST (Wed, 13 Nov 2013) (r86684)
@@ -40,5 +40,9 @@
     <para>
       <link linkend="blah.x2">Templated link?</link>
     </para>
+ <para>
+ <link linkend="something-one-two">something-one-two</link> <link linkend="something-one-two">something-one-two</link>
+ <link linkend="something-one-two">something-one-two</link>
+ </para>
   </section>
 </article>

Modified: trunk/tools/quickbook/test/link-1_7.quickbook
==============================================================================
--- trunk/tools/quickbook/test/link-1_7.quickbook Wed Nov 13 16:47:28 2013 (r86683)
+++ trunk/tools/quickbook/test/link-1_7.quickbook 2013-11-13 16:47:59 EST (Wed, 13 Nov 2013) (r86684)
@@ -49,4 +49,9 @@
 [template thing[]x]
 [link blah.[thing]2 Templated link?]
 
+[template link_in_template[x y] [link something-[x]-[y]]]
+[link_in_template one two]
+[link_in_template one..two]
+[link_in_template one .. two ]
+
 [endsect]


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