351 public: |
351 public: |
352 calculate_time_c(void){time = 0;}; |
352 calculate_time_c(void){time = 0;}; |
353 |
353 |
354 unsigned long long get_time(void) {return time;}; |
354 unsigned long long get_time(void) {return time;}; |
355 |
355 |
|
356 /* NOTE: we should really remove this function, and replace it with extract_integer_value() (in absyntax_utils.h) |
|
357 * but right now I don't want to spend time checking if this change will introduce some conversion bug |
|
358 * since it returns a long long, and not a float! |
|
359 */ |
356 void *get_integer_value(token_c *token) { |
360 void *get_integer_value(token_c *token) { |
357 std::string str = ""; |
361 std::string str = ""; |
358 for (unsigned int i = 0; i < strlen(token->value); i++) |
362 for (unsigned int i = 0; i < strlen(token->value); i++) |
359 if (token->value[i] != '_') |
363 if (token->value[i] != '_') |
360 str += token->value[i]; |
364 str += token->value[i]; |
361 current_value = atof(str.c_str()); |
365 current_value = atof(str.c_str()); |
362 return NULL; |
366 return NULL; |
363 } |
367 } |
364 |
368 |
|
369 /* NOTE: this function is incomplete, as it should also be removing '_' inserted into the literal, |
|
370 * but we leave it for now. |
|
371 * In truth, we should really have an extract_real_value() in absyntax_util.h !!! |
|
372 */ |
365 void *get_float_value(token_c *token) { |
373 void *get_float_value(token_c *token) { |
366 current_value = atof(token->value); |
374 current_value = atof(token->value); |
367 return NULL; |
375 return NULL; |
368 } |
376 } |
369 |
377 |
386 } |
394 } |
387 |
395 |
388 /* SYM_TOKEN(fixed_point_c) */ |
396 /* SYM_TOKEN(fixed_point_c) */ |
389 void *visit(fixed_point_c *symbol) {return get_float_value(symbol);} |
397 void *visit(fixed_point_c *symbol) {return get_float_value(symbol);} |
390 |
398 |
391 /* SYM_REF2(days_c, days, hours) */ |
399 |
392 void *visit(days_c *symbol) { |
400 /* SYM_REF5(interval_c, days, hours, minutes, seconds, milliseconds) */ |
393 if (symbol->hours) |
401 void *visit(interval_c *symbol) { |
394 symbol->hours->accept(*this); |
402 current_value = 0; |
395 symbol->days->accept(*this); |
403 if (NULL != symbol->milliseconds) symbol->milliseconds->accept(*this); |
396 time += (unsigned long long)(current_value * 24 * 3600 * SECOND); |
404 time += (unsigned long long)(current_value * MILLISECOND); |
397 return NULL; |
405 |
398 } |
406 current_value = 0; |
399 |
407 if (NULL != symbol->seconds) symbol->seconds->accept(*this); |
400 /* SYM_REF2(hours_c, hours, minutes) */ |
408 time += (unsigned long long)(current_value * SECOND); |
401 void *visit(hours_c *symbol) { |
409 |
402 if (symbol->minutes) |
410 current_value = 0; |
403 symbol->minutes->accept(*this); |
411 if (NULL != symbol->minutes) symbol->minutes->accept(*this); |
404 symbol->hours->accept(*this); |
|
405 time += (unsigned long long)(current_value * 3600 * SECOND); |
|
406 return NULL; |
|
407 } |
|
408 |
|
409 /* SYM_REF2(minutes_c, minutes, seconds) */ |
|
410 void *visit(minutes_c *symbol) { |
|
411 if (symbol->seconds) |
|
412 symbol->seconds->accept(*this); |
|
413 symbol->minutes->accept(*this); |
|
414 time += (unsigned long long)(current_value * 60 * SECOND); |
412 time += (unsigned long long)(current_value * 60 * SECOND); |
415 return NULL; |
413 |
416 } |
414 current_value = 0; |
417 |
415 if (NULL != symbol->hours) symbol->hours->accept(*this); |
418 /* SYM_REF2(seconds_c, seconds, milliseconds) */ |
416 time += (unsigned long long)(current_value * 60 * 60 * SECOND); |
419 void *visit(seconds_c *symbol) { |
417 |
420 if (symbol->milliseconds) |
418 current_value = 0; |
421 symbol->milliseconds->accept(*this); |
419 if (NULL != symbol->days) symbol->days->accept(*this); |
422 symbol->seconds->accept(*this); |
420 time += (unsigned long long)(current_value * 60 * 60 * 24 * SECOND); |
423 time += (unsigned long long)(current_value * SECOND); |
421 |
424 return NULL; |
422 return NULL; |
425 } |
423 } |
426 |
|
427 /* SYM_REF2(milliseconds_c, milliseconds, unused) */ |
|
428 void *visit(milliseconds_c *symbol) { |
|
429 symbol->milliseconds->accept(*this); |
|
430 time += (unsigned long long)(current_value * MILLISECOND); |
|
431 return NULL; |
|
432 } |
|
433 }; |
424 }; |
434 |
425 |
435 /***********************************************************************/ |
426 /***********************************************************************/ |
436 /***********************************************************************/ |
427 /***********************************************************************/ |
437 /***********************************************************************/ |
428 /***********************************************************************/ |
789 } |
780 } |
790 |
781 |
791 /* signed_integer DOTDOT signed_integer */ |
782 /* signed_integer DOTDOT signed_integer */ |
792 //SYM_REF2(subrange_c, lower_limit, upper_limit) |
783 //SYM_REF2(subrange_c, lower_limit, upper_limit) |
793 void *visit(subrange_c *symbol) { |
784 void *visit(subrange_c *symbol) { |
794 int dimension = extract_integer(symbol->upper_limit) - extract_integer(symbol->lower_limit) + 1; |
785 int dimension = extract_integer_value(symbol->upper_limit) - extract_integer_value(symbol->lower_limit) + 1; |
795 switch (current_mode) { |
786 switch (current_mode) { |
796 case arrayname_im: |
787 case arrayname_im: |
797 current_array_name += "_"; |
788 current_array_name += "_"; |
798 { |
789 { |
799 std::stringstream ss; |
790 std::stringstream ss; |