|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69169 - branches/quickbook-filenames/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-02-22 15:30:48
Author: danieljames
Date: 2011-02-22 15:30:47 EST (Tue, 22 Feb 2011)
New Revision: 69169
URL: http://svn.boost.org/trac/boost/changeset/69169
Log:
Single rule for all headings.
Text files modified:
branches/quickbook-filenames/tools/quickbook/src/block_element_grammar.cpp | 56 ++++++---------------------------------
branches/quickbook-filenames/tools/quickbook/src/grammar_impl.hpp | 9 +++++-
branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp | 47 ++++++++++++++++++---------------
3 files changed, 42 insertions(+), 70 deletions(-)
Modified: branches/quickbook-filenames/tools/quickbook/src/block_element_grammar.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/block_element_grammar.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/block_element_grammar.cpp 2011-02-22 15:30:47 EST (Tue, 22 Feb 2011)
@@ -26,7 +26,7 @@
struct block_element_grammar_local
{
cl::rule<scanner>
- h, h1, h2, h3, h4, h5, h6, heading,
+ heading,
blurb, blockquote,
warning, caution, important, note, tip,
inner_phrase, def_macro,
@@ -85,16 +85,6 @@
[actions.end_section]
;
- elements.add
- ("heading", element_info(element_info::block, &local.h))
- ("h1", element_info(element_info::block, &local.h1))
- ("h2", element_info(element_info::block, &local.h2))
- ("h3", element_info(element_info::block, &local.h3))
- ("h4", element_info(element_info::block, &local.h4))
- ("h5", element_info(element_info::block, &local.h5))
- ("h6", element_info(element_info::block, &local.h6))
- ;
-
local.heading
= actions.values.scoped
[ space
@@ -104,44 +94,16 @@
]
;
- // This looks verbose now, but it'll eventually be replaced with a
- // more automatic version (see how doc_info works).
-
- local.h
- = cl::eps_p [actions.values.tag(block_tags::generic_heading)]
- >> local.heading
- ;
-
- local.h1
- = cl::eps_p [actions.values.tag(block_tags::heading1)]
- >> local.heading
- ;
-
- local.h2
- = cl::eps_p [actions.values.tag(block_tags::heading2)]
- >> local.heading
- ;
-
- local.h3
- = cl::eps_p [actions.values.tag(block_tags::heading3)]
- >> local.heading
- ;
-
- local.h4
- = cl::eps_p [actions.values.tag(block_tags::heading4)]
- >> local.heading
- ;
-
- local.h5
- = cl::eps_p [actions.values.tag(block_tags::heading5)]
- >> local.heading
+ elements.add
+ ("heading", element_info(element_info::block, &local.heading, block_tags::generic_heading))
+ ("h1", element_info(element_info::block, &local.heading, block_tags::heading1))
+ ("h2", element_info(element_info::block, &local.heading, block_tags::heading2))
+ ("h3", element_info(element_info::block, &local.heading, block_tags::heading3))
+ ("h4", element_info(element_info::block, &local.heading, block_tags::heading4))
+ ("h5", element_info(element_info::block, &local.heading, block_tags::heading5))
+ ("h6", element_info(element_info::block, &local.heading, block_tags::heading6))
;
- local.h6
- = cl::eps_p [actions.values.tag(block_tags::heading6)]
- >> local.heading
- ;
-
elements.add("blurb", element_info(element_info::block, &local.blurb));
local.blurb =
Modified: branches/quickbook-filenames/tools/quickbook/src/grammar_impl.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/grammar_impl.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/grammar_impl.hpp 2011-02-22 15:30:47 EST (Tue, 22 Feb 2011)
@@ -13,6 +13,7 @@
#include "grammar.hpp"
#include "rule_store.hpp"
+#include "values.hpp"
#include <boost/spirit/include/classic_symbols.hpp>
namespace quickbook
@@ -33,11 +34,15 @@
conditional_or_block = 5
};
- element_info(type_enum t, cl::rule<scanner>* r)
- : type(t), rule(r) {}
+ element_info(
+ type_enum t,
+ cl::rule<scanner>* r,
+ value::tag_type tag = value::no_tag)
+ : type(t), rule(r), tag(tag) {}
type_enum type;
cl::rule<scanner>* rule;
+ value::tag_type tag;
};
struct quickbook_grammar::impl
Modified: branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp 2011-02-22 15:30:47 EST (Tue, 22 Feb 2011)
@@ -68,33 +68,13 @@
struct main_grammar_local
{
- cl::rule<scanner>
- top_level, blocks, paragraph_separator,
- block_element,
- code, code_line, blank_line, hr,
- list, ordered_list, list_item,
- phrase_element, extended_phrase_element, element,
- simple_phrase_end,
- escape,
- inline_code, simple_format,
- simple_bold, simple_italic, simple_underline,
- simple_teletype, template_,
- code_block, macro,
- template_args,
- template_args_1_4, template_arg_1_4,
- template_inner_arg_1_4, brackets_1_4,
- template_args_1_5, template_arg_1_5, template_arg_1_5_content,
- template_inner_arg_1_5, brackets_1_5,
- command_line_macro_identifier, command_line_phrase,
- dummy_block
- ;
-
struct assign_element_type {
assign_element_type(main_grammar_local& l) : l(l) {}
void operator()(element_info& t) const {
l.element_type = t.type;
l.element_rule = *t.rule;
+ l.element_tag = t.tag;
}
main_grammar_local& l;
@@ -112,8 +92,30 @@
element_info::context t;
};
+ cl::rule<scanner>
+ top_level, blocks, paragraph_separator,
+ block_element,
+ code, code_line, blank_line, hr,
+ list, ordered_list, list_item,
+ phrase_element, extended_phrase_element, element,
+ simple_phrase_end,
+ escape,
+ inline_code, simple_format,
+ simple_bold, simple_italic, simple_underline,
+ simple_teletype, template_,
+ code_block, macro,
+ template_args,
+ template_args_1_4, template_arg_1_4,
+ template_inner_arg_1_4, brackets_1_4,
+ template_args_1_5, template_arg_1_5, template_arg_1_5_content,
+ template_inner_arg_1_5, brackets_1_5,
+ command_line_macro_identifier, command_line_phrase,
+ dummy_block
+ ;
+
element_info::type_enum element_type;
cl::rule<scanner> element_rule;
+ value::tag_type element_tag;
assign_element_type assign_element;
main_grammar_local()
@@ -174,6 +176,7 @@
>> cl::eps_p(local.check_element(element_info::in_block))
[actions.inside_paragraph]
[actions.values.reset()]
+ [actions.values.tag(detail::var(local.element_tag))]
>> ( local.element_rule
>> ( (space >> ']') [actions.element]
| cl::eps_p [actions.error]
@@ -384,6 +387,7 @@
>> ( local.element
>> cl::eps_p(local.check_element(element_info::in_phrase))
[actions.values.reset()]
+ [actions.values.tag(detail::var(local.element_tag))]
>> local.element_rule
>> cl::eps_p(space >> ']') [actions.element]
| local.template_
@@ -398,6 +402,7 @@
>> cl::eps_p(local.check_element(element_info::in_conditional))
[actions.inside_paragraph]
[actions.values.reset()]
+ [actions.values.tag(detail::var(local.element_tag))]
>> ( local.element_rule
>> ( (space >> ']') [actions.element]
| cl::eps_p [actions.error]
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