|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62847 - branches/quickbook-1.5-spirit2
From: daniel_james_at_[hidden]
Date: 2010-06-12 09:05:23
Author: danieljames
Date: 2010-06-12 09:05:21 EDT (Sat, 12 Jun 2010)
New Revision: 62847
URL: http://svn.boost.org/trac/boost/changeset/62847
Log:
Split up the grammars.
Added:
branches/quickbook-1.5-spirit2/block_section_grammar.cpp (contents, props changed)
branches/quickbook-1.5-spirit2/block_table_grammar.cpp (contents, props changed)
branches/quickbook-1.5-spirit2/block_template_grammar.cpp (contents, props changed)
branches/quickbook-1.5-spirit2/phrase_image_grammar.cpp (contents, props changed)
Text files modified:
branches/quickbook-1.5-spirit2/Jamfile.v2 | 4
branches/quickbook-1.5-spirit2/block_grammar.cpp | 52 ++++++++
branches/quickbook-1.5-spirit2/block_markup_grammar.cpp | 243 ----------------------------------------
branches/quickbook-1.5-spirit2/grammar.cpp | 4
branches/quickbook-1.5-spirit2/grammar_impl.hpp | 8 +
branches/quickbook-1.5-spirit2/phrase_grammar.cpp | 11
branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp | 64 ----------
7 files changed, 73 insertions(+), 313 deletions(-)
Modified: branches/quickbook-1.5-spirit2/Jamfile.v2
==============================================================================
--- branches/quickbook-1.5-spirit2/Jamfile.v2 (original)
+++ branches/quickbook-1.5-spirit2/Jamfile.v2 2010-06-12 09:05:21 EDT (Sat, 12 Jun 2010)
@@ -33,10 +33,14 @@
grammar.cpp
phrase_grammar.cpp
phrase_markup_grammar.cpp
+ phrase_image_grammar.cpp
phrase_actions.cpp
phrase_image.cpp
block_grammar.cpp
block_markup_grammar.cpp
+ block_template_grammar.cpp
+ block_section_grammar.cpp
+ block_table_grammar.cpp
block_actions.cpp
block_list.cpp
doc_info_grammar.cpp
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:05:21 EDT (Sat, 12 Jun 2010)
@@ -178,5 +178,57 @@
error =
qi::raw[qi::eps] [actions.error];
+ // Block contents
+
+ qi::rule<iterator, quickbook::formatted()>& inside_paragraph2 = store_.create();
+
+ inside_paragraph =
+ qi::eps [actions.phrase_push]
+ >> inside_paragraph2 [actions.process]
+ >> *( +eol
+ >> inside_paragraph2 [actions.process]
+ )
+ >> qi::eps [actions.phrase_pop]
+ ;
+
+ inside_paragraph2 =
+ phrase_attr [member_assign(&quickbook::formatted::content)]
+ [member_assign(&quickbook::formatted::type, "paragraph")]
+ ;
+
+ phrase_attr =
+ qi::eps [actions.phrase_push]
+ >> *( common
+ | comment
+ | (qi::char_ - phrase_end) [actions.process]
+ )
+ >> qi::eps [actions.phrase_pop]
+ ;
+
+ // Make sure that we don't go past a single block, except when
+ // preformatted.
+ phrase_end =
+ ']' | qi::eps(ph::ref(no_eols)) >> eol >> *qi::blank >> qi::eol
+ ;
+
+ // Identifiers
+
+ qi::rule<iterator, raw_string()>& element_id_part = store_.create();
+
+ element_id =
+ ( ':'
+ >> -(qi::eps(qbk_since(105u)) >> space)
+ >> (
+ element_id_part
+ | qi::omit[
+ qi::raw[qi::eps] [actions.element_id_warning]
+ ]
+ )
+ )
+ | qi::eps
+ ;
+
+ element_id_part = qi::raw[+(qi::alnum | qi::char_('_'))]
+ [qi::_val = qi::_1];
}
}
Modified: branches/quickbook-1.5-spirit2/block_markup_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_markup_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/block_markup_grammar.cpp 2010-06-12 09:05:21 EDT (Sat, 12 Jun 2010)
@@ -16,7 +16,6 @@
#include <boost/spirit/include/phoenix_operator.hpp>
#include "grammar_impl.hpp"
#include "block.hpp"
-#include "template.hpp"
#include "actions.hpp"
#include "code.hpp"
#include "misc_rules.hpp"
@@ -36,49 +35,6 @@
void quickbook_grammar::impl::init_block_markup()
{
- qi::rule<iterator, quickbook::title()>& title_phrase = store_.create();
- qi::rule<iterator, std::string()>& inside_paragraph = store_.create();
- qi::rule<iterator, std::string()>& phrase_attr = store_.create();
- qi::rule<iterator>& phrase_end = store_.create();
- qi::rule<iterator, boost::optional<raw_string>()>& element_id = store_.create();
-
- // Sections
-
- qi::rule<iterator, quickbook::begin_section()>& begin_section = store_.create();
- qi::rule<iterator, quickbook::end_section()>& end_section = store_.create();
- block_keyword_rules.add("section", begin_section[actions.process]);
- block_keyword_rules.add("endsect", end_section[actions.process]);
-
- begin_section =
- space
- >> element_id [member_assign(&quickbook::begin_section::id)]
- >> title_phrase [member_assign(&quickbook::begin_section::content)]
- ;
-
- end_section =
- space
- >> position [member_assign(&quickbook::end_section::position)]
- ;
-
- // Headings
-
- qi::rule<iterator, quickbook::heading(int)>& heading = store_.create();
-
- block_keyword_rules.add
- ("h1", heading(1) [actions.process])
- ("h2", heading(2) [actions.process])
- ("h3", heading(3) [actions.process])
- ("h4", heading(4) [actions.process])
- ("h5", heading(5) [actions.process])
- ("h6", heading(6) [actions.process])
- ("heading", heading(-1) [actions.process]);
-
- heading =
- qi::attr(qi::_r1) [member_assign(&quickbook::heading::level)]
- >> space
- >> title_phrase [member_assign(&quickbook::heading::content)]
- ;
-
// Paragraph Blocks
qi::rule<iterator, quickbook::formatted(formatted_type)>& paragraph_block = store_.create();
@@ -129,101 +85,6 @@
>> phrase_attr [member_assign(&quickbook::def_macro::content)]
;
- // Table
-
- qi::rule<iterator, quickbook::table()>& table = store_.create();
- qi::rule<iterator, quickbook::table_row()>& table_row = store_.create();
- qi::rule<iterator, quickbook::table_cell()>& table_cell = store_.create();
- qi::rule<iterator, quickbook::formatted()>& table_cell_body = store_.create();
-
- block_keyword_rules.add("table", table[actions.process]);
-
- table =
- (&(*qi::blank >> qi::eol) | space)
- >> ((
- qi::eps(qbk_since(105u))
- >> element_id [member_assign(&quickbook::table::id)]
- ) | qi::eps)
- >> (&(*qi::blank >> qi::eol) | space)
- >> (*(qi::char_ - eol)) [member_assign(&quickbook::table::title)]
- >> +eol
- >> (*table_row) [member_assign(&quickbook::table::rows)]
- ;
-
- table_row =
- space
- >> '['
- >> ( *table_cell >> ']' >> space
- | error >> qi::attr(quickbook::table_row())
- )
- ;
-
- table_cell =
- space
- >> '['
- >> ( table_cell_body >> ']' >> space
- | error >> qi::attr(quickbook::table_cell())
- )
- ;
-
- table_cell_body =
- inside_paragraph [member_assign(&quickbook::formatted::content)]
- [member_assign(&quickbook::formatted::type, "cell")]
- ;
-
- qi::rule<iterator, quickbook::variablelist()>& variablelist = store_.create();
- qi::rule<iterator, quickbook::varlistentry()>& varlistentry = store_.create();
- qi::rule<iterator, quickbook::formatted()>& varlistterm = store_.create();
- qi::rule<iterator, quickbook::formatted()>& varlistterm_body = store_.create();
- qi::rule<iterator, quickbook::formatted()>& varlistitem = store_.create();
- qi::rule<iterator, quickbook::formatted()>& varlistitem_body = store_.create();
-
- block_keyword_rules.add("variablelist", variablelist[actions.process]);
-
- variablelist =
- (&(*qi::blank >> qi::eol) | space)
- >> (*(qi::char_ - eol)) [member_assign(&quickbook::variablelist::title)]
- >> +eol
- >> (*varlistentry) [member_assign(&quickbook::variablelist::entries)]
- ;
-
- varlistentry =
- space
- >> '['
- >> ( varlistterm
- >> +varlistitem
- >> ']'
- >> space
- | error >> qi::attr(quickbook::varlistentry())
- )
- ;
-
- varlistterm =
- space
- >> '['
- >> ( varlistterm_body >> ']' >> space
- | error >> qi::attr(quickbook::formatted())
- )
- ;
-
- varlistterm_body =
- phrase_attr [member_assign(&quickbook::formatted::content)]
- [member_assign(&quickbook::formatted::type, "varlistterm")]
- ;
-
- varlistitem =
- space
- >> '['
- >> ( varlistitem_body >> ']' >> space
- | error >> qi::attr(quickbook::formatted())
- )
- ;
-
- varlistitem_body =
- inside_paragraph [member_assign(&quickbook::formatted::content)]
- [member_assign(&quickbook::formatted::type, "varlistitem")]
- ;
-
// xinclude
qi::rule<iterator, quickbook::xinclude()>& xinclude = store_.create();
@@ -266,109 +127,5 @@
space
>> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::import::path)]
;
-
- // Define Template
-
- qi::rule<iterator, quickbook::define_template()>& define_template = store_.create();
- qi::rule<iterator, std::vector<std::string>()>& define_template_params = store_.create();
- qi::rule<iterator, quickbook::template_value()>& template_body = store_.create();
- qi::rule<iterator>& template_body_recurse = store_.create();
- qi::rule<iterator, std::string()>& template_id = store_.create();
-
- block_keyword_rules.add("template", define_template[actions.process]);
-
- define_template =
- space
- >> template_id [member_assign(&quickbook::define_template::id)]
- >> -define_template_params [member_assign(&quickbook::define_template::params)]
- >> template_body [member_assign(&quickbook::define_template::body)]
- ;
-
- define_template_params =
- space
- >> '['
- >> *(space >> template_id)
- >> space
- >> ']'
- ;
-
- template_body =
- position [member_assign(&quickbook::template_value::position)]
- >> qi::raw[template_body_recurse] [member_assign(&quickbook::template_value::content)]
- ;
-
- template_body_recurse =
- *( ('[' >> template_body_recurse >> ']')
- | (qi::char_ - ']')
- )
- >> space
- >> &qi::lit(']')
- ;
-
- template_id
- = (qi::alpha | '_') >> *(qi::alnum | '_')
- | qi::repeat(1)[qi::punct - qi::char_("[]")]
- ;
-
- // Block contents
-
- // Used when the title is used both to generate the title text and
- // possibly to generate an id (based on the raw source).
- title_phrase =
- qi::raw[
- phrase_attr [member_assign(&quickbook::title::content)]
- ] [member_assign(&quickbook::title::raw)]
- ;
-
- qi::rule<iterator, quickbook::formatted()>& inside_paragraph2 = store_.create();
-
- inside_paragraph =
- qi::eps [actions.phrase_push]
- >> inside_paragraph2 [actions.process]
- >> *( +eol
- >> inside_paragraph2 [actions.process]
- )
- >> qi::eps [actions.phrase_pop]
- ;
-
- inside_paragraph2 =
- phrase_attr [member_assign(&quickbook::formatted::content)]
- [member_assign(&quickbook::formatted::type, "paragraph")]
- ;
-
- phrase_attr =
- qi::eps [actions.phrase_push]
- >> *( common
- | comment
- | (qi::char_ - phrase_end) [actions.process]
- )
- >> qi::eps [actions.phrase_pop]
- ;
-
- // Make sure that we don't go past a single block, except when
- // preformatted.
- phrase_end =
- ']' | qi::eps(ph::ref(no_eols)) >> eol >> *qi::blank >> qi::eol
- ;
-
- // Identifiers
-
- qi::rule<iterator, raw_string()>& element_id_part = store_.create();
-
- element_id =
- ( ':'
- >> -(qi::eps(qbk_since(105u)) >> space)
- >> (
- element_id_part
- | qi::omit[
- qi::raw[qi::eps] [actions.element_id_warning]
- ]
- )
- )
- | qi::eps
- ;
-
- element_id_part = qi::raw[+(qi::alnum | qi::char_('_'))]
- [qi::_val = qi::_1];
}
}
\ No newline at end of file
Added: branches/quickbook-1.5-spirit2/block_section_grammar.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/block_section_grammar.cpp 2010-06-12 09:05:21 EDT (Sat, 12 Jun 2010)
@@ -0,0 +1,81 @@
+/*=============================================================================
+ Copyright (c) 2002 2004 2006Joel de Guzman
+ Copyright (c) 2004 Eric Niebler
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#include <boost/spirit/include/qi_core.hpp>
+#include <boost/spirit/include/qi_attr.hpp>
+#include <boost/spirit/include/qi_eps.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include "grammar_impl.hpp"
+#include "block.hpp"
+#include "actions.hpp"
+#include "misc_rules.hpp"
+#include "parse_utils.hpp"
+
+namespace quickbook
+{
+ namespace qi = boost::spirit::qi;
+ namespace ph = boost::phoenix;
+
+ // Workaround for clang:
+ namespace {
+ struct dummmy {
+ qi::rule<iterator, raw_string()> a1;
+ };
+ }
+
+ void quickbook_grammar::impl::init_block_section()
+ {
+ qi::rule<iterator, quickbook::title()>& title_phrase = store_.create();
+
+ // Sections
+
+ qi::rule<iterator, quickbook::begin_section()>& begin_section = store_.create();
+ qi::rule<iterator, quickbook::end_section()>& end_section = store_.create();
+ block_keyword_rules.add("section", begin_section[actions.process]);
+ block_keyword_rules.add("endsect", end_section[actions.process]);
+
+ begin_section =
+ space
+ >> element_id [member_assign(&quickbook::begin_section::id)]
+ >> title_phrase [member_assign(&quickbook::begin_section::content)]
+ ;
+
+ end_section =
+ space
+ >> position [member_assign(&quickbook::end_section::position)]
+ ;
+
+ // Headings
+
+ qi::rule<iterator, quickbook::heading(int)>& heading = store_.create();
+
+ block_keyword_rules.add
+ ("h1", heading(1) [actions.process])
+ ("h2", heading(2) [actions.process])
+ ("h3", heading(3) [actions.process])
+ ("h4", heading(4) [actions.process])
+ ("h5", heading(5) [actions.process])
+ ("h6", heading(6) [actions.process])
+ ("heading", heading(-1) [actions.process]);
+
+ heading =
+ qi::attr(qi::_r1) [member_assign(&quickbook::heading::level)]
+ >> space
+ >> title_phrase [member_assign(&quickbook::heading::content)]
+ ;
+
+ title_phrase =
+ qi::raw[
+ phrase_attr [member_assign(&quickbook::title::content)]
+ ] [member_assign(&quickbook::title::raw)]
+ ;
+ }
+}
\ No newline at end of file
Added: branches/quickbook-1.5-spirit2/block_table_grammar.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/block_table_grammar.cpp 2010-06-12 09:05:21 EDT (Sat, 12 Jun 2010)
@@ -0,0 +1,133 @@
+/*=============================================================================
+ Copyright (c) 2002 2004 2006Joel de Guzman
+ Copyright (c) 2004 Eric Niebler
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#include <boost/spirit/include/qi_core.hpp>
+#include <boost/spirit/include/qi_attr.hpp>
+#include <boost/spirit/include/qi_eps.hpp>
+#include <boost/spirit/include/qi_eol.hpp>
+#include <boost/spirit/include/phoenix_core.hpp>
+#include <boost/spirit/include/phoenix_operator.hpp>
+#include "grammar_impl.hpp"
+#include "block.hpp"
+#include "actions.hpp"
+#include "code.hpp"
+#include "misc_rules.hpp"
+#include "parse_utils.hpp"
+
+namespace quickbook
+{
+ namespace qi = boost::spirit::qi;
+ namespace ph = boost::phoenix;
+
+ // Workaround for clang:
+ namespace {
+ struct dummmy {
+ qi::rule<iterator, raw_string()> a1;
+ };
+ }
+
+ void quickbook_grammar::impl::init_block_table()
+ {
+ // Table
+
+ qi::rule<iterator, quickbook::table()>& table = store_.create();
+ qi::rule<iterator, quickbook::table_row()>& table_row = store_.create();
+ qi::rule<iterator, quickbook::table_cell()>& table_cell = store_.create();
+ qi::rule<iterator, quickbook::formatted()>& table_cell_body = store_.create();
+
+ block_keyword_rules.add("table", table[actions.process]);
+
+ table =
+ (&(*qi::blank >> qi::eol) | space)
+ >> ((
+ qi::eps(qbk_since(105u))
+ >> element_id [member_assign(&quickbook::table::id)]
+ ) | qi::eps)
+ >> (&(*qi::blank >> qi::eol) | space)
+ >> (*(qi::char_ - eol)) [member_assign(&quickbook::table::title)]
+ >> +eol
+ >> (*table_row) [member_assign(&quickbook::table::rows)]
+ ;
+
+ table_row =
+ space
+ >> '['
+ >> ( *table_cell >> ']' >> space
+ | error >> qi::attr(quickbook::table_row())
+ )
+ ;
+
+ table_cell =
+ space
+ >> '['
+ >> ( table_cell_body >> ']' >> space
+ | error >> qi::attr(quickbook::table_cell())
+ )
+ ;
+
+ table_cell_body =
+ inside_paragraph [member_assign(&quickbook::formatted::content)]
+ [member_assign(&quickbook::formatted::type, "cell")]
+ ;
+
+ qi::rule<iterator, quickbook::variablelist()>& variablelist = store_.create();
+ qi::rule<iterator, quickbook::varlistentry()>& varlistentry = store_.create();
+ qi::rule<iterator, quickbook::formatted()>& varlistterm = store_.create();
+ qi::rule<iterator, quickbook::formatted()>& varlistterm_body = store_.create();
+ qi::rule<iterator, quickbook::formatted()>& varlistitem = store_.create();
+ qi::rule<iterator, quickbook::formatted()>& varlistitem_body = store_.create();
+
+ block_keyword_rules.add("variablelist", variablelist[actions.process]);
+
+ variablelist =
+ (&(*qi::blank >> qi::eol) | space)
+ >> (*(qi::char_ - eol)) [member_assign(&quickbook::variablelist::title)]
+ >> +eol
+ >> (*varlistentry) [member_assign(&quickbook::variablelist::entries)]
+ ;
+
+ varlistentry =
+ space
+ >> '['
+ >> ( varlistterm
+ >> +varlistitem
+ >> ']'
+ >> space
+ | error >> qi::attr(quickbook::varlistentry())
+ )
+ ;
+
+ varlistterm =
+ space
+ >> '['
+ >> ( varlistterm_body >> ']' >> space
+ | error >> qi::attr(quickbook::formatted())
+ )
+ ;
+
+ varlistterm_body =
+ phrase_attr [member_assign(&quickbook::formatted::content)]
+ [member_assign(&quickbook::formatted::type, "varlistterm")]
+ ;
+
+ varlistitem =
+ space
+ >> '['
+ >> ( varlistitem_body >> ']' >> space
+ | error >> qi::attr(quickbook::formatted())
+ )
+ ;
+
+ varlistitem_body =
+ inside_paragraph [member_assign(&quickbook::formatted::content)]
+ [member_assign(&quickbook::formatted::type, "varlistitem")]
+ ;
+ }
+}
\ No newline at end of file
Added: branches/quickbook-1.5-spirit2/block_template_grammar.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/block_template_grammar.cpp 2010-06-12 09:05:21 EDT (Sat, 12 Jun 2010)
@@ -0,0 +1,67 @@
+/*=============================================================================
+ Copyright (c) 2002 2004 2006Joel de Guzman
+ Copyright (c) 2004 Eric Niebler
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#include <boost/spirit/include/qi_core.hpp>
+#include "grammar_impl.hpp"
+#include "template.hpp"
+#include "actions.hpp"
+#include "misc_rules.hpp"
+#include "parse_utils.hpp"
+
+namespace quickbook
+{
+ namespace qi = boost::spirit::qi;
+
+ void quickbook_grammar::impl::init_block_template()
+ {
+ // Define Template
+
+ qi::rule<iterator, quickbook::define_template()>& define_template = store_.create();
+ qi::rule<iterator, std::vector<std::string>()>& define_template_params = store_.create();
+ qi::rule<iterator, quickbook::template_value()>& template_body = store_.create();
+ qi::rule<iterator>& template_body_recurse = store_.create();
+ qi::rule<iterator, std::string()>& template_id = store_.create();
+
+ block_keyword_rules.add("template", define_template[actions.process]);
+
+ define_template =
+ space
+ >> template_id [member_assign(&quickbook::define_template::id)]
+ >> -define_template_params [member_assign(&quickbook::define_template::params)]
+ >> template_body [member_assign(&quickbook::define_template::body)]
+ ;
+
+ define_template_params =
+ space
+ >> '['
+ >> *(space >> template_id)
+ >> space
+ >> ']'
+ ;
+
+ template_body =
+ position [member_assign(&quickbook::template_value::position)]
+ >> qi::raw[template_body_recurse] [member_assign(&quickbook::template_value::content)]
+ ;
+
+ template_body_recurse =
+ *( ('[' >> template_body_recurse >> ']')
+ | (qi::char_ - ']')
+ )
+ >> space
+ >> &qi::lit(']')
+ ;
+
+ template_id
+ = (qi::alpha | '_') >> *(qi::alnum | '_')
+ | qi::repeat(1)[qi::punct - qi::char_("[]")]
+ ;
+ }
+}
\ No newline at end of file
Modified: branches/quickbook-1.5-spirit2/grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/grammar.cpp 2010-06-12 09:05:21 EDT (Sat, 12 Jun 2010)
@@ -34,8 +34,12 @@
{
init_phrase();
init_phrase_markup();
+ init_phrase_image();
init_block();
init_block_markup();
+ init_block_section();
+ init_block_table();
+ init_block_template();
init_doc_info();
}
}
Modified: branches/quickbook-1.5-spirit2/grammar_impl.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/grammar_impl.hpp (original)
+++ branches/quickbook-1.5-spirit2/grammar_impl.hpp 2010-06-12 09:05:21 EDT (Sat, 12 Jun 2010)
@@ -33,6 +33,7 @@
qi::rule<iterator, std::string()> phrase;
qi::symbols<char, qi::rule<iterator> > phrase_keyword_rules;
qi::symbols<char, qi::rule<iterator> > phrase_symbol_rules;
+ qi::rule<iterator> phrase_end;
// block
qi::rule<iterator> block_start;
@@ -40,6 +41,9 @@
qi::symbols<char, qi::rule<iterator> > block_keyword_rules;
qi::symbols<char, qi::rule<iterator> > block_symbol_rules;
qi::rule<iterator> error;
+ qi::rule<iterator, std::string()> phrase_attr;
+ qi::rule<iterator, std::string()> inside_paragraph;
+ qi::rule<iterator, boost::optional<raw_string>()> element_id;
// doc_info
qi::rule<iterator, quickbook::doc_info()> doc_info_details;
@@ -50,8 +54,12 @@
void init_phrase();
void init_phrase_markup();
+ void init_phrase_image();
void init_block();
void init_block_markup();
+ void init_block_section();
+ void init_block_table();
+ void init_block_template();
void init_doc_info();
};
}
Modified: branches/quickbook-1.5-spirit2/phrase_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_grammar.cpp 2010-06-12 09:05:21 EDT (Sat, 12 Jun 2010)
@@ -11,6 +11,7 @@
#include <boost/spirit/include/qi_core.hpp>
#include <boost/spirit/include/qi_attr.hpp>
#include <boost/spirit/include/qi_eoi.hpp>
+#include <boost/spirit/include/qi_eol.hpp>
#include <boost/spirit/include/qi_eps.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include "grammar_impl.hpp"
@@ -37,7 +38,6 @@
qi::rule<iterator>& escape = store_.create();
qi::rule<iterator, quickbook::call_template()>& call_template = store_.create();
qi::rule<iterator, quickbook::break_()>& break_ = store_.create();
- qi::rule<iterator>& phrase_end = store_.create();
simple_phrase =
*( common
@@ -258,11 +258,10 @@
> qi::raw[qi::repeat(8)[qi::xdigit]] [member_assign(&quickbook::unicode_char::value)]
;
+ // Make sure that we don't go past a single block, except when
+ // preformatted.
phrase_end =
- ']' |
- qi::eps(ph::ref(no_eols)) >>
- eol >> eol // Make sure that we don't go
- ; // past a single block, except
- // when preformatted.
+ ']' | qi::eps(ph::ref(no_eols)) >> eol >> *qi::blank >> qi::eol
+ ;
}
}
Added: branches/quickbook-1.5-spirit2/phrase_image_grammar.cpp
==============================================================================
--- (empty file)
+++ branches/quickbook-1.5-spirit2/phrase_image_grammar.cpp 2010-06-12 09:05:21 EDT (Sat, 12 Jun 2010)
@@ -0,0 +1,79 @@
+/*=============================================================================
+ Copyright (c) 2002 2004 2006 Joel de Guzman
+ Copyright (c) 2004 Eric Niebler
+ http://spirit.sourceforge.net/
+
+ Use, modification and distribution is subject to the Boost Software
+ License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+=============================================================================*/
+
+#include <boost/spirit/include/qi_core.hpp>
+#include <boost/spirit/include/qi_eps.hpp>
+#include "grammar_impl.hpp"
+#include "phrase.hpp"
+#include "actions.hpp"
+#include "misc_rules.hpp"
+#include "parse_utils.hpp"
+
+namespace quickbook
+{
+ namespace qi = boost::spirit::qi;
+ namespace ph = boost::phoenix;
+
+ void quickbook_grammar::impl::init_phrase_image()
+ {
+ // Images
+
+ qi::rule<iterator, quickbook::image()>& image = store_.create();
+ qi::rule<iterator, quickbook::image()>& image_1_4 = store_.create();
+ qi::rule<iterator, quickbook::image()>& image_1_5 = store_.create();
+ qi::rule<iterator, std::string()>& image_filename = store_.create();
+ qi::rule<iterator, quickbook::image::attribute_map()>& image_attributes = store_.create();
+ qi::rule<iterator, std::pair<std::string, std::string>()>& image_attribute = store_.create();
+ qi::rule<iterator, std::string()>& image_attribute_key = store_.create();
+ qi::rule<iterator, std::string()>& image_attribute_value = store_.create();
+
+ phrase_symbol_rules.add("$", image [actions.process]);
+
+ image =
+ (qi::eps(qbk_since(105u)) >> image_1_5) |
+ (qi::eps(qbk_before(105u)) >> image_1_4);
+
+ image_1_4 =
+ position [member_assign(&quickbook::image::position)]
+ >> blank
+ >> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::image::image_filename)]
+ >> &qi::lit(']')
+ ;
+
+ image_1_5 =
+ position [member_assign(&quickbook::image::position)]
+ >> blank
+ >> image_filename [member_assign(&quickbook::image::image_filename)]
+ >> hard_space
+ >> image_attributes [member_assign(&quickbook::image::attributes)]
+ >> &qi::lit(']')
+ ;
+
+ image_filename = qi::raw[
+ +(qi::char_ - (qi::space | phrase_end | '['))
+ >> *(
+ +qi::space
+ >> +(qi::char_ - (qi::space | phrase_end | '['))
+ )];
+
+ image_attributes = *(image_attribute >> space);
+
+ image_attribute =
+ '['
+ >> image_attribute_key [member_assign(&std::pair<std::string, std::string>::first)]
+ >> space
+ >> image_attribute_value [member_assign(&std::pair<std::string, std::string>::second)]
+ >> ']'
+ ;
+
+ image_attribute_key = *(qi::alnum | '_');
+ image_attribute_value = *(qi::char_ - (phrase_end | '['));
+ }
+}
\ No newline at end of file
Modified: branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp (original)
+++ branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp 2010-06-12 09:05:21 EDT (Sat, 12 Jun 2010)
@@ -26,8 +26,6 @@
void quickbook_grammar::impl::init_phrase_markup()
{
- qi::rule<iterator>& phrase_end = store_.create();
-
// Callouts
// Don't use this, it's meant to be private.
@@ -53,59 +51,6 @@
>> -phrase [member_assign(&quickbook::cond_phrase::content)]
;
- // Images
-
- qi::rule<iterator, quickbook::image()>& image = store_.create();
- qi::rule<iterator, quickbook::image()>& image_1_4 = store_.create();
- qi::rule<iterator, quickbook::image()>& image_1_5 = store_.create();
- qi::rule<iterator, std::string()>& image_filename = store_.create();
- qi::rule<iterator, quickbook::image::attribute_map()>& image_attributes = store_.create();
- qi::rule<iterator, std::pair<std::string, std::string>()>& image_attribute = store_.create();
- qi::rule<iterator, std::string()>& image_attribute_key = store_.create();
- qi::rule<iterator, std::string()>& image_attribute_value = store_.create();
-
- phrase_symbol_rules.add("$", image [actions.process]);
-
- image =
- (qi::eps(qbk_since(105u)) >> image_1_5) |
- (qi::eps(qbk_before(105u)) >> image_1_4);
-
- image_1_4 =
- position [member_assign(&quickbook::image::position)]
- >> blank
- >> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::image::image_filename)]
- >> &qi::lit(']')
- ;
-
- image_1_5 =
- position [member_assign(&quickbook::image::position)]
- >> blank
- >> image_filename [member_assign(&quickbook::image::image_filename)]
- >> hard_space
- >> image_attributes [member_assign(&quickbook::image::attributes)]
- >> &qi::lit(']')
- ;
-
- image_filename = qi::raw[
- +(qi::char_ - (qi::space | phrase_end | '['))
- >> *(
- +qi::space
- >> +(qi::char_ - (qi::space | phrase_end | '['))
- )];
-
- image_attributes = *(image_attribute >> space);
-
- image_attribute =
- '['
- >> image_attribute_key [member_assign(&std::pair<std::string, std::string>::first)]
- >> space
- >> image_attribute_value [member_assign(&std::pair<std::string, std::string>::second)]
- >> ']'
- ;
-
- image_attribute_key = *(qi::alnum | '_');
- image_attribute_value = *(qi::char_ - (phrase_end | '['));
-
// URL
qi::rule<iterator, quickbook::link()>& url = store_.create();
@@ -188,14 +133,5 @@
>> blank
>> phrase [member_assign(&quickbook::formatted::content)]
;
-
- // phrase_end
-
- phrase_end =
- ']' |
- qi::eps(ph::ref(no_eols)) >>
- eol >> eol // Make sure that we don't go
- ; // past a single block, except
- // when preformatted.
}
}
\ No newline at end of file
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