|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75355 - branches/quickbook-dev/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-11-06 17:21:02
Author: danieljames
Date: 2011-11-06 17:21:01 EST (Sun, 06 Nov 2011)
New Revision: 75355
URL: http://svn.boost.org/trac/boost/changeset/75355
Log:
Quickbook: Try make some sense of the various block/phrase rules.
Text files modified:
branches/quickbook-dev/tools/quickbook/src/actions.cpp | 2
branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp | 2
branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp | 2
branches/quickbook-dev/tools/quickbook/src/grammar.cpp | 3
branches/quickbook-dev/tools/quickbook/src/grammar.hpp | 3
branches/quickbook-dev/tools/quickbook/src/grammar_impl.hpp | 7 -
branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp | 134 ++++++++++++++++++---------------------
branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp | 2
8 files changed, 72 insertions(+), 83 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-06 17:21:01 EST (Sun, 06 Nov 2011)
@@ -1110,7 +1110,7 @@
bool r = cl::parse(first, last,
content.get_tag() == template_tags::block ?
actions.grammar().block :
- actions.grammar().template_phrase
+ actions.grammar().inline_phrase
).full;
boost::swap(actions.current_file, saved_current_file);
Modified: branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/block_element_grammar.cpp 2011-11-06 17:21:01 EST (Sun, 06 Nov 2011)
@@ -303,7 +303,7 @@
local.inner_phrase =
actions.scoped_output()
[
- phrase [actions.docinfo_value(ph::arg1, ph::arg2)]
+ paragraph_phrase [actions.docinfo_value(ph::arg1, ph::arg2)]
]
;
}
Modified: branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/doc_info_grammar.cpp 2011-11-06 17:21:01 EST (Sun, 06 Nov 2011)
@@ -195,7 +195,7 @@
local.attribute_rules[doc_info_attributes::copyright] = &local.doc_copyright;
- local.doc_phrase = simple_phrase [actions.docinfo_value(ph::arg1, ph::arg2)];
+ local.doc_phrase = nested_phrase [actions.docinfo_value(ph::arg1, ph::arg2)];
local.attribute_rules[doc_info_attributes::purpose] = &local.doc_phrase;
local.attribute_rules[doc_info_attributes::license] = &local.doc_phrase;
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-06 17:21:01 EST (Sun, 06 Nov 2011)
@@ -16,10 +16,9 @@
quickbook_grammar::quickbook_grammar(quickbook::actions& a)
: impl_(new impl(a))
, command_line_macro(impl_->command_line, "command_line_macro")
- , template_phrase(impl_->template_phrase, "template_phrase")
+ , inline_phrase(impl_->inline_phrase, "inline_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-06 17:21:01 EST (Sun, 06 Nov 2011)
@@ -54,10 +54,9 @@
public:
grammar command_line_macro;
- grammar template_phrase;
+ grammar inline_phrase;
grammar phrase;
grammar block;
- grammar block_skip_initial_spaces;
grammar doc_info;
quickbook_grammar(quickbook::actions&);
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-06 17:21:01 EST (Sun, 06 Nov 2011)
@@ -68,10 +68,9 @@
// Main Grammar
cl::rule<scanner> block_start;
cl::rule<scanner> phrase_start;
- cl::rule<scanner> block_skip_initial_spaces;
- cl::rule<scanner> simple_phrase;
- cl::rule<scanner> template_phrase;
- cl::rule<scanner> phrase;
+ cl::rule<scanner> nested_phrase;
+ cl::rule<scanner> inline_phrase;
+ cl::rule<scanner> paragraph_phrase;
cl::rule<scanner> extended_phrase;
cl::rule<scanner> inside_paragraph;
cl::rule<scanner> command_line;
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:01 EST (Sun, 06 Nov 2011)
@@ -111,7 +111,7 @@
template_args_1_5, template_arg_1_5, template_arg_1_5_content,
template_inner_arg_1_5, brackets_1_5,
break_,
- command_line_macro_identifier, command_line_phrase,
+ command_line_macro_identifier,
dummy_block, line_dummy_block, mismatched_square_bracket
;
@@ -164,21 +164,63 @@
main_grammar_local& local = cleanup_.add(
new main_grammar_local(actions));
- block_skip_initial_spaces =
- *(cl::blank_p | comment) >> block_start
+ // phrase/phrase_start is used for an entirely self-contained
+ // phrase. For example, any remaining anchors are written out
+ // at the end instead of being saved for any following content.
+ phrase_start =
+ inline_phrase [actions.phrase_end]
;
- block_start =
- local.top_level >> blank
+ // nested_phrase is used for a phrase nested inside square
+ // brackets.
+ nested_phrase =
+ actions.values.save()
+ [
+ *( local.common(element_info::in_phrase)
+ | (cl::anychar_p - ']') [actions.plain_char]
+ )
+ ]
;
- phrase_start =
- (*( 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]
+ )
+ ]
+ ;
+
+ // 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]
+ )
+ ]
+ ;
+
+ // inline_phrase is used a phrase that isn't nested inside
+ // brackets, but is not self contained. An example of this
+ // is expanding a template, which is parsed separately but
+ // 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]
- )) [actions.phrase_end]
+ )
+ ]
;
+ // Top level blocks
+ 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
@@ -196,6 +238,17 @@
>> cl::eps_p [actions.paragraph]
;
+ // Blocks contains within an element, e.g. a table cell or a footnote.
+ 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]
+ )
+ ] [actions.paragraph]
+ ;
+
local.blocks =
+( local.code
| local.list
@@ -298,7 +351,7 @@
| comment
| cl::eps_p(qbk_since(106u))
>> ( cl::ch_p('[') [actions.plain_char]
- >> simple_phrase
+ >> nested_phrase
>> ( cl::ch_p(']') [actions.plain_char]
| cl::eps_p [actions.error("Missing close bracket")]
)
@@ -471,34 +524,6 @@
| phrase_end
;
- phrase =
- actions.values.save()
- [ *( local.common(element_info::in_phrase)
- | (cl::anychar_p - phrase_end)
- [actions.plain_char]
- )
- ]
- ;
-
- extended_phrase =
- actions.values.save()
- [ *( local.common(element_info::in_conditional)
- | (cl::anychar_p - phrase_end)
- [actions.plain_char]
- )
- ]
- ;
-
- 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]
- )
- ] [actions.paragraph]
- ;
-
escape =
cl::str_p("\\n") [actions.break_]
| cl::str_p("\\ ") // ignore an escaped space
@@ -517,29 +542,6 @@
;
//
- // Simple phrase grammar
- //
-
- simple_phrase =
- actions.values.save()
- [
- *( local.common(element_info::in_phrase)
- | (cl::anychar_p - ']') [actions.plain_char]
- )
- ]
- ;
-
- template_phrase =
- actions.values.save()
- [
- *( local.common(element_info::in_phrase)
- | local.mismatched_square_bracket
- | cl::anychar_p [actions.plain_char]
- )
- ]
- ;
-
- //
// Command line
//
@@ -551,7 +553,7 @@
>> *cl::space_p
>> ( '='
>> *cl::space_p
- >> local.command_line_phrase
+ >> inline_phrase
>> *cl::space_p
| cl::eps_p
) [actions.to_value]
@@ -564,16 +566,6 @@
| +(cl::anychar_p - (cl::space_p | ']' | '='))
;
-
- local.command_line_phrase =
- actions.values.save()
- [ *( local.common(element_info::in_phrase)
- | local.mismatched_square_bracket
- | cl::anychar_p [actions.plain_char]
- )
- ]
- ;
-
// Miscellaneous stuff
// Follows an alphanumeric identifier - ensures that it doesn't
Modified: branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp
==============================================================================
--- branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp (original)
+++ branches/quickbook-dev/tools/quickbook/src/phrase_element_grammar.cpp 2011-11-06 17:21:01 EST (Sun, 06 Nov 2011)
@@ -139,7 +139,7 @@
local.inner_phrase =
blank
>> actions.scoped_output()
- [ phrase [actions.to_value]
+ [ paragraph_phrase [actions.to_value]
]
;
}
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