1 // end_node.hpp 2 // Copyright (c) 2007-2009 Ben Hanson (http://www.benhanson.net/) 3 // 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_SPIRIT_SUPPORT_DETAIL_LEXER_PARSER_TREE_END_NODE_HPP 7 #define BOOST_SPIRIT_SUPPORT_DETAIL_LEXER_PARSER_TREE_END_NODE_HPP 8 9 #include "node.hpp" 10 #include "../../size_t.hpp" 11 12 namespace boost 13 { 14 namespace lexer 15 { 16 namespace detail 17 { 18 class end_node : public node 19 { 20 public: end_node(const std::size_t id_,const std::size_t unique_id_,const std::size_t lexer_state_)21 end_node (const std::size_t id_, const std::size_t unique_id_, 22 const std::size_t lexer_state_) : 23 node (false), 24 _id (id_), 25 _unique_id (unique_id_), 26 _lexer_state (lexer_state_) 27 { 28 node::_firstpos.push_back (this); 29 node::_lastpos.push_back (this); 30 } 31 ~end_node()32 virtual ~end_node () 33 { 34 } 35 what_type() const36 virtual type what_type () const 37 { 38 return END; 39 } 40 traverse(const_node_stack &,bool_stack &) const41 virtual bool traverse (const_node_stack &/*node_stack_*/, 42 bool_stack &/*perform_op_stack_*/) const 43 { 44 return false; 45 } 46 followpos() const47 virtual const node_vector &followpos () const 48 { 49 // _followpos is always empty..! 50 return _followpos; 51 } 52 end_state() const53 virtual bool end_state () const 54 { 55 return true; 56 } 57 id() const58 virtual std::size_t id () const 59 { 60 return _id; 61 } 62 unique_id() const63 virtual std::size_t unique_id () const 64 { 65 return _unique_id; 66 } 67 lexer_state() const68 virtual std::size_t lexer_state () const 69 { 70 return _lexer_state; 71 } 72 73 private: 74 std::size_t _id; 75 std::size_t _unique_id; 76 std::size_t _lexer_state; 77 node_vector _followpos; 78 copy_node(node_ptr_vector &,node_stack &,bool_stack &,bool &) const79 virtual void copy_node (node_ptr_vector &/*node_ptr_vector_*/, 80 node_stack &/*new_node_stack_*/, bool_stack &/*perform_op_stack_*/, 81 bool &/*down_*/) const 82 { 83 // Nothing to do, as end_nodes are not copied. 84 } 85 }; 86 } 87 } 88 } 89 90 #endif 91