...
This commit is contained in:
@@ -112,9 +112,10 @@ public class StructFieldNode(List<Token> tokens, IdentifierToken nameToken, NubT
|
||||
}
|
||||
}
|
||||
|
||||
public class StructNode(List<Token> tokens, IdentifierToken name, NubStructType structType, List<StructFieldNode> fields) : DefinitionNode(tokens, name)
|
||||
public class StructNode(List<Token> tokens, IdentifierToken name, NubStructType structType, bool packed, List<StructFieldNode> fields) : DefinitionNode(tokens, name)
|
||||
{
|
||||
public NubStructType StructType { get; } = structType;
|
||||
public bool Packed { get; } = packed;
|
||||
public List<StructFieldNode> Fields { get; } = fields;
|
||||
|
||||
public override IEnumerable<Node> Children()
|
||||
@@ -132,8 +133,6 @@ public class StructNode(List<Token> tokens, IdentifierToken name, NubStructType
|
||||
|
||||
public abstract class StatementNode(List<Token> tokens) : Node(tokens);
|
||||
|
||||
public abstract class TerminalStatementNode(List<Token> tokens) : StatementNode(tokens);
|
||||
|
||||
public class BlockNode(List<Token> tokens, List<StatementNode> statements) : StatementNode(tokens)
|
||||
{
|
||||
public List<StatementNode> Statements { get; } = statements;
|
||||
@@ -154,7 +153,7 @@ public class StatementFuncCallNode(List<Token> tokens, FuncCallNode funcCall) :
|
||||
}
|
||||
}
|
||||
|
||||
public class ReturnNode(List<Token> tokens, ExpressionNode? value) : TerminalStatementNode(tokens)
|
||||
public class ReturnNode(List<Token> tokens, ExpressionNode? value) : StatementNode(tokens)
|
||||
{
|
||||
public ExpressionNode? Value { get; } = value;
|
||||
|
||||
@@ -164,9 +163,9 @@ public class ReturnNode(List<Token> tokens, ExpressionNode? value) : TerminalSta
|
||||
}
|
||||
}
|
||||
|
||||
public class AssignmentNode(List<Token> tokens, LValueExpressionNode target, ExpressionNode value) : StatementNode(tokens)
|
||||
public class AssignmentNode(List<Token> tokens, ExpressionNode target, ExpressionNode value) : StatementNode(tokens)
|
||||
{
|
||||
public LValueExpressionNode Target { get; } = target;
|
||||
public ExpressionNode Target { get; } = target;
|
||||
public ExpressionNode Value { get; } = value;
|
||||
|
||||
public override IEnumerable<Node> Children()
|
||||
@@ -205,7 +204,7 @@ public class VariableDeclarationNode(List<Token> tokens, IdentifierToken nameTok
|
||||
}
|
||||
}
|
||||
|
||||
public class ContinueNode(List<Token> tokens) : TerminalStatementNode(tokens)
|
||||
public class ContinueNode(List<Token> tokens) : StatementNode(tokens)
|
||||
{
|
||||
public override IEnumerable<Node> Children()
|
||||
{
|
||||
@@ -213,7 +212,7 @@ public class ContinueNode(List<Token> tokens) : TerminalStatementNode(tokens)
|
||||
}
|
||||
}
|
||||
|
||||
public class BreakNode(List<Token> tokens) : TerminalStatementNode(tokens)
|
||||
public class BreakNode(List<Token> tokens) : StatementNode(tokens)
|
||||
{
|
||||
public override IEnumerable<Node> Children()
|
||||
{
|
||||
@@ -308,13 +307,7 @@ public abstract class ExpressionNode(List<Token> tokens, NubType type) : Node(to
|
||||
public NubType Type { get; } = type;
|
||||
}
|
||||
|
||||
public abstract class LValueExpressionNode(List<Token> tokens, NubType type) : ExpressionNode(tokens, type);
|
||||
|
||||
public abstract class RValueExpressionNode(List<Token> tokens, NubType type) : ExpressionNode(tokens, type);
|
||||
|
||||
public abstract class IntermediateExpression(List<Token> tokens) : ExpressionNode(tokens, new NubVoidType());
|
||||
|
||||
public class StringLiteralNode(List<Token> tokens, string value) : RValueExpressionNode(tokens, new NubStringType())
|
||||
public class StringLiteralNode(List<Token> tokens, string value) : ExpressionNode(tokens, new NubStringType())
|
||||
{
|
||||
public string Value { get; } = value;
|
||||
|
||||
@@ -324,7 +317,7 @@ public class StringLiteralNode(List<Token> tokens, string value) : RValueExpress
|
||||
}
|
||||
}
|
||||
|
||||
public class CStringLiteralNode(List<Token> tokens, string value) : RValueExpressionNode(tokens, new NubPointerType(new NubIntType(true, 8)))
|
||||
public class CStringLiteralNode(List<Token> tokens, string value) : ExpressionNode(tokens, new NubPointerType(new NubIntType(true, 8)))
|
||||
{
|
||||
public string Value { get; } = value;
|
||||
|
||||
@@ -334,7 +327,7 @@ public class CStringLiteralNode(List<Token> tokens, string value) : RValueExpres
|
||||
}
|
||||
}
|
||||
|
||||
public class I8LiteralNode(List<Token> tokens, sbyte value) : RValueExpressionNode(tokens, new NubIntType(true, 8))
|
||||
public class I8LiteralNode(List<Token> tokens, sbyte value) : ExpressionNode(tokens, new NubIntType(true, 8))
|
||||
{
|
||||
public sbyte Value { get; } = value;
|
||||
|
||||
@@ -344,7 +337,7 @@ public class I8LiteralNode(List<Token> tokens, sbyte value) : RValueExpressionNo
|
||||
}
|
||||
}
|
||||
|
||||
public class I16LiteralNode(List<Token> tokens, short value) : RValueExpressionNode(tokens, new NubIntType(true, 16))
|
||||
public class I16LiteralNode(List<Token> tokens, short value) : ExpressionNode(tokens, new NubIntType(true, 16))
|
||||
{
|
||||
public short Value { get; } = value;
|
||||
|
||||
@@ -354,7 +347,7 @@ public class I16LiteralNode(List<Token> tokens, short value) : RValueExpressionN
|
||||
}
|
||||
}
|
||||
|
||||
public class I32LiteralNode(List<Token> tokens, int value) : RValueExpressionNode(tokens, new NubIntType(true, 32))
|
||||
public class I32LiteralNode(List<Token> tokens, int value) : ExpressionNode(tokens, new NubIntType(true, 32))
|
||||
{
|
||||
public int Value { get; } = value;
|
||||
|
||||
@@ -364,7 +357,7 @@ public class I32LiteralNode(List<Token> tokens, int value) : RValueExpressionNod
|
||||
}
|
||||
}
|
||||
|
||||
public class I64LiteralNode(List<Token> tokens, long value) : RValueExpressionNode(tokens, new NubIntType(true, 64))
|
||||
public class I64LiteralNode(List<Token> tokens, long value) : ExpressionNode(tokens, new NubIntType(true, 64))
|
||||
{
|
||||
public long Value { get; } = value;
|
||||
|
||||
@@ -374,7 +367,7 @@ public class I64LiteralNode(List<Token> tokens, long value) : RValueExpressionNo
|
||||
}
|
||||
}
|
||||
|
||||
public class U8LiteralNode(List<Token> tokens, byte value) : RValueExpressionNode(tokens, new NubIntType(false, 8))
|
||||
public class U8LiteralNode(List<Token> tokens, byte value) : ExpressionNode(tokens, new NubIntType(false, 8))
|
||||
{
|
||||
public byte Value { get; } = value;
|
||||
|
||||
@@ -384,7 +377,7 @@ public class U8LiteralNode(List<Token> tokens, byte value) : RValueExpressionNod
|
||||
}
|
||||
}
|
||||
|
||||
public class U16LiteralNode(List<Token> tokens, ushort value) : RValueExpressionNode(tokens, new NubIntType(false, 16))
|
||||
public class U16LiteralNode(List<Token> tokens, ushort value) : ExpressionNode(tokens, new NubIntType(false, 16))
|
||||
{
|
||||
public ushort Value { get; } = value;
|
||||
|
||||
@@ -394,7 +387,7 @@ public class U16LiteralNode(List<Token> tokens, ushort value) : RValueExpression
|
||||
}
|
||||
}
|
||||
|
||||
public class U32LiteralNode(List<Token> tokens, uint value) : RValueExpressionNode(tokens, new NubIntType(false, 32))
|
||||
public class U32LiteralNode(List<Token> tokens, uint value) : ExpressionNode(tokens, new NubIntType(false, 32))
|
||||
{
|
||||
public uint Value { get; } = value;
|
||||
|
||||
@@ -404,7 +397,7 @@ public class U32LiteralNode(List<Token> tokens, uint value) : RValueExpressionNo
|
||||
}
|
||||
}
|
||||
|
||||
public class U64LiteralNode(List<Token> tokens, ulong value) : RValueExpressionNode(tokens, new NubIntType(false, 64))
|
||||
public class U64LiteralNode(List<Token> tokens, ulong value) : ExpressionNode(tokens, new NubIntType(false, 64))
|
||||
{
|
||||
public ulong Value { get; } = value;
|
||||
|
||||
@@ -414,7 +407,7 @@ public class U64LiteralNode(List<Token> tokens, ulong value) : RValueExpressionN
|
||||
}
|
||||
}
|
||||
|
||||
public class Float32LiteralNode(List<Token> tokens, float value) : RValueExpressionNode(tokens, new NubFloatType(32))
|
||||
public class Float32LiteralNode(List<Token> tokens, float value) : ExpressionNode(tokens, new NubFloatType(32))
|
||||
{
|
||||
public float Value { get; } = value;
|
||||
|
||||
@@ -424,7 +417,7 @@ public class Float32LiteralNode(List<Token> tokens, float value) : RValueExpress
|
||||
}
|
||||
}
|
||||
|
||||
public class Float64LiteralNode(List<Token> tokens, double value) : RValueExpressionNode(tokens, new NubFloatType(64))
|
||||
public class Float64LiteralNode(List<Token> tokens, double value) : ExpressionNode(tokens, new NubFloatType(64))
|
||||
{
|
||||
public double Value { get; } = value;
|
||||
|
||||
@@ -434,7 +427,7 @@ public class Float64LiteralNode(List<Token> tokens, double value) : RValueExpres
|
||||
}
|
||||
}
|
||||
|
||||
public class BoolLiteralNode(List<Token> tokens, bool value) : RValueExpressionNode(tokens, new NubBoolType())
|
||||
public class BoolLiteralNode(List<Token> tokens, bool value) : ExpressionNode(tokens, new NubBoolType())
|
||||
{
|
||||
public bool Value { get; } = value;
|
||||
|
||||
@@ -444,7 +437,7 @@ public class BoolLiteralNode(List<Token> tokens, bool value) : RValueExpressionN
|
||||
}
|
||||
}
|
||||
|
||||
public class BinaryExpressionNode(List<Token> tokens, NubType type, ExpressionNode left, BinaryOperator @operator, ExpressionNode right) : RValueExpressionNode(tokens, type)
|
||||
public class BinaryExpressionNode(List<Token> tokens, NubType type, ExpressionNode left, BinaryOperator @operator, ExpressionNode right) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public ExpressionNode Left { get; } = left;
|
||||
public BinaryOperator Operator { get; } = @operator;
|
||||
@@ -457,7 +450,7 @@ public class BinaryExpressionNode(List<Token> tokens, NubType type, ExpressionNo
|
||||
}
|
||||
}
|
||||
|
||||
public class UnaryExpressionNode(List<Token> tokens, NubType type, UnaryOperator @operator, ExpressionNode operand) : RValueExpressionNode(tokens, type)
|
||||
public class UnaryExpressionNode(List<Token> tokens, NubType type, UnaryOperator @operator, ExpressionNode operand) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public UnaryOperator Operator { get; } = @operator;
|
||||
public ExpressionNode Operand { get; } = operand;
|
||||
@@ -468,7 +461,7 @@ public class UnaryExpressionNode(List<Token> tokens, NubType type, UnaryOperator
|
||||
}
|
||||
}
|
||||
|
||||
public class FuncCallNode(List<Token> tokens, NubType type, ExpressionNode expression, List<ExpressionNode> parameters) : RValueExpressionNode(tokens, type)
|
||||
public class FuncCallNode(List<Token> tokens, NubType type, ExpressionNode expression, List<ExpressionNode> parameters) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public ExpressionNode Expression { get; } = expression;
|
||||
public List<ExpressionNode> Parameters { get; } = parameters;
|
||||
@@ -483,7 +476,7 @@ public class FuncCallNode(List<Token> tokens, NubType type, ExpressionNode expre
|
||||
}
|
||||
}
|
||||
|
||||
public class VariableIdentifierNode(List<Token> tokens, NubType type, IdentifierToken nameToken) : LValueExpressionNode(tokens, type)
|
||||
public class VariableIdentifierNode(List<Token> tokens, NubType type, IdentifierToken nameToken) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public IdentifierToken NameToken { get; } = nameToken;
|
||||
|
||||
@@ -493,7 +486,7 @@ public class VariableIdentifierNode(List<Token> tokens, NubType type, Identifier
|
||||
}
|
||||
}
|
||||
|
||||
public class FuncIdentifierNode(List<Token> tokens, NubType type, IdentifierToken moduleToken, IdentifierToken nameToken, StringLiteralToken? externSymbolToken) : RValueExpressionNode(tokens, type)
|
||||
public class FuncIdentifierNode(List<Token> tokens, NubType type, IdentifierToken moduleToken, IdentifierToken nameToken, StringLiteralToken? externSymbolToken) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public IdentifierToken ModuleToken { get; } = moduleToken;
|
||||
public IdentifierToken NameToken { get; } = nameToken;
|
||||
@@ -505,7 +498,7 @@ public class FuncIdentifierNode(List<Token> tokens, NubType type, IdentifierToke
|
||||
}
|
||||
}
|
||||
|
||||
public class ArrayInitializerNode(List<Token> tokens, NubType type, List<ExpressionNode> values) : RValueExpressionNode(tokens, type)
|
||||
public class ArrayInitializerNode(List<Token> tokens, NubType type, List<ExpressionNode> values) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public List<ExpressionNode> Values { get; } = values;
|
||||
|
||||
@@ -515,7 +508,7 @@ public class ArrayInitializerNode(List<Token> tokens, NubType type, List<Express
|
||||
}
|
||||
}
|
||||
|
||||
public class ConstArrayInitializerNode(List<Token> tokens, NubType type, List<ExpressionNode> values) : RValueExpressionNode(tokens, type)
|
||||
public class ConstArrayInitializerNode(List<Token> tokens, NubType type, List<ExpressionNode> values) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public List<ExpressionNode> Values { get; } = values;
|
||||
|
||||
@@ -525,7 +518,7 @@ public class ConstArrayInitializerNode(List<Token> tokens, NubType type, List<Ex
|
||||
}
|
||||
}
|
||||
|
||||
public class ArrayIndexAccessNode(List<Token> tokens, NubType type, ExpressionNode target, ExpressionNode index) : LValueExpressionNode(tokens, type)
|
||||
public class ArrayIndexAccessNode(List<Token> tokens, NubType type, ExpressionNode target, ExpressionNode index) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public ExpressionNode Target { get; } = target;
|
||||
public ExpressionNode Index { get; } = index;
|
||||
@@ -537,7 +530,7 @@ public class ArrayIndexAccessNode(List<Token> tokens, NubType type, ExpressionNo
|
||||
}
|
||||
}
|
||||
|
||||
public class ConstArrayIndexAccessNode(List<Token> tokens, NubType type, ExpressionNode target, ExpressionNode index) : LValueExpressionNode(tokens, type)
|
||||
public class ConstArrayIndexAccessNode(List<Token> tokens, NubType type, ExpressionNode target, ExpressionNode index) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public ExpressionNode Target { get; } = target;
|
||||
public ExpressionNode Index { get; } = index;
|
||||
@@ -549,7 +542,7 @@ public class ConstArrayIndexAccessNode(List<Token> tokens, NubType type, Express
|
||||
}
|
||||
}
|
||||
|
||||
public class SliceIndexAccessNode(List<Token> tokens, NubType type, ExpressionNode target, ExpressionNode index) : LValueExpressionNode(tokens, type)
|
||||
public class SliceIndexAccessNode(List<Token> tokens, NubType type, ExpressionNode target, ExpressionNode index) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public ExpressionNode Target { get; } = target;
|
||||
public ExpressionNode Index { get; } = index;
|
||||
@@ -561,17 +554,17 @@ public class SliceIndexAccessNode(List<Token> tokens, NubType type, ExpressionNo
|
||||
}
|
||||
}
|
||||
|
||||
public class AddressOfNode(List<Token> tokens, NubType type, LValueExpressionNode lValue) : RValueExpressionNode(tokens, type)
|
||||
public class AddressOfNode(List<Token> tokens, NubType type, ExpressionNode target) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public LValueExpressionNode LValue { get; } = lValue;
|
||||
public ExpressionNode Target { get; } = target;
|
||||
|
||||
public override IEnumerable<Node> Children()
|
||||
{
|
||||
yield return LValue;
|
||||
yield return Target;
|
||||
}
|
||||
}
|
||||
|
||||
public class StructFieldAccessNode(List<Token> tokens, NubType type, ExpressionNode target, IdentifierToken fieldToken) : LValueExpressionNode(tokens, type)
|
||||
public class StructFieldAccessNode(List<Token> tokens, NubType type, ExpressionNode target, IdentifierToken fieldToken) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public ExpressionNode Target { get; } = target;
|
||||
public IdentifierToken FieldToken { get; } = fieldToken;
|
||||
@@ -582,7 +575,7 @@ public class StructFieldAccessNode(List<Token> tokens, NubType type, ExpressionN
|
||||
}
|
||||
}
|
||||
|
||||
public class StructInitializerNode(List<Token> tokens, NubType type, Dictionary<IdentifierToken, ExpressionNode> initializers) : RValueExpressionNode(tokens, type)
|
||||
public class StructInitializerNode(List<Token> tokens, NubType type, Dictionary<IdentifierToken, ExpressionNode> initializers) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public Dictionary<IdentifierToken, ExpressionNode> Initializers { get; } = initializers;
|
||||
|
||||
@@ -595,7 +588,7 @@ public class StructInitializerNode(List<Token> tokens, NubType type, Dictionary<
|
||||
}
|
||||
}
|
||||
|
||||
public class DereferenceNode(List<Token> tokens, NubType type, ExpressionNode target) : LValueExpressionNode(tokens, type)
|
||||
public class DereferenceNode(List<Token> tokens, NubType type, ExpressionNode target) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public ExpressionNode Target { get; } = target;
|
||||
|
||||
@@ -605,7 +598,7 @@ public class DereferenceNode(List<Token> tokens, NubType type, ExpressionNode ta
|
||||
}
|
||||
}
|
||||
|
||||
public class SizeNode(List<Token> tokens, NubType TargetType) : RValueExpressionNode(tokens, new NubIntType(false, 64))
|
||||
public class SizeNode(List<Token> tokens, NubType TargetType) : ExpressionNode(tokens, new NubIntType(false, 64))
|
||||
{
|
||||
public NubType TargetType { get; } = TargetType;
|
||||
|
||||
@@ -615,7 +608,7 @@ public class SizeNode(List<Token> tokens, NubType TargetType) : RValueExpression
|
||||
}
|
||||
}
|
||||
|
||||
public class CastNode(List<Token> tokens, NubType type, ExpressionNode value) : RValueExpressionNode(tokens, type)
|
||||
public class CastNode(List<Token> tokens, NubType type, ExpressionNode value) : ExpressionNode(tokens, type)
|
||||
{
|
||||
public ExpressionNode Value { get; } = value;
|
||||
|
||||
@@ -625,6 +618,8 @@ public class CastNode(List<Token> tokens, NubType type, ExpressionNode value) :
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class IntermediateExpression(List<Token> tokens) : ExpressionNode(tokens, new NubVoidType());
|
||||
|
||||
public class EnumReferenceIntermediateNode(List<Token> tokens, IdentifierToken moduleToken, IdentifierToken nameToken) : IntermediateExpression(tokens)
|
||||
{
|
||||
public IdentifierToken ModuleToken { get; } = moduleToken;
|
||||
|
||||
Reference in New Issue
Block a user