|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r75268 - branches/quickbook-dev/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2011-11-02 04:51:19
Author: danieljames
Date: 2011-11-02 04:51:16 EDT (Wed, 02 Nov 2011)
New Revision: 75268
URL: http://svn.boost.org/trac/boost/changeset/75268
Log:
Quickbook: Move scoped_context into main_grammar.
It's only used there so it fits into main_grammar's local state. It
would probably be a good idea to move more parsing stuff out of actions.
Or maybe the document state should be moved out of actions.
Text files modified:
branches/quickbook-dev/tools/quickbook/src/actions.cpp | 13 -----------
branches/quickbook-dev/tools/quickbook/src/actions.hpp | 13 -----------
branches/quickbook-dev/tools/quickbook/src/actions_class.cpp | 2 -
branches/quickbook-dev/tools/quickbook/src/actions_class.hpp | 3 --
branches/quickbook-dev/tools/quickbook/src/main_grammar.cpp | 44 +++++++++++++++++++++++++++++++--------
5 files changed, 35 insertions(+), 40 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:51:16 EDT (Wed, 02 Nov 2011)
@@ -1970,17 +1970,4 @@
{
actions.no_eols = saved_no_eols;
}
-
- bool scoped_context_impl::start(int new_context)
- {
- saved_context_ = actions_.context;
- actions_.context = new_context;
-
- return true;
- }
-
- void scoped_context_impl::cleanup()
- {
- actions_.context = saved_context_;
- }
}
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:51:16 EDT (Wed, 02 Nov 2011)
@@ -332,19 +332,6 @@
quickbook::actions& actions;
bool saved_no_eols;
};
-
- struct scoped_context_impl : scoped_action_base
- {
- scoped_context_impl(quickbook::actions& actions)
- : actions_(actions) {}
-
- bool start(int);
- void cleanup();
-
- private:
- quickbook::actions& actions_;
- int saved_context_;
- };
}
#endif // BOOST_SPIRIT_QUICKBOOK_ACTIONS_HPP
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:51:16 EDT (Wed, 02 Nov 2011)
@@ -32,7 +32,6 @@
, anchors()
, no_eols(true)
, warned_about_breaks(false)
- , context(0)
, conditional(true)
, ids(ids)
@@ -55,7 +54,6 @@
, scoped_cond_phrase(*this)
, scoped_output(*this)
, scoped_no_eols(*this)
- , scoped_context(*this)
, element(*this)
, error(*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:51:16 EDT (Wed, 02 Nov 2011)
@@ -46,7 +46,6 @@
string_list anchors;
bool no_eols;
bool warned_about_breaks;
- int context;
bool conditional;
id_manager& ids;
file* current_file_tmp; // Temporary non-const pointer to new
@@ -87,8 +86,6 @@
scoped_output;
scoped_parser<set_no_eols_scoped>
scoped_no_eols;
- scoped_parser<scoped_context_impl>
- scoped_context;
element_action element;
error_action error;
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:51:16 EDT (Wed, 02 Nov 2011)
@@ -36,7 +36,7 @@
bool start()
{
- if (!(l.info.type & l.actions_.context) ||
+ if (!(l.info.type & l.context) ||
qbk_version_n < l.info.qbk_version)
return false;
@@ -85,6 +85,29 @@
main_grammar_local& l_;
};
+ struct scoped_context_impl : scoped_action_base
+ {
+ scoped_context_impl(main_grammar_local& l)
+ : l_(l) {}
+
+ bool start(int new_context)
+ {
+ saved_context_ = l_.context;
+ l_.context = new_context;
+
+ return true;
+ }
+
+ void cleanup()
+ {
+ l_.context = saved_context_;
+ }
+
+ private:
+ main_grammar_local& l_;
+ int saved_context_;
+ };
+
cl::rule<scanner>
top_level, blocks, paragraph_separator,
code, code_line, blank_line, hr,
@@ -114,15 +137,18 @@
cl::rule<scanner, simple_markup_closure::context_t> simple_markup;
cl::rule<scanner> simple_markup_end;
+ int context;
element_info info;
element_info::type_enum element_type;
quickbook::actions& actions_;
+ scoped_parser<scoped_context_impl> scoped_context;
scoped_parser<process_element_impl> process_element;
is_block_type is_block;
main_grammar_local(quickbook::actions& actions)
: actions_(actions)
+ , scoped_context(*this)
, process_element(*this)
, is_block(*this)
{}
@@ -142,7 +168,7 @@
;
phrase_start =
- actions.scoped_context(element_info::in_phrase)
+ local.scoped_context(element_info::in_phrase)
[
*( common
| cl::anychar_p [actions.plain_char]
@@ -151,7 +177,7 @@
;
local.top_level =
- actions.scoped_context(element_info::in_block)
+ local.scoped_context(element_info::in_block)
[ local.blocks
>> *( local.element
>> !(cl::eps_p(local.is_block) >> +eol >> local.blocks)
@@ -236,7 +262,7 @@
;
local.list_item =
- actions.scoped_context(element_info::in_phrase)
+ local.scoped_context(element_info::in_phrase)
[
actions.values.save()
[
@@ -425,7 +451,7 @@
;
phrase =
- actions.scoped_context(element_info::in_phrase)
+ local.scoped_context(element_info::in_phrase)
[
actions.values.save()
[ *( common
@@ -437,7 +463,7 @@
;
extended_phrase =
- actions.scoped_context(element_info::in_conditional)
+ local.scoped_context(element_info::in_conditional)
[
actions.values.save()
[ *( common
@@ -449,7 +475,7 @@
;
inside_paragraph =
- actions.scoped_context(element_info::in_nested_block)
+ local.scoped_context(element_info::in_nested_block)
[
actions.values.save()
[ *( local.paragraph_separator [actions.paragraph]
@@ -483,7 +509,7 @@
//
simple_phrase =
- actions.scoped_context(element_info::in_phrase)
+ local.scoped_context(element_info::in_phrase)
[
actions.values.save()
[
@@ -519,7 +545,7 @@
local.command_line_phrase =
- actions.scoped_context(element_info::in_phrase)
+ local.scoped_context(element_info::in_phrase)
[
actions.values.save()
[ *( common
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