Update of /cvsroot/boost/boost/boost/spirit/tree
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv9824/boost/spirit/tree
Modified Files:
Tag: SPIRIT_RC_1_8_5
ast.hpp common.hpp common_fwd.hpp typeof.hpp
Log Message:
recent changes to HEAD revision
Index: ast.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/spirit/tree/ast.hpp,v
retrieving revision 1.18
retrieving revision 1.18.4.1
diff -u -d -r1.18 -r1.18.4.1
--- ast.hpp 9 Feb 2006 23:10:00 -0000 1.18
+++ ast.hpp 31 Jan 2007 11:04:10 -0000 1.18.4.1
@@ -103,7 +103,9 @@
{
BOOST_SPIRIT_ASSERT(a.trees.size() == 1);
+#if !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES)
a.trees.begin()->children.reserve(a.trees.begin()->children.size()
+ b.trees.size());
+#endif
std::copy(b.trees.begin(),
b.trees.end(),
std::back_insert_iterator<container_t>(
@@ -111,7 +113,9 @@
}
else
{
+#if !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES)
a.trees.reserve(a.trees.size() + b.trees.size());
+#endif
std::copy(b.trees.begin(),
b.trees.end(),
std::back_insert_iterator<container_t>(a.trees));
Index: common.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/spirit/tree/common.hpp,v
retrieving revision 1.21
retrieving revision 1.21.2.1
diff -u -d -r1.21 -r1.21.2.1
--- common.hpp 28 Apr 2006 02:50:43 -0000 1.21
+++ common.hpp 31 Jan 2007 11:04:10 -0000 1.21.2.1
@@ -1,5 +1,6 @@
/*=============================================================================
Copyright (c) 2001-2003 Daniel Nuffer
+ Revised 2007, Copyright (c) Tobias Schwinger
http://spirit.sourceforge.net/
Use, modification and distribution is subject to the Boost Software
@@ -456,7 +457,7 @@
for (typename ContainerT::const_iterator i = nodes.begin();
i != i_end; ++i)
{
- // See docs: token_node_d or leaf_node_d cannot be used with a
+ // See docs: reduced_node_d cannot be used with a
// rule inside the [].
assert(i->children.size() == 0);
c.insert(c.end(), i->value.begin(), i->value.end());
@@ -500,8 +501,6 @@
for (typename ContainerT::const_iterator i = nodes.begin();
i != i_end; ++i)
{
- // See docs: token_node_d or leaf_node_d cannot be used with a
- // rule inside the [].
assert(i->children.size() == 0);
c.insert(c.end(), i->value.begin(), i->value.end());
}
@@ -560,9 +559,6 @@
tree_match(std::size_t length, parse_node_t const& n)
: match<T>(length), trees()
{
-#if !defined(BOOST_SPIRIT_USE_LIST_FOR_TREES)
- trees.reserve(10); // this is more or less an arbitrary number...
-#endif
trees.push_back(node_t(n));
}
@@ -851,7 +847,6 @@
}
};
-//////////////////////////////////
struct no_tree_gen_node_parser_gen
{
template <typename T>
@@ -875,9 +870,72 @@
}
};
-//////////////////////////////////
const no_tree_gen_node_parser_gen no_node_d = no_tree_gen_node_parser_gen();
+//////////////////////////////////
+
+struct leaf_node_parser_gen;
+
+template<typename T>
+struct leaf_node_parser
+: public unary<T, parser<leaf_node_parser<T> > >
+{
+ typedef leaf_node_parser<T> self_t;
+ typedef leaf_node_parser_gen parser_generator_t;
+ typedef unary_parser_category parser_category_t;
+
+ leaf_node_parser(T const& a)
+ : unary<T, parser<leaf_node_parser<T> > >(a) {}
+
+ template <typename ScannerT>
+ typename parser_result<self_t, ScannerT>::type
+ parse(ScannerT const& scanner) const
+ {
+ typedef scanner_policies< typename ScannerT::iteration_policy_t,
+ match_policy, typename ScannerT::action_policy_t > policies_t;
+
+ typedef typename ScannerT::iterator_t iterator_t;
+ typedef typename parser_result<self_t, ScannerT>::type result_t;
+ typedef typename result_t::node_factory_t factory_t;
+
+ iterator_t from = scanner.first;
+ result_t hit = impl::contiguous_parser_parse<result_t>(this->subject(),
+
scanner.change_policies(policies_t(scanner,match_policy(),scanner)),
+ scanner);
+
+ if (hit)
+ return result_t(hit.length(),
+ factory_t::create_node(from, scanner.first, true));
+ else
+ return result_t(hit.length());
+ }
+};
+
+struct leaf_node_parser_gen
+{
+ template <typename T>
+ struct result {
+
+ typedef leaf_node_parser<T> type;
+ };
+
+ template <typename T>
+ static leaf_node_parser<T>
+ generate(parser<T> const& s)
+ {
+ return leaf_node_parser<T>(s.derived());
+ }
+
+ template <typename T>
+ leaf_node_parser<T>
+ operator[](parser<T> const& s) const
+ {
+ return leaf_node_parser<T>(s.derived());
+ }
+};
+
+const leaf_node_parser_gen leaf_node_d = leaf_node_parser_gen();
+const leaf_node_parser_gen token_node_d = leaf_node_parser_gen();
//////////////////////////////////
namespace impl {
@@ -919,7 +977,6 @@
}
};
-//////////////////////////////////
template <typename NodeParserT>
struct node_parser_gen
{
@@ -943,20 +1000,8 @@
return node_parser<T, NodeParserT>(s.derived());
}
};
-
-struct discard_node_op
-{
- template <typename MatchT>
- void operator()(MatchT& m) const
- {
- m.trees.clear();
- }
-};
-
-const node_parser_gen<discard_node_op> discard_node_d =
- node_parser_gen<discard_node_op>();
-
-struct leaf_node_op
+//////////////////////////////////
+struct reduced_node_op
{
template <typename MatchT>
void operator()(MatchT& m) const
@@ -973,10 +1018,21 @@
}
};
-const node_parser_gen<leaf_node_op> leaf_node_d =
- node_parser_gen<leaf_node_op>();
-const node_parser_gen<leaf_node_op> token_node_d =
- node_parser_gen<leaf_node_op>();
+const node_parser_gen<reduced_node_op> reduced_node_d =
+ node_parser_gen<reduced_node_op>();
+
+
+struct discard_node_op
+{
+ template <typename MatchT>
+ void operator()(MatchT& m) const
+ {
+ m.trees.clear();
+ }
+};
+
+const node_parser_gen<discard_node_op> discard_node_d =
+ node_parser_gen<discard_node_op>();
struct infix_node_op
{
Index: common_fwd.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/spirit/tree/common_fwd.hpp,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -d -r1.1 -r1.1.4.1
--- common_fwd.hpp 9 Feb 2006 23:10:00 -0000 1.1
+++ common_fwd.hpp 31 Jan 2007 11:04:10 -0000 1.1.4.1
@@ -51,11 +51,14 @@
template <typename T>
struct no_tree_gen_node_parser;
+ template <typename T>
+ struct leaf_node_parser;
+
template <typename T, typename NodeParserT>
struct node_parser;
struct discard_node_op;
- struct leaf_node_op;
+ struct reduced_node_op;
struct infix_node_op;
struct discard_first_node_op;
struct discard_last_node_op;
Index: typeof.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/spirit/tree/typeof.hpp,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -u -d -r1.1 -r1.1.4.1
--- typeof.hpp 9 Feb 2006 23:10:48 -0000 1.1
+++ typeof.hpp 31 Jan 2007 11:04:10 -0000 1.1.4.1
@@ -33,9 +33,10 @@
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::spirit::common_tree_match_policy,4)
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::spirit::common_tree_tree_policy,2)
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::spirit::no_tree_gen_node_parser,1)
+BOOST_TYPEOF_REGISTER_TEMPLATE(boost::spirit::leaf_node_parser,1)
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::spirit::node_parser,2)
BOOST_TYPEOF_REGISTER_TYPE(boost::spirit::discard_node_op)
-BOOST_TYPEOF_REGISTER_TYPE(boost::spirit::leaf_node_op)
+BOOST_TYPEOF_REGISTER_TYPE(boost::spirit::reduced_node_op)
BOOST_TYPEOF_REGISTER_TYPE(boost::spirit::infix_node_op)
BOOST_TYPEOF_REGISTER_TYPE(boost::spirit::discard_first_node_op)
BOOST_TYPEOF_REGISTER_TYPE(boost::spirit::discard_last_node_op)
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs