
// this version only checks for integers

int is_number_token(int token) {
  int ch;
  int state;
  int done;
  int is_number;
  done = 0;
  is_number = 0;
  state = 0;
  while (!done) {
    if (token == 0)
      ch = 0;
    else {
      ch = MgetChar(kar(token));
      token = kdr(token);
    }

    if (state == 0) {
      if (ch == '-')
        state = 1;
      else if (isdigit(ch))
        state = 2;
      else
        done = 1;
    }
    else if (state == 1) {
      if (isdigit(ch))
        state = 2;
      else
        done = 1;
    }
    else if (state == 2) {
      if (isdigit(ch))
        state = 2;
      else if (ch == 0)
        state = 7;
      else
        done = 1;
    }
    else if (state == 7) {
      done = 1;
      is_number = 1;
    }
  }
  return is_number;
}
