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
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef CBZ_OPERATORS_H
00038 #define CBZ_OPERATORS_H
00039
00040
00041
00042
00043 class Operator
00044 {
00045 public:
00046
00047 typedef enum {SIZEOF = 300,
00048 UPLUS,
00049 UMINUS,
00050 INDIR,
00051 ADDRESS,
00052 POSTINC,
00053 POSTDEC,
00054 PREINC,
00055 PREDEC,
00056 ARROW,
00057 ICR,
00058 DECR,
00059 LS,
00060 RS,
00061 LE,
00062 GE,
00063 EQ,
00064 NE,
00065 ANDAND,
00066 OROR,
00067 MULTassign,
00068 DIVassign,
00069 MODassign,
00070 PLUSassign,
00071 MINUSassign,
00072 LSassign,
00073 RSassign,
00074 ANDassign,
00075 ERassign,
00076 ORassign,
00077 Index
00078 } OperatorID;
00079
00080 private:
00081
00082 unsigned int _id;
00083 int _unary_prec;
00084 int _binary_prec;
00085 bool _is_left_assoc;
00086 string _name;
00087 string _print;
00088
00089 public:
00090
00091 Operator(unsigned int id, const char * print, const char * name,
00092 int unary_prec, int binary_prec,
00093 bool is_left_assoc = true)
00094 : _id(id),
00095 _unary_prec(unary_prec),
00096 _binary_prec(binary_prec),
00097 _is_left_assoc(true),
00098 _name(string(name)),
00099 _print(string(print))
00100 {}
00101
00102 inline unsigned int id() const { return _id; }
00103 inline int unary_prec() const { return _unary_prec; }
00104 inline int binary_prec() const { return _binary_prec; }
00105 inline bool is_left_assoc() const { return _is_left_assoc; }
00106 inline const string & name() const { return _name; }
00107 inline const string & print() const { return _print; }
00108
00109 bool is_assignment() const;
00110 bool is_arithmetic() const;
00111 bool is_comparison() const;
00112 };
00113
00114 typedef map<unsigned int, Operator *, less< unsigned int > > operator_map;
00115
00116 class Operators
00117 {
00118 public:
00119
00120 static operator_map table;
00121
00122 static void init();
00123 };
00124
00125
00126 #endif // CBZ_OPERATORS_H