|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62849 - in branches/quickbook-1.5-spirit2: . test
From: daniel_james_at_[hidden]
Date: 2010-06-12 09:06:29
Author: danieljames
Date: 2010-06-12 09:06:27 EDT (Sat, 12 Jun 2010)
New Revision: 62849
URL: http://svn.boost.org/trac/boost/changeset/62849
Log:
Move the paragraph logic into the actions.
Text files modified:
branches/quickbook-1.5-spirit2/block.hpp | 4 +++
branches/quickbook-1.5-spirit2/block_actions.cpp | 37 ++++++++++++++++++++++++++++++
branches/quickbook-1.5-spirit2/block_actions.hpp | 4 ++
branches/quickbook-1.5-spirit2/block_grammar.cpp | 49 ++++++++++++++++++++++-----------------
branches/quickbook-1.5-spirit2/block_list.cpp | 2 +
branches/quickbook-1.5-spirit2/phrase_actions.cpp | 2 +
branches/quickbook-1.5-spirit2/process.cpp | 1
branches/quickbook-1.5-spirit2/state.cpp | 16 +++++++++++++
branches/quickbook-1.5-spirit2/state.hpp | 3 ++
branches/quickbook-1.5-spirit2/test/code-block-teletype.gold | 2 -
branches/quickbook-1.5-spirit2/test/quickbook-manual.gold | 10 -------
11 files changed, 97 insertions(+), 33 deletions(-)
Modified: branches/quickbook-1.5-spirit2/block.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block.hpp (original)
+++ branches/quickbook-1.5-spirit2/block.hpp 2010-06-12 09:06:27 EDT (Sat, 12 Jun 2010)
@@ -33,6 +33,10 @@
std::string content;
};
+ struct block_separator
+ {
+ };
+
struct list_item
{
file_position position;
Modified: branches/quickbook-1.5-spirit2/block_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_actions.cpp 2010-06-12 09:06:27 EDT (Sat, 12 Jun 2010)
@@ -36,16 +36,30 @@
}
}
+ block_formatted process(quickbook::state& state, block_formatted const& x)
+ {
+ state.paragraph_output();
+ return x;
+ }
+
block_formatted process(quickbook::state& state, paragraph const& x)
{
+ state.paragraph_output();
block_formatted r;
r.type="paragraph";
r.content = x.content;
return r;
}
+ nothing process(quickbook::state& state, block_separator const&)
+ {
+ state.paragraph_output();
+ }
+
begin_section2 process(quickbook::state& state, begin_section const& x)
{
+ state.paragraph_output();
+
// TODO: This uses the generated title.
state.section_id.value = x.id ?
x.id->value :
@@ -82,6 +96,8 @@
end_section2 process(quickbook::state& state, end_section const& x)
{
+ state.paragraph_output();
+
if (state.section_level <= state.min_section_level)
{
detail::outerr(x.position.file,x.position.line)
@@ -110,6 +126,8 @@
heading2 process(quickbook::state& state, heading const& x)
{
+ state.paragraph_output();
+
heading2 r;
// TODO: Is this right?
@@ -151,6 +169,8 @@
nothing process(quickbook::state& state, def_macro const& x)
{
+ state.paragraph_output();
+
state.macro.add(
x.macro_identifier.begin()
, x.macro_identifier.end()
@@ -160,6 +180,8 @@
nothing process(quickbook::state& state, define_template const& x)
{
+ state.paragraph_output();
+
if(!state.templates.add(x)) {
detail::outerr(x.body.position.file, x.body.position.line)
<< "Template Redefinition: " << x.id << std::endl;
@@ -171,6 +193,8 @@
table2 process(quickbook::state& state, table const& x)
{
+ state.paragraph_output();
+
table2 r;
if(!x.title.empty()) r.title = x.title;
@@ -207,6 +231,13 @@
return r;
}
+ variablelist process(quickbook::state& state, variablelist const& x)
+ {
+ state.paragraph_output();
+
+ return x;
+ }
+
namespace
{
int load_snippets(
@@ -305,6 +336,8 @@
xinclude2 process(quickbook::state& state, xinclude const& x)
{
+ state.paragraph_output();
+
xinclude2 r;
r.path = calculate_relative_path(detail::escape_uri(x.path), state).string();
return r;
@@ -312,6 +345,8 @@
nothing process(quickbook::state& state, include const& x)
{
+ state.paragraph_output();
+
fs::path filein = include_search(state.filename.parent_path(), x.path);
raw_string doc_id;
@@ -369,6 +404,8 @@
nothing process(quickbook::state& state, import const& x)
{
+ state.paragraph_output();
+
fs::path path = include_search(state.filename.parent_path(), x.path);
std::string ext = path.extension();
std::vector<define_template> storage;
Modified: branches/quickbook-1.5-spirit2/block_actions.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_actions.hpp (original)
+++ branches/quickbook-1.5-spirit2/block_actions.hpp 2010-06-12 09:06:27 EDT (Sat, 12 Jun 2010)
@@ -15,14 +15,16 @@
namespace quickbook
{
- // TODO: Just generate formatted.
+ block_formatted process(quickbook::state&, block_formatted const&);
block_formatted process(quickbook::state&, paragraph const&);
+ nothing process(quickbook::state&, block_separator const&);
begin_section2 process(quickbook::state&, begin_section const&);
end_section2 process(quickbook::state&, end_section const&);
heading2 process(quickbook::state&, heading const&);
nothing process(quickbook::state&, def_macro const&);
nothing process(quickbook::state&, define_template const&);
table2 process(quickbook::state&, table const&);
+ variablelist process(quickbook::state&, variablelist const&);
xinclude2 process(quickbook::state&, xinclude const&);
nothing process(quickbook::state&, import const&);
nothing process(quickbook::state&, include const&);
Modified: branches/quickbook-1.5-spirit2/block_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_grammar.cpp 2010-06-12 09:06:27 EDT (Sat, 12 Jun 2010)
@@ -20,6 +20,7 @@
#include "code.hpp"
#include "misc_rules.hpp"
#include "parse_utils.hpp"
+#include "state.hpp"
namespace quickbook
{
@@ -33,7 +34,8 @@
qi::rule<iterator, quickbook::code()>& code = store_.create();
qi::rule<iterator, quickbook::list()>& list = store_.create();
qi::rule<iterator, quickbook::hr()>& hr = store_.create();
- qi::rule<iterator, quickbook::paragraph()>& paragraph = store_.create();
+ qi::rule<iterator>& paragraph = store_.create();
+ qi::rule<iterator, quickbook::block_separator()>& block_separator = store_.create();
block_start =
blocks >> blank
@@ -44,9 +46,9 @@
| code [actions.process]
| list [actions.process]
| hr [actions.process]
- | comment >> +eol
- | paragraph [actions.process]
+ | block_separator [actions.process]
| eol
+ | paragraph
)
;
@@ -124,27 +126,29 @@
] >> qi::attr(quickbook::hr())
;
- qi::rule<iterator, std::string()>& paragraph_content = store_.create();
qi::rule<iterator>& paragraph_end = store_.create();
qi::symbols<>& paragraph_end_markups = store_.create();
paragraph =
- paragraph_content [member_assign(&quickbook::paragraph::content)]
- ;
-
- paragraph_content =
- qi::eps [actions.phrase_push]
- >> *( common
+ +( common
| (qi::char_ - // Make sure we don't go past
paragraph_end // a single block.
) [actions.process]
)
- >> qi::eps [actions.phrase_pop]
- >> (&qi::lit('[') | +eol)
;
paragraph_end =
- '[' >> space >> paragraph_end_markups >> hard_space | eol >> *qi::blank >> qi::eol
+ '[' >> space >> paragraph_end_markups >> hard_space | block_separator
+ ;
+
+ // Define block_seperator using qi::eol/qi::blank rather than 'eol'
+ // because we don't want any comments in the blank line.
+
+ block_separator =
+ qi::attr(quickbook::block_separator())
+ >> qi::omit
+ [ qi::eol >> *qi::blank >> qi::eol
+ ]
;
paragraph_end_markups =
@@ -180,20 +184,23 @@
// Block contents
- qi::rule<iterator, quickbook::formatted()>& inside_paragraph2 = store_.create();
+ qi::rule<iterator>& inside_paragraph2 = store_.create();
inside_paragraph =
- qi::eps [actions.phrase_push]
- >> inside_paragraph2 [actions.process]
- >> *( +eol
- >> inside_paragraph2 [actions.process]
+ qi::eps [actions.block_push][actions.phrase_push]
+ >> (
+ inside_paragraph2 [actions.process]
+ % block_separator [actions.process]
)
- >> qi::eps [actions.phrase_pop]
+ >> qi::attr(quickbook::block_separator())
+ [actions.process]
+ >> qi::eps [actions.phrase_pop][actions.block_pop]
;
inside_paragraph2 =
- phrase_attr [member_assign(&quickbook::formatted::content)]
- [member_assign(&quickbook::formatted::type, "paragraph")]
+ *( common
+ | (qi::char_ - phrase_end) [actions.process]
+ )
;
phrase_attr =
Modified: branches/quickbook-1.5-spirit2/block_list.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_list.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_list.cpp 2010-06-12 09:06:27 EDT (Sat, 12 Jun 2010)
@@ -44,6 +44,8 @@
list2 process(quickbook::state& state, quickbook::list const& list)
{
+ state.paragraph_output();
+
list::const_iterator it = list.begin(), end = list.end();
BOOST_ASSERT(it != end);
Modified: branches/quickbook-1.5-spirit2/phrase_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_actions.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_actions.cpp 2010-06-12 09:06:27 EDT (Sat, 12 Jun 2010)
@@ -82,6 +82,8 @@
}
boost::variant<formatted, block_formatted> process(quickbook::state& state, code const& x) {
+ if(x.flow == x.block) state.paragraph_output();
+
std::string program = x.content;
if(x.flow == x.block || x.flow == x.inline_block) {
Modified: branches/quickbook-1.5-spirit2/process.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/process.cpp (original)
+++ branches/quickbook-1.5-spirit2/process.cpp 2010-06-12 09:06:27 EDT (Sat, 12 Jun 2010)
@@ -65,6 +65,7 @@
template void process_action::operator()<image>(image const&) const;
template void process_action::operator()<hr>(hr const&) const;
template void process_action::operator()<paragraph>(paragraph const&) const;
+ template void process_action::operator()<block_separator>(block_separator const&) const;
template void process_action::operator()<list>(list const&) const;
template void process_action::operator()<begin_section>(begin_section const&) const;
template void process_action::operator()<end_section>(end_section const&) const;
Modified: branches/quickbook-1.5-spirit2/state.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/state.cpp (original)
+++ branches/quickbook-1.5-spirit2/state.cpp 2010-06-12 09:06:27 EDT (Sat, 12 Jun 2010)
@@ -13,6 +13,7 @@
#include "actions.hpp"
#include "state.hpp"
#include "quickbook.hpp"
+#include "block.hpp"
#if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310))
#pragma warning(disable:4355)
@@ -95,4 +96,19 @@
block.pop();
templates.pop();
}
+
+ void state::paragraph_output()
+ {
+ std::string paragraph;
+ phrase.swap(paragraph);
+
+ if(!paragraph.empty()) {
+ actions a(*this);
+
+ quickbook::paragraph p;
+ p.content = paragraph;
+
+ a.process(p);
+ }
+ }
}
Modified: branches/quickbook-1.5-spirit2/state.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/state.hpp (original)
+++ branches/quickbook-1.5-spirit2/state.hpp 2010-06-12 09:06:27 EDT (Sat, 12 Jun 2010)
@@ -75,6 +75,9 @@
// push/pop the states and the streams
void push();
void pop();
+
+ //
+ void paragraph_output();
};
}
Modified: branches/quickbook-1.5-spirit2/test/code-block-teletype.gold
==============================================================================
--- branches/quickbook-1.5-spirit2/test/code-block-teletype.gold (original)
+++ branches/quickbook-1.5-spirit2/test/code-block-teletype.gold 2010-06-12 09:06:27 EDT (Sat, 12 Jun 2010)
@@ -5,8 +5,6 @@
<title>Code Block Teletype 1</title>
<articleinfo>
</articleinfo>
- <para>
- </para>
<section id="code_block_teletype_1.a_code_block">
<title><link linkend="code_block_teletype_1.a_code_block">A code block</link></title>
Modified: branches/quickbook-1.5-spirit2/test/quickbook-manual.gold
==============================================================================
--- branches/quickbook-1.5-spirit2/test/quickbook-manual.gold (original)
+++ branches/quickbook-1.5-spirit2/test/quickbook-manual.gold 2010-06-12 09:06:27 EDT (Sat, 12 Jun 2010)
@@ -1541,8 +1541,6 @@
highlighted according to the current <link linkend="quickbook.syntax.phrase.source_mode">Source
Mode</link>:
</para>
- <para>
- </para>
<programlisting><phrase role="preprocessor">#include</phrase> <phrase role="special"><</phrase><phrase role="identifier">iostream</phrase><phrase role="special">></phrase>
@@ -1553,9 +1551,7 @@
<phrase role="keyword">return</phrase> <phrase role="number">0</phrase><phrase role="special">;</phrase>
<phrase role="special">}</phrase>
</programlisting>
- <para>
- </para>
-
+
<programlisting><phrase role="keyword">import</phrase> <phrase role="identifier">cgi</phrase>
<phrase role="keyword">def</phrase> <phrase role="identifier">cookForHtml</phrase><phrase role="special">(</phrase><phrase role="identifier">text</phrase><phrase role="special">):</phrase>
@@ -1564,8 +1560,6 @@
<phrase role="keyword">return</phrase> <phrase role="identifier">cgi</phrase><phrase role="special">.</phrase><phrase role="identifier">escape</phrase><phrase role="special">(</phrase><phrase role="identifier">text</phrase><phrase role="special">)</phrase>
</programlisting>
<para>
- </para>
- <para>
Macros that are already defined are expanded in source code. Example:
</para>
@@ -2849,8 +2843,6 @@
</para>
<section id="quickbook.install.windows">
<title><link linkend="quickbook.install.windows"> Windows 2000, XP, 2003, Vista</link></title>
- <para>
- </para>
<blockquote>
<para>
<emphasis>Section contributed by Julio M. Merino Vidal</emphasis>
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