|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75264 - in branches/quickbook-dev/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2011-11-02 04:49:38
Author: danieljames
Date: 2011-11-02 04:49:33 EDT (Wed, 02 Nov 2011)
New Revision: 75264
URL: http://svn.boost.org/trac/boost/changeset/75264
Log:
Quickbook: Move escaped phrase handling to the main grammar.
Note there's no need to check for the end of the escapse as the
intersection (`&`) rule only passes the content within the esapse.
Text files modified:
branches/quickbook-dev/tools/quickbook/src/actions.cpp | 6 ++++
branches/quickbook-dev/tools/quickbook/src/actions.hpp | 11 ++++++++++
branches/quickbook-dev/tools/quickbook/src/actions_class.cpp | 1
branches/quickbook-dev/tools/quickbook/src/actions_class.hpp | 1
branches/quickbook-dev/tools/quickbook/src/grammar.cpp | 3 +
branches/quickbook-dev/tools/quickbook/src/grammar.hpp | 1
branches/quickbook-dev/tools/quickbook/src/grammar_impl.hpp | 1
branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp | 9 ++++++++
branches/quickbook-dev/tools/quickbook/src/syntax_highlight.cpp | 41 +++++----------------------------------
branches/quickbook-dev/tools/quickbook/test/anchor-1_1.gold | 14 +++++++++++++
branches/quickbook-dev/tools/quickbook/test/anchor-1_1.quickbook | 23 +++++++++++++++++++++
11 files changed, 73 insertions(+), 38 deletions(-)
Modified: branches/quickbook-dev/tools/quickbook/src/actions.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions.cpp 2011-11-02 04:49:33 EDT (Wed, 02 Nov 2011)
@@ -314,6 +314,11 @@
actions.out << markup.post;
}
}
+
+ void phrase_end_action::operator()() const
+ {
+ write_anchors(actions, actions.phrase);
+ }
namespace {
void write_bridgehead(quickbook::actions& actions, int level,
@@ -657,7 +662,6 @@
void post_escape_back::operator()(parse_iterator, parse_iterator) const
{
- write_anchors(escape_actions, escape_actions.phrase);
out << escape_actions.phrase.str();
escape_actions.phrase.pop(); // restore the stream
}
Modified: branches/quickbook-dev/tools/quickbook/src/actions.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions.hpp 2011-11-02 04:49:33 EDT (Wed, 02 Nov 2011)
@@ -118,6 +118,17 @@
quickbook::actions& actions;
};
+ struct phrase_end_action
+ {
+ phrase_end_action(quickbook::actions& actions) :
+ actions(actions) {}
+
+ void operator()() const;
+ void operator()(parse_iterator, parse_iterator) const { (*this)(); }
+
+ quickbook::actions& actions;
+ };
+
struct simple_phrase_action
{
// Handles simple text formats
Modified: branches/quickbook-dev/tools/quickbook/src/actions_class.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions_class.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions_class.cpp 2011-11-02 04:49:33 EDT (Wed, 02 Nov 2011)
@@ -63,6 +63,7 @@
, code_block(phrase, phrase, *this)
, inline_code(phrase, *this)
, paragraph(*this)
+ , phrase_end(*this)
, space_char(phrase)
, plain_char(phrase, *this)
, escape_unicode(phrase, *this)
Modified: branches/quickbook-dev/tools/quickbook/src/actions_class.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/actions_class.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/actions_class.hpp 2011-11-02 04:49:33 EDT (Wed, 02 Nov 2011)
@@ -97,6 +97,7 @@
code_action code_block;
inline_code_action inline_code;
paragraph_action paragraph;
+ phrase_end_action phrase_end;
space space_char;
plain_char_action plain_char;
escape_unicode_action escape_unicode;
Modified: branches/quickbook-dev/tools/quickbook/src/grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/grammar.cpp 2011-11-02 04:49:33 EDT (Wed, 02 Nov 2011)
@@ -16,8 +16,9 @@
quickbook_grammar::quickbook_grammar(quickbook::actions& a)
: impl_(new impl(a))
, command_line_macro(impl_->command_line, "command_line_macro")
- , common(impl_->common, "phrase")
+ , common(impl_->common, "common")
, simple_phrase(impl_->simple_phrase, "simple_phrase")
+ , phrase(impl_->phrase_start, "phrase")
, block(impl_->block_start, "block")
, block_skip_initial_spaces(impl_->block_skip_initial_spaces, "block")
, doc_info(impl_->doc_info_details, "doc_info")
Modified: branches/quickbook-dev/tools/quickbook/src/grammar.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/grammar.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/grammar.hpp 2011-11-02 04:49:33 EDT (Wed, 02 Nov 2011)
@@ -56,6 +56,7 @@
grammar command_line_macro;
grammar common;
grammar simple_phrase;
+ grammar phrase;
grammar block;
grammar block_skip_initial_spaces;
grammar doc_info;
Modified: branches/quickbook-dev/tools/quickbook/src/grammar_impl.hpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/grammar_impl.hpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/grammar_impl.hpp 2011-11-02 04:49:33 EDT (Wed, 02 Nov 2011)
@@ -60,6 +60,7 @@
// Main Grammar
cl::rule<scanner> block_start;
+ cl::rule<scanner> phrase_start;
cl::rule<scanner> block_skip_initial_spaces;
cl::rule<scanner> common;
cl::rule<scanner> simple_phrase;
Modified: branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp 2011-11-02 04:49:33 EDT (Wed, 02 Nov 2011)
@@ -141,6 +141,15 @@
local.top_level >> blank
;
+ phrase_start =
+ actions.scoped_context(element_info::in_phrase)
+ [
+ *( common
+ | cl::anychar_p [actions.plain_char]
+ )
+ ] [actions.phrase_end]
+ ;
+
local.top_level =
actions.scoped_context(element_info::in_block)
[ local.blocks
Modified: branches/quickbook-dev/tools/quickbook/src/syntax_highlight.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/syntax_highlight.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/syntax_highlight.cpp 2011-11-02 04:49:33 EDT (Wed, 02 Nov 2011)
@@ -103,15 +103,6 @@
>> self.escape_actions.macro [do_macro_action(self.out, self.escape_actions)]
;
- qbk_phrase =
- self.escape_actions.scoped_context(element_info::in_phrase)
- [ *( g.common
- | (cl::anychar_p - cl::str_p("``"))
- [self.escape_actions.plain_char]
- )
- ]
- ;
-
escape =
cl::str_p("``") [pre_escape_back(self.escape_actions, save)]
>>
@@ -119,7 +110,7 @@
(
(
(+(cl::anychar_p - "``") >> cl::eps_p("``"))
- & qbk_phrase
+ & g.phrase
)
>> cl::str_p("``")
)
@@ -184,7 +175,7 @@
cl::rule<Scanner>
program, macro, preprocessor, comment, special, string_,
- char_, number, identifier, keyword, qbk_phrase, escape,
+ char_, number, identifier, keyword, escape,
string_char;
quickbook_grammar& g;
@@ -236,16 +227,6 @@
>> self.escape_actions.macro [do_macro_action(self.out, self.escape_actions)]
;
- qbk_phrase =
- self.escape_actions.scoped_context(element_info::in_phrase)
- [
- *( g.common
- | (cl::anychar_p - cl::str_p("``"))
- [self.escape_actions.plain_char]
- )
- ]
- ;
-
escape =
cl::str_p("``") [pre_escape_back(self.escape_actions, save)]
>>
@@ -253,7 +234,7 @@
(
(
(+(cl::anychar_p - "``") >> cl::eps_p("``"))
- & qbk_phrase
+ & g.phrase
)
>> cl::str_p("``")
)
@@ -321,7 +302,7 @@
cl::rule<Scanner>
program, macro, comment, special, string_, string_prefix,
short_string, long_string, number, identifier, keyword,
- qbk_phrase, escape, string_char;
+ escape, string_char;
quickbook_grammar& g;
std::string save;
@@ -362,16 +343,6 @@
>> self.escape_actions.macro [do_macro_action(self.out, self.escape_actions)]
;
- qbk_phrase =
- self.escape_actions.scoped_context(element_info::in_phrase)
- [
- *( g.common
- | (cl::anychar_p - cl::str_p("``"))
- [self.escape_actions.plain_char]
- )
- ]
- ;
-
escape =
cl::str_p("``") [pre_escape_back(self.escape_actions, save)]
>>
@@ -379,7 +350,7 @@
(
(
(+(cl::anychar_p - "``") >> cl::eps_p("``"))
- & qbk_phrase
+ & g.phrase
)
>> cl::str_p("``")
)
@@ -392,7 +363,7 @@
;
}
- cl::rule<Scanner> program, macro, qbk_phrase, escape;
+ cl::rule<Scanner> program, macro, escape;
quickbook_grammar& g;
std::string save;
Modified: branches/quickbook-dev/tools/quickbook/test/anchor-1_1.gold
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/anchor-1_1.gold (original)
+++ branches/quickbook-dev/tools/quickbook/test/anchor-1_1.gold 2011-11-02 04:49:33 EDT (Wed, 02 Nov 2011)
@@ -83,4 +83,18 @@
</listitem>
</itemizedlist>
</section>
+ <section id="anchor_test.anchors_in_templates">
+ <title>Anchors in templates</title>
+ <para>
+ <anchor id="t1"/>Some text.
+ </para>
+ <para>
+ <anchor id="t2"/> Text content
+ </para>
+ </section>
+ <section id="anchor_test.anchors_in_syntax_highlighted_code">
+ <title>Anchors in syntax highlighted code</title>
+<programlisting><phrase role="keyword">int</phrase> <anchor id="s1"/><phrase role="identifier">main</phrase><phrase role="special">()</phrase> <phrase role="special">{}</phrase>
+</programlisting>
+ </section>
</article>
Modified: branches/quickbook-dev/tools/quickbook/test/anchor-1_1.quickbook
==============================================================================
--- branches/quickbook-dev/tools/quickbook/test/anchor-1_1.quickbook (original)
+++ branches/quickbook-dev/tools/quickbook/test/anchor-1_1.quickbook 2011-11-02 04:49:33 EDT (Wed, 02 Nov 2011)
@@ -46,4 +46,25 @@
* Nested Item 2
* Item 3
-[endsect]
\ No newline at end of file
+[endsect]
+
+[section Anchors in templates]
+
+[template anchor1[][#t1]]
+[template para[] Text content]
+
+[anchor1]
+
+Some text.
+
+[#t2]
+
+[para]
+
+[endsect]
+
+[section Anchors in syntax highlighted code]
+
+ int ``[#s1]``main() {}
+
+[endsect]
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk