2021-04-16 21:17:17 +01:00
|
|
|
module compiler.symbols.expressions;
|
|
|
|
|
|
|
|
import compiler.symbols.data;
|
|
|
|
|
|
|
|
/* TODO: Look into arrays later */
|
2021-06-07 15:47:57 +01:00
|
|
|
public class StringExpression : Expression
|
2021-04-16 21:17:17 +01:00
|
|
|
{
|
|
|
|
private string ztring;
|
|
|
|
|
|
|
|
this(string ztring)
|
|
|
|
{
|
|
|
|
this.ztring = ztring;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class OperatorExpression : Expression
|
|
|
|
{
|
|
|
|
/* Operator */
|
|
|
|
private SymbolType operator;
|
|
|
|
|
|
|
|
this(SymbolType operator)
|
|
|
|
{
|
|
|
|
this.operator = operator;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class UnaryOperatorExpression : OperatorExpression
|
|
|
|
{
|
|
|
|
private Expression exp;
|
|
|
|
|
|
|
|
this(SymbolType operator, Expression exp)
|
|
|
|
{
|
|
|
|
super(operator);
|
|
|
|
this.exp = exp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class BinaryOperatorExpression : OperatorExpression
|
|
|
|
{
|
2021-06-15 09:48:01 +01:00
|
|
|
private Expression lhs, rhs;
|
|
|
|
|
2021-04-16 21:17:17 +01:00
|
|
|
/* TODO: Take in operator */
|
|
|
|
this(SymbolType operator, Expression lhs, Expression rhs)
|
|
|
|
{
|
|
|
|
super(operator);
|
2021-06-15 09:48:01 +01:00
|
|
|
this.lhs = lhs;
|
|
|
|
this.rhs = rhs;
|
2021-04-16 21:17:17 +01:00
|
|
|
}
|
2021-06-15 09:49:19 +01:00
|
|
|
|
|
|
|
public Expression getLeftExpression()
|
|
|
|
{
|
|
|
|
return lhs;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Expression getRightExpression()
|
|
|
|
{
|
|
|
|
return rhs;
|
|
|
|
}
|
2021-04-16 21:17:17 +01:00
|
|
|
}
|
|
|
|
|
2021-06-07 15:47:57 +01:00
|
|
|
public class NumberLiteral : Expression
|
2021-04-16 21:17:17 +01:00
|
|
|
{
|
|
|
|
private string numberLiteral;
|
|
|
|
|
|
|
|
/* TODO: Take in info like tyoe */
|
|
|
|
this(string numberLiteral)
|
|
|
|
{
|
|
|
|
this.numberLiteral = numberLiteral;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public class Expression : Statement
|
|
|
|
{
|
|
|
|
import compiler.typecheck.core;
|
|
|
|
/* TODO: Takes in symbol table? */
|
|
|
|
public string evaluateType(TypeChecker typechecker, Container c)
|
|
|
|
{
|
|
|
|
/* TODO: Go through here evaluating the type */
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
this()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: Evalute this expression's type */
|
2021-06-15 13:27:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public final class NewExpression : Expression
|
|
|
|
{
|
|
|
|
private FunctionCall funcCall;
|
|
|
|
|
|
|
|
this(FunctionCall funcCall)
|
|
|
|
{
|
|
|
|
this.funcCall = funcCall;
|
|
|
|
}
|
|
|
|
|
|
|
|
public FunctionCall getFuncCall()
|
|
|
|
{
|
|
|
|
return funcCall;
|
|
|
|
}
|
2021-04-16 21:17:17 +01:00
|
|
|
}
|