WIP: dev #1
@@ -6,10 +6,10 @@ public sealed class Diagnostic(DiagnosticSeverity severity, string message, stri
|
||||
public static DiagnosticBuilder Warning(string message) => new DiagnosticBuilder(DiagnosticSeverity.Warning, message);
|
||||
public static DiagnosticBuilder Error(string message) => new DiagnosticBuilder(DiagnosticSeverity.Error, message);
|
||||
|
||||
public readonly DiagnosticSeverity Severity = severity;
|
||||
public readonly string Message = message;
|
||||
public readonly string? Help = help;
|
||||
public readonly FileInfo? File = file;
|
||||
public DiagnosticSeverity Severity { get; } = severity;
|
||||
public string Message { get; } = message;
|
||||
public string? Help { get; } = help;
|
||||
public FileInfo? File { get; } = file;
|
||||
}
|
||||
|
||||
public sealed class DiagnosticBuilder(DiagnosticSeverity severity, string message)
|
||||
@@ -69,10 +69,10 @@ public sealed class DiagnosticBuilder(DiagnosticSeverity severity, string messag
|
||||
|
||||
public sealed class FileInfo(string file, int line, int column, int length)
|
||||
{
|
||||
public readonly string File = file;
|
||||
public readonly int Line = line;
|
||||
public readonly int Column = column;
|
||||
public readonly int Length = length;
|
||||
public string File { get; } = file;
|
||||
public int Line { get; } = line;
|
||||
public int Column { get; } = column;
|
||||
public int Length { get; } = length;
|
||||
}
|
||||
|
||||
public enum DiagnosticSeverity
|
||||
@@ -84,7 +84,7 @@ public enum DiagnosticSeverity
|
||||
|
||||
public sealed class CompileException(Diagnostic diagnostic) : Exception
|
||||
{
|
||||
public readonly Diagnostic Diagnostic = diagnostic;
|
||||
public Diagnostic Diagnostic { get; } = diagnostic;
|
||||
}
|
||||
|
||||
public static class DiagnosticFormatter
|
||||
|
||||
@@ -162,7 +162,7 @@ public sealed class Parser(string fileName, List<Token> tokens)
|
||||
|
||||
while (TryPeekBinaryOperator(out var op) && GetPrecedence(op) >= minPrecedence)
|
||||
{
|
||||
Consume();
|
||||
Next();
|
||||
var right = ParseExpression(GetPrecedence(op) + 1);
|
||||
left = new NodeExpressionBinary(TokensFrom(startIndex), left, op, right);
|
||||
}
|
||||
@@ -349,22 +349,11 @@ public sealed class Parser(string fileName, List<Token> tokens)
|
||||
return tokens.GetRange(startIndex, index - startIndex);
|
||||
}
|
||||
|
||||
private void ExpectKeyword(Keyword keyword)
|
||||
{
|
||||
if (Peek() is TokenKeyword token && token.Keyword == keyword)
|
||||
{
|
||||
Consume();
|
||||
return;
|
||||
}
|
||||
|
||||
throw new CompileException(Diagnostic.Error($"Expected '{keyword.AsString()}'").At(fileName, Peek()).Build());
|
||||
}
|
||||
|
||||
private bool TryExpectKeyword(Keyword keyword)
|
||||
{
|
||||
if (Peek() is TokenKeyword token && token.Keyword == keyword)
|
||||
{
|
||||
Consume();
|
||||
Next();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -375,7 +364,7 @@ public sealed class Parser(string fileName, List<Token> tokens)
|
||||
{
|
||||
if (Peek() is TokenSymbol token && token.Symbol == symbol)
|
||||
{
|
||||
Consume();
|
||||
Next();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -386,7 +375,7 @@ public sealed class Parser(string fileName, List<Token> tokens)
|
||||
{
|
||||
if (Peek() is TokenSymbol token && token.Symbol == symbol)
|
||||
{
|
||||
Consume();
|
||||
Next();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -397,7 +386,7 @@ public sealed class Parser(string fileName, List<Token> tokens)
|
||||
{
|
||||
if (Peek() is TokenIdent token)
|
||||
{
|
||||
Consume();
|
||||
Next();
|
||||
return token;
|
||||
}
|
||||
|
||||
@@ -408,7 +397,7 @@ public sealed class Parser(string fileName, List<Token> tokens)
|
||||
{
|
||||
if (Peek() is TokenIdent token)
|
||||
{
|
||||
Consume();
|
||||
Next();
|
||||
ident = token;
|
||||
return true;
|
||||
}
|
||||
@@ -421,7 +410,7 @@ public sealed class Parser(string fileName, List<Token> tokens)
|
||||
{
|
||||
if (Peek() is TokenIntLiteral token)
|
||||
{
|
||||
Consume();
|
||||
Next();
|
||||
intLiteral = token;
|
||||
return true;
|
||||
}
|
||||
@@ -434,7 +423,7 @@ public sealed class Parser(string fileName, List<Token> tokens)
|
||||
{
|
||||
if (Peek() is TokenStringLiteral token)
|
||||
{
|
||||
Consume();
|
||||
Next();
|
||||
stringLiteral = token;
|
||||
return true;
|
||||
}
|
||||
@@ -447,7 +436,7 @@ public sealed class Parser(string fileName, List<Token> tokens)
|
||||
{
|
||||
if (Peek() is TokenBoolLiteral token)
|
||||
{
|
||||
Consume();
|
||||
Next();
|
||||
boolLiteral = token;
|
||||
return true;
|
||||
}
|
||||
@@ -456,12 +445,12 @@ public sealed class Parser(string fileName, List<Token> tokens)
|
||||
return false;
|
||||
}
|
||||
|
||||
private Token Consume()
|
||||
private void Next()
|
||||
{
|
||||
if (index >= tokens.Count)
|
||||
throw new CompileException(Diagnostic.Error("Unexpected end of tokens").At(fileName, Peek()).Build());
|
||||
|
||||
return tokens[index++];
|
||||
index += 1;
|
||||
}
|
||||
|
||||
private Token? Peek(int offset = 0)
|
||||
@@ -536,45 +525,45 @@ public sealed class Parser(string fileName, List<Token> tokens)
|
||||
|
||||
public sealed class Ast(List<NodeDefinition> definitions, string fileName)
|
||||
{
|
||||
public string FileName = fileName;
|
||||
public readonly List<NodeDefinition> Definitions = definitions;
|
||||
public string FileName { get; } = fileName;
|
||||
public List<NodeDefinition> Definitions { get; } = definitions;
|
||||
}
|
||||
|
||||
public abstract class Node(List<Token> tokens)
|
||||
{
|
||||
public readonly List<Token> Tokens = tokens;
|
||||
public List<Token> Tokens { get; } = tokens;
|
||||
}
|
||||
|
||||
public abstract class NodeDefinition(List<Token> tokens) : Node(tokens);
|
||||
|
||||
public sealed class NodeDefinitionModule(List<Token> tokens, TokenIdent name) : NodeDefinition(tokens)
|
||||
{
|
||||
public readonly TokenIdent Name = name;
|
||||
public TokenIdent Name { get; } = name;
|
||||
}
|
||||
|
||||
public sealed class NodeDefinitionFunc(List<Token> tokens, TokenIdent name, List<NodeDefinitionFunc.Param> parameters, NodeStatement body, NodeType returnType) : NodeDefinition(tokens)
|
||||
{
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly List<Param> Parameters = parameters;
|
||||
public readonly NodeStatement Body = body;
|
||||
public readonly NodeType ReturnType = returnType;
|
||||
public TokenIdent Name { get; } = name;
|
||||
public List<Param> Parameters { get; } = parameters;
|
||||
public NodeStatement Body { get; } = body;
|
||||
public NodeType ReturnType { get; } = returnType;
|
||||
|
||||
public sealed class Param(List<Token> tokens, TokenIdent name, NodeType type) : Node(tokens)
|
||||
{
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly NodeType Type = type;
|
||||
public TokenIdent Name { get; } = name;
|
||||
public NodeType Type { get; } = type;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class NodeDefinitionStruct(List<Token> tokens, TokenIdent name, List<NodeDefinitionStruct.Field> fields) : NodeDefinition(tokens)
|
||||
{
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly List<Field> Fields = fields;
|
||||
public TokenIdent Name { get; } = name;
|
||||
public List<Field> Fields { get; } = fields;
|
||||
|
||||
public sealed class Field(List<Token> tokens, TokenIdent name, NodeType type) : Node(tokens)
|
||||
{
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly NodeType Type = type;
|
||||
public TokenIdent Name { get; } = name;
|
||||
public NodeType Type { get; } = type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -582,98 +571,98 @@ public abstract class NodeStatement(List<Token> tokens) : Node(tokens);
|
||||
|
||||
public sealed class NodeStatementBlock(List<Token> tokens, List<NodeStatement> statements) : NodeStatement(tokens)
|
||||
{
|
||||
public readonly List<NodeStatement> Statements = statements;
|
||||
public List<NodeStatement> Statements { get; } = statements;
|
||||
}
|
||||
|
||||
public sealed class NodeStatementFuncCall(List<Token> tokens, NodeExpression target, List<NodeExpression> parameters) : NodeStatement(tokens)
|
||||
{
|
||||
public readonly NodeExpression Target = target;
|
||||
public readonly List<NodeExpression> Parameters = parameters;
|
||||
public NodeExpression Target { get; } = target;
|
||||
public List<NodeExpression> Parameters { get; } = parameters;
|
||||
}
|
||||
|
||||
public sealed class NodeStatementReturn(List<Token> tokens, NodeExpression value) : NodeStatement(tokens)
|
||||
{
|
||||
public readonly NodeExpression Value = value;
|
||||
public NodeExpression Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class NodeStatementVariableDeclaration(List<Token> tokens, TokenIdent name, NodeType type, NodeExpression value) : NodeStatement(tokens)
|
||||
{
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly NodeType Type = type;
|
||||
public readonly NodeExpression Value = value;
|
||||
public TokenIdent Name { get; } = name;
|
||||
public NodeType Type { get; } = type;
|
||||
public NodeExpression Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class NodeStatementAssignment(List<Token> tokens, NodeExpression target, NodeExpression value) : NodeStatement(tokens)
|
||||
{
|
||||
public readonly NodeExpression Target = target;
|
||||
public readonly NodeExpression Value = value;
|
||||
public NodeExpression Target { get; } = target;
|
||||
public NodeExpression Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class NodeStatementIf(List<Token> tokens, NodeExpression condition, NodeStatement thenBlock, NodeStatement? elseBlock) : NodeStatement(tokens)
|
||||
{
|
||||
public readonly NodeExpression Condition = condition;
|
||||
public readonly NodeStatement ThenBlock = thenBlock;
|
||||
public readonly NodeStatement? ElseBlock = elseBlock;
|
||||
public NodeExpression Condition { get; } = condition;
|
||||
public NodeStatement ThenBlock { get; } = thenBlock;
|
||||
public NodeStatement? ElseBlock { get; } = elseBlock;
|
||||
}
|
||||
|
||||
public sealed class NodeStatementWhile(List<Token> tokens, NodeExpression condition, NodeStatement block) : NodeStatement(tokens)
|
||||
{
|
||||
public readonly NodeExpression Condition = condition;
|
||||
public readonly NodeStatement Block = block;
|
||||
public NodeExpression Condition { get; } = condition;
|
||||
public NodeStatement Block { get; } = block;
|
||||
}
|
||||
|
||||
public abstract class NodeExpression(List<Token> tokens) : Node(tokens);
|
||||
|
||||
public sealed class NodeExpressionIntLiteral(List<Token> tokens, TokenIntLiteral value) : NodeExpression(tokens)
|
||||
{
|
||||
public readonly TokenIntLiteral Value = value;
|
||||
public TokenIntLiteral Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class NodeExpressionStringLiteral(List<Token> tokens, TokenStringLiteral value) : NodeExpression(tokens)
|
||||
{
|
||||
public readonly TokenStringLiteral Value = value;
|
||||
public TokenStringLiteral Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class NodeExpressionBoolLiteral(List<Token> tokens, TokenBoolLiteral value) : NodeExpression(tokens)
|
||||
{
|
||||
public readonly TokenBoolLiteral Value = value;
|
||||
public TokenBoolLiteral Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class NodeExpressionStructLiteral(List<Token> tokens, TokenIdent module, TokenIdent name, List<NodeExpressionStructLiteral.Initializer> initializers) : NodeExpression(tokens)
|
||||
{
|
||||
public readonly TokenIdent Module = module;
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly List<Initializer> Initializers = initializers;
|
||||
public TokenIdent Module { get; } = module;
|
||||
public TokenIdent Name { get; } = name;
|
||||
public List<Initializer> Initializers { get; } = initializers;
|
||||
|
||||
public sealed class Initializer(List<Token> tokens, TokenIdent name, NodeExpression value) : Node(tokens)
|
||||
{
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly NodeExpression Value = value;
|
||||
public TokenIdent Name { get; } = name;
|
||||
public NodeExpression Value { get; } = value;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class NodeExpressionMemberAccess(List<Token> tokens, NodeExpression target, TokenIdent name) : NodeExpression(tokens)
|
||||
{
|
||||
public readonly NodeExpression Target = target;
|
||||
public readonly TokenIdent Name = name;
|
||||
public NodeExpression Target { get; } = target;
|
||||
public TokenIdent Name { get; } = name;
|
||||
}
|
||||
|
||||
public sealed class NodeExpressionLocalIdent(List<Token> tokens, TokenIdent value) : NodeExpression(tokens)
|
||||
{
|
||||
public readonly TokenIdent Value = value;
|
||||
public TokenIdent Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class NodeExpressionModuleIdent(List<Token> tokens, TokenIdent module, TokenIdent value) : NodeExpression(tokens)
|
||||
{
|
||||
public readonly TokenIdent Module = module;
|
||||
public readonly TokenIdent Value = value;
|
||||
public TokenIdent Module { get; } = module;
|
||||
public TokenIdent Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class NodeExpressionBinary(List<Token> tokens, NodeExpression left, NodeExpressionBinary.Op operation, NodeExpression right) : NodeExpression(tokens)
|
||||
{
|
||||
public readonly NodeExpression Left = left;
|
||||
public readonly Op Operation = operation;
|
||||
public readonly NodeExpression Right = right;
|
||||
public NodeExpression Left { get; } = left;
|
||||
public Op Operation { get; } = operation;
|
||||
public NodeExpression Right { get; } = right;
|
||||
|
||||
public enum Op
|
||||
{
|
||||
@@ -720,12 +709,12 @@ public sealed class NodeTypeVoid(List<Token> tokens) : NodeType(tokens);
|
||||
|
||||
public sealed class NodeTypeUInt(List<Token> tokens, int width) : NodeType(tokens)
|
||||
{
|
||||
public readonly int Width = width;
|
||||
public int Width { get; } = width;
|
||||
}
|
||||
|
||||
public sealed class NodeTypeSInt(List<Token> tokens, int width) : NodeType(tokens)
|
||||
{
|
||||
public readonly int Width = width;
|
||||
public int Width { get; } = width;
|
||||
}
|
||||
|
||||
public sealed class NodeTypeBool(List<Token> tokens) : NodeType(tokens);
|
||||
@@ -734,17 +723,17 @@ public sealed class NodeTypeString(List<Token> tokens) : NodeType(tokens);
|
||||
|
||||
public sealed class NodeTypeCustom(List<Token> tokens, TokenIdent module, TokenIdent name) : NodeType(tokens)
|
||||
{
|
||||
public readonly TokenIdent Module = module;
|
||||
public readonly TokenIdent Name = name;
|
||||
public TokenIdent Module { get; } = module;
|
||||
public TokenIdent Name { get; } = name;
|
||||
}
|
||||
|
||||
public sealed class NodeTypePointer(List<Token> tokens, NodeType to) : NodeType(tokens)
|
||||
{
|
||||
public readonly NodeType To = to;
|
||||
public NodeType To { get; } = to;
|
||||
}
|
||||
|
||||
public sealed class NodeTypeFunc(List<Token> tokens, List<NodeType> parameters, NodeType returnType) : NodeType(tokens)
|
||||
{
|
||||
public readonly List<NodeType> Parameters = parameters;
|
||||
public readonly NodeType ReturnType = returnType;
|
||||
public List<NodeType> Parameters { get; } = parameters;
|
||||
public NodeType ReturnType { get; } = returnType;
|
||||
}
|
||||
@@ -403,29 +403,29 @@ public sealed class Tokenizer(string fileName, string contents)
|
||||
|
||||
public abstract class Token(int line, int column, int length)
|
||||
{
|
||||
public int Line = line;
|
||||
public int Column = column;
|
||||
public int Length = length;
|
||||
public int Line { get; } = line;
|
||||
public int Column { get; } = column;
|
||||
public int Length { get; } = length;
|
||||
}
|
||||
|
||||
public sealed class TokenIdent(int line, int column, int length, string ident) : Token(line, column, length)
|
||||
{
|
||||
public readonly string Ident = ident;
|
||||
public string Ident { get; } = ident;
|
||||
}
|
||||
|
||||
public sealed class TokenIntLiteral(int line, int column, int length, BigInteger value) : Token(line, column, length)
|
||||
{
|
||||
public BigInteger Value = value;
|
||||
public BigInteger Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class TokenStringLiteral(int line, int column, int length, string value) : Token(line, column, length)
|
||||
{
|
||||
public readonly string Value = value;
|
||||
public string Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class TokenBoolLiteral(int line, int column, int length, bool value) : Token(line, column, length)
|
||||
{
|
||||
public readonly bool Value = value;
|
||||
public bool Value { get; } = value;
|
||||
}
|
||||
|
||||
public enum Symbol
|
||||
@@ -467,7 +467,7 @@ public enum Symbol
|
||||
|
||||
public sealed class TokenSymbol(int line, int column, int length, Symbol symbol) : Token(line, column, length)
|
||||
{
|
||||
public readonly Symbol Symbol = symbol;
|
||||
public Symbol Symbol { get; } = symbol;
|
||||
}
|
||||
|
||||
public enum Keyword
|
||||
@@ -484,7 +484,7 @@ public enum Keyword
|
||||
|
||||
public sealed class TokenKeyword(int line, int column, int length, Keyword keyword) : Token(line, column, length)
|
||||
{
|
||||
public readonly Keyword Keyword = keyword;
|
||||
public Keyword Keyword { get; } = keyword;
|
||||
}
|
||||
|
||||
public static class TokenExtensions
|
||||
|
||||
@@ -391,22 +391,22 @@ public sealed class TypeChecker(string fileName, NodeDefinitionFunc function, Mo
|
||||
|
||||
public abstract class TypedNode(List<Token> tokens)
|
||||
{
|
||||
public readonly List<Token> Tokens = tokens;
|
||||
public List<Token> Tokens { get; } = tokens;
|
||||
}
|
||||
|
||||
public abstract class TypedNodeDefinition(List<Token> tokens) : TypedNode(tokens);
|
||||
|
||||
public sealed class TypedNodeDefinitionFunc(List<Token> tokens, TokenIdent name, List<TypedNodeDefinitionFunc.Param> parameters, TypedNodeStatement body, NubType returnType) : TypedNodeDefinition(tokens)
|
||||
{
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly List<Param> Parameters = parameters;
|
||||
public readonly TypedNodeStatement Body = body;
|
||||
public readonly NubType ReturnType = returnType;
|
||||
public TokenIdent Name { get; } = name;
|
||||
public List<Param> Parameters { get; } = parameters;
|
||||
public TypedNodeStatement Body { get; } = body;
|
||||
public NubType ReturnType { get; } = returnType;
|
||||
|
||||
public sealed class Param(List<Token> tokens, TokenIdent name, NubType type) : TypedNode(tokens)
|
||||
{
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly NubType Type = type;
|
||||
public TokenIdent Name { get; } = name;
|
||||
public NubType Type { get; } = type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,99 +414,99 @@ public abstract class TypedNodeStatement(List<Token> tokens) : TypedNode(tokens)
|
||||
|
||||
public sealed class TypedNodeStatementBlock(List<Token> tokens, List<TypedNodeStatement> statements) : TypedNodeStatement(tokens)
|
||||
{
|
||||
public readonly List<TypedNodeStatement> Statements = statements;
|
||||
public List<TypedNodeStatement> Statements { get; } = statements;
|
||||
}
|
||||
|
||||
public sealed class TypedNodeStatementFuncCall(List<Token> tokens, TypedNodeExpression target, List<TypedNodeExpression> parameters) : TypedNodeStatement(tokens)
|
||||
{
|
||||
public readonly TypedNodeExpression Target = target;
|
||||
public readonly List<TypedNodeExpression> Parameters = parameters;
|
||||
public TypedNodeExpression Target { get; } = target;
|
||||
public List<TypedNodeExpression> Parameters { get; } = parameters;
|
||||
}
|
||||
|
||||
public sealed class TypedNodeStatementReturn(List<Token> tokens, TypedNodeExpression value) : TypedNodeStatement(tokens)
|
||||
{
|
||||
public readonly TypedNodeExpression Value = value;
|
||||
public TypedNodeExpression Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class TypedNodeStatementVariableDeclaration(List<Token> tokens, TokenIdent name, NubType type, TypedNodeExpression value) : TypedNodeStatement(tokens)
|
||||
{
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly NubType Type = type;
|
||||
public readonly TypedNodeExpression Value = value;
|
||||
public TokenIdent Name { get; } = name;
|
||||
public NubType Type { get; } = type;
|
||||
public TypedNodeExpression Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class TypedNodeStatementAssignment(List<Token> tokens, TypedNodeExpression target, TypedNodeExpression value) : TypedNodeStatement(tokens)
|
||||
{
|
||||
public readonly TypedNodeExpression Target = target;
|
||||
public readonly TypedNodeExpression Value = value;
|
||||
public TypedNodeExpression Target { get; } = target;
|
||||
public TypedNodeExpression Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class TypedNodeStatementIf(List<Token> tokens, TypedNodeExpression condition, TypedNodeStatement thenBlock, TypedNodeStatement? elseBlock) : TypedNodeStatement(tokens)
|
||||
{
|
||||
public readonly TypedNodeExpression Condition = condition;
|
||||
public readonly TypedNodeStatement ThenBlock = thenBlock;
|
||||
public readonly TypedNodeStatement? ElseBlock = elseBlock;
|
||||
public TypedNodeExpression Condition { get; } = condition;
|
||||
public TypedNodeStatement ThenBlock { get; } = thenBlock;
|
||||
public TypedNodeStatement? ElseBlock { get; } = elseBlock;
|
||||
}
|
||||
|
||||
public sealed class TypedNodeStatementWhile(List<Token> tokens, TypedNodeExpression condition, TypedNodeStatement block) : TypedNodeStatement(tokens)
|
||||
{
|
||||
public readonly TypedNodeExpression Condition = condition;
|
||||
public readonly TypedNodeStatement Block = block;
|
||||
public TypedNodeExpression Condition { get; } = condition;
|
||||
public TypedNodeStatement Block { get; } = block;
|
||||
}
|
||||
|
||||
public abstract class TypedNodeExpression(List<Token> tokens, NubType type) : TypedNode(tokens)
|
||||
{
|
||||
public readonly NubType Type = type;
|
||||
public NubType Type { get; } = type;
|
||||
}
|
||||
|
||||
public sealed class TypedNodeExpressionIntLiteral(List<Token> tokens, NubType type, TokenIntLiteral value) : TypedNodeExpression(tokens, type)
|
||||
{
|
||||
public readonly TokenIntLiteral Value = value;
|
||||
public TokenIntLiteral Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class TypedNodeExpressionStringLiteral(List<Token> tokens, NubType type, TokenStringLiteral value) : TypedNodeExpression(tokens, type)
|
||||
{
|
||||
public readonly TokenStringLiteral Value = value;
|
||||
public TokenStringLiteral Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class TypedNodeExpressionBoolLiteral(List<Token> tokens, NubType type, TokenBoolLiteral value) : TypedNodeExpression(tokens, type)
|
||||
{
|
||||
public readonly TokenBoolLiteral Value = value;
|
||||
public TokenBoolLiteral Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class TypedNodeExpressionStructLiteral(List<Token> tokens, NubType type, List<TypedNodeExpressionStructLiteral.Initializer> initializers) : TypedNodeExpression(tokens, type)
|
||||
{
|
||||
public readonly List<Initializer> Initializers = initializers;
|
||||
public List<Initializer> Initializers { get; } = initializers;
|
||||
|
||||
public sealed class Initializer(List<Token> tokens, TokenIdent name, TypedNodeExpression value) : Node(tokens)
|
||||
{
|
||||
public readonly TokenIdent Name = name;
|
||||
public readonly TypedNodeExpression Value = value;
|
||||
public TokenIdent Name { get; } = name;
|
||||
public TypedNodeExpression Value { get; } = value;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TypedNodeExpressionMemberAccess(List<Token> tokens, NubType type, TypedNodeExpression target, TokenIdent name) : TypedNodeExpression(tokens, type)
|
||||
{
|
||||
public readonly TypedNodeExpression Target = target;
|
||||
public readonly TokenIdent Name = name;
|
||||
public TypedNodeExpression Target { get; } = target;
|
||||
public TokenIdent Name { get; } = name;
|
||||
}
|
||||
|
||||
public sealed class TypedNodeExpressionLocalIdent(List<Token> tokens, NubType type, TokenIdent value) : TypedNodeExpression(tokens, type)
|
||||
{
|
||||
public readonly TokenIdent Value = value;
|
||||
public TokenIdent Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class TypedNodeExpressionModuleIdent(List<Token> tokens, NubType type, TokenIdent module, TokenIdent value) : TypedNodeExpression(tokens, type)
|
||||
{
|
||||
public readonly TokenIdent Module = module;
|
||||
public readonly TokenIdent Value = value;
|
||||
public TokenIdent Module { get; } = module;
|
||||
public TokenIdent Value { get; } = value;
|
||||
}
|
||||
|
||||
public sealed class TypedNodeExpressionBinary(List<Token> tokens, NubType type, TypedNodeExpression left, TypedNodeExpressionBinary.Op operation, TypedNodeExpression right) : TypedNodeExpression(tokens, type)
|
||||
{
|
||||
public readonly TypedNodeExpression Left = left;
|
||||
public readonly Op Operation = operation;
|
||||
public readonly TypedNodeExpression Right = right;
|
||||
public TypedNodeExpression Left { get; } = left;
|
||||
public Op Operation { get; } = operation;
|
||||
public TypedNodeExpression Right { get; } = right;
|
||||
|
||||
public enum Op
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user