File indexing completed on 2025-01-19 09:47:49
0001
0002
0003
0004
0005
0006 #ifndef BOOST_SPIRIT_SUPPORT_DETAIL_LEXER_PARSER_TREE_ITERATION_NODE_HPP
0007 #define BOOST_SPIRIT_SUPPORT_DETAIL_LEXER_PARSER_TREE_ITERATION_NODE_HPP
0008
0009 #include "node.hpp"
0010
0011 namespace boost
0012 {
0013 namespace lexer
0014 {
0015 namespace detail
0016 {
0017 class iteration_node : public node
0018 {
0019 public:
0020 iteration_node (node *next_, const bool greedy_) :
0021 node (true),
0022 _next (next_),
0023 _greedy (greedy_)
0024 {
0025 node_vector::iterator iter_;
0026 node_vector::iterator end_;
0027
0028 _next->append_firstpos (_firstpos);
0029 _next->append_lastpos (_lastpos);
0030
0031 for (iter_ = _lastpos.begin (), end_ = _lastpos.end ();
0032 iter_ != end_; ++iter_)
0033 {
0034 (*iter_)->append_followpos (_firstpos);
0035 }
0036
0037 for (iter_ = _firstpos.begin (), end_ = _firstpos.end ();
0038 iter_ != end_; ++iter_)
0039 {
0040 (*iter_)->greedy (greedy_);
0041 }
0042 }
0043
0044 virtual ~iteration_node ()
0045 {
0046 }
0047
0048 virtual type what_type () const
0049 {
0050 return ITERATION;
0051 }
0052
0053 virtual bool traverse (const_node_stack &node_stack_,
0054 bool_stack &perform_op_stack_) const
0055 {
0056 perform_op_stack_.push (true);
0057 node_stack_.push (_next);
0058 return true;
0059 }
0060
0061 private:
0062
0063 node *_next;
0064 bool _greedy;
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 *ptr_ = new_node_stack_.top ();
0073
0074 node_ptr_vector_->push_back (static_cast<iteration_node *>(0));
0075 node_ptr_vector_->back () = new iteration_node (ptr_, _greedy);
0076 new_node_stack_.top () = node_ptr_vector_->back ();
0077 }
0078 else
0079 {
0080 down_ = true;
0081 }
0082
0083 perform_op_stack_.pop ();
0084 }
0085 };
0086 }
0087 }
0088 }
0089
0090 #endif