Skip to content
Snippets Groups Projects
Verified Commit 194048eb authored by Emily Rowlands's avatar Emily Rowlands
Browse files

Added more checks

parent 045799c5
No related branches found
No related tags found
No related merge requests found
......@@ -17,4 +17,9 @@ public class IdentifierNode extends ASTNode {
this.m_name = name;
}
@Override
public boolean isValidType(NodeType type) {
return type == NodeType.IDENTIFIER;
}
}
package jrr1g18.boring.nodes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class UnaryOperationNode extends ASTNode {
private ASTNode m_operand;
private static final List<NodeType> VALID_NODES;
static {
List<NodeType> nodes = new ArrayList<>();
nodes.add(NodeType.UNARYMINUS);
nodes.add(NodeType.UNARYPLUS);
VALID_NODES = Collections.unmodifiableList(nodes);
}
public UnaryOperationNode(NodeType type, ASTNode operand) {
super(type);
m_operand = operand;
......@@ -12,4 +24,9 @@ public class UnaryOperationNode extends ASTNode {
return m_operand;
}
@Override
public boolean isValidType(NodeType type) {
return VALID_NODES.contains(type);
}
}
......@@ -12,4 +12,9 @@ public class ValueNode extends ASTNode {
public Integer getValue() {
return m_value;
}
@Override
public boolean isValidType(NodeType type) {
return type == NodeType.INTEGER;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment