diff --git a/src/org/nwapw/abacus/tree/OpNode.java b/src/org/nwapw/abacus/tree/BinaryInfixNode.java similarity index 91% rename from src/org/nwapw/abacus/tree/OpNode.java rename to src/org/nwapw/abacus/tree/BinaryInfixNode.java index 475affc..f10913b 100644 --- a/src/org/nwapw/abacus/tree/OpNode.java +++ b/src/org/nwapw/abacus/tree/BinaryInfixNode.java @@ -3,7 +3,7 @@ package org.nwapw.abacus.tree; /** * A tree node that represents an operation being applied to two operands. */ -public class OpNode extends TreeNode { +public class BinaryInfixNode extends TreeNode { /** * The operation being applied. @@ -18,14 +18,14 @@ public class OpNode extends TreeNode { */ private TreeNode right; - private OpNode() {} + private BinaryInfixNode() {} /** * Creates a new operation node with the given operation * and no child nodes. * @param operation the operation. */ - public OpNode(String operation){ + public BinaryInfixNode(String operation){ this(operation, null, null); } @@ -36,7 +36,7 @@ public class OpNode extends TreeNode { * @param left the left node of the expression. * @param right the right node of the expression. */ - public OpNode(String operation, TreeNode left, TreeNode right){ + public BinaryInfixNode(String operation, TreeNode left, TreeNode right){ this.operation = operation; this.left = left; this.right = right; diff --git a/src/org/nwapw/abacus/tree/NumberReducer.java b/src/org/nwapw/abacus/tree/NumberReducer.java index f447589..bb10a5e 100644 --- a/src/org/nwapw/abacus/tree/NumberReducer.java +++ b/src/org/nwapw/abacus/tree/NumberReducer.java @@ -27,10 +27,10 @@ public class NumberReducer implements Reducer { public NumberInterface reduceNode(TreeNode node, Object... children) { if(node instanceof NumberNode) { return ((NumberNode) node).getNumber(); - } else if(node instanceof OpNode){ + } else if(node instanceof BinaryInfixNode){ NumberInterface left = (NumberInterface) children[0]; NumberInterface right = (NumberInterface) children[1]; - Function function = manager.operatorFor(((OpNode) node).getOperation()).getFunction(); + Function function = manager.operatorFor(((BinaryInfixNode) node).getOperation()).getFunction(); if(function == null) return null; return function.apply(left, right); } else if(node instanceof UnaryPrefixNode) { diff --git a/src/org/nwapw/abacus/tree/TreeBuilder.java b/src/org/nwapw/abacus/tree/TreeBuilder.java index eabc565..10663d7 100644 --- a/src/org/nwapw/abacus/tree/TreeBuilder.java +++ b/src/org/nwapw/abacus/tree/TreeBuilder.java @@ -163,7 +163,7 @@ public class TreeBuilder { TreeNode right = fromStringRecursive(source, matches); TreeNode left = fromStringRecursive(source, matches); if(left == null || right == null) return null; - else return new OpNode(operator, left, right); + else return new BinaryInfixNode(operator, left, right); } else { TreeNode applyTo = fromStringRecursive(source, matches); if(applyTo == null) return null;