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

Fix NPE on GlslLexer #633

Merged
merged 1 commit into from
Dec 14, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -190,21 +190,26 @@ public Token<GlslTokenID> nextToken() {
}
}
}
if (current == null) {
}
switch (current) {
case BASIC_TYPE:
return token(GlslTokenID.PRIMITIVE);
case KEYWORD:
return token(GlslTokenID.KEYWORD);
case BUILTIN_VARIABLE:
return token(GlslTokenID.BUILTIN_VARIABLE);
case BUILTIN_FUNCTION:
return token(GlslTokenID.BUILTIN_FUNCTION);
if (current != null) {
switch (current) {
case BASIC_TYPE -> {
return token(GlslTokenID.PRIMITIVE);
}
case KEYWORD -> {
return token(GlslTokenID.KEYWORD);
}
case BUILTIN_VARIABLE -> {
return token(GlslTokenID.BUILTIN_VARIABLE);
}
case BUILTIN_FUNCTION -> {
return token(GlslTokenID.BUILTIN_FUNCTION);
}
}
}
}
}
}

//Those have to be recognized separately for closing bracket recognition
return token(GlslTokenID.TEXT);
}
Expand All @@ -224,21 +229,10 @@ private Token<GlslTokenID> token(GlslTokenID id) {
}

private boolean isDigit(int c) {
switch (c) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
return true;
default:
return false;
}
return switch (c) {
case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' -> true;
default -> false;
};
}

private void readTillNewLine() {
Expand Down
Loading