Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[parser] Fix number parsing in interval #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 2 additions & 3 deletions src/test/java/test/TestInterval.java
Original file line number Diff line number Diff line change
Expand Up @@ -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]");
Expand Down