Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r65162 - in branches/quickbook-1.5-spirit2: . src test
From: dnljms_at_[hidden]
Date: 2010-09-01 04:36:19


Author: danieljames
Date: 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
New Revision: 65162
URL: http://svn.boost.org/trac/boost/changeset/65162

Log:
Merge reorganization of quickbook from trunk.
Added:
   branches/quickbook-1.5-spirit2/src/
   branches/quickbook-1.5-spirit2/src/Jamfile.v2
      - copied, changed from r65159, /branches/quickbook-1.5-spirit2/Jamfile.v2
   branches/quickbook-1.5-spirit2/src/actions.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/actions.cpp
   branches/quickbook-1.5-spirit2/src/actions.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/actions.hpp
   branches/quickbook-1.5-spirit2/src/block.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/block.hpp
   branches/quickbook-1.5-spirit2/src/block_actions.cpp
      - copied unchanged from r65160, /branches/quickbook-1.5-spirit2/block_actions.cpp
   branches/quickbook-1.5-spirit2/src/block_actions.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/block_actions.hpp
   branches/quickbook-1.5-spirit2/src/block_grammar.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/block_grammar.cpp
   branches/quickbook-1.5-spirit2/src/block_list.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/block_list.cpp
   branches/quickbook-1.5-spirit2/src/block_markup_grammar.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/block_markup_grammar.cpp
   branches/quickbook-1.5-spirit2/src/block_section_grammar.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/block_section_grammar.cpp
   branches/quickbook-1.5-spirit2/src/block_table_grammar.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/block_table_grammar.cpp
   branches/quickbook-1.5-spirit2/src/boostbook.cpp
      - copied unchanged from r65160, /branches/quickbook-1.5-spirit2/boostbook.cpp
   branches/quickbook-1.5-spirit2/src/code.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/code.hpp
   branches/quickbook-1.5-spirit2/src/code_grammar.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/code_grammar.cpp
   branches/quickbook-1.5-spirit2/src/code_snippet_actions.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/code_snippet_actions.cpp
   branches/quickbook-1.5-spirit2/src/code_snippet_grammar.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/code_snippet_grammar.cpp
   branches/quickbook-1.5-spirit2/src/code_snippet_grammar.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/code_snippet_grammar.hpp
   branches/quickbook-1.5-spirit2/src/code_snippet_types.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/code_snippet_types.hpp
   branches/quickbook-1.5-spirit2/src/collector.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/collector.cpp
   branches/quickbook-1.5-spirit2/src/collector.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/collector.hpp
   branches/quickbook-1.5-spirit2/src/doc_info.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/doc_info.hpp
   branches/quickbook-1.5-spirit2/src/doc_info_actions.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/doc_info_actions.cpp
   branches/quickbook-1.5-spirit2/src/doc_info_actions.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/doc_info_actions.hpp
   branches/quickbook-1.5-spirit2/src/doc_info_grammar.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/doc_info_grammar.cpp
   branches/quickbook-1.5-spirit2/src/encoder.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/encoder.hpp
   branches/quickbook-1.5-spirit2/src/encoder_impl.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/encoder_impl.cpp
   branches/quickbook-1.5-spirit2/src/encoder_impl.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/encoder_impl.hpp
   branches/quickbook-1.5-spirit2/src/fwd.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/fwd.hpp
   branches/quickbook-1.5-spirit2/src/gen_types.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/gen_types.hpp
   branches/quickbook-1.5-spirit2/src/grammar.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/grammar.cpp
   branches/quickbook-1.5-spirit2/src/grammar.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/grammar.hpp
   branches/quickbook-1.5-spirit2/src/grammar_impl.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/grammar_impl.hpp
   branches/quickbook-1.5-spirit2/src/html.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/html.cpp
   branches/quickbook-1.5-spirit2/src/input_path.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/input_path.cpp
   branches/quickbook-1.5-spirit2/src/input_path.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/input_path.hpp
   branches/quickbook-1.5-spirit2/src/misc_rules.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/misc_rules.cpp
   branches/quickbook-1.5-spirit2/src/misc_rules.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/misc_rules.hpp
   branches/quickbook-1.5-spirit2/src/parse_types.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/parse_types.hpp
   branches/quickbook-1.5-spirit2/src/parse_utils.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/parse_utils.hpp
   branches/quickbook-1.5-spirit2/src/phrase.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/phrase.hpp
   branches/quickbook-1.5-spirit2/src/phrase_actions.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/phrase_actions.cpp
   branches/quickbook-1.5-spirit2/src/phrase_actions.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/phrase_actions.hpp
   branches/quickbook-1.5-spirit2/src/phrase_grammar.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/phrase_grammar.cpp
   branches/quickbook-1.5-spirit2/src/phrase_image.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/phrase_image.cpp
   branches/quickbook-1.5-spirit2/src/phrase_image_grammar.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/phrase_image_grammar.cpp
   branches/quickbook-1.5-spirit2/src/phrase_markup_grammar.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp
   branches/quickbook-1.5-spirit2/src/post_process.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/post_process.cpp
   branches/quickbook-1.5-spirit2/src/post_process.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/post_process.hpp
   branches/quickbook-1.5-spirit2/src/process.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/process.cpp
   branches/quickbook-1.5-spirit2/src/quickbook.cpp
      - copied unchanged from r65160, /branches/quickbook-1.5-spirit2/quickbook.cpp
   branches/quickbook-1.5-spirit2/src/quickbook.hpp
      - copied unchanged from r65160, /branches/quickbook-1.5-spirit2/quickbook.hpp
   branches/quickbook-1.5-spirit2/src/rule_store.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/rule_store.hpp
   branches/quickbook-1.5-spirit2/src/state.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/state.cpp
   branches/quickbook-1.5-spirit2/src/state.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/state.hpp
   branches/quickbook-1.5-spirit2/src/strings.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/strings.hpp
   branches/quickbook-1.5-spirit2/src/syntax_highlight.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/syntax_highlight.hpp
   branches/quickbook-1.5-spirit2/src/syntax_highlight_grammar.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/syntax_highlight_grammar.cpp
   branches/quickbook-1.5-spirit2/src/template.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/template.cpp
   branches/quickbook-1.5-spirit2/src/template.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/template.hpp
   branches/quickbook-1.5-spirit2/src/template_grammar.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/template_grammar.cpp
   branches/quickbook-1.5-spirit2/src/utils.cpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/utils.cpp
   branches/quickbook-1.5-spirit2/src/utils.hpp
      - copied unchanged from r65159, /branches/quickbook-1.5-spirit2/utils.hpp
Removed:
   branches/quickbook-1.5-spirit2/actions.cpp
   branches/quickbook-1.5-spirit2/actions.hpp
   branches/quickbook-1.5-spirit2/block.hpp
   branches/quickbook-1.5-spirit2/block_actions.cpp
   branches/quickbook-1.5-spirit2/block_actions.hpp
   branches/quickbook-1.5-spirit2/block_grammar.cpp
   branches/quickbook-1.5-spirit2/block_list.cpp
   branches/quickbook-1.5-spirit2/block_markup_grammar.cpp
   branches/quickbook-1.5-spirit2/block_section_grammar.cpp
   branches/quickbook-1.5-spirit2/block_table_grammar.cpp
   branches/quickbook-1.5-spirit2/boostbook.cpp
   branches/quickbook-1.5-spirit2/code.hpp
   branches/quickbook-1.5-spirit2/code_grammar.cpp
   branches/quickbook-1.5-spirit2/code_snippet_actions.cpp
   branches/quickbook-1.5-spirit2/code_snippet_grammar.cpp
   branches/quickbook-1.5-spirit2/code_snippet_grammar.hpp
   branches/quickbook-1.5-spirit2/code_snippet_types.hpp
   branches/quickbook-1.5-spirit2/collector.cpp
   branches/quickbook-1.5-spirit2/collector.hpp
   branches/quickbook-1.5-spirit2/doc_info.hpp
   branches/quickbook-1.5-spirit2/doc_info_actions.cpp
   branches/quickbook-1.5-spirit2/doc_info_actions.hpp
   branches/quickbook-1.5-spirit2/doc_info_grammar.cpp
   branches/quickbook-1.5-spirit2/encoder.hpp
   branches/quickbook-1.5-spirit2/encoder_impl.cpp
   branches/quickbook-1.5-spirit2/encoder_impl.hpp
   branches/quickbook-1.5-spirit2/fwd.hpp
   branches/quickbook-1.5-spirit2/gen_types.hpp
   branches/quickbook-1.5-spirit2/grammar.cpp
   branches/quickbook-1.5-spirit2/grammar.hpp
   branches/quickbook-1.5-spirit2/grammar_impl.hpp
   branches/quickbook-1.5-spirit2/html.cpp
   branches/quickbook-1.5-spirit2/input_path.cpp
   branches/quickbook-1.5-spirit2/input_path.hpp
   branches/quickbook-1.5-spirit2/misc_rules.cpp
   branches/quickbook-1.5-spirit2/misc_rules.hpp
   branches/quickbook-1.5-spirit2/parse_types.hpp
   branches/quickbook-1.5-spirit2/parse_utils.hpp
   branches/quickbook-1.5-spirit2/phrase.hpp
   branches/quickbook-1.5-spirit2/phrase_actions.cpp
   branches/quickbook-1.5-spirit2/phrase_actions.hpp
   branches/quickbook-1.5-spirit2/phrase_grammar.cpp
   branches/quickbook-1.5-spirit2/phrase_image.cpp
   branches/quickbook-1.5-spirit2/phrase_image_grammar.cpp
   branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp
   branches/quickbook-1.5-spirit2/post_process.cpp
   branches/quickbook-1.5-spirit2/post_process.hpp
   branches/quickbook-1.5-spirit2/process.cpp
   branches/quickbook-1.5-spirit2/quickbook.cpp
   branches/quickbook-1.5-spirit2/quickbook.hpp
   branches/quickbook-1.5-spirit2/rule_store.hpp
   branches/quickbook-1.5-spirit2/state.cpp
   branches/quickbook-1.5-spirit2/state.hpp
   branches/quickbook-1.5-spirit2/strings.hpp
   branches/quickbook-1.5-spirit2/syntax_highlight.hpp
   branches/quickbook-1.5-spirit2/syntax_highlight_grammar.cpp
   branches/quickbook-1.5-spirit2/template.cpp
   branches/quickbook-1.5-spirit2/template.hpp
   branches/quickbook-1.5-spirit2/template_grammar.cpp
   branches/quickbook-1.5-spirit2/utils.cpp
   branches/quickbook-1.5-spirit2/utils.hpp
Properties modified:
   branches/quickbook-1.5-spirit2/ (props changed)
Text files modified:
   branches/quickbook-1.5-spirit2/Jamfile.v2 | 62 +--------------------------------------
   branches/quickbook-1.5-spirit2/src/Jamfile.v2 | 20 ------------
   branches/quickbook-1.5-spirit2/test/quickbook-testing.jam | 4 +-
   3 files changed, 5 insertions(+), 81 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-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
@@ -8,67 +8,11 @@
 # http://www.boost.org/LICENSE_1_0.txt)
 #==============================================================================
 
-project quickbook
- : requirements
- <toolset>gcc:<c++-template-depth>300
- <toolset>darwin:<c++-template-depth>300
- <toolset>clang:<c++-template-depth>300
- <toolset>gcc:<cflags>-g0
- <toolset>darwin:<cflags>-g0
- <debug-symbols>off
- <warnings>off
+alias quickbook
+ : src//quickbook
     ;
 
-exe quickbook
- :
- process.cpp
- quickbook.cpp
- actions.cpp
- state.cpp
- utils.cpp
- input_path.cpp
- post_process.cpp
- collector.cpp
- template.cpp
- 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_section_grammar.cpp
- block_table_grammar.cpp
- block_actions.cpp
- block_list.cpp
- template_grammar.cpp
- code_grammar.cpp
- doc_info_grammar.cpp
- doc_info_actions.cpp
- code_snippet_actions.cpp
- code_snippet_grammar.cpp
- syntax_highlight_grammar.cpp
- boostbook.cpp
- html.cpp
- encoder_impl.cpp
- misc_rules.cpp
- /boost//program_options
- /boost//filesystem
- : #<define>QUICKBOOK_NO_DATES
- # Still using 'normalize' which has been deprecated.
- #<define>BOOST_FILESYSTEM_NO_DEPRECATED
- <toolset>msvc:<cxxflags>/wd4355
- <toolset>msvc:<cxxflags>/wd4511
- <toolset>msvc:<cxxflags>/wd4512
- <toolset>msvc:<cxxflags>/wd4701
- <toolset>msvc:<cxxflags>/wd4702
- <toolset>msvc:<cxxflags>/wd4244
- <toolset>msvc:<cxxflags>/wd4267
- <toolset>msvc:<cxxflags>/wd4800
- <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
- <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
- ;
+explicit quickbook ;
 
 install dist-bin
     :

Deleted: branches/quickbook-1.5-spirit2/actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/actions.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,62 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2005 Thomas Guest
- 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 "actions.hpp"
-#include "state.hpp"
-#include "doc_info.hpp"
-#include "utils.hpp"
-
-namespace quickbook
-{
- char const* quickbook_get_date = "__quickbook_get_date__";
- char const* quickbook_get_time = "__quickbook_get_time__";
- unsigned qbk_major_version = 0;
- unsigned qbk_minor_version = 0;
- unsigned qbk_version_n = 0; // qbk_major_version * 100 + qbk_minor_version
-
- actions::actions(state& state)
- : state_(state)
- , templates(state.templates)
- , macro(state.macro)
- , process(*this)
- , phrase_push(state.phrase)
- , phrase_pop(state.phrase)
- , block_push(state.block)
- , block_pop(state.block)
- , error(state.error_count)
- {}
-
- void error_action::operator()(file_position pos, unused_type, unused_type) const
- {
- detail::outerr(pos.file,pos.line)
- << "Syntax Error near column " << pos.column << ".\n";
- ++error_count;
- }
-
- void element_id_warning_action::operator()(file_position pos, unused_type, unused_type) const
- {
- detail::outwarn(pos.file,pos.line) << "Empty id.\n";
- }
-
- void phrase_push_action::operator()() const
- {
- phrase.push();
- }
-
- std::string phrase_pop_action::operator()() const
- {
- std::string out;
- phrase.swap(out);
- phrase.pop();
- return out;
- }
-}
-

Deleted: branches/quickbook-1.5-spirit2/actions.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/actions.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,184 +0,0 @@
-/*=============================================================================
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_ACTIONS_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_ACTIONS_HPP
-
-#include <map>
-#include <string>
-#include <vector>
-#include <boost/spirit/include/qi_symbols.hpp>
-#include <boost/spirit/include/phoenix_function.hpp>
-#include "fwd.hpp"
-
-#ifdef BOOST_MSVC
-// disable copy/assignment could not be generated, unreferenced formal params
-#pragma warning (push)
-#pragma warning(disable : 4511 4512 4100)
-#endif
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
- using boost::spirit::unused_type;
-
- extern unsigned qbk_major_version;
- extern unsigned qbk_minor_version;
- extern unsigned qbk_version_n; // qbk_major_version * 100 + qbk_minor_version
-
- struct quickbook_since_impl {
- template <typename Arg1>
- struct result { typedef bool type; };
-
- bool operator()(unsigned min_) const {
- return qbk_version_n >= min_;
- }
- };
-
- struct quickbook_before_impl {
- template <typename Arg1>
- struct result { typedef bool type; };
-
- bool operator()(unsigned max_) const {
- return qbk_version_n < max_;
- }
- };
-
- namespace {
- boost::phoenix::function<quickbook_since_impl> qbk_since;
- boost::phoenix::function<quickbook_before_impl> qbk_before;
- }
-
- // TODO: Define this elsewhere?
-
- struct macro {
- macro() {}
- explicit macro(char const* x) : raw_markup(x) {};
- explicit macro(std::string const& x) : raw_markup(x) {};
-
- std::string raw_markup;
- };
-
- typedef qi::symbols<char, macro> macro_symbols;
-
- typedef boost::iterator_range<iterator> iterator_range;
-
- struct error_action
- {
- // Prints an error message to std::cerr
-
- error_action(
- int& error_count)
- : error_count(error_count) {}
-
- void operator()(file_position, unused_type, unused_type) const;
-
- int& error_count;
- };
-
- extern char const* quickbook_get_date;
- extern char const* quickbook_get_time;
-
- struct element_id_warning_action
- {
- void operator()(file_position, unused_type, unused_type) const;
- };
-
- struct phrase_push_action
- {
- phrase_push_action(collector& phrase)
- : phrase(phrase) {}
-
- void operator()(unused_type, unused_type, unused_type) const {
- return (*this)();
- }
-
- void operator()() const;
-
- collector& phrase;
- };
-
- struct phrase_pop_action
- {
- phrase_pop_action(collector& phrase)
- : phrase(phrase) {}
-
- template <typename Context>
- void operator()(unused_type x1, Context& c, unused_type x2) const
- {
- boost::spirit::_val(x1, c, x2) = (*this)();
- }
-
- std::string operator()() const;
-
- collector& phrase;
- };
-
- struct process_action
- {
- process_action(quickbook::actions& actions)
- : actions(actions) {}
-
- typedef void result_type;
-
- template <typename Arg1, typename Arg2 = void, typename Arg3 = void>
- struct result { typedef void type; };
-
- template <typename Attrib, typename Context>
- void operator()(Attrib& a, Context& c, bool& pass) const {
- (*this)(a);
- }
-
- template <typename T>
- void operator()(boost::optional<T> const& x) const {
- if(x) (*this)(*x);
- }
-
- template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
- void operator()(boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> const& x) const {
- return boost::apply_visitor(*this, x);
- }
-
- void operator()(unused_type) const {
- }
-
- template <typename T>
- void operator()(T const& x) const;
-
- quickbook::actions& actions;
- };
-
- ///////////////////////////////////////////////////////////////////////////
- // actions
- ///////////////////////////////////////////////////////////////////////////
-
- struct actions
- {
- actions(state&);
-
- state& state_;
- template_stack& templates;
- macro_symbols& macro;
-
- process_action process;
- phrase_push_action phrase_push;
- phrase_pop_action phrase_pop;
- phrase_push_action block_push;
- phrase_pop_action block_pop;
- error_action error;
- element_id_warning_action element_id_warning;
- };
-}
-
-#ifdef BOOST_MSVC
-#pragma warning (pop)
-#endif
-
-#endif // BOOST_SPIRIT_QUICKBOOK_ACTIONS_HPP
-

Deleted: branches/quickbook-1.5-spirit2/block.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,115 +0,0 @@
-/*=============================================================================
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_BLOCK_HPP
-
-#include <string>
-#include <vector>
-#include <boost/optional.hpp>
-#include "fwd.hpp"
-#include "parse_types.hpp"
-#include "strings.hpp"
-
-namespace quickbook
-{
- struct block_formatted {
- formatted_type type;
- std::string content;
- };
-
- struct hr
- {
- };
-
- struct paragraph
- {
- std::string content;
- };
-
- struct block_separator
- {
- };
-
- struct list_item
- {
- file_position position;
- std::string indent;
- char mark;
- std::string content;
- };
-
- typedef std::vector<list_item> list;
-
- struct title
- {
- raw_source raw;
- std::string content;
- };
-
- struct begin_section
- {
- boost::optional<raw_string> id;
- title content;
- };
-
- struct end_section
- {
- quickbook::file_position position;
- };
-
- struct heading
- {
- int level;
- boost::optional<raw_string> id;
- title content;
- };
-
- struct def_macro
- {
- std::string macro_identifier;
- std::string content;
- };
-
- typedef std::vector<quickbook::block_formatted> varlistentry;
-
- struct variablelist
- {
- raw_string title;
- std::vector<varlistentry> entries;
- };
-
- typedef quickbook::block_formatted table_cell;
- typedef std::vector<table_cell> table_row;
-
- struct table
- {
- boost::optional<raw_string> id;
- raw_string title;
- std::vector<table_row> rows;
- };
-
- struct xinclude
- {
- std::string path;
- };
-
- struct import
- {
- std::string path;
- };
-
- struct include
- {
- boost::optional<raw_string> id;
- std::string path;
- };
-}
-
-#endif

Deleted: branches/quickbook-1.5-spirit2/block_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_actions.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,416 +0,0 @@
-/*=============================================================================
- 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 <numeric>
-#include <boost/assert.hpp>
-#include <boost/filesystem/v3/convenience.hpp>
-#include "block_actions.hpp"
-#include "actions.hpp"
-#include "state.hpp"
-#include "quickbook.hpp"
-#include "code_snippet_grammar.hpp"
-#include "code_snippet_types.hpp"
-#include "utils.hpp"
-#include "encoder.hpp"
-
-namespace quickbook
-{
- namespace {
- raw_string fully_qualified_id(
- std::string const& library_id,
- raw_string const& qualified_section_id,
- raw_string const& section_id)
- {
- raw_string id;
- id.value = library_id;
- if(!id.empty() && !qualified_section_id.empty()) id.value += '.';
- id.value += qualified_section_id.value;
- if(!id.empty() && !section_id.empty()) id.value += '.';
- id.value += section_id.value;
- return id;
- }
- }
-
- void process(quickbook::state& state, block_formatted const& x)
- {
- state.paragraph_output();
- state.encode(x);
- }
-
- void process(quickbook::state& state, paragraph const& x)
- {
- state.paragraph_output();
- block_formatted r;
- r.type="paragraph";
- r.content = x.content;
- state.encode(r);
- }
-
- void process(quickbook::state& state, block_separator const&)
- {
- state.paragraph_output();
- }
-
- void 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 :
- detail::make_identifier(x.content.raw);
-
- if (state.section_level != 0) {
- state.qualified_section_id.value += '.';
- }
- else {
- BOOST_ASSERT(state.qualified_section_id.empty());
- }
-
- state.qualified_section_id.value += state.section_id.value;
- ++state.section_level;
-
- begin_section2 r;
-
- if (qbk_version_n < 103) // version 1.2 and below
- {
- r.id.value = state.doc_id + "." + state.section_id.value;
- }
- else // version 1.3 and above
- {
- r.linkend.value = r.id.value =
- state.doc_id + "." + state.qualified_section_id.value;
- }
-
- r.content = x.content.content;
- state.encode(r);
- }
-
- void 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)
- << "Mismatched [endsect] near column " << x.position.column << ".\n";
- ++state.error_count;
-
- return;
- }
-
- --state.section_level;
-
- if (state.section_level == 0)
- {
- state.qualified_section_id.value.clear();
- }
- else
- {
- std::string::size_type const n =
- state.qualified_section_id.value.find_last_of('.');
- state.qualified_section_id.value.erase(n, std::string::npos);
- }
-
- state.encode(end_section2());
- }
-
- void process(quickbook::state& state, heading const& x)
- {
- state.paragraph_output();
-
- heading2 r;
-
- // TODO: Is this right?
- bool new_style = qbk_version_n >= 103 || x.level > 0;
-
- r.level = x.level;
- if(r.level < 0) {
- r.level = state.section_level + 2;
- // section_level is zero-based. We need to use a
- // one-based heading which is one greater
- // than the current. Thus: section_level + 2.
- if (r.level > 6) // The max is h6, clip it if it goes
- r.level = 6; // further than that
- }
-
- if (!new_style) // version 1.2 and below
- {
- r.id.value = state.section_id.value + "." +
- detail::make_identifier(x.content.content);
- }
- else // version 1.3 and above
- {
- raw_string id;
- id.value =
- x.id ? x.id->value :
- qbk_version_n >= 106 ? detail::make_identifier(x.content.raw) :
- detail::make_identifier(x.content.content);
-
- r.linkend = r.id = fully_qualified_id(
- state.doc_id, state.qualified_section_id, id);
-
- }
-
- r.content = x.content.content;
-
- state.encode(r);
- }
-
- void process(quickbook::state& state, def_macro const& x)
- {
- state.paragraph_output();
-
- state.macro.add(
- x.macro_identifier.begin()
- , x.macro_identifier.end()
- , quickbook::macro(x.content));
- }
-
- void process(quickbook::state& state, define_template const& x)
- {
- state.paragraph_output();
-
- if(!state.templates.add(x, state.templates.top_scope.get())) {
- detail::outerr(x.body.position.file, x.body.position.line)
- << "Template Redefinition: " << x.id << std::endl;
- ++state.error_count;
- }
- }
-
- void process(quickbook::state& state, table const& x)
- {
- state.paragraph_output();
-
- table2 r;
-
- if(!x.title.empty()) r.title = x.title;
-
- if(qbk_version_n >= 105) {
- if(x.id) {
- r.id = fully_qualified_id(state.doc_id,
- state.qualified_section_id, *x.id);
- }
- else if(r.title) {
- raw_string id;
- id.value = detail::make_identifier(x.title);
-
- r.id = fully_qualified_id(state.doc_id,
- state.qualified_section_id, id);
- }
- }
-
- r.cols = x.rows.empty() ? 0 : x.rows.back().size();
-
- std::vector<table_row>::const_iterator row = x.rows.begin();
-
- // Backwards compatability again: the old version turned the first row
- // into a header at the start of the second row. So it only happened
- // when there was more than one row.
- if (x.rows.size() > 1)
- {
- r.head = *row;
- ++row;
- }
-
- r.rows.assign(row, x.rows.end());
-
- state.encode(r);
- }
-
- void process(quickbook::state& state, variablelist const& x)
- {
- state.paragraph_output();
- state.encode(x);
- }
-
- namespace
- {
- int load_snippets(
- std::string const& file
- , std::vector<define_template>& storage // for storing snippets are stored in a
- // vector of define_templates
- , std::string const& extension
- , std::string const& doc_id)
- {
- std::string code;
- int err = detail::load(file, code);
- if (err != 0)
- return err; // return early on error
-
- iterator first(code.begin(), code.end(), file);
- iterator last(code.end(), code.end());
-
- size_t fname_len = file.size();
- bool is_python = fname_len >= 3
- && file[--fname_len]=='y' && file[--fname_len]=='p' && file[--fname_len]=='.';
- code_snippet_actions a(storage, doc_id, is_python ? "[python]" : "[c++]");
- // TODO: Should I check that parse succeeded?
- if(is_python) {
- python_code_snippet_grammar g(a);
- boost::spirit::qi::parse(first, last, g);
- }
- else {
- cpp_code_snippet_grammar g(a);
- boost::spirit::qi::parse(first, last, g);
- }
-
- return 0;
- }
-
- fs::path include_search(fs::path const & current, std::string const & name)
- {
- fs::path path(name);
-
- // If the path is relative, try and resolve it.
- if (!path.is_complete())
- {
- // See if it can be found locally first.
- if (fs::exists(current / path))
- {
- return current / path;
- }
-
- // Search in each of the include path locations.
- BOOST_FOREACH(std::string const & p, include_path)
- {
- fs::path full(p);
- full /= path;
- if (fs::exists(full))
- {
- return full;
- }
- }
- }
-
- return path;
- }
-
- fs::path path_difference(fs::path const& outdir, fs::path const& path)
- {
- fs::path outtmp, temp;
- fs::path::iterator out = outdir.begin(), file = path.begin();
- for(; out != outdir.end() && file != path.end(); ++out, ++file)
- {
- if(!fs::equivalent(outtmp /= *out, temp /= *file))
- break;
- }
- out = (out == outdir.begin()) ? outdir.end() : out;
-
- fs::path result = fs::path();
- for(; out != outdir.end(); ++out)
- if(*out != ".") result /= "..";
- std::divides<fs::path> concat;
- return std::accumulate(file, path.end(), result, concat);
- }
-
- fs::path calculate_relative_path(std::string const& x, quickbook::state& state)
- {
- // Given a source file and the current filename, calculate the
- // path to the source file relative to the output directory.
- fs::path path(x);
- if (!path.is_complete())
- {
- fs::path infile = fs::absolute(state.filename).normalize();
- path = (infile.parent_path() / path).normalize();
- fs::path outdir = fs::absolute(state.outdir).normalize();
- path = path_difference(outdir, path);
- }
- return path;
- }
- }
-
- void process(quickbook::state& state, xinclude const& x)
- {
- state.paragraph_output();
-
- xinclude2 r;
- r.path = calculate_relative_path(detail::escape_uri(x.path), state).string();
- state.encode(r);
- }
-
- void process(quickbook::state& state, include const& x)
- {
- state.paragraph_output();
-
- fs::path filein = include_search(state.filename.parent_path(), x.path);
- std::string doc_id;
-
- // swap the filenames
- std::swap(state.filename, filein);
-
- // save the doc info strings
- if(qbk_version_n >= 106) {
- doc_id = state.doc_id;
- }
- else {
- std::swap(state.doc_id, doc_id);
- }
-
- // save the version info
- unsigned qbk_major_version_store = qbk_major_version;
- unsigned qbk_minor_version_store = qbk_minor_version;
- unsigned qbk_version_n_store = qbk_version_n;
-
- // scope the macros
- macro_symbols macro = state.macro;
- // scope the templates
- //~ template_symbols templates = state.templates; $$$ fixme $$$
-
- // if an id is specified in this include (as in [include:id foo.qbk])
- // then use it as the doc_id.
- if (x.id) state.doc_id = x.id->value;
-
- // update the __FILENAME__ macro
- *state.macro.find("__FILENAME__") =
- quickbook::macro(state.filename.native());
-
- // parse the file
- quickbook::parse_file(state.filename.native().c_str(), state, true);
-
- // restore the values
- std::swap(state.filename, filein);
-
- std::swap(state.doc_id, doc_id);
-
- if(qbk_version_n >= 106 || qbk_version_n_store >= 106)
- {
- qbk_major_version = qbk_major_version_store;
- qbk_minor_version = qbk_minor_version_store;
- qbk_version_n = qbk_version_n_store;
- }
-
- // restore the macros
- state.macro = macro;
- // restore the templates
- //~ state.templates = templates; $$$ fixme $$$
- }
-
- void 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().generic_string();
- std::vector<define_template> storage;
- state.error_count +=
- load_snippets(path.string(), storage, ext, state.doc_id);
-
- BOOST_FOREACH(define_template const& definition, storage)
- {
- if (!state.templates.add(definition, state.templates.top_scope.get()))
- {
- detail::outerr(definition.body.position.file, definition.body.position.line)
- << "Template Redefinition: " << definition.id << std::endl;
- ++state.error_count;
- }
- }
- }
-}
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/block_actions.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_actions.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,33 +0,0 @@
-/*=============================================================================
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_BLOCK_ACTIONS_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_BLOCK_ACTIONS_HPP
-
-#include "block.hpp"
-
-namespace quickbook
-{
- void process(quickbook::state&, block_formatted const&);
- void process(quickbook::state&, paragraph const&);
- void process(quickbook::state&, block_separator const&);
- void process(quickbook::state&, begin_section const&);
- void process(quickbook::state&, end_section const&);
- void process(quickbook::state&, heading const&);
- void process(quickbook::state&, def_macro const&);
- void process(quickbook::state&, define_template const&);
- void process(quickbook::state&, table const&);
- void process(quickbook::state&, variablelist const&);
- void process(quickbook::state&, xinclude const&);
- void process(quickbook::state&, import const&);
- void process(quickbook::state&, include const&);
- void process(quickbook::state&, list const&);
-}
-
-#endif
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/block_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_grammar.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,195 +0,0 @@
-/*=============================================================================
- 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_operator.hpp>
-#include "grammar_impl.hpp"
-#include "block.hpp"
-#include "actions.hpp"
-#include "misc_rules.hpp"
-#include "parse_utils.hpp"
-#include "state.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
- namespace ph = boost::phoenix;
-
- struct block_grammar_local
- {
- qi::rule<iterator> blocks;
- qi::rule<iterator, qi::locals<qi::rule<iterator> > > block_markup;
- qi::rule<iterator, qi::rule<iterator>()> block_markup_start;
- qi::rule<iterator, quickbook::list()> list;
- qi::rule<iterator, quickbook::list_item()> list_item;
- qi::rule<iterator, std::string()> list_item_content;
- qi::rule<iterator, quickbook::hr()> hr;
- qi::rule<iterator> paragraph;
- qi::rule<iterator, quickbook::block_separator()> block_separator;
- qi::rule<iterator, quickbook::def_macro()> command_line_macro_parse;
- qi::rule<iterator, std::string()> command_line_macro_identifier;
- };
-
- void quickbook_grammar::impl::init_block(bool skip_initial_spaces)
- {
- block_grammar_local& local = store_.create();
-
- if (skip_initial_spaces)
- {
- block_start =
- *(qi::blank | comment) >> local.blocks >> blank
- ;
- }
- else
- {
- block_start =
- local.blocks >> blank
- ;
- }
-
- local.blocks =
- *( local.block_markup
- | indented_code [actions.process]
- | local.list [actions.process]
- | local.hr [actions.process]
- | local.block_separator [actions.process]
- | +eol
- | local.paragraph
- )
- ;
-
- // Block markup
-
- local.block_markup
- = local.block_markup_start [qi::_a = qi::_1]
- >> lazy(qi::_a)
- >> ( (space >> ']' >> +eol)
- | error
- )
- ;
-
- local.block_markup_start
- = '['
- >> space
- >> ( block_keyword_rules >> !(qi::alnum | '_')
- | block_symbol_rules
- )
- ;
-
- // List
-
- local.list =
- &qi::char_("*#")
- >> +local.list_item
- ;
-
- local.list_item =
- position [member_assign(&quickbook::list_item::position)]
- >> (*qi::blank) [member_assign(&quickbook::list_item::indent)]
- >> qi::char_("*#") [member_assign(&quickbook::list_item::mark)]
- >> *qi::blank
- >> local.list_item_content [member_assign(&quickbook::list_item::content)]
- ;
-
- local.list_item_content =
- qi::eps[actions.phrase_push] >>
- *( common
- | (qi::char_ -
- ( qi::eol >> *qi::blank >> &qi::char_("*#")
- | (eol >> *qi::blank >> qi::eol)
- )
- ) [actions.process]
- )
- >> +eol
- >> qi::eps[actions.phrase_pop]
- ;
-
- // Horizontol rule
-
- local.hr =
- qi::omit[
- "----"
- >> *(qi::char_ - eol)
- >> +eol
- ] >> qi::attr(quickbook::hr())
- ;
-
- // Paragraph
-
- local.paragraph =
- +( common
- | (qi::char_ - (local.block_separator | local.block_markup_start))
- [actions.process]
- )
- ;
-
- // Define block_separator using qi::eol/qi::blank rather than 'eol'
- // because we don't want any comments in the blank line.
-
- local.block_separator =
- qi::attr(quickbook::block_separator())
- >> qi::omit
- [ qi::eol >> *qi::blank >> qi::eol
- ]
- ;
-
- // Parse command line macro definition. This is more here out of
- // convenience than anything.
-
- command_line_macro = local.command_line_macro_parse [actions.process];
-
- local.command_line_macro_parse =
- space
- >> local.command_line_macro_identifier [member_assign(&quickbook::def_macro::macro_identifier)]
- >> space
- >> -( '='
- >> space
- >> phrase [member_assign(&quickbook::def_macro::content)]
- >> space
- )
- ;
-
- local.command_line_macro_identifier =
- +(~qi::char_("=]") - qi::space)
- ;
-
- // Error
-
- error = position [actions.error];
-
- // Block contents
-
- inside_paragraph =
- qi::eps [actions.block_push][actions.phrase_push]
- >> *( common
- | (qi::char_ - phrase_end) [actions.process]
- | local.block_separator [actions.process]
- )
- >> qi::attr(quickbook::block_separator())
- [actions.process]
- >> qi::eps [actions.phrase_pop][actions.block_pop]
- ;
-
- // Identifiers
-
- element_id =
- -( ':'
- >> -(qi::eps(qbk_since(105u)) >> space)
- >> (
- qi::raw[+(qi::alnum | '_')] [qi::_val = qi::_1]
- | position [actions.element_id_warning]
- )
- )
- ;
- }
-}

Deleted: branches/quickbook-1.5-spirit2/block_list.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_list.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,96 +0,0 @@
-/*=============================================================================
- 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 <stack>
-#include <boost/assert.hpp>
-#include "block_actions.hpp"
-#include "state.hpp"
-#include "gen_types.hpp"
-#include "utils.hpp"
-#include "encoder.hpp"
-
-#include <iostream>
-
-namespace quickbook
-{
- namespace {
- int indent_length(std::string const& indent)
- {
- int length = 0;
- for(std::string::const_iterator
- first = indent.begin(), end = indent.end(); first != end; ++first)
- {
- switch(*first) {
- case ' ': ++length; break;
- // hardcoded tab to 4 for now
- case '\t': length = ((length + 4) / 4) * 4; break;
- default: BOOST_ASSERT(false);
- }
- }
-
- return length;
- }
- }
-
- struct stack_entry
- {
- explicit stack_entry(list2& list, int indent) : list(list), indent(indent) {}
- list2& list;
- int indent;
- };
-
- void process(quickbook::state& state, quickbook::list const& list)
- {
- state.paragraph_output();
- list::const_iterator it = list.begin(), end = list.end();
- BOOST_ASSERT(it != end);
-
- list2 r;
- r.mark = list.begin()->mark;
- std::stack<stack_entry> stack;
- stack.push(stack_entry(r, 0));
-
- for(list::const_iterator it = list.begin(), end = list.end(); it != end; ++it)
- {
- int new_indent = indent_length(it->indent);
- BOOST_ASSERT(it->mark == '#' || it->mark == '*');
-
- if (new_indent > stack.top().indent)
- {
- stack.push(stack_entry(stack.top().list.items.back().sublist, new_indent));
- stack.top().list.mark = it->mark;
- }
- else if (new_indent < stack.top().indent)
- {
- // TODO: This assumes that new_indent is equal to one of the
- // existing indents.
- while (!stack.empty() && (new_indent < stack.top().indent))
- stack.pop();
- BOOST_ASSERT(!stack.empty());
- }
-
- list_item2 item;
- item.content = it->content;
- stack.top().list.items.push_back(item);
-
- if (it->mark != stack.top().list.mark)
- {
- file_position const pos = it->position;
- detail::outerr(pos.file,pos.line)
- << "Illegal change of list style near column " << pos.column << ".\n";
- detail::outwarn(pos.file,pos.line)
- << "Ignoring change of list style" << std::endl;
- ++state.error_count;
- }
- }
-
- state.encode(r);
- }
-}
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/block_markup_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_markup_grammar.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,129 +0,0 @@
-/*=============================================================================
- 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 "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;
- };
- }
-
- struct block_markup_grammar_local
- {
- qi::rule<iterator, quickbook::block_formatted(formatted_type)> paragraph_block;
- qi::rule<iterator, quickbook::block_formatted()> preformatted;
- qi::rule<iterator, quickbook::def_macro()> def_macro;
- qi::rule<iterator, quickbook::xinclude()> xinclude;
- qi::rule<iterator, quickbook::include()> include;
- qi::rule<iterator, raw_string()> include_id;
- qi::rule<iterator, quickbook::import()> import;
- };
-
- void quickbook_grammar::impl::init_block_markup()
- {
- block_markup_grammar_local& local = store_.create();
-
- // Paragraph Blocks
-
- block_keyword_rules.add
- ("blurb", local.paragraph_block(formatted_type("blurb")) [actions.process])
- ("warning", local.paragraph_block(formatted_type("warning")) [actions.process])
- ("caution", local.paragraph_block(formatted_type("caution")) [actions.process])
- ("important", local.paragraph_block(formatted_type("important")) [actions.process])
- ("note", local.paragraph_block(formatted_type("note")) [actions.process])
- ("tip", local.paragraph_block(formatted_type("tip")) [actions.process])
- ;
-
- block_symbol_rules.add
- (":", local.paragraph_block(formatted_type("blockquote")) [actions.process])
- ;
-
- local.paragraph_block =
- qi::attr(qi::_r1) [member_assign(&quickbook::block_formatted::type)]
- >> space
- >> inside_paragraph [member_assign(&quickbook::block_formatted::content)]
- ;
-
- // Preformatted
-
- block_keyword_rules.add("pre", local.preformatted [actions.process]);
-
- local.preformatted =
- space [ph::ref(no_eols) = false]
- [member_assign(&quickbook::block_formatted::type, "preformatted")]
- >> -eol
- >> phrase [member_assign(&quickbook::block_formatted::content)]
- >> qi::eps [ph::ref(no_eols) = true]
- ;
-
- // Define Macro
-
- block_keyword_rules.add("def", local.def_macro[actions.process]);
-
- local.def_macro =
- space
- >> macro_identifier [member_assign(&quickbook::def_macro::macro_identifier)]
- >> blank
- >> phrase [member_assign(&quickbook::def_macro::content)]
- ;
-
- // xinclude
-
- block_keyword_rules.add("xinclude", local.xinclude[actions.process]);
-
- // TODO: Why do these use phrase_end? It doesn't make any sense.
- local.xinclude =
- space
- >> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::xinclude::path)]
- ;
-
- block_keyword_rules.add("include", local.include[actions.process]);
-
- // Include
-
- local.include =
- space
- >> -(
- ':'
- >> local.include_id
- >> space
- ) [member_assign(&quickbook::include::id)]
- >> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::include::path)]
- ;
-
- local.include_id = qi::raw[*(qi::alnum | '_')] [qi::_val = qi::_1];
-
- // Import
-
- block_keyword_rules.add("import", local.import[actions.process]);
-
- local.import =
- space
- >> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::import::path)]
- ;
- }
-}
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/block_section_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_section_grammar.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,83 +0,0 @@
-/*=============================================================================
- 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;
-
- struct block_section_grammar_local
- {
- qi::rule<iterator, quickbook::title()> title_phrase;
- qi::rule<iterator, quickbook::begin_section()> begin_section;
- qi::rule<iterator, quickbook::end_section()> end_section;
- qi::rule<iterator, quickbook::heading(int)> heading;
- };
-
- void quickbook_grammar::impl::init_block_section()
- {
- block_section_grammar_local& local = store_.create();
-
- // Sections
-
- block_keyword_rules.add("section", local.begin_section[actions.process]);
- block_keyword_rules.add("endsect", local.end_section[actions.process]);
-
- local.begin_section =
- space
- >> element_id [member_assign(&quickbook::begin_section::id)]
- >> space
- >> local.title_phrase [member_assign(&quickbook::begin_section::content)]
- ;
-
- local.end_section =
- space
- >> position [member_assign(&quickbook::end_section::position)]
- ;
-
- // Headings
-
- block_keyword_rules.add
- ("h1", local.heading(1) [actions.process])
- ("h2", local.heading(2) [actions.process])
- ("h3", local.heading(3) [actions.process])
- ("h4", local.heading(4) [actions.process])
- ("h5", local.heading(5) [actions.process])
- ("h6", local.heading(6) [actions.process])
- ("heading", local.heading(-1) [actions.process]);
-
- local.heading =
- qi::attr(qi::_r1) [member_assign(&quickbook::heading::level)]
- >> space
- >> -( qi::eps(qbk_since(106u))
- >> element_id [member_assign(&quickbook::heading::id)]
- >> space
- )
- >> local.title_phrase [member_assign(&quickbook::heading::content)]
- ;
-
- local.title_phrase =
- qi::raw[
- phrase [member_assign(&quickbook::title::content)]
- ] [member_assign(&quickbook::title::raw)]
- ;
- }
-}
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/block_table_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/block_table_grammar.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,119 +0,0 @@
-/*=============================================================================
- 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_eps.hpp>
-#include <boost/spirit/include/qi_eol.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;
-
- struct block_table_grammar_local
- {
- qi::rule<iterator, quickbook::table()> table;
- qi::rule<iterator, quickbook::table_row()> table_row;
- qi::rule<iterator, quickbook::table_cell()> table_cell;
- qi::rule<iterator, quickbook::variablelist()> variablelist;
- qi::rule<iterator, quickbook::varlistentry()> varlistentry;
- qi::rule<iterator, quickbook::block_formatted()> varlistterm;
- qi::rule<iterator, quickbook::block_formatted()> varlistitem;
-
- qi::rule<iterator> nested_cell_check;
- };
-
- void quickbook_grammar::impl::init_block_table()
- {
- block_table_grammar_local& local = store_.create();
-
- // Error checking
-
- local.nested_cell_check = &qi::char_("[]");
- local.nested_cell_check.name("nested cell");
-
- // Table
-
- block_keyword_rules.add("table", local.table[actions.process]);
-
- local.table =
- (&(*qi::blank >> qi::eol) | space)
- > -( qi::eps(qbk_since(105u))
- >> element_id [member_assign(&quickbook::table::id)]
- )
- > (&(*qi::blank >> qi::eol) | space)
- > qi::raw[*(qi::char_ - eol)] [member_assign(&quickbook::table::title)]
- > eol
- > space
- > (*local.table_row) [member_assign(&quickbook::table::rows)]
- ;
-
- local.table_row
- = '['
- > space
- > local.nested_cell_check
- > *local.table_cell
- > ']'
- > space
- ;
-
- local.table_cell
- = '['
- > inside_paragraph [member_assign(&quickbook::block_formatted::content)]
- [member_assign(&quickbook::block_formatted::type, "cell")]
- > ']'
- > space
- ;
-
- local.table.name("table");
- local.table_row.name("table_row");
- local.table_cell.name("table_cell");
-
- block_keyword_rules.add("variablelist", local.variablelist[actions.process]);
-
- local.variablelist =
- (&(*qi::blank >> qi::eol) | space)
- > qi::raw[*(qi::char_ - eol)] [member_assign(&quickbook::variablelist::title)]
- > eol
- > space
- > (*local.varlistentry) [member_assign(&quickbook::variablelist::entries)]
- ;
-
- local.varlistentry
- = '['
- > space
- > local.varlistterm
- > +local.varlistitem
- > ']'
- > space
- ;
-
- local.varlistterm
- = '['
- > phrase [member_assign(&quickbook::block_formatted::content)]
- [member_assign(&quickbook::block_formatted::type, "varlistterm")]
- > ']'
- > space
- ;
-
- local.varlistitem
- = '['
- > inside_paragraph [member_assign(&quickbook::block_formatted::content)]
- [member_assign(&quickbook::block_formatted::type, "varlistitem")]
- > ']'
- > space
- ;
- }
-}

Deleted: branches/quickbook-1.5-spirit2/boostbook.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/boostbook.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,568 +0,0 @@
-#include <algorithm>
-#include <boost/foreach.hpp>
-#include "encoder_impl.hpp"
-
-namespace quickbook
-{
- template <typename Iter>
- std::string encode_impl(Iter first, Iter last)
- {
- std::string r;
-
- for(;first != last; ++first) {
- switch (*first)
- {
- case '<': r += "&lt;"; break;
- case '>': r += "&gt;"; break;
- case '&': r += "&amp;"; break;
- case '"': r += "&quot;"; break;
- default: r += *first; break;
- }
- }
-
- return r;
- }
-
- std::string boostbook_encoder::encode(raw_string const& x)
- {
- return encode_impl(x.begin(), x.end());
- }
-
- std::string boostbook_encoder::encode(std::string const& x)
- {
- return encode_impl(x.begin(), x.end());
- }
-
- std::string boostbook_encoder::encode(char const* x)
- {
- char const* end = x;
- while(*end) ++end;
- return encode_impl(x, end);
- }
-
- std::string boostbook_encoder::encode(char c)
- {
- return encode_impl(&c, &c + 1);
- }
-
- namespace {
- struct boostbook_markup {
- char const* quickbook;
- char const* pre;
- char const* post;
- };
-
- boostbook_markup markups[] = {
- { "", "", "" },
- { "paragraph", "<para>\n", "</para>\n" },
- { "h1", "<bridgehead renderas=\"sect1\">", "</bridgehead>" },
- { "h2", "<bridgehead renderas=\"sect2\">", "</bridgehead>" },
- { "h3", "<bridgehead renderas=\"sect3\">", "</bridgehead>" },
- { "h4", "<bridgehead renderas=\"sect4\">", "</bridgehead>" },
- { "h5", "<bridgehead renderas=\"sect5\">", "</bridgehead>" },
- { "h6", "<bridgehead renderas=\"sect6\">", "</bridgehead>" },
- { "blurb", "<sidebar role=\"blurb\">\n", "</sidebar>\n" },
- { "blockquote", "<blockquote>", "</blockquote>" },
- { "preformatted", "<programlisting>", "</programlisting>" },
- { "warning", "<warning>", "</warning>" },
- { "caution", "<caution>", "</caution>" },
- { "important", "<important>", "</important>" },
- { "note", "<note>", "</note>" },
- { "tip", "<tip>", "</tip>" },
- { "list_item", "<listitem><simpara>\n", "\n</simpara></listitem>" },
- { "bold", "<emphasis role=\"bold\">", "</emphasis>" },
- { "italic", "<emphasis>", "</emphasis>" },
- { "underline", "<emphasis role=\"underline\">", "</emphasis>" },
- { "teletype", "<literal>", "</literal>" },
- { "strikethrough", "<emphasis role=\"strikethrough\">", "</emphasis>" },
- { "quote", "<quote>", "</quote>" },
- { "url", "<ulink url=\"", "</ulink>" },
- { "link", "<link linkend=\"", "</link>" },
- { "funcref", "<functionname alt=\"", "</functionname>" },
- { "classref", "<classname alt=\"", "</classname>" },
- { "memberref", "<methodname alt=\"", "</methodname>" },
- { "enumref", "<enumname alt=\"", "</enumname>" },
- { "macroref", "<macroname alt=\"", "</macroname>" },
- { "headerref", "<headername alt=\"", "</headername>" },
- { "conceptref", "<conceptname alt=\"", "</conceptname>" },
- { "globalref", "<globalname alt=\"", "</globalname>" },
- { "footnote", "<footnote><para>", "</para></footnote>" },
- { "escape", "<!--quickbook-escape-prefix-->", "<!--quickbook-escape-postfix-->" },
- { "replaceable", "<replaceable>", "</replaceable>" },
- { "varlistentry", "<varlistentry>", "</varlistentry>\n" },
- { "varlistterm", "<term>", "</term>" },
- { "varlistitem", "<listitem>", "</listitem>" },
- { "header", "<thead>", "</thead>\n" },
- { "row", "<row>", "</row>\n" },
- { "cell", "<entry>", "</entry>" },
- { "programlisting", "<programlisting>", "</programlisting>\n" },
- { "code", "<code>", "</code>" },
- { "hr", "<para/>", "" },
- { "break", "<sbr/>", "" },
- };
-
- std::map<std::string, boostbook_markup> markup_map;
-
- struct initialize {
- initialize() {
- BOOST_FOREACH(boostbook_markup m, markups) {
- markup_map[m.quickbook] = m;
- }
- }
- } initialize_instance;
-
- boostbook_markup get_markup(std::string const& x) {
- std::map<std::string, boostbook_markup>::const_iterator
- pos = markup_map.find(x);
- BOOST_ASSERT(pos != markup_map.end());
- return pos->second;
- }
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, std::string const& x)
- {
- state.phrase << x;
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, char x)
- {
- state.phrase << encode(x);
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, unicode_char const& x)
- {
- std::string::const_iterator first = x.value.begin(), last = x.value.end();
- while(first != last && *first == '0') ++first;
-
- // Just ignore \u0000
- // Maybe I should issue a warning?
- if(first == last) return;
-
- std::string hex_digits(first, last);
-
- if(hex_digits.size() == 2 && *first > '0' && *first <= '7') {
- using namespace std;
- (*this)(state, strtol(hex_digits.c_str(), 0, 16));
- }
- else {
- state.phrase << "&#x" << hex_digits << ";";
- }
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, anchor const& x)
- {
- state.phrase << "<anchor id=\"";
- state.phrase << encode(x.id);
- state.phrase << "\"/>\n";
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, link const& x)
- {
- boostbook_markup m = get_markup(x.type);
- state.phrase << m.pre;
- state.phrase << encode(x.destination);
- state.phrase << "\">";
- state.phrase << x.content;
- state.phrase << m.post;
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, formatted const& x)
- {
- boostbook_markup m = get_markup(x.type);
- state.phrase << m.pre << x.content << m.post;
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, block_formatted const& x)
- {
- boostbook_markup m = get_markup(x.type);
- state.block << m.pre << x.content << m.post;
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, break_ const& x)
- {
- boostbook_markup m = get_markup("break");
- state.phrase << m.pre;
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, image2 const& x)
- {
- state.phrase << "<inlinemediaobject>";
-
- state.phrase << "<imageobject><imagedata";
-
- for(image2::attribute_map::const_iterator
- attr_first = x.attributes.begin(), attr_last = x.attributes.end();
- attr_first != attr_last; ++attr_first)
- {
- if(attr_first->first == "alt") continue;
-
- state.phrase
- << " "
- << attr_first->first
- << "=\""
- << encode(attr_first->second)
- << "\"";
- }
-
- state.phrase << "></imagedata></imageobject>";
-
- image2::attribute_map::const_iterator it = x.attributes.find("alt");
- if(it != x.attributes.end()) {
- // Also add a textobject -- use the basename of the image file.
- // This will mean we get "alt" attributes of the HTML img.
- state.phrase << "<textobject><phrase>";
- state.phrase << encode(it->second);
- state.phrase << "</phrase></textobject>";
- }
-
- state.phrase << "</inlinemediaobject>";
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, hr)
- {
- state.block << get_markup("hr").pre;
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, begin_section2 const& x)
- {
- state.block << "\n<section id=\"" << encode(x.id) << "\">\n";
- if(x.linkend.empty()) {
- state.block
- << "<title>"
- << x.content
- << "</title>\n"
- ;
- }
- else {
- state.block
- << "<title>"
- << "<link linkend=\""
- << encode(x.linkend)
- << "\">"
- << x.content
- << "</link>"
- << "</title>\n"
- ;
- }
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, end_section2 const& x)
- {
- state.block << "</section>";
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, heading2 const& x)
- {
- state.block
- << "<anchor id=\"" << encode(x.id) << "\"/>"
- << "<bridgehead renderas=\"sect" << x.level << "\">";
-
- if(x.linkend.empty()) {
- state.block << x.content;
- }
- else {
- state.block
- << "<link linkend=\"" << encode(x.linkend) << "\">"
- << x.content << "</link>";
- }
-
- state.block << "</bridgehead>";
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, variablelist const& x)
- {
- state.block << "<variablelist>\n";
-
- state.block << "<title>";
- state.block << encode(x.title);
- state.block << "</title>\n";
-
- boostbook_markup m = get_markup("varlistentry");
-
- for(std::vector<varlistentry>::const_iterator
- it = x.entries.begin(); it != x.entries.end(); ++it)
- {
- state.block << m.pre;
-
- std::vector<quickbook::block_formatted>::const_iterator
- it2 = it->begin(), end2 = it->end();
-
- encode_action encode(state, *this);
- for(;it2 != end2 && std::string(it2->type) == "varlistterm"; ++it2) {
- encode(*it2);
- }
-
- if(it2 != end2) {
- std::string type = "varlistitem";
- boostbook_markup m2 = get_markup(type);
- state.block << m2.pre;
-
- for(;it2 != end2; ++it2) {
- BOOST_ASSERT(type == it2->type);
- state.block << it2->content;
- }
-
- state.block << m2.post;
- }
-
- state.block << m.post;
- }
-
- state.block << "</variablelist>\n";
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, table2 const& x)
- {
- if (x.title)
- {
- state.block << "<table frame=\"all\"";
- if(x.id)
- state.block << " id=\"" << encode(*x.id) << "\"";
- state.block << ">\n";
- state.block << "<title>";
- state.block << encode(*x.title);
- state.block << "</title>";
- }
- else
- {
- state.block << "<informaltable frame=\"all\"";
- if(x.id)
- state.block << " id=\"" << encode(*x.id) << "\"";
- state.block << ">\n";
- }
-
- // This is a bit odd for backwards compatability: the old version just
- // used the last count that was calculated.
- state.block << "<tgroup cols=\"" << x.cols << "\">\n";
-
- boostbook_markup m = get_markup("row");
-
- if (x.head)
- {
- state.block << "<thead>";
- state.block << m.pre;
- std::for_each(x.head->begin(), x.head->end(), encode_action(state, *this));
- state.block << m.post;
- state.block << "</thead>\n";
- }
-
- state.block << "<tbody>\n";
-
- for(std::vector<table_row>::const_iterator
- it = x.rows.begin(); it != x.rows.end(); ++it)
- {
- state.block << m.pre;
- std::for_each(it->begin(), it->end(), encode_action(state, *this));
- state.block << m.post;
- }
-
- state.block << "</tbody>\n" << "</tgroup>\n";
-
- if (x.title)
- {
- state.block << "</table>\n";
- }
- else
- {
- state.block << "</informaltable>\n";
- }
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, xinclude2 const& x)
- {
- state.block << "\n<xi:include href=\"" << x.path << "\" />\n";
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, list2 const& x)
- {
- state.block << std::string(x.mark == '#' ? "<orderedlist>\n" : "<itemizedlist>\n");
-
- for(std::vector<list_item2>::const_iterator
- it = x.items.begin(), end = x.items.end(); it != end; ++it)
- {
- state.block << "<listitem><simpara>\n" << it->content << "\n</simpara>";
- if(!it->sublist.items.empty()) (*this)(state, it->sublist);
- state.block << std::string("</listitem>");
- }
-
- state.block << std::string(x.mark == '#' ? "\n</orderedlist>" : "\n</itemizedlist>");
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, callout_link const& x)
- {
- state.phrase
- << "<co id=\"" << x.identifier << "co\""
- << " linkends=\"" << x.identifier << "\""
- << " />"
- ;
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, callout_list const& x)
- {
- state.block
- << "<calloutlist>";
-
- BOOST_FOREACH(callout_item const& c, x)
- {
- state.block
- << "<callout arearefs=\"" << c.identifier << "co\""
- << " id=\"" << c.identifier << "\""
- << ">"
- << c.content
- << "</callout>";
- }
-
- state.block
- << "</calloutlist>";
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, code_token const& x)
- {
- std::string type = x.type;
- if(type == "space") {
- state.phrase << x.text;
- }
- else {
- state.phrase
- << "<phrase role=\"" << x.type << "\">"
- << encode(x.text)
- << "</phrase>";
- }
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, doc_info const& info)
- {
- // if we're ignoring the document info, we're done.
- if (info.ignore) return;
-
- state.block
- << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- << "<!DOCTYPE "
- << info.doc_type
- << " PUBLIC \"-//Boost//DTD BoostBook XML V1.0//EN\""
- << " \"http://www.boost.org/tools/boostbook/dtd/boostbook.dtd\">";
-
- // Document tag
-
- state.block
- << '<' << info.doc_type << " id=\"" << info.doc_id.get(106) << "\"\n";
-
- if(info.doc_type == "library")
- {
- state.block << " name=\"" << info.doc_title.get(106) << "\"\n";
- }
-
- if(!info.doc_dirname.empty())
- {
- state.block << " dirname=\"" << info.doc_dirname.get(106) << "\"\n";
- }
-
- state.block
- << "last-revision=\"" << info.doc_last_revision.get(106) << "\""
- << " xmlns:xi=\"http://www.w3.org/2001/XInclude\"";
-
- state.block << ">"; // end document tag.
-
- // Title tag
-
- std::string title;
- if(!info.doc_title.empty())
- {
- title = "<title>" + info.doc_title.get(106);
- if (!info.doc_version.empty())
- title += ' ' + info.doc_version.get(106);
- title += "</title>\n";
- }
-
- // Info tag
-
- std::ostringstream tmp;
-
- if(!info.doc_authors.empty())
- {
- tmp << "<authorgroup>\n";
- BOOST_FOREACH(doc_info::author const& author, info.doc_authors) {
- tmp
- << "<author>\n"
- << "<firstname>" << author.firstname.get(106) << "</firstname>\n"
- << "<surname>" << author.surname.get(106) << "</surname>\n"
- << "</author>\n";
- }
- tmp << "</authorgroup>\n";
- }
-
- BOOST_FOREACH(doc_info::copyright_entry const& copyright,
- info.doc_copyrights)
- {
- tmp << "<copyright>\n";
-
- BOOST_FOREACH(unsigned int year, copyright.years) {
- tmp << "<year>" << year << "</year>\n";
- }
-
- tmp
- << "<holder>" << copyright.holder.get(106) << "</holder>\n"
- << "</copyright>\n"
- ;
- }
-
- if (!info.doc_license.empty())
- {
- tmp
- << "<legalnotice>\n"
- << "<para>\n"
- << info.doc_license.get(103)
- << "\n"
- << "</para>\n"
- << "</legalnotice>\n"
- << "\n"
- ;
- }
-
- if (!info.doc_purpose.empty())
- {
- tmp
- << "<" << info.doc_type << "purpose>\n"
- << info.doc_purpose.get(103)
- << "</" << info.doc_type << "purpose>\n"
- << "\n"
- ;
- }
-
- BOOST_FOREACH(docinfo_string const& category, info.doc_categories)
- {
- tmp
- << "<" << info.doc_type << "category name=\"category:"
- << category.get(106)
- << "\"></" << info.doc_type << "category>\n"
- << "\n"
- ;
- }
-
- std::string info_block = tmp.str();
-
- // For 'library', the title comes after the info block.
- if(info.doc_type != "library") state.block << title;
-
- if(!info_block.empty())
- {
- state.block
- << "<" << info.doc_type << "info>\n"
- << info_block
- << "</" << info.doc_type << "info>\n"
- ;
- }
-
- if(info.doc_type == "library") state.block << title;
- }
-
- void boostbook_encoder::operator()(quickbook::state& state, doc_info_post const& x)
- {
- // if we're ignoring the document info, do nothing.
- if (x.info.ignore) return;
-
- // We've finished generating our output. Here's what we'll do
- // *after* everything else.
- state.block << "</" << x.info.doc_type << ">";
- }
-}

Deleted: branches/quickbook-1.5-spirit2/code.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,31 +0,0 @@
-/*=============================================================================
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_CODE_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_CODE_HPP
-
-#include <string>
-#include "fwd.hpp"
-
-namespace quickbook
-{
- struct code {
- enum flow_types { block, inline_block, inline_ };
- flow_types flow;
- file_position position;
- std::string content;
- };
-
- std::string syntax_highlight(
- iterator first, iterator last,
- actions& escape_actions,
- std::string& source_mode);
-}
-
-#endif
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/code_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code_grammar.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,103 +0,0 @@
-/*=============================================================================
- 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_eol.hpp>
-#include <boost/spirit/repository/include/qi_confix.hpp>
-#include "grammar_impl.hpp"
-#include "actions.hpp"
-#include "code.hpp"
-#include "misc_rules.hpp"
-#include "parse_utils.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
- namespace repo = boost::spirit::repository;
- namespace ph = boost::phoenix;
-
- struct code_grammar_local
- {
- qi::rule<iterator, quickbook::code()> indented_code;
- qi::rule<iterator> code_line;
- qi::rule<iterator> blank_line;
- qi::rule<iterator, quickbook::code()> code_block1;
- qi::rule<iterator, quickbook::code()> code_block2;
- qi::rule<iterator, quickbook::code()> inline_code;
- qi::rule<iterator, std::string()> inline_code_block;
- };
-
- void quickbook_grammar::impl::init_code()
- {
- code_grammar_local& local = store_.create();
-
- // Indented code
-
- indented_code = local.indented_code [actions.process];
-
- local.indented_code =
- position [member_assign(&quickbook::code::position)]
- [member_assign(&quickbook::code::flow, quickbook::code::block)]
- >> qi::raw[
- local.code_line
- >> *(*local.blank_line >> local.code_line)
- ]
- [member_assign(&quickbook::code::content)]
- >> *eol
- ;
-
- local.code_line =
- qi::char_(" \t")
- >> *(qi::char_ - eol)
- >> eol
- ;
-
- local.blank_line =
- *qi::blank >> qi::eol
- ;
-
- code_block = (local.code_block1 | local.code_block2) [actions.process];
-
- local.code_block1
- = repo::confix("```", "```")
- [ position [member_assign(&quickbook::code::position)]
- [member_assign(&quickbook::code::flow, quickbook::code::inline_block)]
- >> qi::raw[*(qi::char_ - "```")] [member_assign(&quickbook::code::content)]
- ]
- ;
-
- local.code_block2
- = repo::confix("``", "``")
- [ position [member_assign(&quickbook::code::position)]
- [member_assign(&quickbook::code::flow, quickbook::code::inline_block)]
- >> qi::raw[*(qi::char_ - "``")] [member_assign(&quickbook::code::content)]
- ]
- ;
-
- inline_code = local.inline_code [actions.process];
-
- local.inline_code
- = repo::confix('`', '`')
- [ position [member_assign(&quickbook::code::position)]
- [member_assign(&quickbook::code::flow, quickbook::code::inline_)]
- >> local.inline_code_block [member_assign(&quickbook::code::content)]
- ]
- ;
-
- local.inline_code_block =
- qi::raw
- [ *( ~qi::char_('`') -
- (qi::eol >> *qi::blank >> qi::eol) // Make sure that we don't go
- )
- >> &qi::lit('`')
- ]
- ;
- }
-}

Deleted: branches/quickbook-1.5-spirit2/code_snippet_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code_snippet_actions.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,93 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2005 Thomas Guest
- Copyright (c) 2010 Daniel James
- 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 <numeric>
-#include <functional>
-#include <algorithm>
-#include <iterator>
-#include <boost/lexical_cast.hpp>
-#include "utils.hpp"
-#include "grammar.hpp"
-#include "code_snippet_types.hpp"
-#include "template.hpp"
-
-namespace quickbook
-{
- void code_snippet_actions::process_action::operator()(char x, unused_type, unused_type) const
- {
- actions.code += x;
- }
-
- void code_snippet_actions::process_action::operator()(callout const& x, unused_type, unused_type) const
- {
- actions.code += "``[[callout" + boost::lexical_cast<std::string>(actions.callouts.size()) + "]]``";
-
- callout_source item;
- item.body = template_body(x.content, x.position, true);
- item.role = x.role;
- actions.callouts.push_back(item);
- }
-
- void code_snippet_actions::process_action::operator()(escaped_comment const& x, unused_type, unused_type) const
- {
- if (!actions.code.empty())
- {
- detail::unindent(actions.code); // remove all indents
- if (actions.code.size() != 0)
- {
- actions.snippet += "\n\n";
- actions.snippet += actions.source_type;
- actions.snippet += "``\n" + actions.code + "``\n\n";
- actions.code.clear();
- }
- }
- std::string temp(x.content);
- detail::unindent(temp); // remove all indents
- if (temp.size() != 0)
- {
- actions.snippet += "\n" + temp; // add a linebreak to allow block marskups
- }
- }
-
- void code_snippet_actions::output_action::operator()(code_snippet const& x, unused_type, unused_type) const
- {
- std::vector<std::string> params;
-
- if (!actions.code.empty())
- {
- detail::unindent(actions.code); // remove all indents
- if (actions.code.size() != 0)
- {
- actions.snippet += "\n\n";
- actions.snippet += actions.source_type;
- actions.snippet += "```\n" + actions.code + "```\n\n";
- }
-
- if(actions.callouts.size() > 0)
- {
- for (size_t i = 0; i < actions.callouts.size(); ++i)
- {
- params.push_back("[callout" + boost::lexical_cast<std::string>(i) + "]");
- }
- }
- }
-
- define_template d(x.identifier, params,
- template_body(actions.snippet, x.position, true));
- d.callouts = actions.callouts;
- actions.storage.push_back(d);
-
- actions.callouts.clear();
- actions.code.clear();
- actions.snippet.clear();
- }
-}

Deleted: branches/quickbook-1.5-spirit2/code_snippet_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code_snippet_grammar.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,203 +0,0 @@
-/*=============================================================================
- Copyright (c) 2006 Joel de Guzman
- 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_eol.hpp>
-#include <boost/spirit/include/qi_eps.hpp>
-#include <boost/spirit/include/qi_attr.hpp>
-#include <boost/spirit/repository/include/qi_confix.hpp>
-#include "fwd.hpp"
-#include "code_snippet_types.hpp"
-#include "code_snippet_grammar.hpp"
-#include "misc_rules.hpp"
-#include "parse_utils.hpp"
-
-namespace quickbook
-{
- // TODO: End of file as well as end of line?
-
- namespace qi = boost::spirit::qi;
- namespace repo = boost::spirit::repository;
-
- struct python_code_snippet_grammar::rules
- {
- typedef code_snippet_actions actions_type;
-
- rules(actions_type & actions);
-
- actions_type& actions;
-
- qi::rule<iterator>
- start_, ignore;
- qi::rule<iterator, quickbook::code_snippet()>
- snippet;
- qi::rule<iterator>
- code_elements;
- qi::rule<iterator, std::string()>
- identifier;
- qi::rule<iterator, quickbook::escaped_comment()>
- escaped_comment;
- };
-
- python_code_snippet_grammar::python_code_snippet_grammar(actions_type & actions)
- : python_code_snippet_grammar::base_type(start)
- , rules_pimpl(new rules(actions))
- , start(rules_pimpl->start_) {}
-
- python_code_snippet_grammar::~python_code_snippet_grammar() {}
-
- python_code_snippet_grammar::rules::rules(actions_type& actions)
- : actions(actions)
- {
- start_ =
- +( snippet [actions.output]
- | qi::char_
- )
- ;
-
- identifier =
- (qi::alpha | '_') >> *(qi::alnum | '_')
- ;
-
- snippet =
- position [member_assign(&quickbook::code_snippet::position)]
- >> repo::confix("#[", "#]")
- [ *qi::space
- >> identifier [member_assign(&quickbook::code_snippet::identifier)]
- >> *(!qi::lit("#]") >> code_elements)
- ]
- ;
-
- code_elements =
- escaped_comment [actions.process]
- | ignore
- | +qi::blank [actions.process]
- | qi::char_ [actions.process]
- ;
-
- ignore
- = ( repo::confix(*qi::blank >> "#<-", "#->" >> *qi::blank >> qi::eol)
- [*(qi::char_ - "#->")]
- | repo::confix("\"\"\"<-\"\"\"", "\"\"\"->\"\"\"")
- [*(qi::char_ - "\"\"\"->\"\"\"")]
- | repo::confix("\"\"\"<-", "->\"\"\"")
- [*(qi::char_ - "->\"\"\"")]
- )
- ;
-
- escaped_comment
- = ( repo::confix(*qi::space >> "#`", qi::eol)
- [*(qi::char_ - qi::eol)]
- | repo::confix(*qi::space >> "\"\"\"`", "\"\"\"")
- [*(qi::char_ - "\"\"\"")]
- ) [member_assign(&quickbook::escaped_comment::content)]
- ;
- }
-
- struct cpp_code_snippet_grammar::rules
- {
- typedef code_snippet_actions actions_type;
-
- rules(actions_type & actions);
-
- actions_type& actions;
-
- qi::rule<iterator>
- start_, code_elements, ignore;
- qi::rule<iterator, quickbook::code_snippet()>
- snippet;
- qi::rule<iterator, std::string()>
- identifier;
- qi::rule<iterator, quickbook::callout()>
- inline_callout, line_callout;
- qi::rule<iterator, quickbook::escaped_comment()>
- escaped_comment;
- };
-
- cpp_code_snippet_grammar::cpp_code_snippet_grammar(actions_type & actions)
- : cpp_code_snippet_grammar::base_type(start)
- , rules_pimpl(new rules(actions))
- , start(rules_pimpl->start_) {}
-
- cpp_code_snippet_grammar::~cpp_code_snippet_grammar() {}
-
- cpp_code_snippet_grammar::rules::rules(actions_type & actions)
- : actions(actions)
- {
- start_ =
- +( snippet [actions.output]
- | qi::char_
- )
- ;
-
- identifier =
- (qi::alpha | '_') >> *(qi::alnum | '_')
- ;
-
- snippet
- = position [member_assign(&quickbook::code_snippet::position)]
- >> ( repo::confix("//[", "//]")
- [ *qi::space
- >> identifier [member_assign(&quickbook::code_snippet::identifier)]
- >> *(!qi::lit("//]") >> code_elements)
- ]
- | repo::confix("/*[", "/*]*/")
- [ *qi::space
- >> identifier [member_assign(&quickbook::code_snippet::identifier)]
- >> *qi::space
- >> "*/"
- >> *(!qi::lit("/*]*/") >> code_elements)
- ]
- )
- ;
-
- code_elements =
- escaped_comment [actions.process]
- | ignore
- | line_callout [actions.process]
- | inline_callout [actions.process]
- | +qi::blank [actions.process]
- | qi::char_ [actions.process]
- ;
-
- inline_callout
- = repo::confix("/*<" >> *qi::space, ">*/")
- [ position [member_assign(&quickbook::callout::position)]
- [member_assign(&quickbook::callout::role, "callout_bug")]
- >> (*(qi::char_ - ">*/")) [member_assign(&quickbook::callout::content)]
- ]
- ;
-
- line_callout
- = repo::confix("/*<<" >> *qi::space, ">>*/" >> *qi::space)
- [ position [member_assign(&quickbook::callout::position)]
- [member_assign(&quickbook::callout::role, "line_callout_bug")]
- >> (*(qi::char_ - ">>*/")) [member_assign(&quickbook::callout::content)]
- ]
- ;
-
- ignore
- = repo::confix(*qi::blank >> "//<-", "//->" >> *qi::blank >> qi::eol)
- [*(qi::char_ - "//->")]
- | repo::confix("/*<-*/", "/*->*/")
- [*(qi::char_ - "/*->*/")]
- | repo::confix("/*<-", "->*/")
- [*(qi::char_ - "->*/")]
- ;
-
- escaped_comment =
- *qi::space
- >> ( repo::confix("//`", qi::eol)
- [*(qi::char_ - qi::eol)]
- | repo::confix("/*`", "*/")
- [*(qi::char_ - "*/")]
- ) [member_assign(&quickbook::escaped_comment::content)]
- ;
- }
-}

Deleted: branches/quickbook-1.5-spirit2/code_snippet_grammar.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code_snippet_grammar.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,55 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2010 Daniel James
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_GRAMMARS_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_GRAMMARS_HPP
-
-#include <boost/spirit/include/qi_core.hpp>
-#include <boost/scoped_ptr.hpp>
-#include "fwd.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
-
- struct python_code_snippet_grammar
- : qi::grammar<iterator>
- {
- typedef code_snippet_actions actions_type;
-
- python_code_snippet_grammar(actions_type& actions);
- ~python_code_snippet_grammar();
-
- struct rules;
- boost::scoped_ptr<rules> rules_pimpl;
- qi::rule<iterator> start;
- private:
- python_code_snippet_grammar(python_code_snippet_grammar const&);
- python_code_snippet_grammar& operator=(python_code_snippet_grammar const&);
- };
-
- struct cpp_code_snippet_grammar
- : qi::grammar<iterator>
- {
- typedef code_snippet_actions actions_type;
-
- cpp_code_snippet_grammar(actions_type& actions);
- ~cpp_code_snippet_grammar();
-
- struct rules;
- boost::scoped_ptr<rules> rules_pimpl;
- qi::rule<iterator> start;
- private:
- cpp_code_snippet_grammar(cpp_code_snippet_grammar const&);
- cpp_code_snippet_grammar& operator=(cpp_code_snippet_grammar const&);
- };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_GRAMMARS_HPP

Deleted: branches/quickbook-1.5-spirit2/code_snippet_types.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/code_snippet_types.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,92 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2005 Thomas Guest
- Copyright (c) 2010 Daniel James
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_TYPES_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_CODE_SNIPPET_TYPES_HPP
-
-#include <vector>
-#include <string>
-#include <boost/spirit/include/support_unused.hpp>
-#include "fwd.hpp"
-#include "template.hpp"
-#include "strings.hpp"
-
-namespace quickbook
-{
- struct code_snippet
- {
- file_position position;
- std::string identifier;
- };
-
- struct callout
- {
- char const* role;
- quickbook::file_position position;
- std::string content;
- };
-
- struct escaped_comment
- {
- std::string content;
- };
-}
-
-namespace quickbook
-{
- using boost::spirit::unused_type;
-
- struct code_snippet_actions
- {
- code_snippet_actions(std::vector<define_template>& storage,
- std::string const& doc_id,
- char const* source_type)
- : process(*this)
- , output(*this)
- , storage(storage)
- , doc_id(doc_id)
- , source_type(source_type)
- {}
-
- struct process_action
- {
- explicit process_action(code_snippet_actions& a)
- : actions(a) {}
-
- void operator()(char x, unused_type, unused_type) const;
- void operator()(callout const& x, unused_type, unused_type) const;
- void operator()(escaped_comment const& x, unused_type, unused_type) const;
-
- code_snippet_actions& actions;
- };
-
- struct output_action
- {
- explicit output_action(code_snippet_actions& a)
- : actions(a) {}
-
- void operator()(code_snippet const& x, unused_type, unused_type) const;
-
- code_snippet_actions& actions;
- };
-
- process_action process;
- output_action output;
- std::string code;
- std::string snippet;
- quickbook::callouts callouts;
- std::vector<define_template>& storage;
- std::string const doc_id;
- char const* const source_type;
- };
-}
-
-#endif
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/collector.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/collector.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,73 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- 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/assert.hpp>
-#include <boost/iostreams/device/back_inserter.hpp>
-#include <boost/iostreams/filtering_stream.hpp>
-#include "collector.hpp"
-
-namespace quickbook
-{
- typedef boost::iostreams::filtering_ostream filtering_ostream;
-
- string_stream::string_stream()
- : buffer_ptr(new std::string())
- , stream_ptr(new filtering_ostream(
- boost::iostreams::back_inserter(*buffer_ptr.get())))
- {}
-
- string_stream::string_stream(string_stream const& other)
- : buffer_ptr(other.buffer_ptr)
- , stream_ptr(other.stream_ptr)
- {}
-
- string_stream&
- string_stream::operator=(string_stream const& other)
- {
- buffer_ptr = other.buffer_ptr;
- stream_ptr = other.stream_ptr;
- return *this;
- }
-
- collector::collector()
- : main(default_)
- , top(default_)
- {
- }
-
- collector::collector(string_stream& out)
- : main(out)
- , top(out)
- {
- }
-
- collector::~collector()
- {
- BOOST_ASSERT(streams.empty()); // assert there are no more pushes than pops!!!
- }
-
- void
- collector::push()
- {
- streams.push(string_stream());
- top = boost::ref(streams.top());
- }
-
- void
- collector::pop()
- {
- BOOST_ASSERT(!streams.empty());
- streams.pop();
-
- if (streams.empty())
- top = boost::ref(main);
- else
- top = boost::ref(streams.top());
- }
-}

Deleted: branches/quickbook-1.5-spirit2/collector.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/collector.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,122 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_COLLECTOR_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_COLLECTOR_HPP
-
-#include <string>
-#include <stack>
-#include <ostream>
-#include <boost/ref.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace quickbook
-{
- struct string_stream
- {
- string_stream();
- string_stream(string_stream const& other);
- string_stream& operator=(string_stream const& other);
-
- std::string const& str() const
- {
- stream_ptr->flush();
- return *buffer_ptr.get();
- }
-
- std::ostream& get() const
- {
- return *stream_ptr.get();
- }
-
- void clear()
- {
- buffer_ptr->clear();
- }
-
- void swap(std::string& other)
- {
- stream_ptr->flush();
- std::swap(other, *buffer_ptr.get());
- }
-
- void append(std::string const& other)
- {
- stream_ptr->flush();
- *buffer_ptr.get() += other;
- }
-
- private:
-
- boost::shared_ptr<std::string> buffer_ptr;
- boost::shared_ptr<std::ostream> stream_ptr;
- };
-
- struct collector
- {
- collector();
- collector(string_stream& out);
- ~collector();
-
- void push();
- void pop();
-
- std::ostream& get() const
- {
- return top.get().get();
- }
-
- std::string const& str() const
- {
- return top.get().str();
- }
-
- void clear()
- {
- top.get().clear();
- }
-
- void swap(std::string& other)
- {
- top.get().swap(other);
- }
-
- void append(std::string const& other)
- {
- top.get().append(other);
- }
-
- private:
-
- std::stack<string_stream> streams;
- boost::reference_wrapper<string_stream> main;
- boost::reference_wrapper<string_stream> top;
- string_stream default_;
-
- collector(collector const&);
- collector& operator=(collector const&);
- };
-
- template <typename T>
- inline collector&
- operator<<(collector& out, T const& val)
- {
- out.get() << val;
- return out;
- }
-
- inline collector&
- operator<<(collector& out, std::string const& val)
- {
- out.append(val);
- return out;
- }
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_COLLECTOR_HPP
-

Deleted: branches/quickbook-1.5-spirit2/doc_info.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,89 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2010 Daniel James
-
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_DOC_INFO_HPP
-
-#include <vector>
-#include <string>
-#include <utility>
-#include "fwd.hpp"
-#include "strings.hpp"
-
-namespace quickbook
-{
- struct docinfo_string {
- std::string raw;
- std::string encoded;
-
- docinfo_string() : raw(), encoded() {}
-
- void swap(docinfo_string& x) {
- raw.swap(x.raw);
- encoded.swap(x.encoded);
- }
-
- void clear() {
- raw.clear();
- encoded.clear();
- }
-
- bool empty() const {
- return raw.empty();
- }
-
- std::string const& get(unsigned version) const;
- };
-
- struct doc_info
- {
- typedef std::vector<unsigned int> copyright_years;
- struct copyright_entry {
- copyright_years years;
- docinfo_string holder;
- };
- typedef std::vector<copyright_entry> copyright_list;
- typedef std::vector<docinfo_string> category_list;
- struct author {
- docinfo_string firstname;
- docinfo_string surname;
- };
- typedef std::vector<author> author_list;
-
- std::string doc_type;
- docinfo_string doc_title;
- docinfo_string doc_version;
- docinfo_string doc_id;
- docinfo_string doc_dirname;
- copyright_list doc_copyrights;
- docinfo_string doc_purpose;
- category_list doc_categories;
- author_list doc_authors;
- docinfo_string doc_license;
- docinfo_string doc_last_revision;
- bool ignore;
- };
-
- struct doc_info_post
- {
- doc_info_post(doc_info& info) : info(info) {}
- doc_info& info;
- };
-
- struct version
- {
- version() : major(-1), minor(-1) {}
-
- int major;
- int minor;
- file_position position;
- };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP

Deleted: branches/quickbook-1.5-spirit2/doc_info_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info_actions.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,134 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2010 Daniel James
- 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 <string>
-#include <vector>
-#include <utility>
-#include <boost/algorithm/string/join.hpp>
-#include "fwd.hpp"
-#include "collector.hpp"
-#include "quickbook.hpp"
-#include "doc_info_actions.hpp"
-#include "state.hpp"
-#include "utils.hpp"
-#include "encoder.hpp"
-
-namespace quickbook
-{
- std::string const& docinfo_string::get(unsigned version) const
- {
- return (qbk_version_n < version) ? raw : encoded;
- }
-
- void process(quickbook::state& state, version const& x)
- {
- if(x.major == -1 || x.minor == -1)
- {
- qbk_major_version = 1;
- qbk_minor_version = 1;
- qbk_version_n = 101;
-
- detail::outwarn(x.position.file)
- << "Warning: Quickbook version undefined. "
- "Version 1.1 is assumed" << std::endl;
- }
- else
- {
- qbk_major_version = x.major;
- qbk_minor_version = x.minor;
- qbk_version_n = (qbk_major_version * 100) + qbk_minor_version;
-
- if (qbk_version_n == 106)
- {
- detail::outwarn(x.position.file)
- << "Quickbook 1.6 is still under development and is "
- "likely to change in the future." << std::endl;
- }
- else if(qbk_version_n < 100 || qbk_version_n > 106)
- {
- detail::outerr(x.position.file)
- << "Unknown version of quickbook: quickbook "
- << qbk_major_version
- << "."
- << qbk_minor_version
- << std::endl;
- ++state.error_count;
- }
- }
- }
-
- void process(quickbook::state& state, doc_info const& x)
- {
- doc_info info = x;
-
- // The doc_info in the file has been parsed. Here's what we'll do
- // *before* anything else.
-
- if(!info.doc_title.empty()) {
- state.doc_title = info.doc_title.get(106);
- state.doc_title_raw = info.doc_title.raw;
- }
-
- if(info.doc_id.empty())
- info.doc_id.encoded = info.doc_id.raw = detail::make_identifier(state.doc_title_raw);
-
- if(state.doc_id.empty())
- state.doc_id = info.doc_id.get(106);
-
- // TODO: Set from state.
- if (info.doc_dirname.empty() && info.doc_type == "library")
- info.doc_dirname = info.doc_id;
-
- if (info.doc_last_revision.empty())
- {
- // default value for last-revision is now
-
- char strdate[64];
- strftime(
- strdate, sizeof(strdate),
- (debug_mode ?
- "DEBUG MODE Date: %Y/%m/%d %H:%M:%S $" :
- "$" /* prevent CVS substitution */ "Date: %Y/%m/%d %H:%M:%S $"),
- current_gm_time
- );
- info.doc_last_revision.encoded = info.doc_last_revision.raw = strdate;
- }
-
- // TODO: Should I do this when ignoring docinfo?
-
- if (info.doc_type != "library")
- {
- std::vector<std::string> invalid_attributes;
-
- if (!info.doc_purpose.empty())
- invalid_attributes.push_back("purpose");
-
- if (!info.doc_categories.empty())
- invalid_attributes.push_back("category");
-
- if (!info.doc_dirname.empty())
- invalid_attributes.push_back("dirname");
-
- if(!invalid_attributes.empty())
- {
- detail::outwarn(state.filename.native(),1)
- << (invalid_attributes.size() > 1 ?
- "Invalid attributes" : "Invalid attribute")
- << " for '" << info.doc_type << " document info': "
- << boost::algorithm::join(invalid_attributes, ", ")
- << "\n"
- ;
- }
- }
-
- state.encode(info);
- }
-}

Deleted: branches/quickbook-1.5-spirit2/doc_info_actions.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info_actions.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,24 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2010 Daniel James
- 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)
-=============================================================================*/
-
-#if !defined(BOOST_SPIRIT_QUICKBOOK_DOC_INFO_ACTIONS_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_DOC_INFO_ACTIONS_HPP
-
-#include "fwd.hpp"
-#include "doc_info.hpp"
-
-namespace quickbook
-{
- void process(quickbook::state&, version const&);
- void process(quickbook::state&, doc_info const&);
-}
-
-#endif

Deleted: branches/quickbook-1.5-spirit2/doc_info_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/doc_info_grammar.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,216 +0,0 @@
-/*=============================================================================
- 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_uint.hpp>
-#include <boost/spirit/include/qi_eol.hpp>
-#include <boost/spirit/include/qi_eps.hpp>
-#include <boost/spirit/include/qi_attr_cast.hpp>
-#include <boost/spirit/repository/include/qi_confix.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_container.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <boost/spirit/include/phoenix_fusion.hpp>
-#include "doc_info.hpp"
-#include "grammar_impl.hpp"
-#include "actions.hpp"
-#include "state.hpp"
-#include "parse_utils.hpp"
-#include "misc_rules.hpp"
-#include "utils.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
- namespace repo = boost::spirit::repository;
- namespace ph = boost::phoenix;
-
- struct doc_info_grammar_local
- {
- qi::symbols<char> doc_types;
- qi::rule<iterator, version()> quickbook_version;
- qi::rule<iterator, docinfo_string()> doc_version;
- qi::rule<iterator, docinfo_string()> doc_id;
- qi::rule<iterator, docinfo_string()> doc_dirname;
- qi::rule<iterator, docinfo_string()> doc_category;
- qi::rule<iterator, docinfo_string()> doc_last_revision;
- qi::rule<iterator, std::string()> doc_source_mode; // TODO: raw_source
- qi::rule<iterator, docinfo_string()> doc_purpose;
- qi::rule<iterator, docinfo_string()> doc_license;
- qi::rule<iterator, doc_info::copyright_entry()> doc_copyright;
- qi::rule<iterator, doc_info::author_list()> doc_authors;
- qi::rule<iterator, doc_info::author()> doc_author;
- qi::rule<iterator, docinfo_string()> doc_info_phrase;
- qi::rule<iterator, docinfo_string()> doc_info_text;
- qi::rule<iterator, docinfo_string()> doc_info_text_comma;
- qi::rule<iterator, docinfo_string()> doc_info_title;
- qi::rule<iterator, std::string()> doc_info_phrase_impl;
- qi::rule<iterator, std::string()> doc_info_text_impl;
- qi::rule<iterator, std::string()> doc_info_text_comma_impl;
- qi::rule<iterator, std::string()> doc_info_title_impl;
- };
-
- void quickbook_grammar::impl::init_doc_info()
- {
- doc_info_grammar_local& local = store_.create();
-
- typedef qi::uint_parser<int, 10, 1, 2> uint2_t;
-
- local.doc_types =
- "book", "article", "library", "chapter", "part"
- , "appendix", "preface", "qandadiv", "qandaset"
- , "reference", "set"
- ;
-
- doc_info_details =
- repo::confix(space >> '[' >> space, space >> ']' >> +qi::eol)
- [ qi::raw[local.doc_types] [member_assign(&doc_info::doc_type)]
- >> hard_space
- >> local.doc_info_title [member_assign(&doc_info::doc_title)]
- >> local.quickbook_version [actions.process]
- >> *repo::confix(space >> '[', space >> ']' >> +qi::eol)
- [ local.doc_version [member_assign(&doc_info::doc_version)]
- | local.doc_id [member_assign(&doc_info::doc_id)]
- | local.doc_dirname [member_assign(&doc_info::doc_dirname)]
- | local.doc_copyright [member_push(&doc_info::doc_copyrights)]
- | local.doc_purpose [member_assign(&doc_info::doc_purpose)]
- | local.doc_category [member_push(&doc_info::doc_categories)]
- | local.doc_authors [member_assign(&doc_info::doc_authors)]
- | local.doc_license [member_assign(&doc_info::doc_license)]
- | local.doc_last_revision
- [member_assign(&doc_info::doc_last_revision)]
- // This has to be set in actions so that source code in phrases use the
- // correct encoding.
- | local.doc_source_mode [ph::ref(actions.state_.source_mode) = qi::_1]
- ]
- ]
- ;
-
- local.quickbook_version =
- position [member_assign(&version::position)]
- >> -repo::confix(space >> '[', space >> ']')
- [ "quickbook"
- >> hard_space
- >> qi::uint_ [member_assign(&version::major)]
- >> '.'
- >> uint2_t() [member_assign(&version::minor)]
- ]
- ;
-
- local.doc_version = "version" >> hard_space >> local.doc_info_text;
- local.doc_id = "id" >> hard_space >> local.doc_info_text;
- local.doc_dirname = "dirname" >> hard_space >> local.doc_info_text;
- local.doc_category="category" >> hard_space >> local.doc_info_text;
- local.doc_last_revision = "last-revision" >> hard_space >> local.doc_info_text;
-
- local.doc_copyright =
- "copyright"
- >> hard_space
- >> (+(qi::uint_ >> space)) [member_assign(&doc_info::copyright_entry::years)]
- >> local.doc_info_text [member_assign(&doc_info::copyright_entry::holder)]
- ;
-
- local.doc_purpose =
- "purpose"
- >> hard_space
- >> local.doc_info_phrase
- ;
-
- local.doc_author =
- '['
- >> space
- >> local.doc_info_text_comma [member_assign(&doc_info::author::surname)]
- >> ',' >> space
- >> local.doc_info_text [member_assign(&doc_info::author::firstname)]
- >> ']'
- ;
-
- local.doc_authors
- = "authors"
- >> hard_space
- >> ( (local.doc_author >> space)
- % -(qi::char_(',') >> space)
- );
-
- local.doc_license =
- "license"
- >> hard_space
- >> local.doc_info_phrase
- ;
-
- local.doc_source_mode =
- "source-mode" >> hard_space
- >> (
- qi::string("c++")
- | qi::string("python")
- | qi::string("teletype")
- )
- ;
-
- local.doc_info_phrase =
- qi::raw[
- local.doc_info_phrase_impl [member_assign(&docinfo_string::encoded)]
- ] [member_assign(&docinfo_string::raw)]
- ;
-
- local.doc_info_text =
- qi::raw[
- local.doc_info_text_impl [member_assign(&docinfo_string::encoded)]
- ] [member_assign(&docinfo_string::raw)]
- ;
-
- local.doc_info_text_comma =
- qi::raw[
- local.doc_info_text_comma_impl
- [member_assign(&docinfo_string::encoded)]
- ] [member_assign(&docinfo_string::raw)]
- ;
-
- local.doc_info_title =
- qi::raw[
- local.doc_info_title_impl [member_assign(&docinfo_string::encoded)]
- ] [member_assign(&docinfo_string::raw)]
- ;
-
- local.doc_info_phrase_impl =
- qi::eps [actions.phrase_push]
- >> *( common
- | comment
- | (~qi::char_(']')) [actions.process]
- )
- >> qi::eps [actions.phrase_pop]
- ;
-
- local.doc_info_text_impl =
- qi::eps [actions.phrase_push]
- >> *( escape
- | (~qi::char_(']')) [actions.process]
- )
- >> qi::eps [actions.phrase_pop]
- ;
-
- local.doc_info_text_comma_impl =
- qi::eps [actions.phrase_push]
- >> *( escape
- | (~qi::char_("],")) [actions.process]
- )
- >> qi::eps [actions.phrase_pop]
- ;
-
- local.doc_info_title_impl =
- qi::eps [actions.phrase_push]
- >> *( escape
- | (~qi::char_("[]") - qi::eol)
- [actions.process]
- )
- >> qi::eps [actions.phrase_pop]
- ;
- }
-}

Deleted: branches/quickbook-1.5-spirit2/encoder.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/encoder.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,88 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2010 Daniel James
- 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)
-=============================================================================*/
-
-#if !defined(BOOST_SPIRIT_QUICKBOOK_OUTPUT_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_OUTPUT_HPP
-
-#include <boost/shared_ptr.hpp>
-#include "fwd.hpp"
-#include "phrase.hpp"
-#include "block.hpp"
-#include "syntax_highlight.hpp"
-#include "doc_info.hpp"
-#include "gen_types.hpp"
-#include "template.hpp"
-#include "strings.hpp"
-
-namespace quickbook
-{
- // Base class for encoders.
- //
- // The methods in this class possibly shouldn't be const, as it might be
- // useful to store some state eg. in case anything needs to rearranged in
- // order to create a valid document. Maybe this should act more like a
- // stream? It could have something like the collector interface, with
- // push and pop methods.
-
- struct encoder {
- virtual void operator()(quickbook::state&, doc_info const&) = 0;
- virtual void operator()(quickbook::state&, doc_info_post const&) = 0;
-
- // Note: char is a plain quickbook character, string is an encoded
- // boostbook string. Oops.
- virtual void operator()(quickbook::state&, char) = 0;
- virtual void operator()(quickbook::state&, unicode_char const&) = 0;
- virtual void operator()(quickbook::state&, std::string const&) = 0;
- virtual void operator()(quickbook::state&, anchor const&) = 0;
- virtual void operator()(quickbook::state&, link const&) = 0;
- virtual void operator()(quickbook::state&, formatted const&) = 0;
- virtual void operator()(quickbook::state&, block_formatted const&) = 0;
- virtual void operator()(quickbook::state&, break_ const&) = 0;
- virtual void operator()(quickbook::state&, image2 const&) = 0;
-
- virtual void operator()(quickbook::state&, hr) = 0;
- virtual void operator()(quickbook::state&, begin_section2 const&) = 0;
- virtual void operator()(quickbook::state&, end_section2 const&) = 0;
- virtual void operator()(quickbook::state&, heading2 const&) = 0;
- virtual void operator()(quickbook::state&, variablelist const&) = 0;
- virtual void operator()(quickbook::state&, table2 const&) = 0;
- virtual void operator()(quickbook::state&, xinclude2 const&) = 0;
- virtual void operator()(quickbook::state&, list2 const&) = 0;
- virtual void operator()(quickbook::state&, callout_link const&) = 0;
- virtual void operator()(quickbook::state&, callout_list const&) = 0;
-
- virtual void operator()(quickbook::state&, code_token const&) = 0;
-
- virtual std::string encode(raw_string const&) = 0;
- virtual std::string encode(std::string const&) = 0;
- virtual std::string encode(char) = 0;
- virtual std::string encode(char const*) = 0;
- };
-
- struct encode_action
- {
- typedef void result_type;
-
- encode_action(quickbook::state& state,
- quickbook::encoder& encoder)
- : state(state), encoder(encoder) {}
-
- template <typename T>
- void operator()(T const& x) const {
- encoder(state, x);
- }
-
- quickbook::state& state;
- quickbook::encoder& encoder;
- };
-}
-
-#endif

Deleted: branches/quickbook-1.5-spirit2/encoder_impl.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/encoder_impl.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,17 +0,0 @@
-#include "encoder_impl.hpp"
-
-namespace quickbook
-{
- encoder_ptr create_encoder(std::string const& name)
- {
- if(name == "html") {
- return boost::shared_ptr<encoder>(new html_encoder());
- }
- else if(name == "boostbook") {
- return boost::shared_ptr<encoder>(new boostbook_encoder());
- }
- else {
- BOOST_ASSERT(false);
- }
- }
-}
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/encoder_impl.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/encoder_impl.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,107 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2010 Daniel James
- 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 "fwd.hpp"
-#include "encoder.hpp"
-#include "phrase.hpp"
-#include "state.hpp"
-#include <vector>
-#include <stack>
-
-namespace quickbook
-{
- struct boostbook_encoder : encoder {
- virtual void operator()(quickbook::state&, doc_info const&);
- virtual void operator()(quickbook::state&, doc_info_post const&);
-
- // Note: char is a plain quickbook character, string is an encoded
- // boostbook string. Oops.
- virtual void operator()(quickbook::state&, char);
- virtual void operator()(quickbook::state&, unicode_char const&);
- virtual void operator()(quickbook::state&, std::string const&);
- virtual void operator()(quickbook::state&, anchor const&);
- virtual void operator()(quickbook::state&, link const&);
- virtual void operator()(quickbook::state&, formatted const&);
- virtual void operator()(quickbook::state&, block_formatted const&);
- virtual void operator()(quickbook::state&, break_ const&);
- virtual void operator()(quickbook::state&, image2 const&);
-
- virtual void operator()(quickbook::state&, hr);
- virtual void operator()(quickbook::state&, begin_section2 const&);
- virtual void operator()(quickbook::state&, end_section2 const&);
- virtual void operator()(quickbook::state&, heading2 const&);
- virtual void operator()(quickbook::state&, variablelist const&);
- virtual void operator()(quickbook::state&, table2 const&);
- virtual void operator()(quickbook::state&, xinclude2 const&);
- virtual void operator()(quickbook::state&, list2 const&);
- virtual void operator()(quickbook::state&, callout_link const&);
- virtual void operator()(quickbook::state&, callout_list const&);
-
- virtual void operator()(quickbook::state&, code_token const&);
-
- virtual std::string encode(raw_string const&);
- virtual std::string encode(std::string const&);
- virtual std::string encode(char);
- virtual std::string encode(char const*);
- };
-
- struct html_encoder : encoder {
- html_encoder();
- ~html_encoder();
-
- virtual void operator()(quickbook::state&, doc_info const&);
- virtual void operator()(quickbook::state&, doc_info_post const&);
-
- // Note: char is a plain quickbook character, string is an encoded
- // html string. Oops.
- virtual void operator()(quickbook::state&, char);
- virtual void operator()(quickbook::state&, unicode_char const&);
- virtual void operator()(quickbook::state&, std::string const&);
- virtual void operator()(quickbook::state&, anchor const&);
- virtual void operator()(quickbook::state&, link const&);
- virtual void operator()(quickbook::state&, formatted const&);
- virtual void operator()(quickbook::state&, block_formatted const&);
- virtual void operator()(quickbook::state&, break_ const&);
- virtual void operator()(quickbook::state&, image2 const&);
-
- virtual void operator()(quickbook::state&, hr);
- virtual void operator()(quickbook::state&, begin_section2 const&);
- virtual void operator()(quickbook::state&, end_section2 const&);
- virtual void operator()(quickbook::state&, heading2 const&);
- virtual void operator()(quickbook::state&, variablelist const&);
- virtual void operator()(quickbook::state&, table2 const&);
- virtual void operator()(quickbook::state&, xinclude2 const&);
- virtual void operator()(quickbook::state&, list2 const&);
- virtual void operator()(quickbook::state&, callout_link const&);
- virtual void operator()(quickbook::state&, callout_list const&);
-
- virtual void operator()(quickbook::state&, code_token const&);
-
- virtual std::string encode(raw_string const&);
- virtual std::string encode(std::string const&);
- virtual std::string encode(char);
- virtual std::string encode(char const*);
- private:
- void push_footnotes(quickbook::state&);
- void pop_footnotes(quickbook::state&);
-
- int footnote_id;
- struct footnote {
- footnote(int id, std::string const& content)
- : id(id), content(content) {}
-
- int id;
- std::string content;
- };
- typedef std::vector<footnote> footnotes;
- std::stack<footnotes> footnote_stack;
- };
-}
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/fwd.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/fwd.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,51 +0,0 @@
-/*=============================================================================
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_FWD_HPP)
-#define BOOST_SPIRIT_FWD_HPP
-
-#include <boost/spirit/include/classic_iterator.hpp>
-#include <boost/range.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace quickbook
-{
- struct template_stack;
- struct macro;
- struct doc_info;
-
- struct state;
- struct actions;
- struct code_snippet_actions;
-
- struct collector;
- struct string_stream;
-
- struct rule_store;
-
- typedef boost::spirit::classic::position_iterator<
- std::string::const_iterator> iterator;
- typedef boost::spirit::classic::file_position file_position;
- typedef boost::iterator_range<iterator> raw_source;
-
- struct raw_string;
-
- // templates
-
- struct call_template;
- struct define_template;
-
- // encoder
-
- struct encoder;
- typedef boost::shared_ptr<encoder> encoder_ptr;
- encoder_ptr create_encoder(std::string const&);
-}
-
-#endif
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/gen_types.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/gen_types.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,78 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2010 Daniel James
- 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)
-=============================================================================*/
-
-#if !defined(BOOST_SPIRIT_QUICKBOOK_GEN_TYPES_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_GEN_TYPES_HPP
-
-#include <string>
-#include <vector>
-#include <map>
-#include <boost/optional.hpp>
-#include "block.hpp"
-
-namespace quickbook
-{
- struct image2 {
- typedef std::map<std::string, std::string> attribute_map;
-
- image2(attribute_map const& attributes)
- : attributes(attributes) {}
-
- attribute_map attributes;
- };
-
- struct begin_section2 {
- raw_string id;
- std::string content;
- raw_string linkend;
- };
-
- struct end_section2 {
- };
-
- struct heading2
- {
- int level;
- raw_string id;
- std::string content;
- raw_string linkend;
- };
-
- struct table2
- {
- boost::optional<raw_string> id;
- boost::optional<raw_string> title;
- int cols;
- boost::optional<table_row> head;
- std::vector<table_row> rows;
- };
-
- struct xinclude2
- {
- std::string path;
- };
-
- struct list_item2;
-
- struct list2
- {
- char mark;
- std::vector<list_item2> items;
- };
-
- struct list_item2
- {
- std::string content;
- list2 sublist;
- };
-}
-
-#endif

Deleted: branches/quickbook-1.5-spirit2/grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/grammar.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,90 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2010 Daniel James
- 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 "grammar_impl.hpp"
-#include "utils.hpp"
-#include "actions.hpp"
-#include "state.hpp"
-#include <boost/spirit/include/qi_nonterminal.hpp>
-
-namespace quickbook
-{
- struct error_handler
- {
- error_handler(quickbook::actions& a)
- : actions_(a) {}
-
- void operator()(
- boost::fusion::vector<
- iterator&,
- iterator const&,
- iterator const&,
- boost::spirit::info const&> args,
- boost::spirit::unused_type,
- qi::error_handler_result& r) const
- {
- iterator& first = boost::fusion::at_c<0>(args);
- iterator end = boost::fusion::at_c<1>(args);
- iterator pos = boost::fusion::at_c<2>(args);
- boost::spirit::info const& error = boost::fusion::at_c<3>(args);
-
- detail::outerr(pos.get_position().file, pos.get_position().line)
- << "Syntax error near column "
- << pos.get_position().column
- << ". Expecting "
- << error
- << "."
- << std::endl;
-
- ++actions_.state_.error_count;
-
- // Pretend we've successfully parsed the whole content since we've
- // already complained about the parse error and don't want to
- // complain again.
- r = qi::accept;
- first = end;
- }
-
- quickbook::actions& actions_;
- };
-
- quickbook_grammar::quickbook_grammar(quickbook::actions& a, bool skip_initial_spaces)
- : impl_(new impl(a, skip_initial_spaces))
- , command_line_macro(impl_->command_line_macro, "command_line_macro")
- , phrase(impl_->common, "phrase")
- , simple_phrase(impl_->simple_phrase, "simple_phrase")
- , block(impl_->block_start, "block")
- , doc_info(impl_->doc_info_details, "doc_info")
- {
- qi::on_error(impl_->block_start, error_handler(a));
- }
-
- quickbook_grammar::~quickbook_grammar()
- {
- }
-
- quickbook_grammar::impl::impl(quickbook::actions& a, bool skip_initial_spaces)
- : actions(a)
- , no_eols(true)
- , store_()
- {
- init_phrase();
- init_phrase_markup();
- init_phrase_image();
- init_block(skip_initial_spaces);
- init_block_markup();
- init_block_section();
- init_block_table();
- init_template();
- init_code();
- init_doc_info();
- }
-}

Deleted: branches/quickbook-1.5-spirit2/grammar.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/grammar.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,42 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2010 Daniel James
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP
-
-#include <boost/spirit/include/qi_core.hpp>
-#include <boost/scoped_ptr.hpp>
-#include "fwd.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
-
- class quickbook_grammar
- {
- public:
- struct impl;
-
- private:
- boost::scoped_ptr<impl> impl_;
-
- public:
- qi::grammar<iterator> command_line_macro;
- qi::grammar<iterator> phrase;
- qi::grammar<iterator> simple_phrase;
- qi::grammar<iterator> block;
- qi::grammar<iterator, quickbook::doc_info()> doc_info;
-
- quickbook_grammar(quickbook::actions&, bool skip_initial_spaces = false);
- ~quickbook_grammar();
- };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP

Deleted: branches/quickbook-1.5-spirit2/grammar_impl.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/grammar_impl.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,74 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2010 Daniel James
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_GRAMMARS_IMPL_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_GRAMMARS_IMPL_HPP
-
-#include <boost/spirit/include/qi_core.hpp>
-#include <boost/scoped_ptr.hpp>
-#include "fwd.hpp"
-#include "rule_store.hpp"
-#include "grammar.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
-
- struct quickbook_grammar::impl
- {
- quickbook::actions& actions;
- bool no_eols;
- rule_store store_;
-
- // phrase
- qi::rule<iterator> common;
- qi::rule<iterator> simple_phrase;
- 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;
- qi::rule<iterator> call_template;
- qi::rule<iterator> escape;
-
- // block
- qi::rule<iterator> block_start;
- qi::rule<iterator> command_line_macro;
- 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()> inside_paragraph;
- qi::rule<iterator, boost::optional<raw_string>()> element_id;
-
- // code
- qi::rule<iterator> indented_code;
- qi::rule<iterator> code_block;
- qi::rule<iterator> inline_code;
-
- // doc_info
- qi::rule<iterator, quickbook::doc_info()> doc_info_details;
-
- impl(quickbook::actions&, bool skip_initial_spaces);
-
- private:
-
- void init_phrase();
- void init_phrase_markup();
- void init_phrase_image();
- void init_block(bool skip_initial_spaces);
- void init_block_markup();
- void init_block_section();
- void init_block_table();
- void init_template();
- void init_code();
- void init_doc_info();
- };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_GRAMMARS_HPP

Deleted: branches/quickbook-1.5-spirit2/html.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/html.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,583 +0,0 @@
-#include <algorithm>
-#include <boost/foreach.hpp>
-#include <boost/assert.hpp>
-#include "encoder_impl.hpp"
-
-namespace quickbook
-{
- html_encoder::html_encoder() : footnote_id(0) {}
- html_encoder::~html_encoder() {}
-
- template <typename Iter>
- std::string encode_impl(Iter first, Iter last)
- {
- std::string r;
-
- for(;first != last; ++first) {
- switch (*first)
- {
- case '<': r += "&lt;"; break;
- case '>': r += "&gt;"; break;
- case '&': r += "&amp;"; break;
- case '"': r += "&quot;"; break;
- default: r += *first; break;
- }
- }
-
- return r;
- }
-
- std::string html_encoder::encode(raw_string const& x)
- {
- return encode_impl(x.begin(), x.end());
- }
-
- std::string html_encoder::encode(std::string const& x)
- {
- return encode_impl(x.begin(), x.end());
- }
-
- std::string html_encoder::encode(char const* x)
- {
- char const* end = x;
- while(*end) ++end;
- return encode_impl(x, end);
- }
-
- std::string html_encoder::encode(char c)
- {
- return encode_impl(&c, &c + 1);
- }
-
- namespace {
- struct html_markup {
- char const* quickbook;
- char const* pre;
- char const* post;
- bool block;
- };
-
- html_markup markups[] = {
- { "", "", "" },
- { "paragraph", "<p>\n", "</p>\n" },
- { "blurb", "<div class=\"blurb\">\n", "</div>\n" },
- { "blockquote", "<blockquote>", "</blockquote>" },
- { "preformatted", "<pre>", "</pre>" },
- { "warning", "<div class=\"warning\">", "</div>" },
- { "caution", "<div class=\"caution\">", "</div>" },
- { "important", "<div class=\"important\">", "</div>" },
- { "note", "<div class=\"note\">", "</div>" },
- { "tip", "<div class=\"tip\">", "</div>" },
- { "list_item", "<li>\n", "\n</li>" },
- { "bold", "<strong>", "</strong>" }, // TODO: Or <b>? Should this be semantically meaningfull?
- { "italic", "<em>", "</em>" }, // TODO: Or <i>?
- { "underline", "<u>", "</u>" },
- { "teletype", "<code>", "</code>" },
- { "strikethrough", "<strike>", "</strike>" },
- { "quote", "<q>", "</q>" },
- { "url", "<a href=\"", "</a>" },
- { "link", "<a href=\"#", "</a>" },
- { "funcref", "", "" },
- { "classref", "", "" },
- { "memberref", "", "" },
- { "enumref", "", "" },
- { "macroref", "", "" },
- { "headerref", "", "" },
- { "conceptref", "", "" },
- { "globalref", "", "" },
- // Will need to deal with this explicitly
- { "footnote", "<div class=\"footnote\"><p>", "</p></div>" },
- { "escape", "<!--quickbook-escape-prefix-->", "<!--quickbook-escape-postfix-->" },
- { "replaceable", "<i>", "</i>" },
- // TODO: Is it possible to have an entry with a term, but no items.
- { "varlistentry", "", "" },
- { "varlistterm", "<dt>", "</dt>" },
- { "varlistitem", "<dd>", "</dd>" },
- { "header", "<thead>", "</thead>\n" },
- { "row", "<tr>", "</tr>\n" },
- { "cell", "<td>", "</td>" },
- { "programlisting", "<pre>", "</pre>\n" },
- { "code", "<code>", "</code>" },
- { "hr", "<hr/>", "" },
- { "break", "<br/>", "" },
- };
-
- std::map<std::string, html_markup> markup_map;
-
- struct initialize {
- initialize() {
- BOOST_FOREACH(html_markup m, markups) {
- markup_map[m.quickbook] = m;
- }
- }
- } initialize_instance;
-
- html_markup get_markup(std::string const& x) {
- std::map<std::string, html_markup>::const_iterator
- pos = markup_map.find(x);
- BOOST_ASSERT(pos != markup_map.end());
- return pos->second;
- }
- }
-
- void html_encoder::operator()(quickbook::state& state, std::string const& x)
- {
- state.phrase << x;
- }
-
- void html_encoder::operator()(quickbook::state& state, char x)
- {
- state.phrase << encode(x);
- }
-
- void html_encoder::operator()(quickbook::state& state, unicode_char const& x)
- {
- std::string::const_iterator first = x.value.begin(), last = x.value.end();
- while(first != last && *first == '0') ++first;
-
- // Just ignore \u0000
- // Maybe I should issue a warning?
- if(first == last) return;
-
- std::string hex_digits(first, last);
-
- if(hex_digits.size() == 2 && *first > '0' && *first <= '7') {
- using namespace std;
- (*this)(state, strtol(hex_digits.c_str(), 0, 16));
- }
- else {
- state.phrase << "&#x" << hex_digits << ";";
- }
- }
-
- void html_encoder::operator()(quickbook::state& state, anchor const& x)
- {
- state.phrase << "<a id=\"" << encode(x.id) << "\"/>\n";
- }
-
- void html_encoder::operator()(quickbook::state& state, link const& x)
- {
- html_markup m = get_markup(x.type);
- if(*m.pre) {
- state.phrase << m.pre;
- state.phrase << encode(x.destination);
- state.phrase << "\">";
- state.phrase << x.content;
- state.phrase << m.post;
- }
- else {
- state.phrase << x.content;
- }
- }
-
- void html_encoder::operator()(quickbook::state& state, formatted const& x)
- {
- std::string type = x.type;
- if(type == "footnote") {
- int id = ++footnote_id;
- footnote_stack.top().push_back(footnote(id, x.content));
- // TODO: Maybe get section id from the state?
- state.phrase
- << "<sup id=\"footnote_ref_" << id << "\">"
- << "<a href=\"#footnote_" << id << "\">"
- << "[" << id << "]"
- << "</a>"
- << "</sup>"
- ;
- }
- else {
- html_markup m = get_markup(x.type);
- state.phrase << m.pre << x.content << m.post;
- }
- }
-
- void html_encoder::operator()(quickbook::state& state, block_formatted const& x)
- {
- std::string type = x.type;
- html_markup m = get_markup(x.type);
- state.block << m.pre << x.content << m.post;
- }
-
- void html_encoder::operator()(quickbook::state& state, break_ const& x)
- {
- html_markup m = get_markup("break");
- state.phrase << m.pre;
- }
-
- void html_encoder::operator()(quickbook::state& state, image2 const& x)
- {
- std::map<std::string, char const*> translate;
- translate["alt"] = "alt";
- translate["fileref"] = "src";
- translate["width"] = "width";
- translate["height"] = "height";
-
- state.phrase << "<img";
-
- for(image2::attribute_map::const_iterator
- attr_first = x.attributes.begin(), attr_last = x.attributes.end();
- attr_first != attr_last; ++attr_first)
- {
- char const* html_attribute = translate[attr_first->first];
- if(!html_attribute) continue;
-
- state.phrase
- << " "
- << html_attribute
- << "=\""
- << encode(attr_first->second)
- << "\"";
- }
-
- state.phrase << "/>";
- }
-
- void html_encoder::operator()(quickbook::state& state, hr)
- {
- state.block << get_markup("hr").pre;
- }
-
- void html_encoder::operator()(quickbook::state& state, begin_section2 const& x)
- {
- // TODO: Should this be stored in the 'token', or at least have a nicer interface.
- int level = state.section_level + 1;
- if (level > 6) level = 6;
-
- state.block << "\n<section id=\"" << encode(x.id) << "\">\n";
- if(x.linkend.empty()) {
- state.block
- << "<h" << level << ">"
- << x.content
- << "</h" << level << ">\n"
- ;
- }
- else {
- state.block
- << "<h" << level << " id=\""
- << encode(x.linkend)
- << "\">"
- << x.content
- << "</h" << level << ">\n"
- ;
- }
-
- push_footnotes(state);
- }
-
- void html_encoder::operator()(quickbook::state& state, end_section2 const& x)
- {
- pop_footnotes(state);
-
- state.block << "</section>";
- }
-
- void html_encoder::operator()(quickbook::state& state, heading2 const& x)
- {
- state.block
- << "<h" << x.level << " id=\"" << encode(x.id) << "\">"
- ;
-
- if(!x.linkend.empty()) {
- state.block
- << "<a id=\"" << encode(x.linkend) << "\"></a>"
- ;
- }
- state.block << x.content;
-
- state.block << "</h" << x.level << ">";
- }
-
- void html_encoder::operator()(quickbook::state& state, variablelist const& x)
- {
- // TODO: What should I do for the title?
- state.block << "<p>";
- state.block << encode(x.title);
- state.block << "</p>\n";
-
- state.block << "<dl>\n";
-
- html_markup m = get_markup("varlistentry");
-
- for(std::vector<varlistentry>::const_iterator
- it = x.entries.begin(); it != x.entries.end(); ++it)
- {
- state.block << m.pre;
- std::for_each(it->begin(), it->end(), encode_action(state, *this));
- state.block << m.post;
- }
-
- state.block << "</dl>\n";
- }
-
- void html_encoder::operator()(quickbook::state& state, table2 const& x)
- {
- if (x.title)
- {
- state.block << "<table";
- if(x.id)
- state.block << " id=\"" << encode(*x.id) << "\"";
- state.block << ">\n";
- state.block << "<caption>";
- state.block << encode(*x.title);
- state.block << "</caption>";
- }
- else
- {
- state.block << "<table";
- if(x.id)
- state.block << " id=\"" << encode(*x.id) << "\"";
- state.block << ">\n";
- }
-
- html_markup m = get_markup("row");
-
- if (x.head)
- {
- state.block << "<thead>";
- state.block << m.pre;
- std::for_each(x.head->begin(), x.head->end(), encode_action(state, *this));
- state.block << m.post;
- state.block << "</thead>\n";
- }
-
- state.block << "<tbody>\n";
-
- for(std::vector<table_row>::const_iterator
- it = x.rows.begin(); it != x.rows.end(); ++it)
- {
- state.block << m.pre;
- std::for_each(it->begin(), it->end(), encode_action(state, *this));
- state.block << m.post;
- }
-
- state.block << "</tbody>\n";
-
- state.block << "</table>\n";
- }
-
- void html_encoder::operator()(quickbook::state& state, xinclude2 const& x)
- {
- // TODO: ?????
- //state.phrase << "\n<xi:include href=\"" << x.path << "\" />\n";
- }
-
- void html_encoder::operator()(quickbook::state& state, list2 const& x)
- {
- state.block << std::string(x.mark == '#' ? "<ol>\n" : "<ul>\n");
-
- for(std::vector<list_item2>::const_iterator
- it = x.items.begin(), end = x.items.end(); it != end; ++it)
- {
- state.block << "<li>\n" << it->content;
- if(!it->sublist.items.empty()) (*this)(state, it->sublist);
- state.block << std::string("\n</li>");
- }
-
- state.block << std::string(x.mark == '#' ? "\n</ol>" : "\n</ul>");
- }
-
- void html_encoder::operator()(quickbook::state& state, callout_link const& x)
- {
- state.phrase
- << "<span"
- << " class=\"" << x.role << "\""
- << " id=\"" << x.identifier << "co\""
- << ">"
- << "<a href=\"#" << x.identifier << "\">"
- // TODO: Get correct number
- // TODO: Better style
- << "(c)"
- << "</a>"
- << "</span>"
- ;
- }
-
- void html_encoder::operator()(quickbook::state& state, callout_list const& x)
- {
- state.block
- << "<dl class=\"calloutlist\">";
- unsigned int count = 0;
-
- BOOST_FOREACH(callout_item const& c, x)
- {
- state.block
- << "<dt id=\"" << c.identifier << "\">"
- << "<a href=\"#" << c.identifier << "co\">"
- << "callout " << ++count
- << "</a>"
- << "</dt>"
- << "<dd>"
- << c.content
- << "</dd>"
- ;
- }
-
- state.block
- << "</ol>";
- }
-
- void html_encoder::operator()(quickbook::state& state, code_token const& x)
- {
- std::string type = x.type;
- if(type == "space") {
- state.phrase << x.text;
- }
- else {
- state.phrase
- << "<span class=\"" << x.type << "\">"
- << encode(x.text)
- << "</span>";
- }
- }
-
- void html_encoder::operator()(quickbook::state& state, doc_info const& info)
- {
- // if we're ignoring the document info, we're done.
- if (info.ignore) return;
-
- state.block
- << "<!DOCTYPE html>"
- << "<html><head>"
- << "<title>" << encode(info.doc_title.get(106)) << "</title>"
- << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
- << "</head>"
- << "<body>"
- << "<header>"
- << "<h1>" << encode(info.doc_title.get(106)) << "</h1>"
- ;
-
- if(!info.doc_authors.empty() || !info.doc_copyrights.empty() ||
- !info.doc_license.empty())
- {
- state.block << "<dl>\n";
-
- if(!info.doc_authors.empty())
- {
- state.block
- << "<dt>"
- << (info.doc_authors.size() == 1 ? "Author:" : "Authors:")
- << "</dt>\n"
- ;
-
- BOOST_FOREACH(doc_info::author const& author, info.doc_authors) {
- state.block
- << "<dd>"
- << author.firstname.get(106)
- << " "
- << author.surname.get(106)
- << "</dd>\n";
- }
- }
-
- if(!info.doc_copyrights.empty())
- {
- state.block
- << "<dt>Copyright:</dt>\n"
- ;
-
- BOOST_FOREACH(doc_info::copyright_entry const& copyright,
- info.doc_copyrights)
- {
- state.block << "<dd>&copy; ";
-
- unsigned int range_state = 0;
- unsigned int previous = 0;
- BOOST_FOREACH(unsigned int year, copyright.years) {
- switch(range_state) {
- case 0: // Start
- state.block << year;
- range_state = 1;
- break;
- case 1: // Printed a year in last iteration
- if(year == previous + 1) {
- range_state = 2;
- }
- else {
- state.block << ", " << year;
- range_state = 1;
- }
- break;
- case 2: // In the middle of a range
- if(year != previous + 1) {
- state.block << " - " << previous << ", " << year;
- range_state = 1;
- }
- break;
- }
- previous = year;
- }
- if(range_state == 2) state.block << " - " << previous;
-
- state.block
- << " "
- << copyright.holder.get(106)
- << "</dd>\n"
- ;
- }
- }
-
- if (!info.doc_license.empty())
- {
- state.block
- << "<dt>License:</dt>\n"
- << "<dd>"
- << info.doc_license.get(103)
- << "</dd>\n"
- ;
- }
-
- state.block << "</dl>\n";
- }
-
- state.block
- << "</header>\n"
- ;
-
- push_footnotes(state);
- }
-
- void html_encoder::operator()(quickbook::state& state, doc_info_post const& x)
- {
- // if we're ignoring the document info, do nothing.
- if (x.info.ignore) return;
-
- pop_footnotes(state);
-
- // We've finished generating our output. Here's what we'll do
- // *after* everything else.
- state.block << "</html>";
- }
-
- void html_encoder::push_footnotes(quickbook::state& state)
- {
- footnote_stack.push(footnotes());
- }
-
- void html_encoder::pop_footnotes(quickbook::state& state)
- {
- BOOST_ASSERT(!footnote_stack.empty());
- footnotes notes = footnote_stack.top();
- footnote_stack.pop();
-
- if(!notes.empty()) {
- state.block
- << "<dl class=\"footnotes\">\n";
-
- BOOST_FOREACH(footnote const& x, notes) {
- state.block
- << "<dt id=\"footnote_" << encode(x.id) << "\">"
- << "<a href=\"#footnote_ref_" << encode(x.id) << "\">"
- << "Footnote"
- << "</a>"
- << "</dt>"
- << "<dd>"
- << x.content
- << "</dd>"
- ;
- }
-
- state.block
- << "</dl>\n";
- }
- }
-}

Deleted: branches/quickbook-1.5-spirit2/input_path.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/input_path.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,105 +0,0 @@
-/*=============================================================================
- Copyright (c) 2009 Daniel James
-
- 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/program_options.hpp>
-#include "./input_path.hpp"
-
-#if !(defined(__cygwin__) || defined(__CYGWIN__))
-
-// Everything but cygwin
-
-namespace quickbook { namespace detail
-{
- void validate(boost::any& v,
- const std::vector<std::string>& values,
- input_path*, int)
- {
- std::string path
- = boost::program_options::validators::get_single_string(values);
-
- v = input_path(path);
- }
-}}
-
-#elif defined(QUICKBOOK_CYGWIN_1_5)
-
-// Cygwin 1.5.x
-
-#include <boost/filesystem/v3/config.hpp>
-#include <windows.h>
-#include <sys/cygwin.h>
-
-namespace quickbook { namespace detail
-{
- void validate(boost::any& v,
- const std::vector<std::string>& values,
- input_path*, int)
- {
- std::string path
- = boost::program_options::validators::get_single_string(values);
-
- char result[MAX_PATH + 1];
-
-#if defined(BOOST_WINDOWS_PATH)
- cygwin_conv_to_win32_path(path.c_str(), result);
-#elif defined(BOOST_POSIX_PATH)
- cygwin_conv_to_posix_path(path.c_str(), result);
-#else
-# error "Boost filesystem path type doesn't seem to be set."
-#endif
-
- v = input_path(result);
- }
-}}
-
-#else
-
-// Cygwin 1.7.x
-
-#include <boost/filesystem/v3/config.hpp>
-#include <boost/scoped_array.hpp>
-#include <boost/program_options/errors.hpp>
-#include <windows.h>
-#include <sys/cygwin.h>
-
-namespace quickbook { namespace detail
-{
- void validate(boost::any& v,
- const std::vector<std::string>& values,
- input_path*, int)
- {
- std::string path
- = boost::program_options::validators::get_single_string(values);
-
-#if defined(BOOST_WINDOWS_PATH)
- cygwin_conv_path_t flags = CCP_POSIX_TO_WIN_A | CCP_RELATIVE;
-#elif defined(BOOST_POSIX_PATH)
- cygwin_conv_path_t flags = CCP_WIN_A_TO_POSIX | CCP_RELATIVE;
-#else
-# error "Boost filesystem path type doesn't seem to be set."
-#endif
-
- ssize_t size = cygwin_conv_path(flags, path.c_str(), NULL, 0);
-
- if (size < 0) {
- throw boost::program_options::validation_error(
- boost::program_options::validation_error::invalid_option_value);
- }
-
- boost::scoped_array<char> result(new char[size]);
-
- if(cygwin_conv_path(flags, path.c_str(), result.get(), size)) {
- throw boost::program_options::validation_error(
- boost::program_options::validation_error::invalid_option_value);
- }
-
- v = input_path(result.get());
- }
-}}
-
-#endif

Deleted: branches/quickbook-1.5-spirit2/input_path.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/input_path.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,39 +0,0 @@
-/*=============================================================================
- Copyright (c) 2009 Daniel James
-
- 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)
-=============================================================================*/
-
-#if !defined(BOOST_QUICKBOOK_DETAIL_INPUT_PATH_HPP)
-#define BOOST_QUICKBOOK_DETAIL_INPUT_PATH_HPP
-
-#include <vector>
-#include <string>
-#include <boost/any.hpp>
-
-namespace quickbook { namespace detail
-{
- // Use this class with Boost.Program Options to convert paths to the format
- // the Boost.Filesystem expects. This is needed on cygwin to convert cygwin
- // paths to windows paths (or vice versa, depending on how filesystem is set
- // up).
- //
- // Note that we don't want to convert paths in quickbook files, as they
- // should be platform independent, and aren't necessarily relative to the
- // current directory.
-
- class input_path {
- std::string path_;
- public:
- explicit input_path(char const* c) : path_(c) {}
- explicit input_path(std::string const& c) : path_(c) {}
- operator std::string() const { return path_; }
-
- friend void validate(boost::any&, const std::vector<std::string>&,
- input_path*, int);
- };
-}}
-
-#endif

Deleted: branches/quickbook-1.5-spirit2/misc_rules.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/misc_rules.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,71 +0,0 @@
-/*=============================================================================
- 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_eps.hpp>
-#include <boost/spirit/include/qi_eol.hpp>
-#include "misc_rules.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
-
- qi::rule<iterator, std::string()> macro_identifier;
- qi::rule<iterator> dummy_block;
- qi::rule<iterator> comment;
- qi::rule<iterator> hard_space;
- qi::rule<iterator> space;
- qi::rule<iterator> blank;
- qi::rule<iterator> eol;
- qi::rule<iterator, file_position()> position;
-
- struct get_position
- {
- template <typename Range, typename Context>
- void operator()(Range const& it, Context& c, bool& x) const {
- boost::spirit::_val(it, c, x) = it.begin().get_position();
- }
- };
-
- void init_misc_rules() {
- macro_identifier =
- +(qi::char_ - (qi::space | ']'))
- ;
-
- dummy_block =
- '[' >> *(dummy_block | (qi::char_ - ']')) >> ']'
- ;
-
- comment =
- "[/" >> *(dummy_block | (qi::char_ - ']')) >> ']'
- ;
-
- // Used after an identifier that must not be immediately
- // followed by an alpha-numeric character or underscore.
- hard_space =
- !(qi::alnum | '_') >> space
- ;
-
- space =
- *(qi::space | comment)
- ;
-
- blank =
- *(qi::blank | comment)
- ;
-
- eol =
- blank >> qi::eol
- ;
-
- position =
- qi::raw[qi::eps] [get_position()];
- }
-}

Deleted: branches/quickbook-1.5-spirit2/misc_rules.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/misc_rules.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,29 +0,0 @@
-/*=============================================================================
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_MISC_RULES_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_MISC_RULES_HPP
-
-#include <boost/spirit/include/qi_core.hpp>
-#include "fwd.hpp"
-
-// Just a few stateless parser rules that are used in a lot of places.
-
-namespace quickbook
-{
- extern boost::spirit::qi::rule<iterator, std::string()> macro_identifier;
- extern boost::spirit::qi::rule<iterator> comment;
- extern boost::spirit::qi::rule<iterator> eol;
- extern boost::spirit::qi::rule<iterator> hard_space;
- extern boost::spirit::qi::rule<iterator> space;
- extern boost::spirit::qi::rule<iterator> blank;
- extern boost::spirit::qi::rule<iterator, file_position()> position;
-}
-
-#endif
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/parse_types.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/parse_types.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,26 +0,0 @@
-/*=============================================================================
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_PARSE_TYPES_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_PARSE_TYPES_HPP
-
-#include <string>
-#include "fwd.hpp"
-
-namespace quickbook
-{
- typedef char const* formatted_type;
-
- struct formatted {
- formatted_type type;
- std::string content;
- };
-}
-
-#endif
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/parse_utils.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/parse_utils.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,130 +0,0 @@
-/*=============================================================================
- Copyright (c) 2009 Daniel James
- 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)
-=============================================================================*/
-
-#if !defined(BOOST_SPIRIT_QUICKBOOK_AS_STRING_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_AS_STRING_HPP
-
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/qi_nonterminal.hpp>
-#include <string>
-
-namespace quickbook
-{
- namespace spirit = boost::spirit;
-
- // member_assign - action to assign the attribute to a member of the
- // rule's attributte.
-
- template <typename Struct, typename Member>
- struct member_assign_type {
- member_assign_type(Member Struct::*mem_ptr) : mem_ptr_(mem_ptr) {}
-
- template <typename Context>
- void operator()(Member& attrib, Context& context, bool& pass) const {
- &(spirit::_val)(attrib,context,pass)->*mem_ptr_ = attrib;
- }
-
- template <typename Attrib, typename Context>
- void operator()(Attrib& attrib, Context& context, bool& pass) const {
- &(spirit::_val)(attrib,context,pass)->*mem_ptr_ = attrib;
- }
-
- Member Struct::*mem_ptr_;
- };
-
- template <typename Struct>
- struct member_assign_type<Struct, std::string> {
- member_assign_type(std::string Struct::*mem_ptr) : mem_ptr_(mem_ptr) {}
-
- template <typename Context>
- void operator()(std::string& attrib, Context& context, bool& pass) const {
- &(spirit::_val)(attrib,context,pass)->*mem_ptr_ = attrib;
- }
-
- template <typename Attrib, typename Context>
- void operator()(Attrib& attrib, Context& context, bool& pass) const {
- &(spirit::_val)(attrib,context,pass)->*mem_ptr_ =
- std::string(attrib.begin(), attrib.end());
- }
-
- std::string Struct::*mem_ptr_;
- };
-
- template <typename Struct, typename Member>
- struct fixed_member_assign_type {
- fixed_member_assign_type(Member Struct::*mem_ptr, Member const& m)
- : mem_ptr_(mem_ptr), m_(m) {}
-
- template <typename Attrib, typename Context>
- void operator()(Attrib& attrib, Context& context, bool& pass) const {
- &(spirit::_val)(attrib,context,pass)->*mem_ptr_ = m_;
- }
-
- Member Struct::*mem_ptr_;
- Member m_;
- };
-
- template <typename Struct, typename Member>
- member_assign_type<Struct, Member> member_assign(Member Struct::*mem_ptr) {
- return member_assign_type<Struct, Member>(mem_ptr);
- }
-
- template <typename Struct, typename Member, typename Value>
- fixed_member_assign_type<Struct, Member> member_assign(Member Struct::*mem_ptr, Value const& m) {
- return fixed_member_assign_type<Struct, Member>(mem_ptr, m);
- }
-
- // member_push - action to push the attribute to a member of the
- // rule's attributte.
-
- template <typename Struct, typename Member>
- struct member_push_type {
- member_push_type(Member Struct::*mem_ptr) : mem_ptr_(mem_ptr) {}
-
- template <typename Context>
- void operator()(Member& attrib, Context& context, bool& pass) const {
- (&(spirit::_val)(attrib,context,pass)->*mem_ptr_).push_back(attrib);
- }
-
- template <typename Attrib, typename Context>
- void operator()(Attrib& attrib, Context& context, bool& pass) const {
- (&(spirit::_val)(attrib,context,pass)->*mem_ptr_).push_back(
- typename Member::value_type(attrib));
- }
-
- Member Struct::*mem_ptr_;
- };
-
- template <typename Struct>
- struct member_push_type<Struct, std::vector<std::string> > {
- member_push_type(std::vector<std::string> Struct::*mem_ptr) : mem_ptr_(mem_ptr) {}
-
- template <typename Context>
- void operator()(std::string& attrib, Context& context, bool& pass) const {
- (&(spirit::_val)(attrib,context,pass)->*mem_ptr_).push_back(attrib);
- }
-
- template <typename Attrib, typename Context>
- void operator()(Attrib& attrib, Context& context, bool& pass) const {
- (&(spirit::_val)(attrib,context,pass)->*mem_ptr_).push_back(
- std::string(attrib.begin(), attrib.end()));
- }
-
- std::vector<std::string> Struct::*mem_ptr_;
- };
-
- template <typename Struct, typename Member>
- member_push_type<Struct, Member> member_push(Member Struct::*mem_ptr) {
- return member_push_type<Struct, Member>(mem_ptr);
- }
-}
-
-#endif

Deleted: branches/quickbook-1.5-spirit2/phrase.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,66 +0,0 @@
-/*=============================================================================
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
-
-#include <vector>
-#include <string>
-#include <map>
-#include "fwd.hpp"
-#include "parse_types.hpp"
-
-namespace quickbook
-{
- struct source_mode {
- source_mode() {}
- source_mode(std::string const& m) : mode(m) {}
-
- std::string mode;
- };
-
- struct anchor {
- std::string id;
- };
-
- struct link {
- formatted_type type;
- std::string destination;
- std::string content;
- };
-
- struct simple_markup {
- char symbol;
- std::string raw_content;
- };
-
- struct cond_phrase {
- std::string macro_id;
- std::string content;
- };
-
- struct break_ {
- file_position position;
- };
-
- struct image {
- typedef std::multimap<std::string, std::string> attribute_map;
-
- file_position position;
- std::string image_filename;
- attribute_map attributes;
- };
-
- struct unicode_char {
- std::string value;
- };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_PHRASE_HPP
-

Deleted: branches/quickbook-1.5-spirit2/phrase_actions.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_actions.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,124 +0,0 @@
-/*=============================================================================
- 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/assert.hpp>
-#include "phrase_actions.hpp"
-#include "phrase.hpp"
-#include "actions.hpp"
-#include "state.hpp"
-#include "utils.hpp"
-#include "code.hpp"
-#include "encoder.hpp"
-#include "quickbook.hpp"
-
-namespace quickbook
-{
- void process(quickbook::state& state, source_mode const& s) {
- state.source_mode = s.mode;
- }
-
- // TODO: If I used a different types for quickbook and the generated
- // output, I could possibly do something smarter here.
- void process(quickbook::state& state, macro const& x) {
- if (x.raw_markup == quickbook_get_date)
- {
- char strdate[64];
- strftime(strdate, sizeof(strdate), "%Y-%b-%d", current_time);
- state.encode(state.encoder->encode(strdate));
- }
- else if (x.raw_markup == quickbook_get_time)
- {
- char strdate[64];
- strftime(strdate, sizeof(strdate), "%I:%M:%S %p", current_time);
- state.encode(state.encoder->encode(strdate));
- }
- else
- {
- state.encode(x.raw_markup);
- }
- }
-
- void process(quickbook::state& state, link const& x) {
- link r = x;
- if(r.content.empty()) {
- r.content = state.encoder->encode(x.destination);
- }
- state.encode(r);
- }
-
- void process(quickbook::state& state, simple_markup const& x) {
- formatted r;
- switch(x.symbol) {
- case '*': r.type = "bold"; break;
- case '/': r.type = "italic"; break;
- case '_': r.type = "underline"; break;
- case '=': r.type = "teletype"; break;
- default: BOOST_ASSERT(false);
- }
-
- r.content = state.encoder->encode(x.raw_content);
-
- state.encode(r);
- }
-
- void process(quickbook::state& state, cond_phrase const& x) {
- bool symbol_found = state.macro.find(x.macro_id.c_str());
-
- if(!x.content.empty() && symbol_found) state.encode(x.content);
- }
-
- void process(quickbook::state& state, break_ const& x) {
- detail::outwarn(x.position.file,x.position.line)
- << "in column:" << x.position.column << ", "
- << "[br] and \\n are deprecated" << ".\n";
- state.encode(x);
- }
-
- void 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) {
- // preprocess the code section to remove the initial indentation
- detail::unindent(program);
- if (program.size() == 0)
- return; // Nothing left to do here. The program is empty.
- }
-
- iterator first_(program.begin(), program.end());
- iterator last_(program.end(), program.end());
- first_.set_position(x.position);
-
- // TODO: I don't need to save this, do I?
- std::string save;
- state.phrase.swap(save);
-
- // print the code with syntax coloring
- quickbook::actions actions(state);
- std::string str = syntax_highlight(
- first_, last_, actions, state.source_mode);
-
- state.phrase.swap(save);
-
- if(x.flow == x.block) {
- block_formatted r;
- r.type = "programlisting";
- r.content = str;
- state.encode(r);
- }
- else {
- formatted r;
- r.type = x.flow == x.inline_block ? "programlisting" : "code";
- r.content = str;
- state.encode(r);
- }
- }
-}

Deleted: branches/quickbook-1.5-spirit2/phrase_actions.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_actions.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,29 +0,0 @@
-/*=============================================================================
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_PHRASE_ACTIONS_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_PHRASE_ACTIONS_HPP
-
-#include "phrase.hpp"
-#include "code.hpp"
-
-namespace quickbook
-{
- void process(quickbook::state&, source_mode const&);
- void process(quickbook::state&, macro const&);
- void process(quickbook::state&, link const&);
- void process(quickbook::state&, simple_markup const&);
- void process(quickbook::state&, cond_phrase const&);
- void process(quickbook::state&, break_ const&);
- void process(quickbook::state&, code const&);
- void process(quickbook::state&, image const&);
- void process(quickbook::state&, call_template const&);
-}
-
-#endif

Deleted: branches/quickbook-1.5-spirit2/phrase_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_grammar.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,178 +0,0 @@
-/*=============================================================================
- 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_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/repository/include/qi_confix.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include "grammar_impl.hpp"
-#include "phrase.hpp"
-#include "code.hpp"
-#include "actions.hpp"
-#include "misc_rules.hpp"
-#include "parse_utils.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
- namespace repo = boost::spirit::repository;
- namespace ph = boost::phoenix;
-
- struct phrase_grammar_local
- {
- qi::rule<iterator> macro;
- qi::rule<iterator> phrase_markup;
- qi::rule<iterator, qi::locals<qi::rule<iterator> > > phrase_markup_impl;
- qi::rule<iterator, quickbook::break_()> break_;
- qi::rule<iterator, quickbook::simple_markup(), qi::locals<char> > simple_format;
- qi::rule<iterator, std::string(char)> simple_format_body;
- qi::rule<iterator, void(char)> simple_format_chars;
- qi::rule<iterator, void(char)> simple_format_end;
- qi::rule<iterator> simple_phrase_end;
- qi::rule<iterator, quickbook::break_()> escape_break;
- qi::rule<iterator, quickbook::formatted()> escape_punct;
- qi::rule<iterator, quickbook::formatted()> escape_markup;
- qi::rule<iterator, quickbook::unicode_char()> escape_unicode16;
- qi::rule<iterator, quickbook::unicode_char()> escape_unicode32;
- };
-
- void quickbook_grammar::impl::init_phrase()
- {
- phrase_grammar_local& local = store_.create();
-
- simple_phrase =
- *( common
- | (qi::char_ - ']') [actions.process]
- )
- ;
-
- phrase =
- qi::eps [actions.phrase_push]
- >> *( common
- | (qi::char_ - phrase_end) [actions.process]
- )
- >> qi::eps [actions.phrase_pop]
- ;
-
- common =
- local.macro
- | local.phrase_markup
- | code_block [actions.process]
- | inline_code [actions.process]
- | local.simple_format [actions.process]
- | escape
- | comment
- ;
-
- local.macro =
- ( actions.macro // must not be followed by
- >> !(qi::alpha | '_') // alpha or underscore
- ) [actions.process]
- ;
-
- local.phrase_markup =
- repo::confix('[', ']')
- [ local.phrase_markup_impl
- | call_template
- | local.break_ [actions.process]
- ]
- ;
-
- local.phrase_markup_impl
- = ( phrase_keyword_rules >> !(qi::alnum | '_')
- | phrase_symbol_rules
- ) [qi::_a = qi::_1]
- >> lazy(qi::_a)
- ;
-
- local.break_ =
- position [member_assign(&quickbook::break_::position)]
- >> "br"
- ;
-
- local.simple_format
- = qi::char_("*/_=") [qi::_a = qi::_1]
- >> local.simple_format_body(qi::_a)[member_assign(&quickbook::simple_markup::raw_content)]
- >> qi::char_(qi::_a) [member_assign(&quickbook::simple_markup::symbol)]
- ;
-
- local.simple_format_body
- = qi::raw
- [ qi::graph
- >> ( &local.simple_format_end(qi::_r1)
- | local.simple_format_chars(qi::_r1)
- )
- ]
- ;
-
- local.simple_format_chars
- = *( qi::char_ -
- ( (qi::graph >> qi::lit(qi::_r1))
- | local.simple_phrase_end // Make sure that we don't go
- ) // past a single block
- )
- >> qi::graph // qi::graph must precede qi::lit(qi::_r1)
- >> &local.simple_format_end(qi::_r1)
- ;
-
- local.simple_format_end
- = qi::lit(qi::_r1)
- >> (qi::space | qi::punct | qi::eoi)
- ;
-
- local.simple_phrase_end = '[' | phrase_end;
-
- escape =
- ( local.escape_break
- | "\\ " // ignore an escaped char
- | local.escape_punct
- | local.escape_unicode16
- | local.escape_unicode32
- | local.escape_markup
- ) [actions.process]
- ;
-
- local.escape_break =
- position [member_assign(&quickbook::break_::position)]
- >> "\\n"
- ;
-
- local.escape_punct =
- '\\'
- >> qi::repeat(1)[qi::punct] [member_assign(&quickbook::formatted::content)]
- [member_assign(&quickbook::formatted::type, "")]
- ;
-
- local.escape_markup =
- repo::confix("'''" >> -eol, "'''") [*(qi::char_ - "'''")]
- [member_assign(&quickbook::formatted::content)]
- [member_assign(&quickbook::formatted::type, "escape")]
- ;
-
- local.escape_unicode16 =
- "\\u"
- > qi::raw[qi::repeat(4)[qi::xdigit]] [member_assign(&quickbook::unicode_char::value)]
- ;
-
- local.escape_unicode32 =
- "\\U"
- > 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 >> *qi::blank >> qi::eol
- ;
- }
-}

Deleted: branches/quickbook-1.5-spirit2/phrase_image.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_image.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,119 +0,0 @@
-/*=============================================================================
- 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/filesystem/v3/convenience.hpp>
-#include <boost/filesystem/v3/fstream.hpp>
-#include "phrase_actions.hpp"
-#include "phrase.hpp"
-#include "gen_types.hpp"
-#include "state.hpp"
-#include "utils.hpp"
-#include "encoder.hpp"
-
-namespace quickbook
-{
- namespace fs = boost::filesystem;
-
- void process(quickbook::state& state, image const& x)
- {
- typedef image2::attribute_map attribute_map;
- typedef attribute_map::value_type attribute;
-
- attribute_map attributes(x.attributes.begin(), x.attributes.end());
-
- if(attributes.size() != x.attributes.size()) {
- std::map<std::string, std::string> duplicates;
- std::set_difference(
- x.attributes.begin(), x.attributes.end(),
- attributes.begin(), attributes.end(),
- std::inserter(duplicates, duplicates.end()));
-
- for(std::map<std::string, std::string>::iterator
- begin = duplicates.begin(), end = duplicates.end();
- begin != end; ++begin)
- {
- detail::outwarn(x.position.file, x.position.line)
- << "Duplicate image attribute: "
- << begin->first
- << std::endl;
- }
- }
-
- fs::path const img_path(x.image_filename);
- attributes.insert(attribute("fileref", x.image_filename));
- // Note: If there is already an alt attribute this is a no-op.
- attributes.insert(attribute("alt", img_path.stem().generic_string()));
-
- if(img_path.extension() == ".svg")
- {
- //
- // SVG's need special handling:
- //
- // 1) We must set the "format" attribute, otherwise
- // HTML generation produces code that will not display
- // the image at all.
- // 2) We need to set the "contentwidth" and "contentdepth"
- // attributes, otherwise the image will be displayed inside
- // a tiny box with scrollbars (Firefox), or else cropped to
- // fit in a tiny box (IE7).
- //
- attributes.insert(attribute("format", "SVG"));
- //
- // Image paths are relative to the html subdirectory:
- // TODO: This only works when you're running in the correct directory.
- // Support 'boost:' directories? Include paths?
- //
- fs::path img;
- if(img_path.root_path().empty())
- img = "html" / img_path; // relative path
- else
- img = img_path; // absolute path
- //
- // Now load the SVG file:
- //
- std::string svg_text;
- fs::ifstream fs(img);
- char c;
- while(fs.get(c) && fs.good())
- svg_text.push_back(c);
- //
- // Extract the svg header from the file:
- //
- std::string::size_type a, b;
- a = svg_text.find("<svg");
- b = svg_text.find('>', a);
- svg_text = (a == std::string::npos) ? "" : svg_text.substr(a, b - a);
- //
- // Now locate the "width" and "height" attributes
- // and borrow their values:
- //
- a = svg_text.find("width");
- a = svg_text.find('=', a);
- a = svg_text.find('\"', a);
- b = svg_text.find('\"', a + 1);
- if(a != std::string::npos)
- {
- attributes.insert(attribute("contentwidth",
- std::string(svg_text.begin() + a + 1, svg_text.begin() + b)));
- }
- a = svg_text.find("height");
- a = svg_text.find('=', a);
- a = svg_text.find('\"', a);
- b = svg_text.find('\"', a + 1);
- if(a != std::string::npos)
- {
- attributes.insert(attribute("contentdepth",
- std::string(svg_text.begin() + a + 1, svg_text.begin() + b)));
- }
- }
-
- state.encode(image2(attributes));
- }
-}
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/phrase_image_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_image_grammar.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,83 +0,0 @@
-/*=============================================================================
- 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 <boost/spirit/repository/include/qi_confix.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 repo = boost::spirit::repository;
-
- struct image_grammar_local
- {
- qi::rule<iterator, quickbook::image()> image;
- qi::rule<iterator, quickbook::image()> image_1_4;
- qi::rule<iterator, quickbook::image()> image_1_5;
- qi::rule<iterator, std::string()> image_filename;
- qi::rule<iterator, quickbook::image::attribute_map()> image_attributes;
- qi::rule<iterator, std::pair<std::string, std::string>()> image_attribute;
- qi::rule<iterator, std::string()> image_attribute_key;
- qi::rule<iterator, std::string()> image_attribute_value;
- };
-
- void quickbook_grammar::impl::init_phrase_image()
- {
- image_grammar_local& local = store_.create();
-
- phrase_symbol_rules.add("$", local.image [actions.process]);
-
- local.image =
- (qi::eps(qbk_since(105u)) >> local.image_1_5) |
- (qi::eps(qbk_before(105u)) >> local.image_1_4);
-
- local.image_1_4 =
- position [member_assign(&quickbook::image::position)]
- >> blank
- >> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::image::image_filename)]
- >> &qi::lit(']')
- ;
-
- local.image_1_5 =
- position [member_assign(&quickbook::image::position)]
- >> blank
- >> local.image_filename [member_assign(&quickbook::image::image_filename)]
- >> hard_space
- >> local.image_attributes [member_assign(&quickbook::image::attributes)]
- >> &qi::lit(']')
- ;
-
- local.image_filename = qi::raw[
- +(qi::char_ - (qi::space | phrase_end | '['))
- >> *(
- +qi::space
- >> +(qi::char_ - (qi::space | phrase_end | '['))
- )];
-
- local.image_attributes = *(local.image_attribute >> space);
-
- local.image_attribute =
- repo::confix('[', ']')
- [ local.image_attribute_key [member_assign(&std::pair<std::string, std::string>::first)]
- >> space
- >> local.image_attribute_value [member_assign(&std::pair<std::string, std::string>::second)]
- ]
- ;
-
- local.image_attribute_key = *(qi::alnum | '_');
- local.image_attribute_value = *(qi::char_ - (phrase_end | '['));
- }
-}
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/phrase_markup_grammar.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,137 +0,0 @@
-/*=============================================================================
- 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_symbols.hpp>
-#include <boost/spirit/include/qi_attr.hpp>
-#include <boost/spirit/include/qi_eps.hpp>
-#include "grammar_impl.hpp"
-#include "phrase.hpp"
-#include "actions.hpp"
-#include "template.hpp"
-#include "misc_rules.hpp"
-#include "parse_utils.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
- namespace ph = boost::phoenix;
-
- struct phrase_markup_grammar_local
- {
- qi::rule<iterator, quickbook::callout_link()> callout_link;
- qi::rule<iterator, quickbook::cond_phrase()> cond_phrase;
- qi::rule<iterator, quickbook::link()> url;
- qi::symbols<char, formatted_type> link_symbol;
- qi::rule<iterator, quickbook::link(formatted_type)> link;
- qi::rule<iterator, quickbook::anchor()> anchor;
- qi::rule<iterator, quickbook::formatted(formatted_type)> formatted;
- };
-
- void quickbook_grammar::impl::init_phrase_markup()
- {
- phrase_markup_grammar_local& local = store_.create();
-
- // Callouts
-
- // Don't use this, it's meant to be private.
- phrase_symbol_rules.add("[callout]", local.callout_link [actions.process]);
-
- local.callout_link =
- (*~qi::char_(' ')) [member_assign(&quickbook::callout_link::role)]
- >> ' '
- >> (*~qi::char_(']')) [member_assign(&quickbook::callout_link::identifier)]
- ;
-
- // Conditional Phrase
-
- phrase_symbol_rules.add("?", local.cond_phrase [actions.process]);
-
- local.cond_phrase =
- blank
- >> macro_identifier [member_assign(&quickbook::cond_phrase::macro_id)]
- >> -phrase [member_assign(&quickbook::cond_phrase::content)]
- ;
-
- // URL
-
- phrase_symbol_rules.add("@", local.url [actions.process]);
-
- local.url
- = (*(qi::char_ - (']' | qi::space))) [member_assign(&quickbook::link::destination)]
- [member_assign(&quickbook::link::type, "url")]
- >> ( &qi::lit(']')
- | (hard_space >> phrase) [member_assign(&quickbook::link::content)]
- )
- ;
-
- // Link
-
- phrase_keyword_rules.add
- ("link", local.link(formatted_type("link")) [actions.process])
- ("funcref", local.link(formatted_type("funcref")) [actions.process])
- ("classref", local.link(formatted_type("classref")) [actions.process])
- ("memberref", local.link(formatted_type("memberref")) [actions.process])
- ("enumref", local.link(formatted_type("enumref")) [actions.process])
- ("macroref", local.link(formatted_type("macroref")) [actions.process])
- ("headerref", local.link(formatted_type("headerref")) [actions.process])
- ("conceptref", local.link(formatted_type("conceptref")) [actions.process])
- ("globalref", local.link(formatted_type("globalref")) [actions.process])
- ;
-
- local.link =
- qi::attr(qi::_r1) [member_assign(&quickbook::link::type)]
- >> space
- >> (*(qi::char_ - (']' | qi::space))) [member_assign(&quickbook::link::destination)]
- >> ( &qi::lit(']')
- | (hard_space >> phrase) [member_assign(&quickbook::link::content)]
- )
- ;
-
- // Anchor
-
- phrase_symbol_rules.add("#", local.anchor [actions.process]);
-
- local.anchor =
- blank
- >> (*(qi::char_ - phrase_end)) [member_assign(&quickbook::anchor::id)]
- ;
-
- // Source Mode
-
- phrase_keyword_rules.add
- ("c++", qi::attr(quickbook::source_mode("c++")) [actions.process])
- ("python", qi::attr(quickbook::source_mode("python")) [actions.process])
- ("teletype", qi::attr(quickbook::source_mode("teletype")) [actions.process])
- ;
-
- // Formatted
-
- phrase_symbol_rules.add
- ("*", local.formatted(formatted_type("bold")) [actions.process])
- ("'", local.formatted(formatted_type("italic")) [actions.process])
- ("_", local.formatted(formatted_type("underline")) [actions.process])
- ("^", local.formatted(formatted_type("teletype")) [actions.process])
- ("-", local.formatted(formatted_type("strikethrough")) [actions.process])
- ("\"", local.formatted(formatted_type("quote")) [actions.process])
- ("~", local.formatted(formatted_type("replaceable")) [actions.process])
- ;
-
- phrase_keyword_rules.add
- ("footnote", local.formatted(formatted_type("footnote")) [actions.process])
- ;
-
- local.formatted =
- qi::attr(qi::_r1) [member_assign(&quickbook::formatted::type)]
- >> blank
- >> phrase [member_assign(&quickbook::formatted::content)]
- ;
- }
-}
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/post_process.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/post_process.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,491 +0,0 @@
-/*=============================================================================
- Copyright (c) 2005 2006 Joel de Guzman
- 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 "post_process.hpp"
-#include "utils.hpp"
-#include <boost/spirit/include/qi_core.hpp>
-#include <boost/spirit/include/qi_lexeme.hpp>
-#include <boost/spirit/include/qi_char_.hpp>
-#include <boost/spirit/include/phoenix_core.hpp>
-#include <boost/spirit/include/phoenix_bind.hpp>
-#include <boost/spirit/include/phoenix_operator.hpp>
-#include <set>
-#include <stack>
-#include <cctype>
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
- namespace ph = boost::phoenix;
- typedef std::string::const_iterator iter_type;
-
- struct printer
- {
- printer(std::string& out, int& current_indent, int linewidth)
- : prev(0), out(out), current_indent(current_indent) , column(0)
- , in_string(false), linewidth(linewidth) {}
-
- void indent()
- {
- BOOST_ASSERT(current_indent >= 0); // this should not happen!
- for (int i = 0; i < current_indent; ++i)
- out += ' ';
- column = current_indent;
- }
-
- void break_line()
- {
- out.erase(out.find_last_not_of(' ')+1); // trim trailing spaces
- out += '\n';
- indent();
- }
-
- bool line_is_empty() const
- {
- for (iter_type i = out.end()-(column-current_indent); i != out.end(); ++i)
- {
- if (*i != ' ')
- return false;
- }
- return true;
- }
-
- void align_indent()
- {
- // make sure we are at the proper indent position
- if (column != current_indent)
- {
- if (column > current_indent)
- {
- if (line_is_empty())
- {
- // trim just enough trailing spaces down to current_indent position
- out.erase(out.end()-(column-current_indent), out.end());
- column = current_indent;
- }
- else
- {
- // nope, line is not empty. do a hard CR
- break_line();
- }
- }
- else
- {
- // will this happen? (i.e. column <= current_indent)
- while (column != current_indent)
- {
- out += ' ';
- ++column;
- }
- }
- }
- }
-
- void print(char ch)
- {
- // Print a char. Attempt to break the line if we are exceeding
- // the target linewidth. The linewidth is not an absolute limit.
- // There are many cases where a line will exceed the linewidth
- // and there is no way to properly break the line. Preformatted
- // code that exceeds the linewidth are examples. We cannot break
- // preformatted code. We shall not attempt to be very strict with
- // line breaking. What's more important is to have a reproducable
- // output (i.e. processing two logically equivalent xml files
- // results in two lexically equivalent xml files). *** pretty
- // formatting is a secondary goal ***
-
- // Strings will occur only in tag attributes. Normal content
- // will have &quot; instead. We shall deal only with tag
- // attributes here.
- if (ch == '"')
- in_string = !in_string; // don't break strings!
-
- if (!in_string && std::isspace(static_cast<unsigned char>(ch)))
- {
- // we can break spaces if they are not inside strings
- if (!std::isspace(static_cast<unsigned char>(prev)))
- {
- if (column >= linewidth)
- {
- break_line();
- if (column == 0 && ch == ' ')
- {
- ++column;
- out += ' ';
- }
- }
- else
- {
- ++column;
- out += ' ';
- }
- }
- }
- else
- {
- // we can break tag boundaries and stuff after
- // delimiters if they are not inside strings
- // and *only-if* the preceding char is a space
- if (!in_string
- && column >= linewidth
- && (ch == '<' && std::isspace(static_cast<unsigned char>(prev))))
- break_line();
- out += ch;
- ++column;
- }
-
- prev = ch;
- }
-
- void
- print(iter_type f, iter_type l)
- {
- for (iter_type i = f; i != l; ++i)
- print(*i);
- }
-
- void
- print(std::string const& x)
- {
- print(x.begin(), x.end());
- }
-
- void
- print_tag(std::string const& str, bool is_flow_tag)
- {
- if (is_flow_tag)
- {
- print(str);
- }
- else
- {
- // This is not a flow tag, so, we're going to do a
- // carriage return anyway. Let us remove extra right
- // spaces.
- BOOST_ASSERT(!str.empty()); // this should not happen
- iter_type i = str.end();
- while (i != str.begin() && std::isspace(static_cast<unsigned char>(*(i-1))))
- --i;
- print(str.begin(), i);
- }
- }
-
- char prev;
- std::string& out;
- int& current_indent;
- int column;
- bool in_string;
- int linewidth;
- };
-
- char const* block_tags_[] =
- {
- "author"
- , "blockquote"
- , "bridgehead"
- , "callout"
- , "calloutlist"
- , "caution"
- , "copyright"
- , "entry"
- , "important"
- , "informaltable"
- , "itemizedlist"
- , "legalnotice"
- , "listitem"
- , "note"
- , "orderedlist"
- , "para"
- , "row"
- , "section"
- , "simpara"
- , "table"
- , "tbody"
- , "textobject"
- , "tgroup"
- , "thead"
- , "tip"
- , "variablelist"
- , "varlistentry"
- , "warning"
- , "xml"
- , "xi:include"
-
- // TODO: Should separate html and boostbook tags.
- , "dd"
- , "dl"
- , "dt"
- , "div"
- , "ol"
- , "p"
- , "pre"
- , "td"
- , "tr"
- , "ul"
- };
-
- char const* doc_types_[] =
- {
- "book"
- , "article"
- , "library"
- , "chapter"
- , "part"
- , "appendix"
- , "preface"
- , "qandadiv"
- , "qandaset"
- , "reference"
- , "set"
- };
-
- struct tidy_compiler
- {
- tidy_compiler(std::string& out, int linewidth)
- : out(out), current_indent(0), printer_(out, current_indent, linewidth)
- {
- static int const n_block_tags = sizeof(block_tags_)/sizeof(char const*);
- for (int i = 0; i != n_block_tags; ++i)
- {
- block_tags.insert(block_tags_[i]);
- }
-
- static int const n_doc_types = sizeof(doc_types_)/sizeof(char const*);
- for (int i = 0; i != n_doc_types; ++i)
- {
- block_tags.insert(doc_types_[i]);
- block_tags.insert(doc_types_[i] + std::string("info"));
- block_tags.insert(doc_types_[i] + std::string("purpose"));
- }
- }
-
- bool is_flow_tag(std::string const& tag)
- {
- return block_tags.find(tag) == block_tags.end();
- }
-
- std::set<std::string> block_tags;
- std::stack<std::string> tags;
- std::string& out;
- int current_indent;
- printer printer_;
- std::string current_tag;
- };
-
- template <typename Iterator>
- struct tidy_grammar : qi::grammar<Iterator>
- {
- typedef boost::iterator_range<Iterator> iterator_range;
-
- tidy_grammar(tidy_compiler& state, int indent)
- : tidy_grammar::base_type(tidy)
- , state(state), indent(indent)
- {
- tag =
- qi::lexeme[qi::raw[
- +(qi::alpha | qi::char_("_:"))
- ]]
- [ph::bind(&tidy_grammar::do_tag, this, qi::_1)];
-
- code_tags.add
- ("<programlisting>", "</programlisting>")
- ("<pre>", "</pre>")
- ;
-
- code %= qi::raw[
- code_tags [qi::_a = qi::_1]
- >> *(qi::char_ - qi::lit(qi::_a))
- >> qi::lit(qi::_a)
- ];
-
- // What's the business of lexeme_d['>' >> *space]; ?
- // It is there to preserve the space after the tag that is
- // otherwise consumed by the space skipper.
-
- escape =
- ( "<!--quickbook-escape-prefix-->"
- >> qi::raw[*(qi::char_ - "<!--quickbook-escape-postfix-->")]
- >> qi::lexeme[
- "<!--quickbook-escape-postfix-->"
- >> qi::raw[*qi::space]
- ]
- ) [ph::bind(&tidy_grammar::do_escape, this, qi::_1, qi::_2)]
- ;
-
- start_tag = qi::raw['<' >> tag >> *(qi::char_ - '>') >> qi::lexeme['>' >> *qi::space]];
- start_end_tag = qi::raw[
- '<' >> tag >> *(qi::char_ - ("/>" | qi::lit('>'))) >> qi::lexeme["/>" >> *qi::space]
- | "<?" >> tag >> *(qi::char_ - '?') >> qi::lexeme["?>" >> *qi::space]
- | "<!--" >> *(qi::char_ - "-->") >> qi::lexeme["-->" >> *qi::space]
- | "<!" >> tag >> *(qi::char_ - '>') >> qi::lexeme['>' >> *qi::space]
- ];
- content = qi::lexeme[ +(qi::char_ - '<') ];
- end_tag = qi::raw["</" >> +(qi::char_ - '>') >> qi::lexeme['>' >> *qi::space]];
-
- markup =
- escape
- | code [ph::bind(&tidy_grammar::do_code, this, qi::_1)]
- | start_end_tag [ph::bind(&tidy_grammar::do_start_end_tag, this, qi::_1)]
- | start_tag [ph::bind(&tidy_grammar::do_start_tag, this, qi::_1)]
- | end_tag [ph::bind(&tidy_grammar::do_end_tag, this, qi::_1)]
- | content [ph::bind(&tidy_grammar::do_content, this, qi::_1)]
- ;
-
- tidy = +markup;
- }
-
- void do_escape(iterator_range x, iterator_range post) const
- {
- // Trim spaces from contents and append
- Iterator f = x.begin(), l = x.end();
- while (f != l && std::isspace(*f))
- ++f;
- while (f != l && std::isspace(*(l - 1)))
- --l;
- state.out.append(f, l);
-
- // Append spaces trailing the closing tag.
- state.out.append(post.begin(), post.end());
- }
-
- void do_code(std::string const& x) const
- {
- state.out += '\n';
- // print the string taking care of line
- // ending CR/LF platform issues
- for (iter_type i = x.begin(), l = x.end(); i != l; ++i)
- {
- if (*i == '\n')
- {
- state.out += '\n';
- ++i;
- if (i != l && *i != '\r')
- state.out += *i;
- }
- else if (*i == '\r')
- {
- state.out += '\n';
- ++i;
- if (i != l && *i != '\n')
- state.out += *i;
- }
- else
- {
- state.out += *i;
- }
- }
- state.out += '\n';
- state.printer_.indent();
- }
-
- void do_tag(iterator_range x) const
- {
- state.current_tag = std::string(x.begin(), x.end());
- }
-
- void do_start_end_tag(std::string const& x) const
- {
- bool is_flow_tag = state.is_flow_tag(state.current_tag);
- if (!is_flow_tag)
- state.printer_.align_indent();
- state.printer_.print_tag(x, is_flow_tag);
- if (!is_flow_tag)
- state.printer_.break_line();
- }
-
- void do_start_tag(std::string const& x) const
- {
- state.tags.push(state.current_tag);
- bool is_flow_tag = state.is_flow_tag(state.current_tag);
- if (!is_flow_tag)
- state.printer_.align_indent();
- state.printer_.print_tag(x, is_flow_tag);
- if (!is_flow_tag)
- {
- state.current_indent += indent;
- state.printer_.break_line();
- }
- }
-
- void do_content(std::string const& x) const
- {
- state.printer_.print(x);
- }
-
- void do_end_tag(std::string const& x) const
- {
- bool is_flow_tag = state.is_flow_tag(state.tags.top());
- if (!is_flow_tag)
- {
- state.current_indent -= indent;
- state.printer_.align_indent();
- }
- state.printer_.print_tag(x, is_flow_tag);
- if (!is_flow_tag)
- state.printer_.break_line();
- state.tags.pop();
- }
-
- tidy_compiler& state;
- int indent;
-
- qi::rule<Iterator> tidy, tag,
- markup, escape;
- qi::rule<Iterator, std::string()>
- start_tag, start_end_tag,
- content, end_tag;
- qi::rule<Iterator, qi::locals<std::string>, std::string()> code;
- qi::symbols<char, std::string> code_tags;
- };
-
- int post_process(
- std::string const& in
- , std::ostream& out
- , int indent
- , int linewidth)
- {
- if (indent == -1)
- indent = 2; // set default to 2
- if (linewidth == -1)
- linewidth = 80; // set default to 80
-
- try
- {
- std::string tidy;
- tidy_compiler state(tidy, linewidth);
- tidy_grammar<iter_type> g(state, indent);
- iter_type first = in.begin(), last = in.end();
- bool r = parse(first, last, g, qi::space);
- if (r && first == last)
- {
- out << tidy;
- return 0;
- }
- else
- {
- // fallback!
- ::quickbook::detail::outerr("")
- << "Warning: Post Processing Failed."
- << std::endl;
- out << in;
- return 1;
- }
- }
-
- catch(...)
- {
- // fallback!
- ::quickbook::detail::outerr("")
- << "Post Processing Failed."
- << std::endl;
- out << in;
- return 1;
- }
- }
-}
-

Deleted: branches/quickbook-1.5-spirit2/post_process.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/post_process.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,25 +0,0 @@
-/*=============================================================================
- Copyright (c) 2005 2006 Joel de Guzman
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_POST_PROCESS_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_POST_PROCESS_HPP
-
-#include <iostream>
-#include <string>
-
-namespace quickbook
-{
- int post_process(
- std::string const& in
- , std::ostream& out
- , int indent
- , int linewidth);
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_POST_PROCESS_HPP
-

Deleted: branches/quickbook-1.5-spirit2/process.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/process.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,73 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2010 Daniel James
- 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 "fwd.hpp"
-#include "phrase_actions.hpp"
-#include "block_actions.hpp"
-#include "actions.hpp"
-#include "state.hpp"
-#include "parse_types.hpp"
-#include "code.hpp"
-#include "syntax_highlight.hpp"
-#include "template.hpp"
-#include "doc_info_actions.hpp"
-#include "encoder.hpp"
-
-namespace quickbook
-{
- template <typename T>
- void process_action::operator()(T const& x) const
- {
- process(actions.state_, x);
- }
-
- template <typename T>
- void process(quickbook::state& state, T const& x)
- {
- state.encode(x);
- }
-
- template void process_action::operator()<std::string>(std::string const&) const;
- template void process_action::operator()<formatted>(formatted const&) const;
- template void process_action::operator()<block_formatted>(block_formatted const&) const;
- template void process_action::operator()<source_mode>(source_mode const&) const;
- template void process_action::operator()<macro>(macro const&) const;
- template void process_action::operator()<call_template>(call_template const&) const;
- template void process_action::operator()<anchor>(anchor const&) const;
- template void process_action::operator()<link>(link const&) const;
- template void process_action::operator()<simple_markup>(simple_markup const&) const;
- template void process_action::operator()<cond_phrase>(cond_phrase const&) const;
- template void process_action::operator()<break_>(break_ const&) const;
- 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;
- template void process_action::operator()<heading>(heading const&) const;
- template void process_action::operator()<def_macro>(def_macro const&) const;
- template void process_action::operator()<variablelist>(variablelist const&) const;
- template void process_action::operator()<table>(table const&) const;
- template void process_action::operator()<xinclude>(xinclude const&) const;
- template void process_action::operator()<import>(import const&) const;
- template void process_action::operator()<include>(include const&) const;
- template void process_action::operator()<code>(code const&) const;
- template void process_action::operator()<define_template>(define_template const&) const;
- template void process_action::operator()<code_token>(code_token const&) const;
- template void process_action::operator()<char>(char const&) const;
- template void process_action::operator()<unicode_char>(unicode_char const&) const;
- template void process_action::operator()<version>(version const&) const;
- template void process_action::operator()<doc_info>(doc_info const&) const;
- template void process_action::operator()<doc_info_post>(doc_info_post const&) const;
- template void process_action::operator()<callout_link>(callout_link const&) const;
- template void process_action::operator()<callout_list>(callout_list const&) const;
-}
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/quickbook.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/quickbook.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,346 +0,0 @@
-/*=============================================================================
- 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 <stdexcept>
-#include <fstream>
-#include <iostream>
-#include <vector>
-#include <boost/program_options.hpp>
-#include <boost/filesystem/v3/path.hpp>
-#include <boost/filesystem/v3/operations.hpp>
-#include <boost/ref.hpp>
-#include "fwd.hpp"
-#include "quickbook.hpp"
-#include "state.hpp"
-#include "actions.hpp"
-#include "grammar.hpp"
-#include "post_process.hpp"
-#include "utils.hpp"
-#include "input_path.hpp"
-#include "doc_info.hpp"
-
-#if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310))
-#pragma warning(disable:4355)
-#endif
-
-#define QUICKBOOK_VERSION "Quickbook Spirit 2 port"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
- namespace fs = boost::filesystem;
- tm* current_time; // the current time
- tm* current_gm_time; // the current UTC time
- bool debug_mode; // for quickbook developers only
- bool ms_errors = false; // output errors/warnings as if for VS
- std::vector<std::string> include_path;
- std::vector<std::string> preset_defines;
-
- ///////////////////////////////////////////////////////////////////////////
- //
- // Parse the macros passed as command line parameters
- //
- ///////////////////////////////////////////////////////////////////////////
-
- static void set_macros(quickbook_grammar& g)
- {
- for(std::vector<std::string>::const_iterator
- it = preset_defines.begin(),
- end = preset_defines.end();
- it != end; ++it)
- {
- iterator first(it->begin(), it->end(), "command line parameter");
- iterator last(it->end(), it->end());
-
- parse(first, last, g.command_line_macro);
- }
- }
-
- ///////////////////////////////////////////////////////////////////////////
- //
- // Parse a file
- //
- ///////////////////////////////////////////////////////////////////////////
- int
- parse_file(char const* filein_, state& state_, bool ignore_docinfo)
- {
- using std::cerr;
- using std::vector;
- using std::string;
-
- std::string storage;
- int err = detail::load(filein_, storage);
- if (err != 0) {
- ++state_.error_count;
- return err;
- }
-
- iterator first(storage.begin(), storage.end(), filein_);
- iterator last(storage.end(), storage.end());
- iterator start = first;
-
- doc_info info;
- actions actor(state_);
- quickbook_grammar g(actor);
- set_macros(g);
- bool success = parse(first, last, g.doc_info, info);
-
- if (success || ignore_docinfo)
- {
- if(!success) first = start;
-
- info.ignore = ignore_docinfo;
-
- actor.process(info);
-
- success = parse(first, last, g.block);
- if (success && first == last)
- {
- actor.process(doc_info_post(info));
- }
- }
- else {
- file_position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
- << "Doc Info error near column " << pos.column << ".\n";
- }
-
- if (!success || first != last)
- {
- file_position const pos = first.get_position();
- detail::outerr(pos.file,pos.line)
- << "Syntax Error near column " << pos.column << ".\n";
- ++state_.error_count;
- }
-
- return state_.error_count ? 1 : 0;
- }
-
- static int
- parse_document(char const* filein_, fs::path const& outdir, string_stream& out, std::string const& encoder)
- {
- quickbook::state state(filein_, outdir, out, create_encoder(encoder));
- bool r = parse_file(filein_, state);
- if (state.section_level != 0)
- detail::outwarn(filein_)
- << "Warning missing [endsect] detected at end of file."
- << std::endl;
-
- if(state.error_count)
- {
- detail::outerr(filein_)
- << "Error count: " << state.error_count << ".\n";
- }
-
- return r;
- }
-
- static int
- parse_document(
- char const* filein_
- , char const* fileout_
- , int indent
- , int linewidth
- , bool pretty_print
- , std::string const& encoder)
- {
- int result = 0;
- std::ofstream fileout(fileout_);
- fs::path outdir = fs::path(fileout_).parent_path();
- if (outdir.empty())
- outdir = ".";
- if (pretty_print)
- {
- string_stream buffer;
- result = parse_document(filein_, outdir, buffer, encoder);
- if (result == 0)
- {
- result = post_process(buffer.str(), fileout, indent, linewidth);
- }
- }
- else
- {
- string_stream buffer;
- result = parse_document(filein_, outdir, buffer, encoder);
- fileout << buffer.str();
- }
- return result;
- }
-}
-
-///////////////////////////////////////////////////////////////////////////
-//
-// Main program
-//
-///////////////////////////////////////////////////////////////////////////
-
-namespace quickbook
-{
- void init_misc_rules();
-}
-
-int
-main(int argc, char* argv[])
-{
- quickbook::init_misc_rules();
-
- try
- {
- using boost::program_options::options_description;
- using boost::program_options::variables_map;
- using boost::program_options::store;
- using boost::program_options::parse_command_line;
- using boost::program_options::command_line_parser;
- using boost::program_options::notify;
- using boost::program_options::value;
- using boost::program_options::positional_options_description;
-
- // First thing, the filesystem should record the current working directory.
- boost::filesystem::initial_path<boost::filesystem::path>();
-
- options_description desc("Allowed options");
- desc.add_options()
- ("help", "produce help message")
- ("version", "print version string")
- ("no-pretty-print", "disable XML pretty printing")
- ("indent", value<int>(), "indent spaces")
- ("linewidth", value<int>(), "line width")
- ("input-file", value<quickbook::detail::input_path>(), "input file")
- ("output-file", value<quickbook::detail::input_path>(), "output file")
- ("debug", "debug mode (for developers)")
- ("ms-errors", "use Microsoft Visual Studio style error & warn message format")
- ("include-path,I", value< std::vector<quickbook::detail::input_path> >(), "include path")
- ("define,D", value< std::vector<std::string> >(), "define macro")
- ("boostbook", "generate boostbook (default)")
- ("html", "generate html")
- ;
-
- positional_options_description p;
- p.add("input-file", -1);
-
- variables_map vm;
- int indent = -1;
- int linewidth = -1;
- bool pretty_print = true;
- store(command_line_parser(argc, argv).options(desc).positional(p).run(), vm);
- notify(vm);
-
- // TODO: Allow overwritten options.
- std::string encoder = vm.count("html") ? "html" : "boostbook";
-
- if (vm.count("help"))
- {
- std::cout << desc << "\n";
- return 0;
- }
-
- if (vm.count("version"))
- {
- std::cout << QUICKBOOK_VERSION << std::endl;
- return 0;
- }
-
- if (vm.count("ms-errors"))
- quickbook::ms_errors = true;
-
- if (vm.count("no-pretty-print"))
- pretty_print = false;
-
- if (vm.count("indent"))
- indent = vm["indent"].as<int>();
-
- if (vm.count("linewidth"))
- linewidth = vm["linewidth"].as<int>();
-
- if (vm.count("debug"))
- {
- static tm timeinfo;
- timeinfo.tm_year = 2000 - 1900;
- timeinfo.tm_mon = 12 - 1;
- timeinfo.tm_mday = 20;
- timeinfo.tm_hour = 12;
- timeinfo.tm_min = 0;
- timeinfo.tm_sec = 0;
- timeinfo.tm_isdst = -1;
- mktime(&timeinfo);
- quickbook::current_time = &timeinfo;
- quickbook::current_gm_time = &timeinfo;
- quickbook::debug_mode = true;
- }
- else
- {
- time_t t = std::time(0);
- static tm lt = *localtime(&t);
- static tm gmt = *gmtime(&t);
- quickbook::current_time = &lt;
- quickbook::current_gm_time = &gmt;
- quickbook::debug_mode = false;
- }
-
- if (vm.count("include-path"))
- {
- std::vector<quickbook::detail::input_path> paths
- = vm["include-path"].as<
- std::vector<quickbook::detail::input_path> >();
- quickbook::include_path
- = std::vector<std::string>(paths.begin(), paths.end());
- }
-
- if (vm.count("define"))
- {
- quickbook::preset_defines
- = vm["define"].as<std::vector<std::string> >();
- }
-
- if (vm.count("input-file"))
- {
- std::string filein
- = vm["input-file"].as<quickbook::detail::input_path>();
- std::string fileout;
-
- if (vm.count("output-file"))
- {
- fileout = vm["output-file"].as<quickbook::detail::input_path>();
- }
- else
- {
- fileout = quickbook::detail::remove_extension(filein.c_str());
- // TODO: More generic here:
- fileout += encoder == "html" ? ".html" : ".xml";
- }
-
- std::cout << "Generating Output File: "
- << fileout
- << std::endl;
-
- return quickbook::parse_document(filein.c_str(), fileout.c_str(), indent, linewidth, pretty_print, encoder);
- }
- else
- {
- quickbook::detail::outerr("") << "Error: No filename given\n\n"
- << desc << std::endl;
- return 1;
- }
- }
-
- catch(std::exception& e)
- {
- quickbook::detail::outerr("") << "Error: " << e.what() << "\n";
- return 1;
- }
-
- catch(...)
- {
- quickbook::detail::outerr("") << "Error: Exception of unknown type caught\n";
- return 1;
- }
-
- return 0;
-}

Deleted: branches/quickbook-1.5-spirit2/quickbook.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/quickbook.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,32 +0,0 @@
-/*=============================================================================
- Copyright (c) 2009 Daniel James
- 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)
-=============================================================================*/
-
-#if !defined(BOOST_SPIRIT_QUICKBOOK_QUICKBOOK_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_QUICKBOOK_HPP
-
-#include <time.h>
-#include <string>
-#include <vector>
-#include "fwd.hpp"
-
-namespace quickbook
-{
- extern tm* current_time; // the current time
- extern tm* current_gm_time; // the current UTC time
- extern bool debug_mode;
- extern std::vector<std::string> include_path;
- extern std::vector<std::string> preset_defines;
-
- // forward declarations
- int parse_file(char const* filein_, state&, bool ignore_docinfo = false);
-}
-
-#endif

Deleted: branches/quickbook-1.5-spirit2/rule_store.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/rule_store.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,83 +0,0 @@
-/*=============================================================================
- Copyright (c) 2010 Daniel James
-
- 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)
-=============================================================================*/
-
-// This header defines a class which can will manage quickbook rules for a
-// grammar class so that it doesn't have to declare every rule it'll use.
-//
-// TODO: Noncopyable, but some sort of reference counting scheme would work.
-
-#if !defined(BOOST_SPIRIT_QUICKBOOK_RULE_STORE_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_RULE_STORE_HPP
-
-#include <deque>
-#include <boost/assert.hpp>
-#include <utility>
-
-namespace quickbook
-{
- namespace detail
- {
- template <typename T>
- void delete_impl(void* ptr) {
- delete static_cast<T*>(ptr);
- }
-
- struct scoped_void
- {
- void* ptr_;
- void (*del_)(void*);
-
- scoped_void() : ptr_(0), del_(0) {}
- scoped_void(scoped_void const& src) : ptr_(0), del_(0) {
- BOOST_ASSERT(!src.ptr_);
- }
- ~scoped_void() {
- if(ptr_) del_(ptr_);
- }
-
- void store(void* ptr, void (*del)(void* x)) {
- ptr = ptr_;
- del = del_;
- }
- private:
- scoped_void& operator=(scoped_void const&);
- };
- }
-
- struct rule_store
- {
- struct instantiate
- {
- rule_store& s;
- instantiate(rule_store& s) : s(s) {}
-
- template <typename T>
- operator T&() {
- std::auto_ptr<T> obj(new T());
- T& ref = *obj;
- s.store_.push_back(detail::scoped_void());
- s.store_.back().store(obj.release(), &detail::delete_impl<T>);
- return ref;
- }
- };
-
- rule_store() {}
-
- instantiate create() {
- instantiate i(*this);
- return i;
- }
-
- std::deque<detail::scoped_void> store_;
- private:
- rule_store& operator=(rule_store const&);
- rule_store(rule_store const&);
- };
-}
-
-#endif

Copied: branches/quickbook-1.5-spirit2/src/Jamfile.v2 (from r65159, /branches/quickbook-1.5-spirit2/Jamfile.v2)
==============================================================================
--- /branches/quickbook-1.5-spirit2/Jamfile.v2 (original)
+++ branches/quickbook-1.5-spirit2/src/Jamfile.v2 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
@@ -69,23 +69,3 @@
       <toolset>msvc:<define>_CRT_SECURE_NO_DEPRECATE
       <toolset>msvc:<define>_SCL_SECURE_NO_DEPRECATE
     ;
-
-install dist-bin
- :
- quickbook
- :
- <install-type>EXE
- <location>../../dist/bin
- :
- release
- ;
-
-install dist-lib
- :
- quickbook
- :
- <install-type>LIB
- <location>../../dist/lib
- :
- release
- ;

Deleted: branches/quickbook-1.5-spirit2/state.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/state.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,126 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2005 Thomas Guest
- 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/filesystem/v3/operations.hpp>
-#include "actions.hpp"
-#include "state.hpp"
-#include "quickbook.hpp"
-#include "block.hpp"
-
-#if (defined(BOOST_MSVC) && (BOOST_MSVC <= 1310))
-#pragma warning(disable:4355)
-#endif
-
-namespace quickbook
-{
- namespace fs = boost::filesystem;
-
- state::state(char const* filein_, fs::path const& outdir_, string_stream& out_,
- encoder_ptr const& encoder)
- // header info
- : doc_id()
- , doc_title()
-
- // main output stream
- , block(out_)
- , phrase()
- , encoder(encoder)
-
- // state
- , filename(fs::absolute(fs::path(filein_)))
- , outdir(outdir_)
- , macro()
- , section_level(0)
- , min_section_level(0)
- , section_id()
- , qualified_section_id()
- , source_mode("c++")
-
- // temporary or global state
- , template_depth(0)
- , templates()
- , error_count(0)
- {
- // turn off __FILENAME__ macro on debug mode = true
- std::string filename_str = debug_mode ?
- std::string("NO_FILENAME_MACRO_GENERATED_IN_DEBUG_MODE") :
- filename.native();
-
- // add the predefined macros
- macro.add
- ("__DATE__", quickbook::macro(quickbook_get_date))
- ("__TIME__", quickbook::macro(quickbook_get_time))
- ("__FILENAME__", quickbook::macro(filename_str))
- ;
- }
-
- void state::push()
- {
- state_stack.push(
- boost::make_tuple(
- macro
- , section_level
- , min_section_level
- , section_id
- , qualified_section_id
- , source_mode
- )
- );
-
- phrase.push();
- block.push();
- templates.push();
- }
-
- void state::pop()
- {
- boost::tie(
- macro
- , section_level
- , min_section_level
- , section_id
- , qualified_section_id
- , source_mode
- ) = state_stack.top();
- state_stack.pop();
-
- phrase.pop();
- block.pop();
- templates.pop();
- }
-
- void state::paragraph_output()
- {
- std::string paragraph;
- phrase.swap(paragraph);
-
- // TODO: Use spirit to do this?
-
- std::string::const_iterator
- pos = paragraph.begin(),
- end = paragraph.end();
-
- while(pos != paragraph.end() && (
- *pos == ' ' || *pos == '\t' || *pos == '\n' || *pos == '\r'))
- {
- ++pos;
- }
-
- if(pos != end) {
- actions a(*this);
-
- quickbook::paragraph p;
- p.content = paragraph;
-
- a.process(p);
- }
- }
-}

Deleted: branches/quickbook-1.5-spirit2/state.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/state.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,92 +0,0 @@
-/*=============================================================================
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_ACTIONS_CLASS_HPP)
-#define BOOST_SPIRIT_ACTIONS_CLASS_HPP
-
-#include <stack>
-#include <boost/tuple/tuple.hpp>
-#include <boost/filesystem/v3/path.hpp>
-#include "fwd.hpp"
-#include "collector.hpp"
-#include "template.hpp"
-#include "actions.hpp"
-#include "strings.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
- namespace fs = boost::filesystem;
-
- struct state
- {
- state(char const* filein_, fs::path const& outdir, string_stream& out_,
- encoder_ptr const&);
-
- ///////////////////////////////////////////////////////////////////////////
- // State
- ///////////////////////////////////////////////////////////////////////////
-
- static int const max_template_depth = 100;
-
- std::string doc_id;
- std::string doc_title;
- std::string doc_title_raw;
-
- // main output stream
- collector phrase;
- collector block;
- encoder_ptr encoder;
-
- fs::path outdir;
-
- // file state
- fs::path filename;
-
- // scope state
- macro_symbols macro;
- int section_level;
- int min_section_level;
- raw_string section_id;
- raw_string qualified_section_id;
- std::string source_mode;
-
- typedef boost::tuple<
- macro_symbols
- , int
- , int
- , raw_string
- , raw_string
- , std::string>
- state_tuple;
-
- std::stack<state_tuple> state_stack;
-
- // temporary or global state
- int template_depth;
- template_stack templates;
- int error_count;
-
- // push/pop the states and the streams
- void push();
- void pop();
-
- //
- void paragraph_output();
-
- template <typename T>
- void encode(T const& x) {
- const std::type_info &info = typeid(x);
- (*encoder)(*this, x);
- }
- };
-}
-
-#endif // BOOST_SPIRIT_ACTIONS_CLASS_HPP
-

Deleted: branches/quickbook-1.5-spirit2/strings.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/strings.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,40 +0,0 @@
-/*=============================================================================
- Copyright (c) 2010 Daniel James
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_STRINGS_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_STRINGS_HPP
-
-#include "fwd.hpp"
-
-namespace quickbook
-{
- struct raw_string {
- raw_string() {}
- raw_string(raw_source const& x) : value(x.begin(), x.end()) {}
- raw_string& operator=(raw_source const& x) {
- value.assign(x.begin(), x.end());
- return *this;
- }
- raw_string& operator=(std::string const& x) {
- value = x;
- return *this;
- }
- raw_string& operator=(char const* x) {
- value = x;
- return *this;
- }
- std::string::const_iterator begin() const { return value.begin(); }
- std::string::const_iterator end() const { return value.end(); }
- bool empty() const { return value.empty(); }
- void clear() { value.clear(); }
-
- std::string value;
- };
-}
-
-#endif

Deleted: branches/quickbook-1.5-spirit2/syntax_highlight.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/syntax_highlight.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,24 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- Copyright (c) 2004 Eric Niebler
- Copyright (c) 2010 Daniel James
- 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)
-=============================================================================*/
-
-#if !defined(BOOST_SPIRIT_QUICKBOOK_SYNTAX_HIGHLIGHT_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_SYNTAX_HIGHLIGHT_HPP
-
-namespace quickbook
-{
- struct code_token
- {
- std::string text;
- char const* type;
- };
-}
-
-#endif
\ No newline at end of file

Deleted: branches/quickbook-1.5-spirit2/syntax_highlight_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/syntax_highlight_grammar.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,410 +0,0 @@
-/*=============================================================================
- 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_auxiliary.hpp>
-#include <boost/spirit/include/qi_string.hpp>
-#include <boost/spirit/include/qi_directive.hpp>
-#include <boost/spirit/repository/include/qi_confix.hpp>
-#include "grammar.hpp"
-#include "actions.hpp"
-#include "phrase.hpp"
-#include "utils.hpp"
-#include "syntax_highlight.hpp"
-#include "parse_utils.hpp"
-#include "misc_rules.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
- namespace repo = boost::spirit::repository;
-
- using boost::spirit::unused_type;
-
- struct parse_escaped_impl
- {
- parse_escaped_impl(quickbook::actions& actions)
- : actions(actions) {}
-
- void operator()(boost::iterator_range<iterator> escaped, unused_type, unused_type) const {
- quickbook_grammar g(actions);
- iterator first = escaped.begin(), last = escaped.end();
- while(first != last) {
- if(!qi::parse(first, last, g.phrase)) {
- actions.process(*first);
- ++first;
- }
- }
- }
-
- quickbook::actions& actions;
- };
-
- // Grammar for C++ highlighting
- struct cpp_highlight : public qi::grammar<iterator>
- {
- cpp_highlight(quickbook::actions& actions)
- : cpp_highlight::base_type(program), actions(actions)
- , parse_escaped(actions)
- {
- program
- =
- *( space
- | macro
- | escape
- | preprocessor
- | comment
- | keyword
- | identifier
- | special
- | string_
- | char_
- | number
- | unexpected
- ) [actions.process]
- ;
-
- macro =
- ( actions.macro // must not be followed by
- >> !(qi::alpha | '_') // alpha or underscore
- )
- ;
-
- escape =
- "``"
- >> ( (qi::raw[+(qi::char_ - "``")] >> "``")
- [parse_escaped]
- | position [actions.error]
- >> *qi::char_
- )
- ;
-
- space
- = qi::raw[+qi::space]
- [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "space")]
- ;
-
- preprocessor
- = qi::raw[
- '#' >> *qi::space
- >> ((qi::alpha | '_') >> *(qi::alnum | '_'))
- ] [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "preprocessor")]
- ;
-
- comment
- = qi::raw[
- repo::confix("//", -qi::eol) [*(qi::char_ - qi::eol)]
- | repo::confix("/*", -qi::lit("*/")) [*(qi::char_ - "*/")]
- ] [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "comment")]
- ;
-
- keyword
- = qi::raw[keyword_ >> !(qi::alnum | '_')]
- [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "keyword")]
- ;
-
- keyword_
- = "and_eq", "and", "asm", "auto", "bitand", "bitor",
- "bool", "break", "case", "catch", "char", "class",
- "compl", "const_cast", "const", "continue", "default",
- "delete", "do", "double", "dynamic_cast", "else",
- "enum", "explicit", "export", "extern", "false",
- "float", "for", "friend", "goto", "if", "inline",
- "int", "long", "mutable", "namespace", "new", "not_eq",
- "not", "operator", "or_eq", "or", "private",
- "protected", "public", "register", "reinterpret_cast",
- "return", "short", "signed", "sizeof", "static",
- "static_cast", "struct", "switch", "template", "this",
- "throw", "true", "try", "typedef", "typeid",
- "typename", "union", "unsigned", "using", "virtual",
- "void", "volatile", "wchar_t", "while", "xor_eq", "xor"
- ;
-
- special
- = (+qi::char_("~!%^&*()+={[}]:;,<.>?/|\\-"))
- [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "special")]
- ;
-
- string_char = ('\\' >> qi::char_) | (qi::char_ - '\\');
-
- string_
- = qi::raw[
- -qi::no_case['l']
- >> repo::confix('"', -qi::lit('"')) [*(string_char - '"')]
- ] [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "string")]
- ;
-
- char_ =
- qi::raw[
- -qi::no_case['l']
- >> repo::confix('\'', -qi::lit('\'')) [*(string_char - '\'')]
- ] [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "char")]
- ;
-
- number
- = qi::raw
- [
- (
- qi::no_case["0x"] >> qi::hex
- | '0' >> qi::oct
- | qi::long_double
- )
- >> *qi::no_case[qi::char_("ldfu")]
- ] [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "number")]
- ;
-
- identifier
- = qi::raw[(qi::alpha | '_') >> *(qi::alnum | '_')]
- [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "identifier")]
- ;
-
- // TODO: warn user?
- unexpected
- = qi::raw[qi::char_] [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "error")]
- ;
- }
-
- qi::rule<iterator> program, escape, string_char;
- qi::rule<iterator, quickbook::macro()> macro;
- qi::rule<iterator, code_token()>
- space, preprocessor, comment, special, string_,
- char_, number, identifier, keyword, unexpected;
-
- quickbook::actions& actions;
-
- qi::symbols<> keyword_;
- parse_escaped_impl parse_escaped;
- std::string save;
- };
-
- // Grammar for Python highlighting
- // See also: The Python Reference Manual
- // http://docs.python.org/ref/ref.html
- struct python_highlight : public qi::grammar<iterator>
- {
- python_highlight(quickbook::actions& actions)
- : python_highlight::base_type(program), actions(actions)
- , parse_escaped(actions)
- {
- program
- =
- *( space
- | macro
- | escape
- | comment
- | keyword
- | identifier
- | special
- | string_
- | number
- | unexpected
- ) [actions.process]
- ;
-
- macro =
- ( actions.macro // must not be followed by
- >> !(qi::alpha | '_') // alpha or underscore
- )
- ;
-
- escape =
- "``"
- >> ( (qi::raw[+(qi::char_ - "``")] >> "``")
- [parse_escaped]
- | position [actions.error]
- >> *qi::char_
- )
- ;
-
- space
- = qi::raw[+qi::space] [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "space")]
- ;
-
- comment
- = qi::raw[
- '#' >> *(qi::char_ - qi::eol) >> -qi::eol
- ] [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "comment")]
- ;
-
- keyword
- = qi::raw[keyword_ >> !(qi::alnum | '_')]
- [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "keyword")]
- ; // make sure we recognize whole words only
-
- keyword_
- =
- "and", "del", "for", "is", "raise",
- "assert", "elif", "from", "lambda", "return",
- "break", "else", "global", "not", "try",
- "class", "except", "if", "or", "while",
- "continue", "exec", "import", "pass", "yield",
- "def", "finally", "in", "print",
-
- // Technically "as" and "None" are not yet keywords (at Python
- // 2.4). They are destined to become keywords, and we treat them
- // as such for syntax highlighting purposes.
-
- "as", "None"
- ;
-
- special
- = (+qi::char_("~!%^&*()+={[}]:;,<.>/|\\-"))
- [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "special")]
- ;
-
- string_prefix
- = qi::no_case[qi::string("u") >> - qi::string("r")]
- ;
-
- string_
- = qi::raw[
- -string_prefix
- >> (long_string | short_string)
- ] [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "string")]
- ;
-
- string_char = ('\\' >> qi::char_) | (qi::char_ - '\\');
-
- short_string
- = repo::confix('\'', -qi::lit('\'')) [*(string_char - '\'')]
- | repo::confix('"', -qi::lit('"')) [*(string_char - '"')]
- ;
-
- long_string
- = repo::confix("'''", -qi::lit("'''")) [*(string_char - "'''")]
- | repo::confix("\"\"\"", -qi::lit("\"\"\"")) [*(string_char - "\"\"\"")]
- ;
-
- number
- = qi::raw[
- (
- qi::no_case["0x"] >> qi::hex
- | '0' >> qi::oct
- | qi::long_double
- )
- >> *qi::no_case[qi::char_("lj")]
- ] [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "number")]
- ;
-
- identifier
- = qi::raw[(qi::alpha | '_') >> *(qi::alnum | '_')]
- [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "identifier")]
- ;
-
- // TODO: warn user?
- unexpected
- = qi::raw[qi::char_] [member_assign(&code_token::text)]
- [member_assign(&code_token::type, "error")]
- ;
- }
-
- qi::rule<iterator>
- program, string_prefix, short_string, long_string,
- escape, string_char;
- qi::rule<iterator, quickbook::macro()> macro;
- qi::rule<iterator, code_token()>
- space, comment, special, string_,
- number, identifier, keyword, unexpected;
-
- quickbook::actions& actions;
-
- qi::symbols<> keyword_;
- parse_escaped_impl parse_escaped;
- std::string save;
- };
-
- // Grammar for plain text (no actual highlighting)
- struct teletype_highlight : public qi::grammar<iterator>
- {
- teletype_highlight(quickbook::actions& actions)
- : teletype_highlight::base_type(program), actions(actions)
- , parse_escaped(actions)
- {
- program
- =
- *( macro [actions.process]
- | escape
- | qi::char_ [actions.process]
- )
- ;
-
- macro =
- ( actions.macro // must not be followed by
- >> !(qi::alpha | '_') // alpha or underscore
- )
- ;
-
- escape =
- "``"
- >> ( (qi::raw[+(qi::char_ - "``")] >> "``")
- [parse_escaped]
- | position [actions.error]
- >> *qi::char_
- )
- ;
- }
-
- qi::rule<iterator> program, escape;
- qi::rule<iterator, quickbook::macro()> macro;
-
- quickbook::actions& actions;
-
- parse_escaped_impl parse_escaped;
- std::string save;
- };
-
- std::string syntax_highlight(
- iterator first, iterator last,
- actions& escape_actions,
- std::string& source_mode)
- {
- escape_actions.phrase_push();
-
- // print the code with syntax coloring
- if (source_mode == "c++")
- {
- cpp_highlight cpp_p(escape_actions);
- parse(first, last, cpp_p);
- }
- else if (source_mode == "python")
- {
- python_highlight python_p(escape_actions);
- parse(first, last, python_p);
- }
- else if (source_mode == "teletype")
- {
- teletype_highlight teletype_p(escape_actions);
- parse(first, last, teletype_p);
- }
- else
- {
- BOOST_ASSERT(0);
- }
-
- return escape_actions.phrase_pop();
- }
-}

Deleted: branches/quickbook-1.5-spirit2/template.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/template.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,529 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- 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_symbols.hpp>
-#include <boost/lexical_cast.hpp>
-#include "template.hpp"
-#include "phrase_actions.hpp"
-#include "grammar.hpp"
-#include "state.hpp"
-#include "utils.hpp"
-
-#ifdef BOOST_MSVC
-#pragma warning(disable : 4355)
-#endif
-
-namespace quickbook
-{
- namespace detail
- {
- int callout_id = 0;
- }
-
- struct template_symbol
- {
- template_symbol(
- std::string const& identifier,
- std::vector<std::string> const& params,
- template_body const& body,
- quickbook::callouts const& callouts,
- template_scope const* parent)
- : identifier(identifier)
- , params(params)
- , body(body)
- , callouts(callouts)
- , parent(parent) {}
-
- std::string identifier;
- std::vector<std::string> params;
- template_body body;
- quickbook::callouts callouts;
- template_scope const* parent;
- };
-
- typedef boost::spirit::qi::symbols<char, template_symbol> template_symbols;
-
- // template scope
- //
- // 1.4-: parent_scope is the previous scope on the stack
- // (the template's dynamic parent).
- // 1.5+: parent_scope is the template's lexical parent.
- //
- // This means that a search along the parent_scope chain will follow the
- // correct lookup chain for that version of quickboook.
- //
- // symbols contains the templates defined in this scope.
-
- struct template_scope
- {
- template_scope() : parent_scope() {}
- template_scope const* parent_scope;
- template_symbols symbols;
- boost::scoped_ptr<template_scope> next;
- };
-
- template_stack::template_stack()
- : scope(template_stack::parser(*this))
- , top_scope(new template_scope())
- {
- }
-
- template_stack::~template_stack() {}
-
- template_symbol const* template_stack::prefix_find(iterator& first, iterator const& last) const
- {
- // search all scopes for the longest matching symbol.
- iterator found = first;
- template_symbol const* result = 0;
- for (template_scope const* i = top_scope.get(); i; i = i->parent_scope)
- {
- iterator iter = first;
- template_symbol const* symbol = i->symbols.prefix_find(iter, last);
- if(symbol && iter.base() > found.base())
- {
- found = iter;
- result = symbol;
- }
- }
- first = found;
- return result;
- }
-
- template_symbol const* template_stack::find(std::string const& symbol) const
- {
- for (template_scope const* i = top_scope.get(); i; i = i->parent_scope)
- {
- if (template_symbol const* ts = i->symbols.find(symbol.c_str()))
- return ts;
- }
- return 0;
- }
-
- template_symbol const* template_stack::find_top_scope(std::string const& symbol) const
- {
- return top_scope->symbols.find(symbol.c_str());
- }
-
- bool template_stack::add(
- define_template const& definition,
- template_scope const* parent)
- {
- BOOST_ASSERT(top_scope);
-
- if (this->find_top_scope(definition.id)) {
- return false;
- }
-
- template_symbol ts(
- definition.id,
- definition.params,
- definition.body,
- definition.callouts,
- parent);
-
- top_scope->symbols.add(ts.identifier.c_str(), ts);
-
- return true;
- }
-
- void template_stack::push()
- {
- boost::scoped_ptr<template_scope> new_scope(
- new template_scope());
- new_scope->parent_scope = top_scope.get();
-
- new_scope->next.swap(top_scope);
- new_scope.swap(top_scope);
- }
-
- void template_stack::pop()
- {
- boost::scoped_ptr<template_scope> popped_scope;
- popped_scope.swap(top_scope);
- popped_scope->next.swap(top_scope);
- }
-
- namespace
- {
- iterator find_bracket_end(iterator begin, iterator const& end)
- {
- unsigned int depth = 1;
-
- while(depth > 0) {
- char const* search_chars = "[]\\";
- begin = std::find_first_of(begin, end, search_chars, search_chars + 3);
- if(begin == end) return begin;
-
- if(*begin == '\\')
- {
- if(++begin == end) return begin;
- ++begin;
- }
- else
- {
- depth += (*begin == '[') ? 1 : -1;
- ++begin;
- }
- }
-
- return begin;
- }
-
- iterator find_first_seperator(iterator const& begin, iterator const& end)
- {
- if(qbk_version_n < 105) {
- char const* whitespace = " \t\r\n";
- return std::find_first_of(begin, end, whitespace, whitespace + 4);
- }
- else {
- iterator pos = begin;
-
- while(true)
- {
- char const* search_chars = " \t\r\n\\[";
- pos = std::find_first_of(pos, end, search_chars, search_chars + 6);
- if(pos == end) return pos;
-
- switch(*pos)
- {
- case '[':
- pos = find_bracket_end(++pos, end);
- break;
- case '\\':
- if(++pos == end) return pos;
- ++pos;
- break;
- default:
- return pos;
- }
- }
- }
- }
-
- bool break_arguments(
- std::vector<template_body>& args
- , std::vector<std::string> const& params
- , boost::spirit::classic::file_position const& pos
- )
- {
- // Quickbook 1.4-: If there aren't enough parameters seperated by
- // '..' then seperate the last parameter using
- // whitespace.
- // Quickbook 1.5+: If '..' isn't used to seperate the parameters
- // then use whitespace to separate them
- // (2 = template name + argument).
-
- if (qbk_version_n < 105 || args.size() == 1)
- {
-
- while (args.size() < params.size())
- {
- // Try to break the last argument at the first space found
- // and push it into the back of args. Do this
- // recursively until we have all the expected number of
- // arguments, or if there are no more spaces left.
-
- template_body& body = args.back();
- iterator begin(body.content.begin(), body.content.end(), body.position.file);
- iterator end(body.content.end(), body.content.end());
-
- iterator l_pos = find_first_seperator(begin, end);
- if (l_pos == end)
- break;
- char const* whitespace = " \t\r\n";
- char const* whitespace_end = whitespace + 4;
- iterator r_pos = l_pos;
- while(r_pos != end && std::find(whitespace, whitespace_end, *r_pos) != whitespace_end) ++r_pos;
- if (r_pos == end)
- break;
- template_body second(std::string(r_pos, end), begin.get_position(), false);
- body.content = std::string(begin, l_pos);
- args.push_back(second);
- }
- }
-
- if (args.size() != params.size())
- {
- detail::outerr(pos.file, pos.line)
- << "Invalid number of arguments passed. Expecting: "
- << params.size()
- << " argument(s), got: "
- << args.size()
- << " argument(s) instead."
- << std::endl;
- return false;
- }
- return true;
- }
-
- std::pair<bool, std::vector<std::string>::const_iterator>
- get_arguments(
- std::vector<template_body>& args
- , std::vector<std::string> const& params
- , template_scope const& scope
- , file_position const& pos
- , quickbook::state& state
- )
- {
- std::vector<template_body>::const_iterator arg = args.begin();
- std::vector<std::string>::const_iterator tpl = params.begin();
- std::vector<std::string> empty_params;
-
-
- // Store each of the argument passed in as local templates:
- while (arg != args.end())
- {
- if (!state.templates.add(
- define_template(*tpl, empty_params, *arg),
- &scope))
- {
- detail::outerr(pos.file,pos.line)
- << "Duplicate Symbol Found" << std::endl;
- ++state.error_count;
- return std::make_pair(false, tpl);
- }
- ++arg; ++tpl;
- }
- return std::make_pair(true, tpl);
- }
-
- bool parse_template(
- template_body const& body
- , bool escape
- , std::string& result
- , quickbook::state& state
- )
- {
- // How do we know if we are to parse the template as a block or
- // a phrase? We apply a simple heuristic: if the body starts with
- // a newline, then we regard it as a block, otherwise, we parse
- // it as a phrase.
- //
- // Note: this is now done in the grammar.
-
- if (escape)
- {
- // escape the body of the template
- // we just copy out the literal body
- result = body.content;
- return true;
- }
- else if (!body.is_block)
- {
- quickbook::actions actions(state);
- quickbook_grammar g(actions);
-
- // do a phrase level parse
- iterator first(body.content.begin(), body.content.end(), body.position);
- iterator last(body.content.end(), body.content.end());
- bool r = boost::spirit::qi::parse(first, last, g.simple_phrase) && first == last;
- // do a phrase level parse
- std::string phrase;
- state.phrase.swap(phrase);
- result = phrase;
- return r;
- }
- else
- {
- quickbook::actions actions(state);
- quickbook_grammar g(actions, true);
-
- // 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.
-
- std::string content = body.content + "\n\n";
- iterator first(content.begin(), content.end(), body.position);
- iterator last(content.end(), content.end());
- bool r = boost::spirit::qi::parse(first, last, g.block) && first == last;
- state.paragraph_output();
- std::string block;
- state.block.swap(block);
- result = block;
- return r;
- }
- }
- }
-
- void process(quickbook::state& state, call_template const& x)
- {
- ++state.template_depth;
- if (state.template_depth > state.max_template_depth)
- {
- detail::outerr(x.position.file, x.position.line)
- << "Infinite loop detected" << std::endl;
- --state.template_depth;
- ++state.error_count;
- return;
- }
-
- // The template arguments should have the scope that the template was
- // called from, not the template's own scope.
- //
- // Note that for quickbook 1.4- this value is just ignored when the
- // arguments are expanded.
- template_scope const& call_scope = *state.templates.top_scope;
-
- std::string result;
- state.push(); // scope the state
- {
- // Store the current section level so that we can ensure that
- // [section] and [endsect] tags in the template are balanced.
- state.min_section_level = state.section_level;
-
- // Quickbook 1.4-: When expanding the tempalte continue to use the
- // current scope (the dynamic scope).
- // Quickbook 1.5+: Use the scope the template was defined in
- // (the static scope).
- if (qbk_version_n >= 105)
- state.templates.top_scope->parent_scope = x.symbol->parent;
-
- std::vector<template_body> args = x.args;
-
- ///////////////////////////////////
- // Initialise the arguments
-
- if (!x.symbol->callouts.size())
- {
- // Break the arguments for a template
-
- if (!break_arguments(args, x.symbol->params, x.position))
- {
- state.pop(); // restore the state
- --state.template_depth;
- ++state.error_count;
- return;
- }
- }
- else
- {
- if (!args.empty())
- {
- detail::outerr(x.position.file, x.position.line)
- << "Arguments for code snippet."
- <<std::endl;
- ++state.error_count;
-
- args.clear();
- }
-
- unsigned int size = x.symbol->params.size();
-
- for(unsigned int i = 0; i < size; ++i)
- {
- std::string callout_id = state.doc_id +
- boost::lexical_cast<std::string>(detail::callout_id + i);
-
- std::string code;
- code += "[[callout]";
- code += x.symbol->callouts[i].role;
- code += " ";
- code += callout_id;
- code += "]";
-
- args.push_back(template_body(code, x.position, false));
- }
- }
-
- ///////////////////////////////////
- // Prepare the arguments as local templates
- bool get_arg_result;
- std::vector<std::string>::const_iterator tpl;
- boost::tie(get_arg_result, tpl) =
- get_arguments(args, x.symbol->params,
- call_scope, x.position, state);
-
- if (!get_arg_result)
- {
- state.pop(); // restore the state
- --state.template_depth;
- return;
- }
-
- ///////////////////////////////////
- // parse the template body:
-
- if (!parse_template(x.symbol->body, x.escape, result, state))
- {
- detail::outerr(x.position.file,x.position.line)
- << "Expanding "
- << (x.symbol->body.is_block ? "block" : "phrase")
- << " template:" << x.symbol->identifier << std::endl
- << std::endl
- << "------------------begin------------------" << std::endl
- << x.symbol->body.content
- << "------------------end--------------------" << std::endl
- << std::endl;
- state.pop(); // restore the state
- --state.template_depth;
- ++state.error_count;
- return;
- }
-
- if (state.section_level != state.min_section_level)
- {
- detail::outerr(x.position.file,x.position.line)
- << "Mismatched sections in template " << x.symbol->identifier << std::endl;
- state.pop(); // restore the actions' states
- --state.template_depth;
- ++state.error_count;
- return;
- }
- }
-
- state.pop(); // restore the state
-
- if(x.symbol->callouts.size()) {
- callout_list list;
- BOOST_FOREACH(callout_source const& c, x.symbol->callouts) {
- std::string callout_id = state.doc_id +
- boost::lexical_cast<std::string>(detail::callout_id++);
-
- std::string callout_value;
- state.push();
- // TODO: adjust the position?
- bool r = parse_template(c.body, false, callout_value, state);
- state.pop();
-
- if(!r)
- {
- detail::outerr(c.body.position.file, c.body.position.line)
- << "Expanding callout."
- << std::endl;
- --state.template_depth;
- ++state.error_count;
- return;
- }
-
- callout_item item;
- item.identifier = callout_id;
- item.content = callout_value;
- list.push_back(item);
- }
-
- state.push();
- {
- quickbook::actions actions(state);
- actions.process(list);
- }
- result += state.block.str();
- state.pop();
- }
-
- --state.template_depth;
-
- if(x.symbol->body.is_block) {
- state.paragraph_output();
- state.block << result;
- }
- else {
- state.phrase << result;
- }
- }
-}

Deleted: branches/quickbook-1.5-spirit2/template.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/template.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,140 +0,0 @@
-/*=============================================================================
- Copyright (c) 2002 2004 2006 Joel de Guzman
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_TEMPLATE_STACK_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_TEMPLATE_STACK_HPP
-
-#include <string>
-#include <vector>
-#include <boost/spirit/include/qi_parse.hpp>
-#include <boost/spirit/home/qi/detail/assign_to.hpp>
-#include <boost/scoped_ptr.hpp>
-#include "fwd.hpp"
-
-namespace quickbook
-{
- namespace qi = boost::spirit::qi;
-
- struct template_scope;
- struct template_symbol;
-
- struct template_body
- {
- template_body() {}
- template_body(
- std::string const& content,
- quickbook::file_position position,
- bool is_block
- )
- :
- content(content),
- position(position),
- is_block(is_block)
- {}
-
- std::string content;
- quickbook::file_position position;
- bool is_block;
- };
-
- struct callout_link {
- std::string role;
- std::string identifier;
- };
-
- struct callout_source {
- std::string role;
- template_body body;
- };
-
- struct callout_item {
- std::string identifier;
- std::string content;
- };
-
- typedef std::vector<callout_source> callouts;
- typedef std::vector<callout_item> callout_list;
-
- struct define_template
- {
- define_template() {}
-
- define_template(
- std::string id,
- std::vector<std::string> params,
- template_body const& body
- )
- :
- id(id), params(params), body(body)
- {}
-
- std::string id;
- std::vector<std::string> params;
- template_body body;
- quickbook::callouts callouts;
- };
-
- struct call_template {
- file_position position;
- bool escape;
- template_symbol const* symbol;
- std::vector<template_body> args;
- };
-
- struct template_stack
- {
- struct parser : boost::spirit::qi::primitive_parser<parser>
- {
- template <typename Ctx, typename Itr>
- struct attribute {
- typedef template_symbol const* type;
- };
-
- parser(template_stack& ts)
- : ts(ts) {}
-
- template <typename Context, typename Skipper, typename Attribute>
- bool parse(iterator& first, iterator const& last
- , Context& context, Skipper const& skipper, Attribute& attr) const
- {
- boost::spirit::qi::skip_over(first, last, skipper);
- template_symbol const* symbol = ts.prefix_find(first, last);
- if(symbol) boost::spirit::traits::assign_to(symbol, attr);
- return symbol;
- }
-
- template_stack& ts;
- };
-
- template_stack();
- ~template_stack();
- template_symbol const* prefix_find(iterator& first, iterator const& last) const;
- template_symbol const* find(std::string const& symbol) const;
- template_symbol const* find_top_scope(std::string const& symbol) const;
- // Add the given template symbol to the current scope.
- // If a parent scope isn't supplied, uses the current scope.
- bool add(define_template const&, template_scope const* parent);
- void push();
- void pop();
-
- // Set the current scope's parent.
- void set_parent_scope(template_scope const&);
-
- parser scope;
- boost::scoped_ptr<template_scope> top_scope;
-
- private:
- friend struct parser;
-
- template_stack(template_stack const&);
- template_stack& operator=(template_stack const&);
- };
-}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_TEMPLATE_STACK_HPP
-

Deleted: branches/quickbook-1.5-spirit2/template_grammar.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/template_grammar.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,124 +0,0 @@
-/*=============================================================================
- 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_eps.hpp>
-#include <boost/spirit/include/qi_eol.hpp>
-#include <boost/spirit/repository/include/qi_confix.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;
- namespace repo = boost::spirit::repository;
-
- struct template_grammar_local
- {
- qi::rule<iterator, quickbook::define_template()> define_template;
- qi::rule<iterator, std::vector<std::string>()> define_template_params;
- qi::rule<iterator, quickbook::template_body()> template_body;
- qi::rule<iterator> template_body_recurse;
- qi::rule<iterator, std::string()> template_id;
- qi::rule<iterator, quickbook::call_template()> call_template;
- qi::rule<iterator, std::vector<quickbook::template_body>()> template_args;
- qi::rule<iterator, quickbook::template_body()> template_arg_1_4;
- qi::rule<iterator> brackets_1_4;
- qi::rule<iterator, quickbook::template_body()> template_arg_1_5;
- qi::rule<iterator> brackets_1_5;
- };
-
- void quickbook_grammar::impl::init_template()
- {
- template_grammar_local& local = store_.create();
-
- block_keyword_rules.add("template", local.define_template[actions.process]);
-
- local.define_template =
- space
- >> local.template_id [member_assign(&quickbook::define_template::id)]
- >> -local.define_template_params [member_assign(&quickbook::define_template::params)]
- >> local.template_body [member_assign(&quickbook::define_template::body)]
- ;
-
- local.define_template_params =
- space
- >> repo::confix('[', ']')
- [space >> *(local.template_id >> space)]
- ;
-
- local.template_body =
- position [member_assign(&quickbook::template_body::position)]
- >> qi::matches[&(*qi::blank >> qi::eol)]
- [member_assign(&quickbook::template_body::is_block)]
- >> qi::raw[local.template_body_recurse]
- [member_assign(&quickbook::template_body::content)]
- ;
-
- local.template_body_recurse =
- *( repo::confix('[', ']')[local.template_body_recurse]
- | (qi::char_ - ']')
- )
- >> space
- >> &qi::lit(']')
- ;
-
- local.template_id
- = (qi::alpha | '_') >> *(qi::alnum | '_')
- | qi::repeat(1)[qi::punct - qi::char_("[]")]
- ;
-
- call_template = local.call_template [actions.process];
-
- local.call_template =
- position [member_assign(&quickbook::call_template::position)]
- >> qi::matches['`'] [member_assign(&quickbook::call_template::escape)]
- >> ( // Lookup the template name
- (&qi::punct >> actions.templates.scope)
- | (actions.templates.scope >> hard_space)
- ) [member_assign(&quickbook::call_template::symbol)]
- >> local.template_args [member_assign(&quickbook::call_template::args)]
- >> &qi::lit(']')
- ;
-
- local.template_args =
- qi::eps(qbk_before(105u)) >> -(local.template_arg_1_4 % "..") |
- qi::eps(qbk_since(105u)) >> -(local.template_arg_1_5 % "..");
-
- local.template_arg_1_4 =
- position [member_assign(&quickbook::template_body::position)]
- >> qi::matches[&(*qi::blank >> qi::eol)]
- [member_assign(&quickbook::template_body::is_block)]
- >> qi::raw[+(local.brackets_1_4 | ~qi::char_(']') - "..")]
- [member_assign(&quickbook::template_body::content)]
- ;
-
- local.brackets_1_4 =
- repo::confix('[', ']')
- [+(local.brackets_1_4 | ~qi::char_(']') - "..")]
- ;
-
- local.template_arg_1_5 =
- position [member_assign(&quickbook::template_body::position)]
- >> qi::matches[&(*qi::blank >> qi::eol)]
- [member_assign(&quickbook::template_body::is_block)]
- >> qi::raw[+(local.brackets_1_5 | '\\' >> qi::char_ | ~qi::char_("[]") - "..")]
- [member_assign(&quickbook::template_body::content)]
- ;
-
- local.brackets_1_5 =
- repo::confix('[', ']')
- [+(local.brackets_1_5 | '\\' >> qi::char_ | ~qi::char_("[]"))]
- ;
- }
-}

Modified: branches/quickbook-1.5-spirit2/test/quickbook-testing.jam
==============================================================================
--- branches/quickbook-1.5-spirit2/test/quickbook-testing.jam (original)
+++ branches/quickbook-1.5-spirit2/test/quickbook-testing.jam 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
@@ -50,7 +50,7 @@
             : $(input)
             : $(requirements)
                 <location-prefix>$(target-name).test
- <quickbook-testing.quickbook-command>..//quickbook
+ <quickbook-testing.quickbook-command>../src//quickbook
         ]
 
         [ targets.create-typed-target RUN
@@ -81,7 +81,7 @@
         [ targets.create-typed-target RUN_FAIL
             : $(project)
             : $(target-name)
- : ..//quickbook
+ : ../src//quickbook
             : $(requirements)
               <preserve-test-targets>on
               <dependency>$(input)

Deleted: branches/quickbook-1.5-spirit2/utils.cpp
==============================================================================
--- branches/quickbook-1.5-spirit2/utils.cpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,293 +0,0 @@
-/*=============================================================================
- 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 "utils.hpp"
-#include <boost/spirit/include/classic_core.hpp>
-
-#include <cctype>
-#include <cstring>
-#include <stdexcept>
-#include <fstream>
-#include <iostream>
-#include <map>
-
-namespace quickbook {
- extern bool ms_errors;
-}
-
-namespace quickbook { namespace detail
-{
- char filter_identifier_char(char ch)
- {
- if (!std::isalnum(static_cast<unsigned char>(ch)))
- ch = '_';
- return static_cast<char>(std::tolower(static_cast<unsigned char>(ch)));
- }
-
- // un-indent a code segment
- void unindent(std::string& program)
- {
- // Erase leading blank lines and newlines:
- std::string::size_type start = program.find_first_not_of(" \t");
- if (start != std::string::npos &&
- (program[start] == '\r' || program[start] == '\n'))
- {
- program.erase(0, start);
- }
- start = program.find_first_not_of("\r\n");
- program.erase(0, start);
-
- if (program.size() == 0)
- return; // nothing left to do
-
- // Get the first line indent
- std::string::size_type indent = program.find_first_not_of(" \t");
- std::string::size_type pos = 0;
- if (std::string::npos == indent)
- {
- // Nothing left to do here. The code is empty (just spaces).
- // We clear the program to signal the caller that it is empty
- // and return early.
- program.clear();
- return;
- }
-
- // Calculate the minimum indent from the rest of the lines
- do
- {
- pos = program.find_first_not_of("\r\n", pos);
- if (std::string::npos == pos)
- break;
-
- std::string::size_type n = program.find_first_not_of(" \t", pos);
- if (n != std::string::npos)
- {
- char ch = program[n];
- if (ch != '\r' && ch != '\n') // ignore empty lines
- indent = (std::min)(indent, n-pos);
- }
- }
- while (std::string::npos != (pos = program.find_first_of("\r\n", pos)));
-
- // Trim white spaces from column 0..indent
- pos = 0;
- program.erase(0, indent);
- while (std::string::npos != (pos = program.find_first_of("\r\n", pos)))
- {
- if (std::string::npos == (pos = program.find_first_not_of("\r\n", pos)))
- {
- break;
- }
-
- std::string::size_type next = program.find_first_of("\r\n", pos);
- program.erase(pos, (std::min)(indent, next-pos));
- }
- }
-
- // remove the extension from a filename
- std::string
- remove_extension(std::string const& filename)
- {
- std::string::size_type const n = filename.find_last_of('.');
- if(std::string::npos == n)
- {
- return filename;
- }
- else
- {
- return std::string(filename.begin(), filename.begin()+n);
- }
- }
-
- std::string escape_uri(std::string uri)
- {
- for (std::string::size_type n = 0; n < uri.size(); ++n)
- {
- static char const mark[] = "-_.!~*'()?\\/";
- if((!std::isalnum(static_cast<unsigned char>(uri[n])) || 127 < static_cast<unsigned char>(uri[n]))
- && 0 == std::strchr(mark, uri[n]))
- {
- static char const hex[] = "0123456789abcdef";
- char escape[] = { hex[uri[n] / 16], hex[uri[n] % 16] };
- uri.insert(n + 1, escape, 2);
- uri[n] = '%';
- n += 2;
- }
- }
- return uri;
- }
-
- std::ostream& outerr(std::string const& file, int line)
- {
- if (line >= 0)
- {
- if (ms_errors)
- return std::clog << file << "(" << line << "): error: ";
- else
- return std::clog << file << ":" << line << ": error: ";
- }
- else
- {
- return std::clog << file << ": error: ";
- }
- }
-
- std::ostream& outwarn(std::string const& file, int line)
- {
- if (line >= 0)
- {
- if (ms_errors)
- return std::clog << file << "(" << line << "): warning: ";
- else
- return std::clog << file << ":" << line << ": warning: ";
- }
- else
- {
- return std::clog << file << ": warning: ";
- }
- }
-
- // Read the first few bytes in a file to see it starts with a byte order
- // mark. If it doesn't, then write the characters we've already read in.
- // Although, given how UTF-8 works, if even part of the BOM was matched,
- // the file is probably broken.
-
- template <class InputIterator, class OutputIterator>
- bool check_bom(InputIterator& begin, InputIterator end,
- OutputIterator out, char const* chars, int length)
- {
- char const* ptr = chars;
-
- while(begin != end && *begin == *ptr) {
- ++begin;
- ++ptr;
- --length;
- if(length == 0) return true;
- }
-
- // Failed to match, so write the skipped characters to storage:
- while(chars != ptr) *out++ = *chars++;
-
- return false;
- }
-
- template <class InputIterator, class OutputIterator>
- std::string read_bom(InputIterator& begin, InputIterator end,
- OutputIterator out)
- {
- if(begin == end) return "";
-
- const char* utf8 = "\xef\xbb\xbf";
- const char* utf32be = "\0\0\xfe\xff";
- const char* utf32le = "\xff\xfe\0\0";
-
- unsigned char c = *begin;
- switch(c)
- {
- case 0xEF: { // UTF-8
- return check_bom(begin, end, out, utf8, 3) ? "UTF-8" : "";
- }
- case 0xFF: // UTF-16/UTF-32 little endian
- return !check_bom(begin, end, out, utf32le, 2) ? "" :
- check_bom(begin, end, out, utf32le + 2, 2) ? "UTF-32" : "UTF-16";
- case 0: // UTF-32 big endian
- return check_bom(begin, end, out, utf32be, 4) ? "UTF-32" : "";
- case 0xFE: // UTF-16 big endian
- return check_bom(begin, end, out, utf32be + 2, 2) ? "UTF-16" : "";
- default:
- return "";
- }
- }
-
- // Copy a string, converting mac and windows style newlines to unix
- // newlines.
-
- template <class InputIterator, class OutputIterator>
- bool normalize(InputIterator begin, InputIterator end,
- OutputIterator out, std::string const& filename)
- {
- std::string encoding = read_bom(begin, end, out);
-
- if(encoding != "UTF-8" && encoding != "") {
- outerr(filename) << encoding << " is not supported. Please use UTF-8."
- << std::endl;
-
- return false;
- }
-
- while(begin != end) {
- if(*begin == '\r') {
- *out++ = '\n';
- ++begin;
- if(begin != end && *begin == '\n') ++begin;
- }
- else {
- *out++ = *begin++;
- }
- }
-
- return true;
- }
-
- int load(std::string const& filename, std::string& storage)
- {
- using std::cerr;
- using std::endl;
- using std::ios;
- using std::ifstream;
- using std::istream_iterator;
-
- ifstream in(filename.c_str(), std::ios_base::in);
-
- if (!in)
- {
- outerr(filename) << "Could not open input file." << endl;
- return 1;
- }
-
- // Turn off white space skipping on the stream
- in.unsetf(ios::skipws);
-
- if(!normalize(
- istream_iterator<char>(in),
- istream_iterator<char>(),
- std::back_inserter(storage),
- filename))
- {
- 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;
- }
-
- file_type get_file_type(std::string const& extension)
- {
- static std::map<std::string, file_type> ftypes;
- if (ftypes.empty())
- {
- // init the map of types
- ftypes["cpp"] = cpp_file;
- ftypes["hpp"] = cpp_file;
- ftypes["h"] = cpp_file;
- ftypes["c"] = cpp_file;
- ftypes["cxx"] = cpp_file;
- ftypes["hxx"] = cpp_file;
- ftypes["ipp"] = cpp_file;
- ftypes["py"] = python_file;
- }
- return ftypes[extension];
- }
-
-}}
-
-

Deleted: branches/quickbook-1.5-spirit2/utils.hpp
==============================================================================
--- branches/quickbook-1.5-spirit2/utils.hpp 2010-09-01 04:35:41 EDT (Wed, 01 Sep 2010)
+++ (empty file)
@@ -1,71 +0,0 @@
-/*=============================================================================
- 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)
-=============================================================================*/
-#if !defined(BOOST_SPIRIT_QUICKBOOK_UTILS_HPP)
-#define BOOST_SPIRIT_QUICKBOOK_UTILS_HPP
-
-#include <string>
-#include <iostream>
-#include <cctype>
-#include <boost/ref.hpp>
-
-namespace quickbook { namespace detail
-{
- char filter_identifier_char(char ch);
-
- template <typename Iterator>
- inline std::string
- make_identifier(Iterator const& first, Iterator const& last)
- {
- std::string out_name;
- for (Iterator i = first; i != last; ++i)
- out_name += filter_identifier_char(*i);
- return out_name;
- }
-
- template <typename Container>
- inline std::string
- make_identifier(Container const& x)
- {
- return make_identifier(x.begin(), x.end());
- }
-
- // un-indent a code segment
- void unindent(std::string& program);
-
- // remove the extension from a filename
- std::string remove_extension(std::string const& filename);
-
- std::string escape_uri(std::string uri);
-
- // Preformats an error/warning message so that it can be parsed by
- // common IDEs. Uses the ms_errors global to determine if VS format
- // or GCC format. Returns the stream to continue ouput of the verbose
- // error message.
- std::ostream & outerr(std::string const& file, int line = -1);
- std::ostream & outwarn(std::string const& file, int line = -1);
-
- // load file into memory with extra trailing newlines to eliminate
- // the need to check for end of file in the grammar.
- int load(std::string const& filename, std::string& storage);
-
- // given a file extension, return the type of the source file
- // we'll have an internal database for known file types.
-
- enum file_type
- {
- cpp_file
- , python_file
- };
-
- file_type get_file_type(std::string const& extension);
-}}
-
-#endif // BOOST_SPIRIT_QUICKBOOK_UTILS_HPP
-


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