summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2016-05-11 21:11:29 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2016-05-11 21:11:29 -0400
commitfd0a1a0a63818fc1098b01b561c636457c1284ba (patch)
treeb7800a87dba99b8a26c3e101cd3c0b71351c70da /BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java
parentfff6dc5d43539af05ae2679640240b8545b36947 (diff)
Minor changes
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java
index 8118faa..c1cd5c7 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/ShuntingYard.java
@@ -63,12 +63,11 @@ public class ShuntingYard<TokenType> {
}
private final class TokenShunter implements Consumer<String> {
- private IList<TokenType> output;
+ private IList<TokenType> output;
private Deque<String> stack;
private Function<String, TokenType> transform;
- public TokenShunter(IList<TokenType> outpt,
- Deque<String> stack,
+ public TokenShunter(IList<TokenType> outpt, Deque<String> stack,
Function<String, TokenType> transform) {
this.output = outpt;
this.stack = stack;
@@ -176,8 +175,7 @@ public class ShuntingYard<TokenType> {
* The function to use to transform strings to tokens
* @return A list of tokens in postfix notation
*/
- public IList<TokenType> postfix(
- IList<String> input,
+ public IList<TokenType> postfix(IList<String> input,
Function<String, TokenType> tokenTransformer) {
if (input == null) {
throw new NullPointerException("Input must not be null");
@@ -191,9 +189,8 @@ public class ShuntingYard<TokenType> {
input.forEach(new TokenShunter(output, stack, tokenTransformer));
- while (!stack.isEmpty()) {
- output.add(tokenTransformer.apply(stack.pop()));
- }
+ stack.forEach(
+ (token) -> output.add(tokenTransformer.apply(token)));
return output;
}