00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef lestes__lang__cplus__lex___basic_token_hh___included
00029 #define lestes__lang__cplus__lex___basic_token_hh___included
00030
00031
00032
00033
00034
00035
00036
00037 #include <lestes/common.hh>
00038 #include <lestes/equality.hh>
00039 #include <lestes/pointer_helpers.hh>
00040
00041 package(lestes);
00042 package(lang);
00043 package(cplus);
00044 package(lex);
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 template <typename Type, typename Location, typename Value>
00055 class basic_token: public ::lestes::std::object {
00056 public:
00057
00058 typedef typename convert<Type>::to_ptr type_type;
00059
00060 typedef typename convert<Value>::to_ptr value_type;
00061
00062 typedef typename convert<Location>::to_ptr location_type;
00063
00064 Type type_get(void) const;
00065
00066 Value value_get(void) const;
00067
00068 Location location_get(void) const;
00069
00070 bool equals(const ptr< basic_token<Type,Location,Value> > &rhs) const;
00071 protected:
00072
00073 basic_token(const Location &a_location, const Type &a_type, const Value &a_value);
00074
00075 virtual void gc_mark(void);
00076 private:
00077
00078 typename convert<Type>::to_srp type;
00079
00080 typename convert<Value>::to_srp value;
00081
00082 typename convert<Location>::to_srp location;
00083
00084 basic_token(const basic_token<Type,Location,Value> ©);
00085
00086 basic_token<Type,Location,Value> &operator=
00087 (const basic_token<Type,Location,Value> &rhs);
00088 };
00089
00090
00091
00092
00093
00094
00095
00096 template <typename Type, typename Location, typename Value>
00097 basic_token<Type,Location,Value>::basic_token(const Location &a_location,
00098 const Type &a_type, const Value &a_value):
00099 type(a_type),
00100 value(a_value),
00101 location(a_location)
00102 {
00103 }
00104
00105
00106
00107
00108
00109 template <typename Type, typename Location, typename Value>
00110 inline Type basic_token<Type,Location,Value>::type_get(void) const
00111 {
00112 return type;
00113 }
00114
00115
00116
00117
00118
00119 template <typename Type, typename Location, typename Value>
00120 inline Value basic_token<Type,Location,Value>::value_get(void) const
00121 {
00122 return value;
00123 }
00124
00125
00126
00127
00128
00129 template <typename Type, typename Location, typename Value>
00130 inline Location basic_token<Type,Location,Value>::location_get(void) const
00131 {
00132 return location;
00133 }
00134
00135
00136
00137
00138 template <typename Type, typename Location, typename Value>
00139 inline void basic_token<Type,Location,Value>::gc_mark(void)
00140 {
00141 gc_mark_srp(type);
00142 gc_mark_srp(location);
00143 gc_mark_srp(value);
00144
00145 ::lestes::std::object::gc_mark();
00146 }
00147
00148
00149
00150
00151
00152
00153 template <typename Type, typename Location, typename Value>
00154 bool basic_token<Type,Location,Value>::equals(
00155 const ptr< basic_token<Type,Location,Value> > &rhs) const
00156 {
00157 return
00158 is_equal(type,rhs->type_get()) &&
00159 is_equal(value,rhs->value_get()) &&
00160 is_equal(location,rhs->location_get());
00161 }
00162
00163 end_package(lex);
00164 end_package(cplus);
00165 end_package(lang);
00166 end_package(lestes);
00167 #endif
00168