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