void append_e0(int token) {
  int token_tail;
  token_tail = last(token);
  rplacd(token_tail, kons(MmakeChar('e'), kons(MmakeChar('0'), 0)));
  return;
}

// this version checks for floats and integers

int is_number_token(int token) {
  int ch;
  int state;
  int has_decimal;
  int has_e;
  int save_token;
  int processing;
  int ret;

  save_token = token;
  state = 0;
  // if we have a float number without exponent we will
  // append "e0" to the token
  has_decimal = 0;
  has_e = 0;

  processing = 1;
  while (processing) {
    if (token == 0)
      ch = 0;
    else {
      ch = MgetChar(kar(token));
      if (ch == '.')
        has_decimal = 1;
      else
      if (ch == 'e' || ch == 'E')
        has_e = 1;
      token = kdr(token);
    }
 
    if (state == 0) {
      if (ch == '-')
        state = 1;
      else
      if (isdigit(ch))
        state = 2;
      else
      if (ch == '.')
        state = 3;
      else {
        processing = 0;
        ret = 0;
      }
    }
    else
    if (state == 1) {
      if (ch == '.')
        state = 3;
      else
      if (isdigit(ch))
        state = 2;
      else {
        processing = 0;
        ret = 0;
      }
    }
    else
    if (state == 2) {
      if (ch == '.')
        state = 3;
      else
      if (isdigit(ch))
        state = 2;
      else
      if (ch == 'e' || ch == 'E')
        state = 4;
      else
      if (ch == 0)
        state = 7;
      else {
        processing = 0;
        ret = 0;
      }
    }
    else
    if (state == 3) {
      if (ch == 'e' || ch == 'E')
        state = 4;
      else
      if (isdigit(ch))
        state = 3;
      else
      if (ch == 0)
        state = 7;
      else {
        processing = 0;
        ret = 0;
      }
    }
    else
    if (state == 4) {
      if (ch == '-' || ch == '+')
        state = 5;
      else
      if (isdigit(ch))
        state = 6;
      else {
        processing = 0;
        ret = 0;
      }
    }
    else
    if (state == 5) {
      if (isdigit(ch))
        state = 6;
      else {
        processing = 0;
        ret = 0;
      }
    }
    else
    if (state == 6) {
      if (ch == 0)
        state = 7;
      else
      if (isdigit(ch))
        state = 6;
      else {
        processing = 0;
        ret = 0;
      }
    }
    else
    if (state == 7) {
      if (has_decimal && !has_e)
        append_e0(save_token);
      processing = 0;
      ret = 1;
    }
  } // while
  return ret;
}
