Administrator approval is now required for registering new accounts. If you are registering a new account, and are external to the University, please ask the repository owner to contact ServiceLine to request your account be approved. Repository owners must include the newly registered email address, and specific repository in the request for approval.

Verified Commit e44d2f02 authored by Emily Rowlands's avatar Emily Rowlands
Browse files

Started work on AST things

parent 25047382
package jrr1g18.boring.ast;
public abstract class ASTNode {
public enum NodeType {
INTEGER, ADD, SUB, MUL, DIV,
}
private final NodeType m_type;
private ASTNode m_parent;
public ASTNode(NodeType type, ASTNode parent) {
m_type = type;
m_parent = parent;
}
public ASTNode(NodeType type) {
m_type = type;
m_parent = null;
}
public NodeType getType() {
return m_type;
}
public ASTNode getParent() {
return m_parent;
}
}
package jrr1g18.boring.ast;
import jrr1g18.boring.tokens.Token.TokenType;
public class BinaryOperationNode extends ASTNode {
TokenType m_operation;
public BinaryOperationNode(NodeType type, TokenType operatorType,
ASTNode parent) {
super(type, parent);
m_operation = operatorType;
}
public BinaryOperationNode(NodeType type, TokenType operatorType) {
super(type);
m_operation = operatorType;
}
}
package jrr1g18.boring.ast;
public class ValueNode extends ASTNode {
private int m_value;
public ValueNode(NodeType type, ASTNode parent, int value) {
super(type, parent);
m_value = value;
}
public ValueNode(NodeType type, int value) {
super(type);
m_value = value;
}
public int getValue() {
return m_value;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment