2 // Copyright (c) 2007-2009 Ben Hanson (http://www.benhanson.net/)
4 // Distributed under the Boost Software License, Version 1.0. (See accompanying
5 // file licence_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifndef BOOST_LEXER_SELECTION_NODE_HPP
7 #define BOOST_LEXER_SELECTION_NODE_HPP
17 class selection_node : public node
20 selection_node (node *left_, node *right_) :
21 node (left_->nullable () || right_->nullable ()),
25 _left->append_firstpos (_firstpos);
26 _right->append_firstpos (_firstpos);
27 _left->append_lastpos (_lastpos);
28 _right->append_lastpos (_lastpos);
31 virtual ~selection_node ()
35 virtual type what_type () const
40 virtual bool traverse (const_node_stack &node_stack_,
41 bool_stack &perform_op_stack_) const
43 perform_op_stack_.push (true);
45 switch (_right->what_type ())
50 perform_op_stack_.push (false);
56 node_stack_.push (_right);
57 node_stack_.push (_left);
62 // Not owner of these pointers...
66 virtual void copy_node (node_ptr_vector &node_ptr_vector_,
67 node_stack &new_node_stack_, bool_stack &perform_op_stack_,
70 if (perform_op_stack_.top ())
72 node *rhs_ = new_node_stack_.top ();
74 new_node_stack_.pop ();
76 node *lhs_ = new_node_stack_.top ();
78 node_ptr_vector_->push_back (static_cast<selection_node *>(0));
79 node_ptr_vector_->back () = new selection_node (lhs_, rhs_);
80 new_node_stack_.top () = node_ptr_vector_->back ();
87 perform_op_stack_.pop ();
In the beginning the Universe was created. This has made a lot of
people very angry and has been widely regarded as a bad move.
Douglas Adams