|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69177 - in branches/quickbook-filenames/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2011-02-22 15:40:13
Author: danieljames
Date: 2011-02-22 15:40:08 EST (Tue, 22 Feb 2011)
New Revision: 69177
URL: http://svn.boost.org/trac/boost/changeset/69177
Log:
Clean up the grammars a bit.
Text files modified:
branches/quickbook-filenames/tools/quickbook/src/actions.cpp | 10 ++++++
branches/quickbook-filenames/tools/quickbook/src/block_element_grammar.cpp | 49 ++++++++++++++++-----------------
branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp | 31 ++++++++------------
branches/quickbook-filenames/tools/quickbook/src/phrase_element_grammar.cpp | 58 +++++++++++++--------------------------
branches/quickbook-filenames/tools/quickbook/src/phrase_tags.hpp | 6 ++++
branches/quickbook-filenames/tools/quickbook/test/link.quickbook | 2
6 files changed, 73 insertions(+), 83 deletions(-)
Modified: branches/quickbook-filenames/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/actions.cpp 2011-02-22 15:40:08 EST (Tue, 22 Feb 2011)
@@ -65,6 +65,7 @@
void anchor_action(quickbook::actions&, value);
void link_action(quickbook::actions&, value);
void phrase_action_(quickbook::actions&, value);
+ void source_mode_action(quickbook::actions&, value);
void element_action::operator()(iterator first, iterator) const
{
@@ -134,6 +135,10 @@
case phrase_tags::replaceable:
case phrase_tags::footnote:
return phrase_action_(actions, v);
+ case source_mode_tags::cpp:
+ case source_mode_tags::python:
+ case source_mode_tags::teletype:
+ return source_mode_action(actions, v);
default:
break;
}
@@ -518,6 +523,11 @@
escape_actions.phrase.pop(); // restore the stream
}
+ void source_mode_action(quickbook::actions& actions, value source_mode)
+ {
+ actions.source_mode = source_mode_tags::name(source_mode.get_tag());
+ }
+
void code_action::operator()(iterator first, iterator last) const
{
if(!actions.output_pre(out)) return;
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:40:08 EST (Tue, 22 Feb 2011)
@@ -27,8 +27,7 @@
struct block_element_grammar_local
{
cl::rule<scanner>
- heading, blockquote,
- inner_phrase, def_macro,
+ heading, inner_block, inner_phrase, def_macro,
table, table_row, variablelist,
varlistentry, varlistterm, varlistitem, table_cell,
preformatted, begin_section, end_section,
@@ -98,22 +97,14 @@
("h6", element_info(element_info::block, &local.heading, block_tags::heading6))
;
- elements.add("blurb", element_info(element_info::block, &inside_paragraph, block_tags::blurb));
-
- elements.add
- (":", element_info(element_info::block, &local.blockquote, block_tags::blockquote));
- ;
-
- local.blockquote =
- blank >> inside_paragraph
- ;
-
elements.add
- ("warning", element_info(element_info::block, &inside_paragraph, block_tags::warning))
- ("caution", element_info(element_info::block, &inside_paragraph, block_tags::caution))
- ("important", element_info(element_info::block, &inside_paragraph, block_tags::important))
- ("note", element_info(element_info::block, &inside_paragraph, block_tags::note))
- ("tip", element_info(element_info::block, &inside_paragraph, block_tags::tip))
+ ("blurb", element_info(element_info::block, &local.inner_block, block_tags::blurb))
+ (":", element_info(element_info::block, &local.inner_block, block_tags::blockquote))
+ ("warning", element_info(element_info::block, &local.inner_block, block_tags::warning))
+ ("caution", element_info(element_info::block, &local.inner_block, block_tags::caution))
+ ("important", element_info(element_info::block, &local.inner_block, block_tags::important))
+ ("note", element_info(element_info::block, &local.inner_block, block_tags::note))
+ ("tip", element_info(element_info::block, &local.inner_block, block_tags::tip))
;
elements.add
@@ -124,7 +115,8 @@
space
>> !eol
>> actions.scoped_no_eols()
- [phrase] [actions.phrase_value]
+ [ local.inner_phrase
+ ]
;
elements.add
@@ -134,7 +126,8 @@
local.def_macro =
space
>> macro_identifier [actions.values.entry(ph::arg1, ph::arg2)]
- >> blank >> phrase [actions.phrase_value]
+ >> blank
+ >> local.inner_phrase
;
local.identifier =
@@ -205,18 +198,17 @@
local.varlistterm =
space
>> cl::ch_p('[')
- >> actions.values.save()
- [ phrase
- >> cl::ch_p(']')
+ >> local.inner_phrase
+ >> ( cl::ch_p(']')
>> space
| cl::eps_p [actions.error]
- ] [actions.phrase_value]
+ )
;
local.varlistitem =
space
>> cl::ch_p('[')
- >> ( inside_paragraph
+ >> ( local.inner_block
>> cl::ch_p(']')
>> space
| cl::eps_p [actions.error]
@@ -256,7 +248,7 @@
space
>> cl::ch_p('[')
>> ( cl::eps_p
- >> inside_paragraph
+ >> local.inner_block
>> cl::ch_p(']')
>> space
| cl::eps_p [actions.error]
@@ -291,6 +283,13 @@
>> (*(cl::anychar_p - phrase_end)) [actions.values.entry(ph::arg1, ph::arg2)]
;
+ local.inner_block =
+ actions.scoped_output()
+ [
+ inside_paragraph [actions.out_value]
+ ]
+ ;
+
local.inner_phrase =
actions.scoped_output()
[
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:40:08 EST (Tue, 22 Feb 2011)
@@ -374,17 +374,13 @@
;
inside_paragraph =
- actions.scoped_output()
- [ actions.values.save()
- [
- ( *( common
- | (cl::anychar_p - phrase_end)
+ actions.values.save()
+ [ *( local.paragraph_separator [actions.paragraph]
+ | common
+ | (cl::anychar_p - phrase_end)
[actions.plain_char]
- | local.paragraph_separator
- [actions.paragraph]
- ) ) [actions.paragraph]
- ] [actions.out_value]
- ]
+ )
+ ] [actions.paragraph]
;
local.phrase_element
@@ -419,11 +415,10 @@
)
;
-
local.element
= cl::eps_p(cl::punct_p)
- >> elements [local.assign_element]
- | elements [local.assign_element]
+ >> elements [local.assign_element]
+ | elements [local.assign_element]
>> (cl::eps_p - (cl::alnum_p | '_'))
;
@@ -448,7 +443,7 @@
simple_phrase = actions.values.save()[
*( common
- | (cl::anychar_p - ']') [actions.plain_char]
+ | (cl::anychar_p - ']') [actions.plain_char]
)
]
;
@@ -461,15 +456,15 @@
actions.values.list(block_tags::macro_definition)
[ *cl::space_p
>> local.command_line_macro_identifier
- [actions.values.entry(ph::arg1, ph::arg2)]
+ [actions.values.entry(ph::arg1, ph::arg2)]
>> *cl::space_p
>> ( '='
>> *cl::space_p
>> local.command_line_phrase
>> *cl::space_p
| cl::eps_p
- ) [actions.phrase_value]
- ] [actions.element]
+ ) [actions.phrase_value]
+ ] [actions.element]
;
local.command_line_macro_identifier =
@@ -479,7 +474,7 @@
local.command_line_phrase =
*( common
- | (cl::anychar_p - ']') [actions.plain_char]
+ | (cl::anychar_p - ']') [actions.plain_char]
)
;
Modified: branches/quickbook-filenames/tools/quickbook/src/phrase_element_grammar.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/phrase_element_grammar.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/phrase_element_grammar.cpp 2011-02-22 15:40:08 EST (Tue, 22 Feb 2011)
@@ -26,9 +26,7 @@
struct phrase_element_grammar_local
{
cl::rule<scanner>
- image, anchor, link, url,
- source_mode_cpp, source_mode_python, source_mode_teletype,
- cond_phrase, inner_phrase
+ image, anchor, link, empty, cond_phrase, inner_phrase
;
};
@@ -79,18 +77,16 @@
;
elements.add
- ("@", element_info(element_info::phrase, &local.url, phrase_tags::url))
- ;
-
- local.url =
- (*(cl::anychar_p - (']' | hard_space)))
- [actions.values.entry(ph::arg1, ph::arg2)]
- >> hard_space
- >> local.inner_phrase
- ;
-
- elements.add
+ ("@", element_info(element_info::phrase, &local.link, phrase_tags::url))
("link", element_info(element_info::phrase, &local.link, phrase_tags::link))
+ ("funcref", element_info(element_info::phrase, &local.link, phrase_tags::funcref))
+ ("classref", element_info(element_info::phrase, &local.link, phrase_tags::classref))
+ ("memberref", element_info(element_info::phrase, &local.link, phrase_tags::memberref))
+ ("enumref", element_info(element_info::phrase, &local.link, phrase_tags::enumref))
+ ("macroref", element_info(element_info::phrase, &local.link, phrase_tags::macroref))
+ ("headerref", element_info(element_info::phrase, &local.link, phrase_tags::headerref))
+ ("conceptref", element_info(element_info::phrase, &local.link, phrase_tags::conceptref))
+ ("globalref", element_info(element_info::phrase, &local.link, phrase_tags::globalref))
;
local.link =
@@ -111,17 +107,6 @@
;
elements.add
- ("funcref", element_info(element_info::phrase, &local.link, phrase_tags::funcref))
- ("classref", element_info(element_info::phrase, &local.link, phrase_tags::classref))
- ("memberref", element_info(element_info::phrase, &local.link, phrase_tags::memberref))
- ("enumref", element_info(element_info::phrase, &local.link, phrase_tags::enumref))
- ("macroref", element_info(element_info::phrase, &local.link, phrase_tags::macroref))
- ("headerref", element_info(element_info::phrase, &local.link, phrase_tags::headerref))
- ("conceptref", element_info(element_info::phrase, &local.link, phrase_tags::conceptref))
- ("globalref", element_info(element_info::phrase, &local.link, phrase_tags::globalref))
- ;
-
- elements.add
("*", element_info(element_info::phrase, &local.inner_phrase, phrase_tags::bold))
("'", element_info(element_info::phrase, &local.inner_phrase, phrase_tags::italic))
("_", element_info(element_info::phrase, &local.inner_phrase, phrase_tags::underline))
@@ -129,27 +114,22 @@
("-", element_info(element_info::phrase, &local.inner_phrase, phrase_tags::strikethrough))
("\"", element_info(element_info::phrase, &local.inner_phrase, phrase_tags::quote))
("~", element_info(element_info::phrase, &local.inner_phrase, phrase_tags::replaceable))
+ ("footnote", element_info(element_info::phrase, &local.inner_phrase, phrase_tags::footnote))
;
elements.add
- ("c++", element_info(element_info::phrase, &local.source_mode_cpp))
- ("python", element_info(element_info::phrase, &local.source_mode_python))
- ("teletype", element_info(element_info::phrase, &local.source_mode_teletype))
+ ("c++", element_info(element_info::phrase, &local.empty, source_mode_tags::cpp))
+ ("python", element_info(element_info::phrase, &local.empty, source_mode_tags::python))
+ ("teletype", element_info(element_info::phrase, &local.empty, source_mode_tags::teletype))
;
- local.source_mode_cpp = cl::eps_p [cl::assign_a(actions.source_mode, "c++")];
- local.source_mode_python = cl::eps_p [cl::assign_a(actions.source_mode, "python")];
- local.source_mode_teletype = cl::eps_p [cl::assign_a(actions.source_mode, "teletype")];
-
- elements.add
- ("footnote", element_info(element_info::phrase, &local.inner_phrase, phrase_tags::footnote))
- ;
+ local.empty = cl::eps_p;
local.inner_phrase =
- blank >>
- actions.scoped_output()
- [ phrase [actions.phrase_value]
- ]
+ blank
+ >> actions.scoped_output()
+ [ phrase [actions.phrase_value]
+ ]
;
}
}
Modified: branches/quickbook-filenames/tools/quickbook/src/phrase_tags.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/phrase_tags.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/phrase_tags.hpp 2011-02-22 15:40:08 EST (Tue, 22 Feb 2011)
@@ -21,6 +21,12 @@
(bold)(italic)(underline)(teletype)(strikethrough)(quote)(replaceable)
(footnote)
)
+
+ QUICKBOOK_VALUE_NAMED_TAGS(source_mode_tags, 0x550,
+ ((cpp)("c++"))
+ ((python)("python"))
+ ((teletype)("teletype"))
+ )
}
#endif
Modified: branches/quickbook-filenames/tools/quickbook/test/link.quickbook
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/link.quickbook (original)
+++ branches/quickbook-filenames/tools/quickbook/test/link.quickbook 2011-02-22 15:40:08 EST (Tue, 22 Feb 2011)
@@ -4,7 +4,7 @@
[section Different types of links]
[@http://www.boost.org/]
-[@http://www.boost.org/ Boost]
+[@ http://www.boost.org/ Boost]
[link link-id]
[link link-id Link Text]
[#link-id]
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