Skip to content

Commit

Permalink
[parser] Fix number parsing in interval
Browse files Browse the repository at this point in the history
  • Loading branch information
Hazurl committed Sep 6, 2023
1 parent dadafb7 commit 172d89b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/main/java/leekscript/compiler/LexicalParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/test/TestInterval.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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("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]");
Expand Down

0 comments on commit 172d89b

Please sign in to comment.