stage4/generate_c/generate_c_base.cc
changeset 547 dab341e80664
parent 312 29add821207d
child 594 c8092e909886
equal deleted inserted replaced
546:8cc4c51c4bfc 547:dab341e80664
   408 
   408 
   409 /* SYM_REF2(duration_c, neg, interval) */
   409 /* SYM_REF2(duration_c, neg, interval) */
   410 void *visit(duration_c *symbol) {
   410 void *visit(duration_c *symbol) {
   411   TRACE("duration_c");
   411   TRACE("duration_c");
   412   s4o.print("__time_to_timespec(");
   412   s4o.print("__time_to_timespec(");
   413   if (NULL == symbol->neg)
   413   
   414     s4o.print("1");  /* positive time value */
   414   if (NULL == symbol->neg)    s4o.print("1");  /* positive time value */
   415   else
   415   else                        symbol->neg->accept(*this);  /* this will print '-1'   :-) */
   416     symbol->neg->accept(*this);  /* this will print '-1'   :-) */
   416 
   417 
   417   s4o.print(", ");
   418   s4o.print(", ");
       
   419 
       
   420   symbol->interval->accept(*this);
   418   symbol->interval->accept(*this);
   421   if (typeid(*symbol->interval) == typeid(hours_c)) {s4o.print(", 0");}
       
   422   if (typeid(*symbol->interval) == typeid(minutes_c)) {s4o.print(", 0, 0");}
       
   423   if (typeid(*symbol->interval) == typeid(seconds_c)) {s4o.print(", 0, 0, 0");}
       
   424   if (typeid(*symbol->interval) == typeid(milliseconds_c)) {s4o.print(", 0, 0, 0, 0");}
       
   425   s4o.print(")");
   419   s4o.print(")");
   426   return NULL;
   420   return NULL;
   427 }
   421 }
   428 
   422 
   429 
   423 
   430 /* SYM_TOKEN(fixed_point_c) */
   424 /* SYM_TOKEN(fixed_point_c) */
   431 void *visit(fixed_point_c *symbol) {return print_striped_token(symbol);}
   425 void *visit(fixed_point_c *symbol) {return print_striped_token(symbol);}
   432 
   426 
   433 
   427 /* SYM_REF5(interval_c, days, hours, minutes, seconds, milliseconds) */
   434 /* SYM_REF2(days_c, days, hours) */
   428 void *visit(interval_c *symbol) {
   435 void *visit(days_c *symbol) {
   429   TRACE("interval_c");
   436   TRACE("days_c");
   430   /* s4o.print("0, 0, 0, 0, 0");  // milliseconds, seconds, minutes, hours, days */
   437   if (NULL == symbol->hours)
   431   if (NULL == symbol->milliseconds) s4o.print("0");  /* milliseconds */
   438     s4o.print("0, 0, 0, 0");  /* milliseconds, seconds, minutes, hours */
   432   else                              symbol->milliseconds->accept(*this);
   439   else
   433   s4o.print(", ");
   440     symbol->hours->accept(*this);
   434 
   441 
   435   if (NULL == symbol->seconds)      s4o.print("0");  /* seconds */
   442   s4o.print(", ");
   436   else                              symbol->seconds->accept(*this);
   443 
   437   s4o.print(", ");
   444   symbol->days->accept(*this);
   438 
   445   return NULL;
   439   if (NULL == symbol->minutes)      s4o.print("0");  /* minutes */
   446 }
   440   else                              symbol->minutes->accept(*this);
   447 
   441   s4o.print(", ");
   448 
   442 
   449 /* SYM_REF2(hours_c, hours, minutes) */
   443   if (NULL == symbol->hours)        s4o.print("0");  /* hours */
   450 void *visit(hours_c *symbol) {
   444   else                              symbol->hours->accept(*this);
   451   TRACE("hours_c");
   445   s4o.print(", ");
   452   if (NULL == symbol->minutes)
   446 
   453     s4o.print("0, 0, 0");  /* milliseconds, seconds, minutes */
   447   if (NULL == symbol->days)         s4o.print("0");  /* days */
   454   else
   448   else                              symbol->days->accept(*this);
   455     symbol->minutes->accept(*this);
   449 
   456 
   450   return NULL;
   457   s4o.print(", ");
   451 }
   458 
   452 
   459   symbol->hours->accept(*this);
       
   460   return NULL;
       
   461 }
       
   462 
       
   463 
       
   464 /* SYM_REF2(minutes_c, minutes, seconds) */
       
   465 void *visit(minutes_c *symbol) {
       
   466   TRACE("minutes_c");
       
   467   if (NULL == symbol->seconds)
       
   468     s4o.print("0, 0");  /* milliseconds, seconds */
       
   469   else
       
   470     symbol->seconds->accept(*this);
       
   471 
       
   472   s4o.print(", ");
       
   473 
       
   474   symbol->minutes->accept(*this);
       
   475   return NULL;
       
   476 }
       
   477 
       
   478 
       
   479 /* SYM_REF2(seconds_c, seconds, milliseconds) */
       
   480 void *visit(seconds_c *symbol) {
       
   481   TRACE("seconds_c");
       
   482   if (NULL == symbol->milliseconds)
       
   483     s4o.print("0");  /* milliseconds */
       
   484   else
       
   485     symbol->milliseconds->accept(*this);
       
   486 
       
   487   s4o.print(", ");
       
   488 
       
   489   symbol->seconds->accept(*this);
       
   490   return NULL;
       
   491 }
       
   492 
       
   493 
       
   494 /* SYM_REF2(milliseconds_c, milliseconds, unused) */
       
   495 void *visit(milliseconds_c *symbol) {
       
   496   TRACE("milliseconds_c");
       
   497   symbol->milliseconds->accept(*this);
       
   498   return NULL;
       
   499 }
       
   500 
   453 
   501 /************************************/
   454 /************************************/
   502 /* B 1.2.3.2 - Time of day and Date */
   455 /* B 1.2.3.2 - Time of day and Date */
   503 /************************************/
   456 /************************************/
   504 
   457