From 42990231fee502552b769b9af4c04ac0dcaeb195 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Sat, 25 Mar 2017 19:13:42 -0400 Subject: Update Pratt parser --- .../pratt/commands/BinaryPostCommand.java | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/parserutils/pratt/commands/BinaryPostCommand.java') 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 + * The key type of the tokens. + * + * @param + * The value type of the tokens. + * + * @param + * The state type of the parser. */ public abstract class BinaryPostCommand extends NonInitialCommand { 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 -- cgit v1.2.3