diff options
| author | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-25 19:13:42 -0400 |
|---|---|---|
| committer | bculkin2442 <bjculkin@mix.wvu.edu> | 2017-03-25 19:13:42 -0400 |
| commit | 42990231fee502552b769b9af4c04ac0dcaeb195 (patch) | |
| tree | 4dbe0ba0bc54fffafacc9ab12349efd76c52041c /BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/BinaryPostCommand.java | |
| parent | 674d9769821775484fe6913b93c650189fbedfed (diff) | |
Update Pratt parser
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.java | 29 |
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 |
