ucc.c
Token *tokenize(char *p) {
  Token head;
  head.next = NULL;
  Token *cur = &head;

  while (*p) {
    if (isspace(*p)) {
      p++;
      continue;
    }

    if (*p == '+' || *p == '-') {
      cur = new_token(TK_RESERVED, cur, p++);
      continue;
    }

    if (isdigit(*p)) {
      cur = new_token(TK_NUM, cur, p);
      cur->val = strtol(p, &p, 10);
      continue;
    }

    error("Cannot tokenize");
  }

  new_token(TK_EOF, cur, p);
  return (head.next);
}
// Tokenize input char p then return it
Tokenize input char p then return it
Tokenize input char p then return it
Token *tokenize(char *p) {
  Token head;
  head.next = NULL;
  Token *cur = &head;
  while (*p) {
    if (isspace(*p)) {
      p++;
      continue;
    }
    if (*p == '+' || *p == '-') {
      cur = new_token(TK_RESERVED, cur, p++);
      continue;
    }
    if (isdigit(*p)) {
      cur = new_token(TK_NUM, cur, p);
      cur->val = strtol(p, &p, 10);
      continue;
    }
    error("Cannot tokenize");
  }
  new_token(TK_EOF, cur, p);
  return (head.next);
}
Token * tokenize ( char * p ) { Token head ; head . next = NULL ; Token * cur = & head ; while ( * p ) { if ( isspace ( * p ) ) { p ++ ; continue ; } if ( * p == ' ' || * p == ' ' ) { cur = new_token ( TK_RESERVED , cur , p ++ ) ; continue ; } if ( isdigit ( * p ) ) { cur = new_token ( TK_NUM , cur , p ) ; cur -> val = strtol ( p , & p , 10 ) ; continue ; } error ( " " ) ; } new_token ( TK_EOF , cur , p ) ; return ( head . next ) ; }
Tokenize input char p then return it
Tokenize input char p then return it