311 * integer {digit}((_?{digit})*) |
311 * integer {digit}((_?{digit})*) |
312 */ |
312 */ |
313 real64_t extract_real_value(symbol_c *sym, bool *overflow) { |
313 real64_t extract_real_value(symbol_c *sym, bool *overflow) { |
314 std::string str = ""; |
314 std::string str = ""; |
315 real_c *real_sym; |
315 real_c *real_sym; |
|
316 fixed_point_c *fixed_point_sym; |
316 char *endptr; |
317 char *endptr; |
317 real64_t ret; |
318 real64_t ret; |
318 |
319 |
319 if ((real_sym = dynamic_cast<real_c *>(sym)) == NULL) ERROR; |
320 if ((real_sym = dynamic_cast<real_c *>(sym)) != NULL) { |
320 for(unsigned int i = 0; i < strlen(real_sym->value); i++) |
321 for(unsigned int i = 0; i < strlen(real_sym->value); i++) |
321 if (real_sym->value[i] != '_') str += real_sym->value[i]; |
322 if (real_sym->value[i] != '_') str += real_sym->value[i]; |
|
323 } |
|
324 else if ((fixed_point_sym = dynamic_cast<fixed_point_c *>(sym)) != NULL) { |
|
325 for(unsigned int i = 0; i < strlen(fixed_point_sym->value); i++) |
|
326 if (fixed_point_sym->value[i] != '_') str += fixed_point_sym->value[i]; |
|
327 } |
|
328 else ERROR; |
322 |
329 |
323 errno = 0; // since strtoXX() may legally return 0, we must set errno to 0 to detect errors correctly! |
330 errno = 0; // since strtoXX() may legally return 0, we must set errno to 0 to detect errors correctly! |
324 #if (real64_t == float) |
331 #if (real64_t == float) |
325 ret = strtof(str.c_str(), &endptr); |
332 ret = strtof(str.c_str(), &endptr); |
326 #elif (real64_t == double) |
333 #elif (real64_t == double) |
833 void *constant_folding_c::visit(boolean_false_c *symbol) { |
840 void *constant_folding_c::visit(boolean_false_c *symbol) { |
834 SET_CVALUE(bool, symbol, false); |
841 SET_CVALUE(bool, symbol, false); |
835 return NULL; |
842 return NULL; |
836 } |
843 } |
837 |
844 |
838 |
845 /************************/ |
|
846 /* B 1.2.3.1 - Duration */ |
|
847 /********* **************/ |
|
848 void *constant_folding_c::visit(fixed_point_c *symbol) { |
|
849 bool overflow; |
|
850 SET_CVALUE(real64, symbol, extract_real_value(symbol, &overflow)); |
|
851 if (overflow) SET_OVFLOW(real64, symbol); |
|
852 return NULL; |
|
853 } |
839 |
854 |
840 |
855 |
841 |
856 |
842 /****************************************/ |
857 /****************************************/ |
843 /* B.2 - Language IL (Instruction List) */ |
858 /* B.2 - Language IL (Instruction List) */ |