private static TokenType?unsignedNumber(Scanner s) { if (!s.isDigit()) { return(null); } while (s.isDigit()) { s.readChar(); } if (s.isExponent()) { return(readExponent(s)); } if (s.peek() != '.') { return(TokenType.Integer); } return(remainingFloat(s)); }
private static TokenType?remainingFloat(Scanner s) { s.readChar(); // Skip the '.' while (s.isDigit() || s.isExponent()) { if (s.isExponent()) { return(readExponent(s)); } s.readChar(); } return(TokenType.Double); }
private static TokenType?readExponent(Scanner s) { s.readChar(); // Skip exponent market var read = false; if (s.isOneOf("+-")) { s.readChar(); read = true; } while (s.isDigit()) { read = true; s.readChar(); } if (read) { return(TokenType.Double); } // It's not a floating point number in exponent format. // Read it as a symbol instead. matchSymbol(s); return(TokenType.Symbol); }
private static TokenType? unsignedNumber(Scanner s) { if (!s.isDigit()) return null; while (s.isDigit()) s.readChar(); if (s.isExponent()) return readExponent(s); if (s.peek() != '.') return TokenType.Integer; return remainingFloat(s); }
private static TokenType? remainingFloat(Scanner s) { s.readChar(); // Skip the '.' while (s.isDigit() || s.isExponent()) { if (s.isExponent()) return readExponent(s); s.readChar(); } return TokenType.Double; }
private static TokenType? readExponent(Scanner s) { s.readChar(); // Skip exponent market var read = false; if (s.isOneOf("+-")) { s.readChar(); read = true; } while (s.isDigit()) { read = true; s.readChar(); } if(read) return TokenType.Double; // It's not a floating point number in exponent format. // Read it as a symbol instead. matchSymbol(s); return TokenType.Symbol; }