stage4/generate_cc/generate_cc_base.cc
changeset 16 e8b99f896416
parent 0 fb772792efd1
child 26 fd67f54e64e1
equal deleted inserted replaced
15:0b472e25eb16 16:e8b99f896416
   170       r_exp->accept(*this);
   170       r_exp->accept(*this);
   171       s4o.print(")");
   171       s4o.print(")");
   172       return NULL;
   172       return NULL;
   173     }
   173     }
   174 
   174 
   175 
       
   176     void *print_unary_expression(symbol_c *exp,
   175     void *print_unary_expression(symbol_c *exp,
   177 				 const char *operation) {
   176 				 const char *operation) {
   178       s4o.print(operation);
   177       s4o.print(operation);
   179       s4o.print("(");
   178       s4o.print("(");
   180       exp->accept(*this);
   179       exp->accept(*this);
   181       s4o.print(")");
   180       s4o.print(")");
   182       return NULL;
   181       return NULL;
   183     }
   182     }
   184 
   183 
       
   184     void *print_binary_function(const char *function,
       
   185           symbol_c *l_exp,
       
   186 				  symbol_c *r_exp) {
       
   187       s4o.print(function);
       
   188       s4o.print("(");
       
   189       l_exp->accept(*this);
       
   190       s4o.print(", ");
       
   191       r_exp->accept(*this);
       
   192       s4o.print(")");
       
   193       return NULL;
       
   194    	}
       
   195 
       
   196     void *print_compare_function(const char *function,
       
   197           const char *compare_sign,
       
   198           symbol_c *l_exp,
       
   199           symbol_c *r_exp) {
       
   200       s4o.print(function);
       
   201       s4o.print("(");
       
   202       s4o.print(compare_sign);
       
   203       s4o.print(", ");
       
   204       l_exp->accept(*this);
       
   205       s4o.print(", ");
       
   206       r_exp->accept(*this);
       
   207       s4o.print(")");
       
   208       return NULL;
       
   209     }
   185 
   210 
   186 /***************************/
   211 /***************************/
   187 /* 2.1.6 - Pragmas */
   212 /* 2.1.6 - Pragmas */
   188 /***************************/
   213 /***************************/
   189     /* Do not use print_token() as it will change everything into uppercase */
   214     /* Do not use print_token() as it will change everything into uppercase */
   307 
   332 
   308 
   333 
   309 /* SYM_REF2(duration_c, neg, interval) */
   334 /* SYM_REF2(duration_c, neg, interval) */
   310 void *visit(duration_c *symbol) {
   335 void *visit(duration_c *symbol) {
   311   TRACE("duration_c");
   336   TRACE("duration_c");
   312   s4o.print("TIME(");
   337   s4o.print("__time_to_timespec(");
   313   if (NULL == symbol->neg)
   338   if (NULL == symbol->neg)
   314     s4o.print("1");  /* positive time value */
   339     s4o.print("1");  /* positive time value */
   315   else
   340   else
   316     symbol->neg->accept(*this);  /* this will print '-1'   :-) */
   341     symbol->neg->accept(*this);  /* this will print '-1'   :-) */
   317 
   342 
   318   s4o.print(", ");
   343   s4o.print(", ");
   319 
   344 
   320   symbol->interval->accept(*this);
   345   symbol->interval->accept(*this);
       
   346   if (typeid(*symbol->interval) == typeid(hours_c)) {s4o.print(", 0");}
       
   347   if (typeid(*symbol->interval) == typeid(minutes_c)) {s4o.print(", 0, 0");}
       
   348   if (typeid(*symbol->interval) == typeid(seconds_c)) {s4o.print(", 0, 0, 0");}
       
   349   if (typeid(*symbol->interval) == typeid(milliseconds_c)) {s4o.print(", 0, 0, 0, 0");}
   321   s4o.print(")");
   350   s4o.print(")");
   322   return NULL;
   351   return NULL;
   323 }
   352 }
   324 
   353 
   325 
   354 
   399 /************************************/
   428 /************************************/
   400 
   429 
   401 /* SYM_REF2(time_of_day_c, daytime, unused) */
   430 /* SYM_REF2(time_of_day_c, daytime, unused) */
   402 void *visit(time_of_day_c *symbol) {
   431 void *visit(time_of_day_c *symbol) {
   403   TRACE("time_of_day_c");
   432   TRACE("time_of_day_c");
   404   s4o.print("TOD(");
   433   s4o.print("__tod_to_timespec(");
   405   symbol->daytime->accept(*this);
   434   symbol->daytime->accept(*this);
   406   s4o.print(")");
   435   s4o.print(")");
   407   return NULL;
   436   return NULL;
   408 }
   437 }
   409 
   438 
   421 
   450 
   422 
   451 
   423 /* SYM_REF2(date_c, date_literal, unused) */
   452 /* SYM_REF2(date_c, date_literal, unused) */
   424 void *visit(date_c *symbol) {
   453 void *visit(date_c *symbol) {
   425   TRACE("date_c");
   454   TRACE("date_c");
   426   s4o.print("DATE(");
   455   s4o.print("__date_to_timespec(");
   427   symbol->date_literal->accept(*this);
   456   symbol->date_literal->accept(*this);
   428   s4o.print(")");
   457   s4o.print(")");
   429   return NULL;
   458   return NULL;
   430 }
   459 }
   431 
   460 
   443 
   472 
   444 
   473 
   445 /* SYM_REF2(date_and_time_c, date_literal, daytime) */
   474 /* SYM_REF2(date_and_time_c, date_literal, daytime) */
   446 void *visit(date_and_time_c *symbol) {
   475 void *visit(date_and_time_c *symbol) {
   447   TRACE("date_and_time_c");
   476   TRACE("date_and_time_c");
   448   s4o.print("DT(");
   477   s4o.print("__dt_to_timespec(");
   449   symbol->daytime->accept(*this);
   478   symbol->daytime->accept(*this);
   450   s4o.print(", ");
   479   s4o.print(", ");
   451   symbol->date_literal->accept(*this);
   480   symbol->date_literal->accept(*this);
   452   s4o.print(")");
   481   s4o.print(")");
   453   return NULL;
   482   return NULL;