Boost logo

Boost-Commit :

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


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

Log:
Only allow phrase templates in attribute values. Refs #2035.

Added:
   trunk/tools/quickbook/test/templates-1_7-fail2.quickbook (contents, props changed)
Text files modified:
   trunk/tools/quickbook/src/actions.cpp | 18 ++++++++++++++++++
   trunk/tools/quickbook/src/main_grammar.cpp | 26 ++++++++++++++++++++------
   trunk/tools/quickbook/src/template_tags.hpp | 1 +
   trunk/tools/quickbook/test/Jamfile.v2 | 1 +
   trunk/tools/quickbook/test/templates-1_7-fail2.quickbook | 11 +++++++++++
   5 files changed, 51 insertions(+), 6 deletions(-)

Modified: trunk/tools/quickbook/src/actions.cpp
==============================================================================
--- trunk/tools/quickbook/src/actions.cpp Wed Nov 13 12:38:31 2013 (r86682)
+++ trunk/tools/quickbook/src/actions.cpp 2013-11-13 16:47:28 EST (Wed, 13 Nov 2013) (r86683)
@@ -191,6 +191,7 @@
         case code_tags::inline_code_block:
         case code_tags::inline_code:
             return code_action(state, v);
+ case template_tags::attribute_template:
         case template_tags::template_:
             return do_template_action(state, v, first.base());
         default:
@@ -1367,6 +1368,9 @@
     void do_template_action(quickbook::state& state, value template_list,
             string_iterator first)
     {
+ bool const is_attribute_template =
+ template_list.get_tag() == template_tags::attribute_template;
+
         // Get the arguments
         value_consumer values = template_list;
 
@@ -1429,6 +1433,20 @@
         }
 
         ///////////////////////////////////
+ // Check that attribute templates are phrase templates
+
+ if (is_attribute_template &&
+ symbol->content.get_tag() != template_tags::phrase)
+ {
+ detail::outerr(state.current_file, first)
+ << "Only phrase templates can be used in attribute values."
+ << std::endl;
+
+ ++state.error_count;
+ return;
+ }
+
+ ///////////////////////////////////
         // Initialise the arguments
 
         switch(symbol->content.get_tag())

Modified: trunk/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- trunk/tools/quickbook/src/main_grammar.cpp Wed Nov 13 12:38:31 2013 (r86682)
+++ trunk/tools/quickbook/src/main_grammar.cpp 2013-11-13 16:47:28 EST (Wed, 13 Nov 2013) (r86683)
@@ -91,7 +91,7 @@
                         paragraph_separator, inside_paragraph,
                         code, code_line, blank_line, hr,
                         inline_code, skip_inline_code,
- template_,
+ template_, attribute_template, template_body,
                         code_block, skip_code_block, macro,
                         template_args,
                         template_args_1_4, template_arg_1_4,
@@ -653,7 +653,24 @@
             ( '['
>> space
>> state.values.list(template_tags::template_)
- [ ( cl::str_p('`')
+ [ local.template_body
+ >> ']'
+ ]
+ ) [element_action]
+ ;
+
+ local.attribute_template =
+ ( '['
+ >> space
+ >> state.values.list(template_tags::attribute_template)
+ [ local.template_body
+ >> ']'
+ ]
+ ) [element_action]
+ ;
+
+ local.template_body =
+ ( cl::str_p('`')
>> cl::eps_p(cl::punct_p)
>> state.templates.scope
                             [state.values.entry(ph::arg1, ph::arg2, template_tags::escape)]
@@ -675,9 +692,6 @@
                     )
>> space
>> !local.template_args
- >> ']'
- ]
- ) [element_action]
             ;
 
         local.template_args =
@@ -945,7 +959,7 @@
                         )
                     ) [error("Elements not allowed in attribute values.")]
>> local.square_brackets
- | local.template_
+ | local.attribute_template
                 | cl::eps_p(cl::ch_p('[')) [error("Unmatched template in attribute value.")]
>> local.square_brackets
                 | raw_escape

Modified: trunk/tools/quickbook/src/template_tags.hpp
==============================================================================
--- trunk/tools/quickbook/src/template_tags.hpp Wed Nov 13 12:38:31 2013 (r86682)
+++ trunk/tools/quickbook/src/template_tags.hpp 2013-11-13 16:47:28 EST (Wed, 13 Nov 2013) (r86683)
@@ -15,6 +15,7 @@
 {
     QUICKBOOK_VALUE_TAGS(template_tags, 0x100,
         (template_)
+ (attribute_template)
         (escape)
         (identifier)
         (block)

Modified: trunk/tools/quickbook/test/Jamfile.v2
==============================================================================
--- trunk/tools/quickbook/test/Jamfile.v2 Wed Nov 13 12:38:31 2013 (r86682)
+++ trunk/tools/quickbook/test/Jamfile.v2 2013-11-13 16:47:28 EST (Wed, 13 Nov 2013) (r86683)
@@ -113,6 +113,7 @@
     [ quickbook-error-test templates-1_6-fail1 ]
     [ quickbook-test templates-1_7 ]
     [ quickbook-error-test templates-1_7-fail1 ]
+ [ quickbook-error-test templates-1_7-fail2 ]
     [ quickbook-test unicode_escape-1_5 ]
     [ quickbook-test unmatched_element-1_5 ]
     [ quickbook-test unmatched_element-1_6 ]

Added: trunk/tools/quickbook/test/templates-1_7-fail2.quickbook
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ trunk/tools/quickbook/test/templates-1_7-fail2.quickbook 2013-11-13 16:47:28 EST (Wed, 13 Nov 2013) (r86683)
@@ -0,0 +1,11 @@
+[article Template 1.7 fail
+[quickbook 1.7]
+]
+
+[/ This should fail because it's a block template called from an attribute ]
+
+[template fail[]
+
+Block template.]
+
+[link this-should-[fail]]


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