Skip to content

Commit

Permalink
Refactor: return empty line
Browse files Browse the repository at this point in the history
  • Loading branch information
xCollateral committed Aug 8, 2024
1 parent 9311ae7 commit caa1d32
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.vulkanmod.vulkan.shader.parser;

import com.mojang.blaze3d.vertex.VertexFormat;
import net.vulkanmod.vulkan.shader.descriptor.ImageDescriptor;
import net.vulkanmod.vulkan.shader.descriptor.UBO;

Expand Down Expand Up @@ -38,7 +37,7 @@ public void process(String vertShader, String fragShader) {
String line = iterator.next();

String parsedLine = this.parseLine(line);
if(parsedLine != null) {
if (parsedLine != null) {
vshOut.append(parsedLine);
vshOut.append("\n");
}
Expand All @@ -57,7 +56,7 @@ public void process(String vertShader, String fragShader) {
String line = iterator.next();

String parsedLine = this.parseLine(line);
if(parsedLine != null) {
if (parsedLine != null) {
fshOut.append(parsedLine);
fshOut.append("\n");
}
Expand Down Expand Up @@ -87,19 +86,20 @@ private String parseLine(String line) {

StringTokenizer tokenizer = new StringTokenizer(line);

//empty line
if(!tokenizer.hasMoreTokens()) return null;
// empty line
if (!tokenizer.hasMoreTokens())
return "\n";

String token = tokenizer.nextToken();

switch (token) {
case "uniform" -> this.state = State.MATCHING_UNIFORM;
case "in", "out" -> this.state = State.MATCHING_IN_OUT;
case "#version" -> {
return null;
return null;
}
case "#moj_import" -> {
if(tokenizer.countTokens() != 1) {
if (tokenizer.countTokens() != 1) {
throw new IllegalArgumentException("Token count != 1");
}

Expand All @@ -111,7 +111,7 @@ private String parseLine(String line) {
}
}

if(tokenizer.countTokens() < 2) {
if (tokenizer.countTokens() < 2) {
throw new IllegalArgumentException("Less than 3 tokens present");
}

Expand Down

0 comments on commit caa1d32

Please sign in to comment.