33 lines
669 B
Java
33 lines
669 B
Java
package serene.simple;
|
|
|
|
public class SymbolNode extends Node {
|
|
public String name;
|
|
|
|
public SymbolNode(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Node other) {
|
|
if (other instanceof SymbolNode) {
|
|
SymbolNode n = (SymbolNode) other;
|
|
|
|
if (this.name.equals(n.name)) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
return super.equals(other);
|
|
}
|
|
|
|
@Override
|
|
public Object eval(Scope scope) {
|
|
return scope.lookupSymbol(this.name);
|
|
}
|
|
|
|
public String toString() {
|
|
return String.format("Symbol<%s>", this.name);
|
|
}
|
|
}
|