summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/parserutils/ShuntingYard.java
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2020-11-12 20:05:01 -0500
committerBen Culkin <scorpress@gmail.com>2020-11-12 20:05:01 -0500
commit6dcd129a10af0034b38bfe843d223c4593deee09 (patch)
treee27cf2574a10da36d9a737e1fef48da8e5681da8 /base/src/main/java/bjc/utils/parserutils/ShuntingYard.java
parentc41cfde634d70c3a50adf3979cc5239e5ae52e73 (diff)
Cleanup part 2
Diffstat (limited to 'base/src/main/java/bjc/utils/parserutils/ShuntingYard.java')
-rw-r--r--base/src/main/java/bjc/utils/parserutils/ShuntingYard.java25
1 files changed, 8 insertions, 17 deletions
diff --git a/base/src/main/java/bjc/utils/parserutils/ShuntingYard.java b/base/src/main/java/bjc/utils/parserutils/ShuntingYard.java
index 2418517..8d61b4a 100644
--- a/base/src/main/java/bjc/utils/parserutils/ShuntingYard.java
+++ b/base/src/main/java/bjc/utils/parserutils/ShuntingYard.java
@@ -113,10 +113,8 @@ public class ShuntingYard<TokenType> {
/*
* Complain about trying to add an incorrect operator
*/
- if (operator == null)
- throw new NullPointerException("Operator must not be null");
- else if (precedence == null)
- throw new NullPointerException("Precedence must not be null");
+ if (operator == null) throw new NullPointerException("Operator must not be null");
+ else if (precedence == null) throw new NullPointerException("Precedence must not be null");
/*
* Add the operator to the ones we handle
@@ -141,7 +139,7 @@ public class ShuntingYard<TokenType> {
* Get the precedence of operators
*/
final int rightPrecedence = operators.get(right).getPrecedence();
- final int leftPrecedence = operators.get(left).getPrecedence();
+ final int leftPrecedence = operators.get(left).getPrecedence();
/*
* Evaluate what we were asked
@@ -165,10 +163,8 @@ public class ShuntingYard<TokenType> {
/*
* Check our input
*/
- if (input == null)
- throw new NullPointerException("Input must not be null");
- else if (transformer == null)
- throw new NullPointerException("Transformer must not be null");
+ if (input == null) throw new NullPointerException("Input must not be null");
+ else if (transformer == null) throw new NullPointerException("Transformer must not be null");
/*
* Here's what we're handing back
@@ -226,9 +222,7 @@ public class ShuntingYard<TokenType> {
}
}
- for (String token : stack) {
- output.add(transformer.apply(token));
- }
+ for (String token : stack) output.add(transformer.apply(token));
return output;
}
@@ -244,10 +238,7 @@ public class ShuntingYard<TokenType> {
/*
* Check if we want to remove all operators
*/
- if (operator == null) {
- operators = new FunctionalMap<>();
- } else {
- operators.remove(operator);
- }
+ if (operator == null) operators = new FunctionalMap<>();
+ else operators.remove(operator);
}
}