mirror of
https://github.com/DanilaFe/abacus
synced 2024-11-17 08:03:09 -08:00
Implement a variable TreeNode.
This commit is contained in:
parent
21e059c1ca
commit
0a15043b63
21
core/src/main/kotlin/org/nwapw/abacus/tree/VariableNode.kt
Normal file
21
core/src/main/kotlin/org/nwapw/abacus/tree/VariableNode.kt
Normal file
|
@ -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 <T : Any> reduce(reducer: Reducer<T>): T? {
|
||||||
|
return reducer.reduceNode(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return variable
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user