From 0a15043b636301cf9920a8975b1eeea20a9a7e7f Mon Sep 17 00:00:00 2001 From: Danila Fedorin Date: Fri, 18 Aug 2017 14:20:49 -0700 Subject: [PATCH] Implement a variable TreeNode. --- .../org/nwapw/abacus/tree/VariableNode.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 core/src/main/kotlin/org/nwapw/abacus/tree/VariableNode.kt diff --git a/core/src/main/kotlin/org/nwapw/abacus/tree/VariableNode.kt b/core/src/main/kotlin/org/nwapw/abacus/tree/VariableNode.kt new file mode 100644 index 0000000..0bf05c6 --- /dev/null +++ b/core/src/main/kotlin/org/nwapw/abacus/tree/VariableNode.kt @@ -0,0 +1,21 @@ +package org.nwapw.abacus.tree + +/** + * A tree node that holds a placeholder variable. + * + * This node holds a variable string, and acts similarly to a number, + * with the key difference of not actually holding a value at runtime. + * + * @param variable the actual variable name that this node represents. + */ +data class VariableNode(val variable: String) : TreeNode() { + + override fun reduce(reducer: Reducer): T? { + return reducer.reduceNode(this) + } + + override fun toString(): String { + return variable + } + +} \ No newline at end of file