Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r69888 - in branches/quickbook-filenames/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2011-03-12 05:08:02


Author: danieljames
Date: 2011-03-12 05:08:00 EST (Sat, 12 Mar 2011)
New Revision: 69888
URL: http://svn.boost.org/trac/boost/changeset/69888

Log:
Don't require newlines at end of grammars.
Text files modified:
   branches/quickbook-filenames/tools/quickbook/src/actions.cpp | 28 +++++++---------------------
   branches/quickbook-filenames/tools/quickbook/src/code_snippet.cpp | 6 +++---
   branches/quickbook-filenames/tools/quickbook/src/doc_info_grammar.cpp | 2 +-
   branches/quickbook-filenames/tools/quickbook/src/main_grammar.cpp | 7 ++++---
   branches/quickbook-filenames/tools/quickbook/src/utils.cpp | 4 ----
   branches/quickbook-filenames/tools/quickbook/src/utils.hpp | 2 --
   branches/quickbook-filenames/tools/quickbook/test/templates.gold | 18 ++++++++++++++++++
   branches/quickbook-filenames/tools/quickbook/test/templates.quickbook | 20 +++++++++++++++++++-
   8 files changed, 52 insertions(+), 35 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-03-12 05:08:00 EST (Sat, 12 Mar 2011)
@@ -1031,28 +1031,14 @@
             }
             else
             {
- if (!body.is_block)
- {
- // do a phrase level parse
- actions.filename = body.filename;
- iterator first(body.content.begin(), body.position);
- iterator last(body.content.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.begin(), body.position);
+ iterator last(body.content.end());
                     
- actions.filename = body.filename;
- std::string content = body.content + "\n\n";
- iterator first(content.begin(), body.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-filenames/tools/quickbook/src/code_snippet.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/code_snippet.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/code_snippet.cpp 2011-03-12 05:08:00 EST (Sat, 12 Mar 2011)
@@ -116,7 +116,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(
                             "\"\"\"<-\"\"\"",
@@ -134,7 +134,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 >> "\"\"\"`",
@@ -241,7 +241,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-filenames/tools/quickbook/src/doc_info_grammar.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/doc_info_grammar.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/doc_info_grammar.cpp 2011-03-12 05:08:00 EST (Sat, 12 Mar 2011)
@@ -133,7 +133,7 @@
                 )
>> space [actions.values.sort()]
>> ']'
- >> +cl::eol_p
+ >> (+cl::eol_p | cl::end_p)
             ;
 
         local.quickbook_version =

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-03-12 05:08:00 EST (Sat, 12 Mar 2011)
@@ -151,6 +151,7 @@
                 | cl::space_p [actions.space_char]
                 | cl::anychar_p [actions.plain_char]
                 )
+ >> cl::eps_p [actions.paragraph]
             ]
             ;
 
@@ -171,7 +172,7 @@
         local.hr =
             cl::str_p("----")
>> *(cl::anychar_p - eol)
- >> +eol
+ >> (+eol | cl::end_p)
             ;
 
         local.element
@@ -200,7 +201,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 =
@@ -238,7 +239,7 @@
                 )
             ]
             ]
- >> +eol
+ >> (+eol | cl::end_p)
             ;
 
         common =

Modified: branches/quickbook-filenames/tools/quickbook/src/utils.cpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/utils.cpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/utils.cpp 2011-03-12 05:08:00 EST (Sat, 12 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-filenames/tools/quickbook/src/utils.hpp
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/src/utils.hpp (original)
+++ branches/quickbook-filenames/tools/quickbook/src/utils.hpp 2011-03-12 05:08:00 EST (Sat, 12 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-filenames/tools/quickbook/test/templates.gold
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/templates.gold (original)
+++ branches/quickbook-filenames/tools/quickbook/test/templates.gold 2011-03-12 05:08:00 EST (Sat, 12 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-filenames/tools/quickbook/test/templates.quickbook
==============================================================================
--- branches/quickbook-filenames/tools/quickbook/test/templates.quickbook (original)
+++ branches/quickbook-filenames/tools/quickbook/test/templates.quickbook 2011-03-12 05:08:00 EST (Sat, 12 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