summaryrefslogtreecommitdiff
path: root/dice-lang/src/bjc/dicelang/expr/Shunter.java
diff options
context:
space:
mode:
authorbjculkin <bjculkin@mix.wvu.edu>2017-04-11 17:51:13 -0400
committerbjculkin <bjculkin@mix.wvu.edu>2017-04-11 17:51:13 -0400
commit40858cee415643769ee5f6216b0cd4335996ff2f (patch)
tree86b1c334fa2e5b79cddc16984f5ad43c3c72e41f /dice-lang/src/bjc/dicelang/expr/Shunter.java
parent767ca1b248da19b754d42a814b71b43ef16090be (diff)
General cleanup and fixes
Diffstat (limited to 'dice-lang/src/bjc/dicelang/expr/Shunter.java')
-rw-r--r--dice-lang/src/bjc/dicelang/expr/Shunter.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/dice-lang/src/bjc/dicelang/expr/Shunter.java b/dice-lang/src/bjc/dicelang/expr/Shunter.java
index 5d8cb7c..bbece0f 100644
--- a/dice-lang/src/bjc/dicelang/expr/Shunter.java
+++ b/dice-lang/src/bjc/dicelang/expr/Shunter.java
@@ -39,7 +39,12 @@ public class Shunter {
* respecting their left associativity.
*/
int leftPriority = tok.type.operatorPriority;
- int rightPriority = curOp == null ? 0 : curOp.type.operatorPriority;
+
+ int rightPriority;
+ if(curOp == null)
+ rightPriority = 0;
+ else
+ rightPriority = curOp.type.operatorPriority;
boolean isHigherPrec = leftPriority >= rightPriority;
@@ -53,7 +58,11 @@ public class Shunter {
curOp = opStack.peek();
leftPriority = tok.type.operatorPriority;
- rightPriority = curOp == null ? 0 : curOp.type.operatorPriority;
+
+ if(curOp == null)
+ rightPriority = 0;
+ else
+ rightPriority = curOp.type.operatorPriority;
isHigherPrec = leftPriority >= rightPriority;
}
@@ -65,7 +74,8 @@ public class Shunter {
Token curOp = opStack.peek();
/*
- * Pop things until we find the matching paren.
+ * Pop things until we find the matching
+ * parenthesis.
*/
while(curOp.type != TokenType.OPAREN) {
Token tk = opStack.pop();
@@ -92,4 +102,4 @@ public class Shunter {
return postfixTokens.toArray(new Token[0]);
}
-}
+} \ No newline at end of file