Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r70617 - in branches/quickbook-dev/tools/quickbook: . src test
From: dnljms_at_[hidden]
Date: 2011-03-27 06:31:15


Author: danieljames
Date: 2011-03-27 06:31:13 EDT (Sun, 27 Mar 2011)
New Revision: 70617
URL: http://svn.boost.org/trac/boost/changeset/70617

Log:
Quickbook: Don't require newlines at end of grammar.
Properties modified:
   branches/quickbook-dev/tools/quickbook/ (props changed)
Text files modified:
   branches/quickbook-dev/tools/quickbook/src/actions.cpp | 29 ++++++++---------------------
   branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp | 6 +++---
   branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp | 2 +-
   branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp | 7 ++++---
   branches/quickbook-dev/tools/quickbook/src/utils.cpp | 4 ----
   branches/quickbook-dev/tools/quickbook/src/utils.hpp | 2 --
   branches/quickbook-dev/tools/quickbook/test/templates.gold | 18 ++++++++++++++++++
   branches/quickbook-dev/tools/quickbook/test/templates.quickbook | 20 +++++++++++++++++++-
   8 files changed, 53 insertions(+), 35 deletions(-)

Modified: branches/quickbook-dev/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions.cpp 2011-03-27 06:31:13 EDT (Sun, 27 Mar 2011)
@@ -1115,28 +1115,15 @@
             }
             else
             {
- if (!body.is_block())
- {
- // do a phrase level parse
- actions.filename = body.filename;
- iterator first = body.content.get_quickbook_range().begin();
- iterator last = body.content.get_quickbook_range().end();
-
- return cl::parse(first, last, actions.grammar().simple_phrase).full;
- }
- else
- {
- // do a block level parse
- // ensure that we have enough trailing newlines to eliminate
- // the need to check for end of file in the grammar.
+ actions.filename = body.filename;
+ iterator first = body.content.get_quickbook_range().begin();
+ iterator last = body.content.get_quickbook_range().end();
                     
- actions.filename = body.filename;
- std::string content = body.content.get_quickbook() + "\n\n";
- iterator first(content.begin(), body.content.get_position());
- iterator last(content.end());
-
- return cl::parse(first, last, actions.grammar().block).full;
- }
+ return cl::parse(first, last,
+ body.is_block ?
+ actions.grammar().block :
+ actions.grammar().simple_phrase
+ ).full;
             }
         }
     }

Modified: branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/code_snippet.cpp 2011-03-27 06:31:13 EDT (Sun, 27 Mar 2011)
@@ -136,7 +136,7 @@
                     = cl::confix_p(
                             *cl::blank_p >> "#<-",
                             *cl::anychar_p,
- "#->" >> *cl::blank_p >> cl::eol_p
+ "#->" >> *cl::blank_p >> (cl::eol_p | cl::end_p)
                         )
                     | cl::confix_p(
                             "\"\"\"<-\"\"\"",
@@ -154,7 +154,7 @@
                         cl::confix_p(
                             *cl::space_p >> "#`",
                             (*cl::anychar_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)],
- cl::eol_p
+ (cl::eol_p | cl::end_p)
                         )
                     | cl::confix_p(
                             *cl::space_p >> "\"\"\"`",
@@ -276,7 +276,7 @@
                     = cl::confix_p(
                             *cl::space_p >> "//`",
                             (*cl::anychar_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)],
- cl::eol_p
+ (cl::eol_p | cl::end_p)
                         )
                     | cl::confix_p(
                             *cl::space_p >> "/*`",

Modified: branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp 2011-03-27 06:31:13 EDT (Sun, 27 Mar 2011)
@@ -137,7 +137,7 @@
                 )
>> space [actions.values.sort()]
>> ']'
- >> +cl::eol_p
+ >> (+cl::eol_p | cl::end_p)
             ;
 
         local.quickbook_version =

Modified: branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp 2011-03-27 06:31:13 EDT (Sun, 27 Mar 2011)
@@ -153,6 +153,7 @@
                 | cl::space_p [actions.space_char]
                 | cl::anychar_p [actions.plain_char]
                 )
+ >> cl::eps_p [actions.paragraph]
             ]
             ;
 
@@ -174,7 +175,7 @@
                 cl::str_p("----")
>> actions.values.list(block_tags::hr)
                 [ *(cl::anychar_p - eol)
- >> +eol
+ >> (+eol | cl::end_p)
                 ] [actions.element]
             ;
 
@@ -203,7 +204,7 @@
             ;
 
         local.code_line =
- cl::blank_p >> *(cl::anychar_p - cl::eol_p) >> cl::eol_p
+ cl::blank_p >> *(cl::anychar_p - cl::eol_p) >> (cl::eol_p | cl::end_p)
             ;
 
         local.blank_line =
@@ -241,7 +242,7 @@
                 )
             ]
             ]
- >> +eol
+ >> (+eol | cl::end_p)
             ;
 
         common =

Modified: branches/quickbook-dev/tools/quickbook/src/utils.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/utils.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/utils.cpp 2011-03-27 06:31:13 EDT (Sun, 27 Mar 2011)
@@ -244,10 +244,6 @@
             return 1;
         }
 
- // ensure that we have enough trailing newlines to eliminate
- // the need to check for end of file in the grammar.
- storage.push_back('\n');
- storage.push_back('\n');
         return 0;
     }
 

Modified: branches/quickbook-dev/tools/quickbook/src/utils.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/utils.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/utils.hpp 2011-03-27 06:31:13 EDT (Sun, 27 Mar 2011)
@@ -46,8 +46,6 @@
 
     std::string escape_uri(std::string uri);
 
- // load file into memory with extra trailing newlines to eliminate
- // the need to check for end of file in the grammar.
     int load(fs::path const& filename, std::string& storage);
 
     // given a file extension, return the type of the source file

Modified: branches/quickbook-dev/tools/quickbook/test/templates.gold
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/templates.gold (original)
+++ branches/quickbook-dev/tools/quickbook/test/templates.gold 2011-03-27 06:31:13 EDT (Sun, 27 Mar 2011)
@@ -107,4 +107,22 @@
       phrase template. End phrase template.
     </para>
   </section>
+ <section id="templates.block_markup">
+ <title><link linkend="templates.block_markup">Block Markup</link></title>
+ <itemizedlist>
+ <listitem>
+ <simpara>
+ a
+ </simpara>
+ </listitem>
+ <listitem>
+ <simpara>
+ b
+ </simpara>
+ </listitem>
+ </itemizedlist>
+ <para/>
+
+<programlisting><phrase role="keyword">int</phrase> <phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{}</phrase></programlisting>
+ </section>
 </article>

Modified: branches/quickbook-dev/tools/quickbook/test/templates.quickbook
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/templates.quickbook (original)
+++ branches/quickbook-dev/tools/quickbook/test/templates.quickbook 2011-03-27 06:31:13 EDT (Sun, 27 Mar 2011)
@@ -165,4 +165,22 @@
 [phrase [block Hello!]]
 [phrase [phrase Hello!]]
 
-[endsect]
\ No newline at end of file
+[endsect]
+
+[/----------------------------------- Block Markup ]
+
+[section Block Markup]
+
+[template list
+* a
+* b]
+
+[template horizontal
+----]
+
+[template codeblock
+ int main() {}]
+
+[list][horizontal][codeblock]
+
+[endsect]


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