diff --git a/src/main/java/leekscript/compiler/LexicalParser.java b/src/main/java/leekscript/compiler/LexicalParser.java index 5ad617f1..4890d70d 100644 --- a/src/main/java/leekscript/compiler/LexicalParser.java +++ b/src/main/java/leekscript/compiler/LexicalParser.java @@ -187,13 +187,13 @@ private boolean tryParseNumber(ErrorReporter error) throws LeekCompilerException } if (c == '.') { - if (stream.getSubStringSince(startingPoint).contains(".")) { - error.report(new AnalyzeError(new Token(TokenType.NOTHING, ".", aiFile, stream.getLineCounter(), stream.getCharCounter() + 1), AnalyzeErrorLevel.ERROR, Error.INVALID_CHAR)); + // We don't eat the dot if it's followed by another dot + if (stream.peek(1) == '.') { break; } - // We don't eat the dot if it's not followed by another dot - if (stream.peek(1) == '.') { + if (stream.getSubStringSince(startingPoint).contains(".")) { + error.report(new AnalyzeError(new Token(TokenType.NOTHING, ".", aiFile, stream.getLineCounter(), stream.getCharCounter() + 1), AnalyzeErrorLevel.ERROR, Error.INVALID_CHAR)); break; } diff --git a/src/test/java/test/TestInterval.java b/src/test/java/test/TestInterval.java index cc4c1ea9..d43efcbc 100644 --- a/src/test/java/test/TestInterval.java +++ b/src/test/java/test/TestInterval.java @@ -9,9 +9,8 @@ public void run() throws Exception { section("Interval.constructor()"); code("return [..]").equals("[..]"); code("return [1..2]").equals("[1..2]"); - DISABLED_code("return [1.0..2.0]").equals("[1.0..2.0]"); - code_v1("return [1.0 .. 2.0]").equals("[1..2]"); - code_v2_("return [1.0 .. 2.0]").equals("[1.0..2.0]"); + code_v1("return [1.0..2.0]").equals("[1..2]"); + code_v2_("return [1.0..2.0]").equals("[1.0..2.0]"); code("return [-10..-2]").equals("[-10..-2]"); code("return [1 * 5 .. 8 + 5]").equals("[5..13]"); code("return ]-∞..5]").equals("]-∞..5]");