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