stage4/generate_c/generate_c_base.cc
changeset 312 29add821207d
parent 308 833cb2eba36f
child 547 dab341e80664
equal deleted inserted replaced
311:8fcea60029de 312:29add821207d
   103       return NULL;
   103       return NULL;
   104     }
   104     }
   105 
   105 
   106     void *print_striped_token(token_c *token, int offset = 0) {
   106     void *print_striped_token(token_c *token, int offset = 0) {
   107       std::string str = "";
   107       std::string str = "";
   108       for (unsigned int i = offset; i < strlen(token->value); i++)
   108       bool leading_zero = true;
   109         if (token->value[i] != '_')
   109       for (unsigned int i = offset; i < strlen(token->value); i++) {
       
   110         if (leading_zero &&
       
   111         	(token->value[i] != '0' ||
       
   112         	 i == strlen(token->value) - 1 ||
       
   113         	 token->value[i + 1] == '.'
       
   114         	))
       
   115           leading_zero = false;
       
   116     	if (!leading_zero && token->value[i] != '_')
   110           str += token->value[i];
   117           str += token->value[i];
       
   118       }
   111       return s4o.printupper(str);
   119       return s4o.printupper(str);
   112     }
   120     }
   113 
   121 
   114     void *print_striped_binary_token(token_c *token, unsigned int offset = 0) {
   122     void *print_striped_binary_token(token_c *token, unsigned int offset = 0) {
   115       /* convert the binary value to hexadecimal format... */
   123       /* convert the binary value to hexadecimal format... */
   418   return NULL;
   426   return NULL;
   419 }
   427 }
   420 
   428 
   421 
   429 
   422 /* SYM_TOKEN(fixed_point_c) */
   430 /* SYM_TOKEN(fixed_point_c) */
   423 void *visit(fixed_point_c *symbol) {return print_token(symbol);}
   431 void *visit(fixed_point_c *symbol) {return print_striped_token(symbol);}
   424 
   432 
   425 
   433 
   426 /* SYM_REF2(days_c, days, hours) */
   434 /* SYM_REF2(days_c, days, hours) */
   427 void *visit(days_c *symbol) {
   435 void *visit(days_c *symbol) {
   428   TRACE("days_c");
   436   TRACE("days_c");