File indexing completed on 2025-01-19 09:47:49
0001
0002
0003
0004
0005
0006 #ifndef BOOST_SPIRIT_SUPPORT_DETAIL_LEXER_PARSER_TREE_SEQUENCE_NODE_HPP
0007 #define BOOST_SPIRIT_SUPPORT_DETAIL_LEXER_PARSER_TREE_SEQUENCE_NODE_HPP
0008
0009 #include "node.hpp"
0010
0011 namespace boost
0012 {
0013 namespace lexer
0014 {
0015 namespace detail
0016 {
0017 class sequence_node : public node
0018 {
0019 public:
0020 sequence_node (node *left_, node *right_) :
0021 node (left_->nullable () && right_->nullable ()),
0022 _left (left_),
0023 _right (right_)
0024 {
0025 _left->append_firstpos (_firstpos);
0026
0027 if (_left->nullable ())
0028 {
0029 _right->append_firstpos (_firstpos);
0030 }
0031
0032 if (_right->nullable ())
0033 {
0034 _left->append_lastpos (_lastpos);
0035 }
0036
0037 _right->append_lastpos (_lastpos);
0038
0039 node_vector &lastpos_ = _left->lastpos ();
0040 const node_vector &firstpos_ = _right->firstpos ();
0041
0042 for (node_vector::iterator iter_ = lastpos_.begin (),
0043 end_ = lastpos_.end (); iter_ != end_; ++iter_)
0044 {
0045 (*iter_)->append_followpos (firstpos_);
0046 }
0047 }
0048
0049 virtual ~sequence_node ()
0050 {
0051 }
0052
0053 virtual type what_type () const
0054 {
0055 return SEQUENCE;
0056 }
0057
0058 virtual bool traverse (const_node_stack &node_stack_,
0059 bool_stack &perform_op_stack_) const
0060 {
0061 perform_op_stack_.push (true);
0062
0063 switch (_right->what_type ())
0064 {
0065 case SEQUENCE:
0066 case SELECTION:
0067 case ITERATION:
0068 perform_op_stack_.push (false);
0069 break;
0070 default:
0071 break;
0072 }
0073
0074 node_stack_.push (_right);
0075 node_stack_.push (_left);
0076 return true;
0077 }
0078
0079 private:
0080
0081 node *_left;
0082 node *_right;
0083
0084 virtual void copy_node (node_ptr_vector &node_ptr_vector_,
0085 node_stack &new_node_stack_, bool_stack &perform_op_stack_,
0086 bool &down_) const
0087 {
0088 if (perform_op_stack_.top ())
0089 {
0090 node *rhs_ = new_node_stack_.top ();
0091
0092 new_node_stack_.pop ();
0093
0094 node *lhs_ = new_node_stack_.top ();
0095
0096 node_ptr_vector_->push_back (static_cast<sequence_node *>(0));
0097 node_ptr_vector_->back () = new sequence_node (lhs_, rhs_);
0098 new_node_stack_.top () = node_ptr_vector_->back ();
0099 }
0100 else
0101 {
0102 down_ = true;
0103 }
0104
0105 perform_op_stack_.pop ();
0106 }
0107 };
0108 }
0109 }
0110 }
0111
0112 #endif