checkNumberOrSymbol method

bool checkNumberOrSymbol(
  1. String? ch
)

Implementation

bool checkNumberOrSymbol(String? ch) {
  bool isSymbol = false;
  bool inBrackets = false;
  if (isValidSymbolChar(ch, true, false)) {
    token = ch;
    isSymbol =
        isSymbol || !(ch!.compareTo('0') >= 0 && ch.compareTo('9') <= 0);
    inBrackets = checkBrackets(ch, inBrackets);
    ch = peekChar();
    inBrackets = checkBrackets(ch, inBrackets);
    while (isValidSymbolChar(ch, !isSymbol || inBrackets, inBrackets)) {
      token = token! + ch!;
      isSymbol = isSymbol ||
          (ch != noChar &&
              !(ch.compareTo('0') >= 0 && ch.compareTo('9') <= 0));
      index++;
      ch = peekChar();
      inBrackets = checkBrackets(ch, inBrackets);
    }
    if (isSymbol) {
      type = TokenType.symbol;
    } else {
      type = TokenType.number;
    }
    return true;
  } else {
    return false;
  }
}