Changeset 1981 for to-imperative/trunk/trefal
- Timestamp:
- May 24, 2006, 4:03:20 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
to-imperative/trunk/trefal/work/trf/trf_expr.hpp
r1922 r1981 17 17 18 18 /// Create an empty expression 19 Expr::Expr () {create_chunk(); }19 Expr::Expr () {create_chunk(); chunk->alloc(0);} 20 20 21 21 /// Create an expression with one term with integer value … … 110 110 inline bool is_empty() { return (this->get_len() == 0);} 111 111 112 /// Print expression 113 void Expr::print(FILE *fd){ 114 uint len = this->get_len(); 115 116 Term cur_trm; 117 for (uint i=0; i<len; i++){ 118 cur_trm = chunk->getData()[i]; 119 120 switch (cur_trm.type){ 121 case typeInt : 122 fprintf(fd, "%d", cur_trm.getInt()); 123 break; 124 case typeChar: 125 fprintf(fd, "%c", cur_trm.getChar()); 126 break; 127 case typeFloat: 128 fprintf(fd, "%f", cur_trm.getFloat()); 129 break; 130 case typeExpr: 131 fprintf(fd, "("); 132 cur_trm.getExpr()->print(fd); 133 fprintf(fd, ")"); 134 break; 135 case typeUninit: 136 fprintf(fd, "[empty]"); 137 break; 138 } 139 } 140 } 141 /// PrintLN expression 142 void Expr::println(FILE *fd){ 143 this->print(fd); 144 fprintf(fd, "\n"); 145 } 146 112 147 /// Print expression (for testing purposes) 113 void Expr:: print(){148 void Expr::my_print(){ 114 149 uint len = this->get_len(); 115 150 printf("Expr: size = %d val = ", len); … … 133 168 printf("("); 134 169 printf("\033[%um",0); 135 cur_trm.getExpr()-> print();170 cur_trm.getExpr()->my_print(); 136 171 printf("\033[%um\033[%um", 1, 36); 137 172 printf(")"); … … 147 182 /// Dump expression contents (recursive) 148 183 void dump(){ 149 this-> print();184 this->my_print(); 150 185 printf("\n"); 151 186 } … … 182 217 }; 183 218 219 Expr Expr_create_Integer(char *str){ 220 return Expr(atoi(str)); 221 }
Note: See TracChangeset
for help on using the changeset viewer.