summaryrefslogtreecommitdiff
path: root/JPratt/src/main/java/com/ashardalon/pratt/commands/BinaryPostCommand.java
diff options
context:
space:
mode:
Diffstat (limited to 'JPratt/src/main/java/com/ashardalon/pratt/commands/BinaryPostCommand.java')
-rw-r--r--JPratt/src/main/java/com/ashardalon/pratt/commands/BinaryPostCommand.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/JPratt/src/main/java/com/ashardalon/pratt/commands/BinaryPostCommand.java b/JPratt/src/main/java/com/ashardalon/pratt/commands/BinaryPostCommand.java
new file mode 100644
index 0000000..bacab23
--- /dev/null
+++ b/JPratt/src/main/java/com/ashardalon/pratt/commands/BinaryPostCommand.java
@@ -0,0 +1,36 @@
+package com.ashardalon.pratt.commands;
+
+/**
+ * A operator with fixed precedence.
+ *
+ * @author bjculkin
+ *
+ * @param <K>
+ * The key type of the tokens.
+ *
+ * @param <V>
+ * The value type of the tokens.
+ *
+ * @param <C>
+ * The state type of the parser.
+ */
+public abstract class BinaryPostCommand<K, V, C> extends NonInitialCommand<K, V, C> {
+ private final int leftPower;
+
+ /**
+ * Create a new operator with fixed precedence.
+ *
+ * @param precedence
+ * The precedence of the operator.
+ */
+ public BinaryPostCommand(final int precedence) {
+ if(precedence < 0) throw new IllegalArgumentException("Precedence must be non-negative");
+
+ leftPower = precedence;
+ }
+
+ @Override
+ public int leftBinding() {
+ return leftPower;
+ }
+} \ No newline at end of file