|
||
Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages
operators.hGo to the documentation of this file.00001 // $Id: operators.h,v 1.7 2003/08/07 23:13:10 pnav Exp $ 00002 // ---------------------------------------------------------------------- 00003 // 00004 // C-Breeze 00005 // C Compiler Framework 00006 // 00007 // Copyright (c) 2000 University of Texas at Austin 00008 // 00009 // Samuel Z. Guyer 00010 // Daniel A. Jimenez 00011 // Calvin Lin 00012 // 00013 // Permission is hereby granted, free of charge, to any person 00014 // obtaining a copy of this software and associated documentation 00015 // files (the "Software"), to deal in the Software without 00016 // restriction, including without limitation the rights to use, copy, 00017 // modify, merge, publish, distribute, sublicense, and/or sell copies 00018 // of the Software, and to permit persons to whom the Software is 00019 // furnished to do so, subject to the following conditions: 00020 // 00021 // The above copyright notice and this permission notice shall be 00022 // included in all copies or substantial portions of the Software. 00023 // 00024 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00025 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00026 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00027 // NONINFRINGEMENT. IN NO EVENT SHALL THE UNIVERSITY OF TEXAS AT 00028 // AUSTIN BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 00029 // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 00030 // OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00031 // THE SOFTWARE. 00032 // 00033 // We acknowledge the C-to-C Translator from MIT Laboratory for 00034 // Computer Science for inspiring parts of the C-Breeze design. 00035 // 00036 // ---------------------------------------------------------------------- 00037 00038 #ifndef CBZ_OPERATORS_H 00039 #define CBZ_OPERATORS_H 00040 00041 // The following values have been defined so that we can separate the 00042 // representation of the AST from any particular aspect of the parser. 00043 00044 class Operator 00045 { 00046 public: 00047 00048 typedef enum {SIZEOF = 300, // Make sure we are past regular chars 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 |
Generated on February 1, 2006
Back to the C-Breeze home page