? bib.diff ? detail/bibliography.hpp Index: block.hpp =================================================================== RCS file: /cvsroot/boost/boost/tools/quickbook/block.hpp,v retrieving revision 1.20 diff -u -r1.20 block.hpp --- block.hpp 27 Feb 2007 15:22:15 -0000 1.20 +++ block.hpp 22 Jun 2007 16:15:15 -0000 @@ -104,6 +104,9 @@ '[' >> space >> ( begin_section | end_section + | begin_bib + | end_bib + | bib_entry [actions.end_bib_entry] | headings | blurb | blockquote @@ -380,7 +383,8 @@ paragraph_end_markups = "section", "endsect", "h1", "h2", "h3", "h4", "h5", "h6", - "blurb", ":", "pre", "def", "table", "include" + "blurb", ":", "pre", "def", "table", "include", + "bibliography", "endbib" ; paragraph_end = @@ -403,10 +407,99 @@ close_bracket) [actions.plain_char] ) ; + + begin_bib = + str_p("bibliography") [actions.begin_bib] + ; + + end_bib = + str_p("endbib") [actions.end_bib] + ; + + bib_entry = + str_p("bibentry") [actions.begin_bib_entry] + >> + *( + space >> '[' >> + ( + bib_authors + | bib_title + | bib_pages + | bib_book + | bib_journal + | bib_conference + ) + >> space >> ch_p(']') + >> +eol_p + ) + ; + + bib_authors = + "authors" >> hard_space + >> bib_author [push_back_a(actions.bib_entry.authors, name)] + >> *( ',' + >> bib_author [push_back_a(actions.bib_entry.authors, name)] + ) + ; + + bib_author = + space + >> '[' >> space + >> (*(anychar_p - ',')) [assign_a(name.second)] // surname + >> ',' >> space + >> (*(anychar_p - ']')) [assign_a(name.first)] // firstname + >> ']' + ; + + bib_title = + "title" >> hard_space + >> (*(anychar_p - ']')) [assign_a(actions.bib_entry.title)] + ; + + bib_pages = + "pages" >> hard_space + >> (*(anychar_p - ']')) [assign_a(actions.bib_entry.pages)] + ; + + bib_copyright = + "copyright" >> hard_space + >> (*(anychar_p - ']')) [assign_a(actions.bib_entry.copyright)] + ; + + bib_publisher = + "publisher" >> hard_space + >> (*(anychar_p - ']')) [assign_a(actions.bib_entry.publisher)] + ; + + bib_book = + str_p("book") [assign_a(actions.bib_entry.type)] + >> + *( + space >> '[' >> + ( + bib_copyright + | bib_publisher + ) + >> space >> ch_p(']') + >> +eol_p + ) + ; + + bib_journal = + "journal" >> hard_space + >> (*(anychar_p - ']')) // [assign_a(actions.doc_version)] + ; + + bib_conference = + "conference" >> hard_space + >> (*(anychar_p - ']')) // [assign_a(actions.doc_version)] + ; } bool no_eols; + std::pair name; // temporary name storage + rule start_, blocks, block_markup, code, code_line, paragraph, space, blank, comment, headings, h, h1, h2, h3, h4, h5, h6, hr, blurb, blockquote, admonition, @@ -417,7 +510,11 @@ xinclude, include, hard_space, eol, paragraph_end, template_, template_id, template_formal_arg, template_body, identifier, dummy_block, import, - inside_paragraph; + inside_paragraph, + begin_bib, end_bib, bib_entry, bib_authors, bib_author, + bib_title, bib_pages, bib_copyright, bib_publisher, + bib_volume, bib_issue, bib_date, bib_location, + bib_journal, bib_conference, bib_book; symbols<> paragraph_end_markups; Index: code_snippet.hpp =================================================================== RCS file: /cvsroot/boost/boost/tools/quickbook/code_snippet.hpp,v retrieving revision 1.6 diff -u -r1.6 code_snippet.hpp --- code_snippet.hpp 7 Mar 2007 04:53:03 -0000 1.6 +++ code_snippet.hpp 22 Jun 2007 16:15:15 -0000 @@ -19,8 +19,8 @@ : grammar { cpp_code_snippet_grammar(std::vector& storage, std::string const& doc_id) - : storage(storage) - , doc_id(doc_id) + : doc_id(doc_id) + , storage(storage) {} template Index: detail/actions.cpp =================================================================== RCS file: /cvsroot/boost/boost/tools/quickbook/detail/actions.cpp,v retrieving revision 1.51 diff -u -r1.51 actions.cpp --- detail/actions.cpp 9 May 2007 12:56:07 -0000 1.51 +++ detail/actions.cpp 22 Jun 2007 16:15:15 -0000 @@ -21,6 +21,8 @@ #include "../phrase.hpp" #include "../code_snippet.hpp" +#include + namespace quickbook { // Handles line-breaks (DEPRECATED!!!) @@ -459,7 +461,8 @@ tinfo.push_back(*arg); template_symbol template_(tinfo, pos); - if (template_symbol* p = actions.templates.find_top_scope(*tpl)) + // if (template_symbol* p = actions.templates.find_top_scope(*tpl)) + if (actions.templates.find_top_scope(*tpl)) { detail::outerr(pos.file,pos.line) << "Duplicate Symbol Found" << std::endl; @@ -1025,6 +1028,7 @@ out << " " << year << "\n"; } + void pre(collector& out, quickbook::actions& actions, bool ignore_docinfo) { // The doc_info in the file has been parsed. Here's what we'll do @@ -1175,5 +1179,60 @@ { phrase.swap(out); } + + void begin_bibliography_action::operator()(iterator, iterator) const + { + // we probably need to generate an id for the bibliography so + // we can link to it. + actions.out << "\n" + << " Bibliography\n"; + } + + void end_bibliography_action::operator()(iterator, iterator) const + { + actions.out << "\n"; + } + + void begin_bibentry_action::operator()(iterator, iterator) const + { + BOOST_ASSERT(actions.bib_entry.empty()); + // I guess we don't need to to anything here... + } + + void end_bibentry_action::operator()(iterator, iterator) const + { + BOOST_ASSERT(!actions.bib_entry.empty()); + actions::bibliographic_entry& bib = actions.bib_entry; + + // having accrued bibliographic information, we should now be able + // to correctly generate the entire reference + + actions.out << " \n"; + actions.out << " \n"; + for_each(bib.authors.begin(), bib.authors.end(), xml_author(actions.out)); + actions.out << " \n"; + actions.out << " " << bib.title << "\n"; + + if(bib.type == "book") { + actions.out << " " << bib.copyright << "\n"; + actions.out << " " << bib.publisher << "\n"; + } + else if(bib.type == "journal") { + } + else if(bib.type == "conference") { + } + + + if(!bib.pages.empty()) { + actions.out << "\n " << bib.pages << "\n"; + } + + actions.out << "\n \n"; + + // reset the bibliographic entry + bib.clear(); + } + + } Index: detail/actions.hpp =================================================================== RCS file: /cvsroot/boost/boost/tools/quickbook/detail/actions.hpp,v retrieving revision 1.36 diff -u -r1.36 actions.hpp --- detail/actions.hpp 27 Feb 2007 15:22:15 -0000 1.36 +++ detail/actions.hpp 22 Jun 2007 16:15:15 -0000 @@ -695,6 +695,51 @@ std::string& out; collector& phrase; }; + + + struct begin_bibliography_action + { + begin_bibliography_action(quickbook::actions& a) + : actions(a) + {} + + void operator()(iterator, iterator) const; + + quickbook::actions& actions; + }; + + struct end_bibliography_action + { + end_bibliography_action(quickbook::actions& a) + : actions(a) + {} + + void operator()(iterator, iterator) const; + + quickbook::actions& actions; + }; + + struct begin_bibentry_action + { + begin_bibentry_action(quickbook::actions& a) + : actions(a) + {} + + void operator()(iterator, iterator) const; + + quickbook::actions& actions; + }; + + struct end_bibentry_action + { + end_bibentry_action(quickbook::actions& a) + : actions(a) + {} + + void operator()(iterator, iterator) const; + + quickbook::actions& actions; + }; } #endif // BOOST_SPIRIT_QUICKBOOK_ACTIONS_HPP Index: detail/actions_class.cpp =================================================================== RCS file: /cvsroot/boost/boost/tools/quickbook/detail/actions_class.cpp,v retrieving revision 1.9 diff -u -r1.9 actions_class.cpp --- detail/actions_class.cpp 27 Feb 2007 15:22:15 -0000 1.9 +++ detail/actions_class.cpp 22 Jun 2007 16:15:15 -0000 @@ -51,6 +51,7 @@ , section_id() , qualified_section_id() , source_mode("c++") + , bib_entry() // temporary or global state , table_title() @@ -168,6 +169,11 @@ , escape_pre(phrase, escape_pre_) , escape_post(phrase, escape_post_) + + , begin_bib(*this) + , end_bib(*this) + , begin_bib_entry(*this) + , end_bib_entry(*this) { // turn off __FILENAME__ macro on debug mode = true std::string filename_str = debug_mode ? Index: detail/actions_class.hpp =================================================================== RCS file: /cvsroot/boost/boost/tools/quickbook/detail/actions_class.hpp,v retrieving revision 1.9 diff -u -r1.9 actions_class.hpp --- detail/actions_class.hpp 27 Feb 2007 15:22:15 -0000 1.9 +++ detail/actions_class.hpp 22 Jun 2007 16:15:15 -0000 @@ -27,10 +27,37 @@ /////////////////////////////////////////////////////////////////////////// typedef std::vector string_list; - typedef std::vector > author_list; + + typedef std::pair author_name; + typedef std::vector author_list; + typedef std::pair mark_type; + static int const max_template_depth = 100; + struct bibliographic_entry + { + void clear() + { + authors.clear(); + title.clear(); + pages.clear(); + } + + bool empty() const + { return authors.empty(); } + + + author_list authors; + std::string type; + std::string title; + std::string pages; + std::string copyright; + std::string publisher; + std::string date; + }; + + // header info std::string doc_type; std::string doc_title; @@ -65,6 +92,7 @@ std::string section_id; std::string qualified_section_id; std::string source_mode; + bibliographic_entry bib_entry; typedef boost::tuple< fs::path @@ -189,6 +217,11 @@ markup_action escape_pre; markup_action escape_post; + + begin_bibliography_action begin_bib; + end_bibliography_action end_bib; + begin_bibentry_action begin_bib_entry; + end_bibentry_action end_bib_entry; }; } Index: detail/post_process.cpp =================================================================== RCS file: /cvsroot/boost/boost/tools/quickbook/detail/post_process.cpp,v retrieving revision 1.31 diff -u -r1.31 post_process.cpp --- detail/post_process.cpp 21 Feb 2007 00:48:28 -0000 1.31 +++ detail/post_process.cpp 22 Jun 2007 16:15:15 -0000 @@ -177,6 +177,9 @@ char const* block_tags_[] = { "author" + , "authorgroup" + , "biblioentry" + , "bibliography" , "blockquote" , "bridgehead" , "caution"