DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
/*============================================================================= Copyright (c) 2001-2003 Daniel Nuffer Copyright (c) 2001-2007 Hartmut Kaiser http://spirit.sourceforge.net/ Use, modification and distribution is subject to the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef BOOST_SPIRIT_TREE_AST_HPP #define BOOST_SPIRIT_TREE_AST_HPP #include
#include
#include
/////////////////////////////////////////////////////////////////////////////// namespace boost { namespace spirit { ////////////////////////////////// // ast_match_policy is simply an id so the correct specialization of // tree_policy can be found. template < typename IteratorT, typename NodeFactoryT, typename T > struct ast_match_policy : public common_tree_match_policy< ast_match_policy
, IteratorT, NodeFactoryT, ast_tree_policy< ast_match_policy
, NodeFactoryT, T >, T > { typedef common_tree_match_policy< ast_match_policy
, IteratorT, NodeFactoryT, ast_tree_policy< ast_match_policy
, NodeFactoryT, T >, T > common_tree_match_policy_; ast_match_policy() { } template
ast_match_policy(PolicyT const & policies) : common_tree_match_policy_(policies) { } }; ////////////////////////////////// template
struct ast_tree_policy : public common_tree_tree_policy
{ typedef typename MatchPolicyT::match_t match_t; typedef typename MatchPolicyT::iterator_t iterator_t; template
static void concat(MatchAT& a, MatchBT const& b) { BOOST_SPIRIT_ASSERT(a && b); #if defined(BOOST_SPIRIT_DEBUG) && \ (BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES) BOOST_SPIRIT_DEBUG_OUT << "\n>>>AST concat. a = " << a << "\n\tb = " << b << "<<<\n"; #endif typedef typename tree_match
::container_t container_t; // test for size() is nessecary, because no_tree_gen_node leaves a.trees // and/or b.trees empty if (0 != b.trees.size() && b.trees.begin()->value.is_root()) { BOOST_SPIRIT_ASSERT(b.trees.size() == 1); container_t tmp; std::swap(a.trees, tmp); // save a into tmp std::swap(b.trees, a.trees); // make b.trees[0] be new root (a.trees[0]) container_t* pnon_root_trees = &a.trees; while (pnon_root_trees->size() > 0 && pnon_root_trees->begin()->value.is_root()) { pnon_root_trees = & pnon_root_trees->begin()->children; } pnon_root_trees->insert(pnon_root_trees->begin(), tmp.begin(), tmp.end()); } else if (0 != a.trees.size() && a.trees.begin()->value.is_root()) { 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
( a.trees.begin()->children)); } 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
(a.trees)); } #if defined(BOOST_SPIRIT_DEBUG) && \ (BOOST_SPIRIT_DEBUG_FLAGS & BOOST_SPIRIT_DEBUG_FLAGS_NODES) BOOST_SPIRIT_DEBUG_OUT << ">>>after AST concat. a = " << a << "<<<\n\n"; #endif return; } template
static void group_match(MatchT& m, parser_id const& id, Iterator1T const& first, Iterator2T const& last) { if (!m) return; typedef typename tree_match
::container_t container_t; typedef typename container_t::iterator cont_iterator_t; typedef typename NodeFactoryT::template factory
factory_t; if (m.trees.size() == 1 #ifdef BOOST_SPIRIT_NO_TREE_NODE_COLLAPSING && !(id.to_long() && m.trees.begin()->value.id().to_long()) #endif ) { // set rule_id's. There may have been multiple nodes created. // Because of root_node[] they may be left-most children of the top // node. container_t* punset_id = &m.trees; while (punset_id->size() > 0 && punset_id->begin()->value.id() == 0) { punset_id->begin()->value.id(id); punset_id = &punset_id->begin()->children; } m.trees.begin()->value.is_root(false); } else { match_t newmatch(m.length(), m.trees.empty() ? factory_t::empty_node() : factory_t::create_node(first, last, false)); std::swap(newmatch.trees.begin()->children, m.trees); // set this node and all it's unset children's rule_id newmatch.trees.begin()->value.id(id); for (cont_iterator_t i = newmatch.trees.begin(); i != newmatch.trees.end(); ++i) { if (i->value.id() == 0) i->value.id(id); } m = newmatch; } } template
static void apply_op_to_match(FunctorT const& op, MatchT& m) { op(m); } }; namespace impl { template
struct tree_policy_selector
> { typedef ast_tree_policy< ast_match_policy
, NodeFactoryT, T > type; }; } // namespace impl ////////////////////////////////// struct gen_ast_node_parser_gen; template
struct gen_ast_node_parser : public unary
> > { typedef gen_ast_node_parser
self_t; typedef gen_ast_node_parser_gen parser_generator_t; typedef unary_parser_category parser_category_t; gen_ast_node_parser(T const& a) : unary
> >(a) {} template
typename parser_result
::type parse(ScannerT const& scan) const { typedef typename ScannerT::iteration_policy_t iteration_policy_t; typedef typename ScannerT::match_policy_t::iterator_t iterator_t; typedef typename ScannerT::match_policy_t::factory_t factory_t; typedef ast_match_policy
match_policy_t; typedef typename ScannerT::action_policy_t action_policy_t; typedef scanner_policies< iteration_policy_t, match_policy_t, action_policy_t > policies_t; return this->subject().parse(scan.change_policies(policies_t(scan))); } }; ////////////////////////////////// struct gen_ast_node_parser_gen { template
struct result { typedef gen_ast_node_parser
type; }; template
static gen_ast_node_parser
generate(parser
const& s) { return gen_ast_node_parser
(s.derived()); } template
gen_ast_node_parser
operator[](parser
const& s) const { return gen_ast_node_parser
(s.derived()); } }; ////////////////////////////////// const gen_ast_node_parser_gen gen_ast_node_d = gen_ast_node_parser_gen(); ////////////////////////////////// struct root_node_op { template
void operator()(MatchT& m) const { BOOST_SPIRIT_ASSERT(m.trees.size() > 0); m.trees.begin()->value.is_root(true); } }; const node_parser_gen
root_node_d = node_parser_gen
(); /////////////////////////////////////////////////////////////////////////////// // // Parse functions for ASTs // /////////////////////////////////////////////////////////////////////////////// template < typename AstFactoryT, typename IteratorT, typename ParserT, typename SkipT > inline tree_parse_info
ast_parse( IteratorT const& first_, IteratorT const& last_, parser
const& parser, SkipT const& skip_, AstFactoryT const & /*dummy_*/ = AstFactoryT()) { typedef skip_parser_iteration_policy
iter_policy_t; typedef ast_match_policy
ast_match_policy_t; typedef scanner_policies
scanner_policies_t; typedef scanner
scanner_t; iter_policy_t iter_policy(skip_); scanner_policies_t policies(iter_policy); IteratorT first = first_; scanner_t scan(first, last_, policies); tree_match
hit = parser.derived().parse(scan); return tree_parse_info
( first, hit, hit && (first == last_), hit.length(), hit.trees); } ////////////////////////////////// template
inline tree_parse_info
ast_parse( IteratorT const& first_, IteratorT const& last_, parser
const& parser, SkipT const& skip_) { typedef node_val_data_factory
default_factory_t; return ast_parse(first_, last_, parser, skip_, default_factory_t()); } ////////////////////////////////// template
inline tree_parse_info
ast_parse( IteratorT const& first_, IteratorT const& last, parser
const& parser) { typedef ast_match_policy
ast_match_policy_t; IteratorT first = first_; scanner< IteratorT, scanner_policies
> scan(first, last); tree_match
hit = parser.derived().parse(scan); return tree_parse_info
( first, hit, hit && (first == last), hit.length(), hit.trees); } ////////////////////////////////// template
inline tree_parse_info
ast_parse( CharT const* str, parser
const& parser, SkipT const& skip) { CharT const* last = str; while (*last) last++; return ast_parse(str, last, parser, skip); } ////////////////////////////////// template
inline tree_parse_info
ast_parse( CharT const* str, parser
const& parser) { CharT const* last = str; while (*last) { last++; } return ast_parse(str, last, parser); } /////////////////////////////////////////////////////////////////////////////// }} // namespace boost::spirit #endif
ast.hpp
Page URL
File URL
Prev 1/10
Next
Download
( 11 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.