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_SEQUENCE_NODE_HPP
7 #define BOOST_LEXER_SEQUENCE_NODE_HPP
17 class sequence_node : public node
20 sequence_node (node *left_, node *right_) :
21 node (left_->nullable () && right_->nullable ()),
25 _left->append_firstpos (_firstpos);
27 if (_left->nullable ())
29 _right->append_firstpos (_firstpos);
32 if (_right->nullable ())
34 _left->append_lastpos (_lastpos);
37 _right->append_lastpos (_lastpos);
39 node_vector &lastpos_ = _left->lastpos ();
40 const node_vector &firstpos_ = _right->firstpos ();
42 for (node_vector::iterator iter_ = lastpos_.begin (),
43 end_ = lastpos_.end (); iter_ != end_; ++iter_)
45 (*iter_)->append_followpos (firstpos_);
49 virtual ~sequence_node ()
53 virtual type what_type () const
58 virtual bool traverse (const_node_stack &node_stack_,
59 bool_stack &perform_op_stack_) const
61 perform_op_stack_.push (true);
63 switch (_right->what_type ())
68 perform_op_stack_.push (false);
74 node_stack_.push (_right);
75 node_stack_.push (_left);
80 // Not owner of these pointers...
84 virtual void copy_node (node_ptr_vector &node_ptr_vector_,
85 node_stack &new_node_stack_, bool_stack &perform_op_stack_,
88 if (perform_op_stack_.top ())
90 node *rhs_ = new_node_stack_.top ();
92 new_node_stack_.pop ();
94 node *lhs_ = new_node_stack_.top ();
96 node_ptr_vector_->push_back (static_cast<sequence_node *>(0));
97 node_ptr_vector_->back () = new sequence_node (lhs_, rhs_);
98 new_node_stack_.top () = node_ptr_vector_->back ();
105 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