summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/BinaryPostCommand.java
diff options
context:
space:
mode:
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/BinaryPostCommand.java')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/BinaryPostCommand.java29
1 files changed, 25 insertions, 4 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/BinaryPostCommand.java b/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/BinaryPostCommand.java
index 7aaf735..806f2f3 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/BinaryPostCommand.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/BinaryPostCommand.java
@@ -2,14 +2,35 @@ package bjc.utils.parserutils.pratt.commands;
import bjc.utils.parserutils.pratt.NonInitialCommand;
-/*
- * A command with constant binding power.
+/**
+ * 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;
- public BinaryPostCommand(int power) {
- leftPower = power;
+ /**
+ * Create a new operator with fixed precedence.
+ *
+ * @param precedence
+ * The precedence of the operator.
+ */
+ public BinaryPostCommand(int precedence) {
+ if (precedence < 0) {
+ throw new IllegalArgumentException("Precedence must be non-negative");
+ }
+
+ leftPower = precedence;
}
@Override