|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75357 - in branches/quickbook-dev/tools/quickbook: src test
From: dnljms_at_[hidden]
Date: 2011-11-06 17:21:33
Author: danieljames
Date: 2011-11-06 17:21:32 EST (Sun, 06 Nov 2011)
New Revision: 75357
URL: http://svn.boost.org/trac/boost/changeset/75357
Log:
Quickbook: Move more phrase parsing into local.common.
This change has two side effects: anchors are placed slightly better and
non-element/template square brackets are terminated by the end of a
paragraph.
Text files modified:
branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp | 86 ++++++++++++++++-----------------------
branches/quickbook-dev/tools/quickbook/test/anchor-1_1.gold | 6 +-
2 files changed, 39 insertions(+), 53 deletions(-)
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-06 17:21:32 EST (Sun, 06 Nov 2011)
@@ -112,7 +112,7 @@
template_inner_arg_1_5, brackets_1_5,
break_,
command_line_macro_identifier,
- dummy_block, line_dummy_block, mismatched_square_bracket
+ dummy_block, line_dummy_block, square_brackets
;
struct simple_markup_closure
@@ -175,33 +175,27 @@
// brackets.
nested_phrase =
actions.values.save()
- [
- *( local.common(element_info::in_phrase)
- | (cl::anychar_p - ']') [actions.plain_char]
- )
- ]
+ [*( ~cl::eps_p(']')
+ >> local.common(element_info::in_phrase)
+ )]
;
// paragraph_phrase is like a nested_phrase but is also terminated
// by a paragraph end.
paragraph_phrase =
actions.values.save()
- [ *( local.common(element_info::in_phrase)
- | (cl::anychar_p - phrase_end)
- [actions.plain_char]
- )
- ]
+ [*( ~cl::eps_p(phrase_end)
+ >> local.common(element_info::in_phrase)
+ )]
;
// extended_phrase is like a paragraph_phrase but allows some block
// elements.
extended_phrase =
actions.values.save()
- [ *( local.common(element_info::in_conditional)
- | (cl::anychar_p - phrase_end)
- [actions.plain_char]
- )
- ]
+ [*( ~cl::eps_p(phrase_end)
+ >> local.common(element_info::in_conditional)
+ )]
;
// inline_phrase is used a phrase that isn't nested inside
@@ -210,11 +204,7 @@
// is part of the paragraph that contains it.
inline_phrase =
actions.values.save()
- [
- *( local.common(element_info::in_phrase)
- | local.mismatched_square_bracket
- | cl::anychar_p [actions.plain_char]
- )
+ [ *local.common(element_info::in_phrase)
]
;
@@ -222,18 +212,16 @@
block_start = local.top_level;
local.top_level =
- cl::eps_p[local.top_level.parse_blocks = true]
- >> *( cl::eps_p(local.top_level.parse_blocks) >> local.blocks
+ cl::eps_p [local.top_level.parse_blocks = true]
+ >> *( cl::eps_p(local.top_level.parse_blocks)
+ >> local.blocks
| local.element(element_info::in_block)
[local.top_level.parse_blocks = false]
>> !(cl::eps_p(local.is_block) >> +eol)
[local.top_level.parse_blocks = true]
| local.paragraph_separator [local.top_level.parse_blocks = true]
- | ( local.common(element_info::in_phrase)
- | local.mismatched_square_bracket
- | cl::space_p [actions.space_char]
- | cl::anychar_p [actions.plain_char]
- ) [local.top_level.parse_blocks = false]
+ | local.common(element_info::in_phrase)
+ [local.top_level.parse_blocks = false]
)
>> cl::eps_p [actions.paragraph]
;
@@ -242,9 +230,8 @@
inside_paragraph =
actions.values.save()
[ *( local.paragraph_separator [actions.paragraph]
- | local.common(element_info::in_nested_block)
- | (cl::anychar_p - phrase_end)
- [actions.plain_char]
+ | ~cl::eps_p(']')
+ >> local.common(element_info::in_nested_block)
)
] [actions.paragraph]
;
@@ -327,13 +314,11 @@
local.list_item =
actions.values.save()
[
- *( local.common(element_info::in_phrase)
- | local.mismatched_square_bracket
- | (cl::anychar_p -
- ( cl::eol_p >> *cl::blank_p
- >> (cl::ch_p('*') | '#' | cl::eol_p)
- )
- ) [actions.plain_char]
+ *( ~cl::eps_p
+ ( cl::eol_p >> *cl::blank_p
+ >> (cl::ch_p('*') | '#' | cl::eol_p)
+ )
+ >> local.common(element_info::in_phrase)
)
]
>> (+eol | cl::end_p)
@@ -349,20 +334,21 @@
| local.simple_markup
| escape
| comment
- | cl::eps_p(qbk_since(106u))
- >> ( cl::ch_p('[') [actions.plain_char]
- >> nested_phrase
- >> ( cl::ch_p(']') [actions.plain_char]
- | cl::eps_p [actions.error("Missing close bracket")]
- )
- )
+ | cl::eps_p(qbk_since(106u)) >> local.square_brackets
+ | cl::space_p [actions.space_char]
+ | cl::anychar_p [actions.plain_char]
;
- local.mismatched_square_bracket =
- cl::eps_p(qbk_since(106u))
- >> cl::ch_p(']') [actions.plain_char]
- >> cl::eps_p [actions.error("Mismatched close bracket")]
- ;
+ local.square_brackets =
+ ( cl::ch_p('[') [actions.plain_char]
+ >> paragraph_phrase
+ >> ( cl::ch_p(']') [actions.plain_char]
+ | cl::eps_p [actions.error("Missing close bracket")]
+ )
+ | cl::ch_p(']') [actions.plain_char]
+ >> cl::eps_p [actions.error("Mismatched close bracket")]
+ )
+ ;
local.macro =
// must not be followed by alpha or underscore
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-06 17:21:32 EST (Sun, 06 Nov 2011)
@@ -75,7 +75,7 @@
</listitem>
<listitem>
<simpara>
- <anchor id="a16"/> Nested Item 3
+ <anchor id="a16"/>Nested Item 3
</simpara>
</listitem>
</itemizedlist>
@@ -94,7 +94,7 @@
<anchor id="t1"/>Some text.
</para>
<para>
- <anchor id="t2"/> Text content
+ <anchor id="t2"/>Text content
</para>
</section>
<section id="anchor_test.anchors_in_syntax_highlighted_code">
@@ -127,7 +127,7 @@
<row>
<entry>
<para>
- <anchor id="table2"/> Cell 2
+ <anchor id="table2"/>Cell 2
</para>
</entry>
</row>
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