Skip to content

Commit

Permalink
Merge pull request jMonkeyEngine#633 from tonihele/bugfix/issue-632
Browse files Browse the repository at this point in the history
Fix NPE on GlslLexer
  • Loading branch information
tonihele authored Dec 14, 2024
2 parents 1572302 + 334c415 commit 933a006
Showing 1 changed file with 20 additions and 26 deletions.
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

0 comments on commit 933a006

Please sign in to comment.