Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65359 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2010-09-08 20:11:04


Author: danieljames
Date: 2010-09-08 20:11:02 EDT (Wed, 08 Sep 2010)
New Revision: 65359
URL: http://svn.boost.org/trac/boost/changeset/65359

Log:
Use confix parsers in a few places.
Text files modified:
   trunk/tools/quickbook/src/code_snippet.cpp | 127 +++++++++++++++++++++++----------------
   1 files changed, 75 insertions(+), 52 deletions(-)

Modified: trunk/tools/quickbook/src/code_snippet.cpp
==============================================================================
--- trunk/tools/quickbook/src/code_snippet.cpp (original)
+++ trunk/tools/quickbook/src/code_snippet.cpp 2010-09-08 20:11:02 EDT (Wed, 08 Sep 2010)
@@ -9,6 +9,7 @@
 
 #include <boost/spirit/include/classic_core.hpp>
 #include <boost/spirit/include/classic_actor.hpp>
+#include <boost/spirit/include/classic_confix.hpp>
 #include <boost/bind.hpp>
 #include <boost/lexical_cast.hpp>
 #include "template_stack.hpp"
@@ -108,26 +109,35 @@
                     cl::str_p("#]")
                     ;
 
- ignore =
- *cl::blank_p >> "#<-"
- >> (*(cl::anychar_p - "#->"))
- >> "#->" >> *cl::blank_p >> cl::eol_p
- | "\"\"\"<-\"\"\""
- >> (*(cl::anychar_p - "\"\"\"->\"\"\""))
- >> "\"\"\"->\"\"\""
- | "\"\"\"<-"
- >> (*(cl::anychar_p - "->\"\"\""))
- >> "->\"\"\""
+ ignore
+ = cl::confix_p(
+ *cl::blank_p >> "#<-",
+ *cl::anychar_p,
+ "#->" >> *cl::blank_p >> cl::eol_p
+ )
+ | cl::confix_p(
+ "\"\"\"<-\"\"\"",
+ *cl::anychar_p,
+ "\"\"\"->\"\"\""
+ )
+ | cl::confix_p(
+ "\"\"\"<-",
+ *cl::anychar_p,
+ "->\"\"\""
+ )
                     ;
 
                 escaped_comment =
- *cl::space_p >> "#`"
- >> ((*(cl::anychar_p - cl::eol_p))
- >> cl::eol_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
- | *cl::space_p >> "\"\"\"`"
- >> (*(cl::anychar_p - "\"\"\""))
- [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
- >> "\"\"\""
+ cl::confix_p(
+ *cl::space_p >> "#`",
+ (*cl::anychar_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)],
+ cl::eol_p
+ )
+ | cl::confix_p(
+ *cl::space_p >> "\"\"\"`",
+ (*cl::anychar_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)],
+ "\"\"\""
+ )
                     ;
             }
 
@@ -187,41 +197,54 @@
                     cl::str_p("//]") | "/*]*/"
                     ;
 
- inline_callout =
- "/*<"
- >> *cl::space_p
- >> (*(cl::anychar_p - ">*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)]
- >> ">*/"
- ;
-
- line_callout =
- "/*<<"
- >> *cl::space_p
- >> (*(cl::anychar_p - ">>*/")) [boost::bind(&actions_type::callout, &actions, _1, _2)]
- >> ">>*/"
- >> *cl::space_p
- ;
-
- ignore =
- *cl::blank_p >> "//<-"
- >> (*(cl::anychar_p - "//->"))
- >> "//->" >> *cl::blank_p >> cl::eol_p
- | "/*<-*/"
- >> (*(cl::anychar_p - "/*->*/"))
- >> "/*->*/"
- | "/*<-"
- >> (*(cl::anychar_p - "->*/"))
- >> "->*/"
- ;
-
- escaped_comment =
- *cl::space_p >> "//`"
- >> ((*(cl::anychar_p - cl::eol_p))
- >> cl::eol_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
- | *cl::space_p >> "/*`"
- >> (*(cl::anychar_p - "*/"))
- [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)]
- >> "*/"
+ inline_callout
+ = cl::confix_p(
+ "/*<" >> *cl::space_p,
+ (*cl::anychar_p) [boost::bind(&actions_type::callout, &actions, _1, _2)],
+ ">*/"
+ )
+ ;
+
+ line_callout
+ = cl::confix_p(
+ "/*<<" >> *cl::space_p,
+ (*cl::anychar_p) [boost::bind(&actions_type::callout, &actions, _1, _2)],
+ ">>*/"
+ )
+ >> *cl::space_p
+ ;
+
+ ignore
+ = cl::confix_p(
+ *cl::blank_p >> "//<-",
+ *cl::anychar_p,
+ "//->"
+ )
+ >> *cl::blank_p
+ >> cl::eol_p
+ | cl::confix_p(
+ "/*<-*/",
+ *cl::anychar_p,
+ "/*->*/"
+ )
+ | cl::confix_p(
+ "/*<-",
+ *cl::anychar_p,
+ "->*/"
+ )
+ ;
+
+ escaped_comment
+ = cl::confix_p(
+ *cl::space_p >> "//`",
+ (*cl::anychar_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)],
+ cl::eol_p
+ )
+ | cl::confix_p(
+ *cl::space_p >> "/*`",
+ (*cl::anychar_p) [boost::bind(&actions_type::escaped_comment, &actions, _1, _2)],
+ "*/"
+ )
                     ;
             }
 


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