Ejemplo n.º 1
0
static uint8_t	switch_case(t_buffer *dst, char c, va_list ap, t_flags *flag)
{
	if (c == 'd' || c == 'i')
		case_nbr(dst, ap, flag);
	else if (c == 'o')
		case_o(dst, ap, flag);
	else if (c == 'u')
		case_u(dst, ap, flag);
	else if (c == 'x')
		case_x(dst, ap, flag);
	else if (c == 'X')
		case_x_maj(dst, ap, flag);
	else if (c == 'p')
		case_p(dst, ap, flag);
	else if (c == 's')
		case_s(dst, ap, flag);
	else if (c == 'c')
		case_c(dst, ap, flag);
	else
		return (0);
	return (1);
}
Ejemplo n.º 2
0
void output_token(tokenizer_t t){
  // NO OUTPUT
  return;

  if(t == NULL){
    // printf("t == NULL\n");
  }
  if(t->tok.kind == TOK_ID){
    // printf("%d:TOK_ID (%s)\n", t->line, t->tok.name);
  }else if(t->tok.kind == TOK_INT_LITERAL){
    // printf("%d:TOK_INT_LITERAL (%d)\n", t->line, t->tok.ival);
  }else{
    // switch
    // #define case_x(k) case k: printf("%s\n", #k); break
    switch(t->tok.kind){
      case_x(TOK_INT);
      case_x(TOK_BREAK);
      case_x(TOK_CONTINUE);
      case_x(TOK_ELSE);
      case_x(TOK_IF);
      case_x(TOK_RETURN);
      case_x(TOK_WHILE);
      case_x(TOK_INT_LITERAL);
      case_x(TOK_ID);
      case_x(TOK_EOF);
      case_x(TOK_LPAREN);
      case_x(TOK_RPAREN);
      case_x(TOK_LBRACE);
      case_x(TOK_RBRACE);
      case_x(TOK_MUL);
      case_x(TOK_PLUS);
      case_x(TOK_MINUS);
      case_x(TOK_DIV);
      case_x(TOK_REM);
      case_x(TOK_BANG);
      case_x(TOK_LT);
      case_x(TOK_GT);
      case_x(TOK_LE);
      case_x(TOK_GE);
      case_x(TOK_EQ);
      case_x(TOK_NEQ);
      case_x(TOK_SEMICOLON);
      case_x(TOK_ASSIGN);
      case_x(TOK_COMMA);
   }    
  }
}