summaryrefslogtreecommitdiff
path: root/dice-lang/src/bjc/dicelang/v2/Shunter.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2017-02-11 08:44:28 -0500
committerbculkin2442 <bjculkin@mix.wvu.edu>2017-02-11 08:44:28 -0500
commit1cf218ba93396c7be7f4b3ee25d8008a41777273 (patch)
tree24fbb7a13c206c75e7c828862e04a5d0ae64cd5a /dice-lang/src/bjc/dicelang/v2/Shunter.java
parent6ca8c6764a8b8769a7a295c0479962a6588580a2 (diff)
Parse double and some dice
Diffstat (limited to 'dice-lang/src/bjc/dicelang/v2/Shunter.java')
-rw-r--r--dice-lang/src/bjc/dicelang/v2/Shunter.java59
1 files changed, 59 insertions, 0 deletions
diff --git a/dice-lang/src/bjc/dicelang/v2/Shunter.java b/dice-lang/src/bjc/dicelang/v2/Shunter.java
new file mode 100644
index 0000000..bca08eb
--- /dev/null
+++ b/dice-lang/src/bjc/dicelang/v2/Shunter.java
@@ -0,0 +1,59 @@
+package bjc.dicelang.v2;
+
+import bjc.utils.funcdata.FunctionalList;
+import bjc.utils.funcdata.FunctionalMap;
+import bjc.utils.funcdata.IList;
+import bjc.utils.funcdata.IMap;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import static bjc.dicelang.v2.Token.Type.*;
+
+public class Shunter {
+ // The binary operators and their
+ // priorities
+ private IMap<Token.Type, Integer> ops;
+
+ // Unary operators that can only be
+ // applied to non-operator tokens
+ private Set<Token.Type> unaryAdjectives;
+
+ // Unary operators that con only be
+ // applied to operator tokens
+ private Set<Token.Type> unaryAdverbs;
+
+ private final int MATH_PREC = 20;
+ private final int DICE_PREC = 10;
+ private final int EXPR_PREC = 0;
+
+ public Shunter() {
+ ops = new FunctionalMap<>();
+
+ unaryAdjectives = new HashSet<>();
+ unaryAdverbs = new HashSet<>();
+
+ ops.put(ADD, 0 + MATH_PREC);
+ ops.put(SUBTRACT, 0 + MATH_PREC);
+
+ ops.put(MULTIPLY, 1 + MATH_PREC);
+ ops.put(IDIVIDE, 1 + MATH_PREC);
+ ops.put(DIVIDE, 1 + MATH_PREC);
+
+ ops.put(DICEGROUP, 0 + DICE_PREC);
+ ops.put(DICECONCAT, 1 + DICE_PREC);
+
+ ops.put(LET, 0 + EXPR_PREC);
+ ops.put(BIND, 1 + EXPR_PREC);
+ }
+
+ public IList<Token> shuntTokens(IList<Token> tks) {
+ IList<Token> returned = new FunctionalList<>();
+
+ for(Token tk : tks.toIterable()) {
+
+ }
+
+ return returned;
+ }
+}