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

Added some VALID_NODES consants

parent 6368aeb0
No related branches found
No related tags found
No related merge requests found
package jrr1g18.boring.nodes; package jrr1g18.boring.nodes;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/** /**
* A class representing a binary operation on the AST. * A class representing a binary operation on the AST.
* *
...@@ -10,6 +14,16 @@ public class BinaryOperationNode extends ASTNode { ...@@ -10,6 +14,16 @@ public class BinaryOperationNode extends ASTNode {
private ASTNode m_lhs; private ASTNode m_lhs;
private ASTNode m_rhs; private ASTNode m_rhs;
private static final List<NodeType> VALID_NODES;
static {
List<NodeType> nodes = new ArrayList<>();
nodes.add(NodeType.ADD);
nodes.add(NodeType.DIV);
nodes.add(NodeType.MUL);
nodes.add(NodeType.SUB);
VALID_NODES = Collections.unmodifiableList(nodes);
}
/** /**
* Create a new BinaryOperationNode * Create a new BinaryOperationNode
* *
...@@ -34,6 +48,6 @@ public class BinaryOperationNode extends ASTNode { ...@@ -34,6 +48,6 @@ public class BinaryOperationNode extends ASTNode {
@Override @Override
public boolean isValidType(NodeType type) { public boolean isValidType(NodeType type) {
return VALID_NODES.contains(type);
} }
} }
/**
*
*/
package jrr1g18.boring.nodes.statements; package jrr1g18.boring.nodes.statements;
/** /**
...@@ -20,7 +17,6 @@ public class EmptyStatementNode extends StatementNode { ...@@ -20,7 +17,6 @@ public class EmptyStatementNode extends StatementNode {
@Override @Override
public boolean isValidType(NodeType type) { public boolean isValidType(NodeType type) {
return type == NodeType.EMPTY_STATEMENT;
return super.isValidType(type);
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment