This commit is contained in:
nub31
2025-06-27 15:55:32 +02:00
parent d9027d6751
commit 19c309c494
20 changed files with 159 additions and 232 deletions

View File

@@ -15,7 +15,7 @@ public static class Parser
private static IEnumerable<Token> _tokens = [];
private static int _index;
public static SyntaxTree? ParseFile(IEnumerable<Token> tokens, string filePath, out IEnumerable<Diagnostic> diagnostics)
public static SyntaxTree? ParseFile(IEnumerable<Token> tokens, out IEnumerable<Diagnostic> diagnostics)
{
_tokens = tokens;
_namespace = null!;
@@ -46,7 +46,7 @@ public static class Parser
}
diagnostics = _diagnostics;
return new SyntaxTree(filePath, _namespace, definitions);
return new SyntaxTree(_namespace, definitions);
}
catch (ParseException ex)
{

View File

@@ -2,4 +2,4 @@
namespace Syntax.Parsing;
public record SyntaxTree(string FilePath, string Namespace, List<DefinitionNode> Definitions);
public record SyntaxTree(string Namespace, List<DefinitionNode> Definitions);

View File

@@ -1,4 +1,5 @@
using Common;
using Syntax.Diagnostics;
using Syntax.Parsing;
using Syntax.Parsing.Node;
using Syntax.Tokenization;
@@ -16,7 +17,7 @@ public static class Binder
private static Dictionary<string, NubType> _variables = new();
private static NubType? _funcReturnType;
public static BoundSyntaxTree Bind(SyntaxTree syntaxTree, DefinitionTable definitionTable)
public static BoundSyntaxTree Bind(SyntaxTree syntaxTree, DefinitionTable definitionTable, out IEnumerable<Diagnostic> diagnostics)
{
_syntaxTree = syntaxTree;
_definitionTable = definitionTable;
@@ -31,7 +32,8 @@ public static class Binder
definitions.Add(BindDefinition(definition));
}
return new BoundSyntaxTree(syntaxTree.FilePath, syntaxTree.Namespace, definitions);
diagnostics = [];
return new BoundSyntaxTree(syntaxTree.Namespace, definitions);
}
private static BoundDefinitionNode BindDefinition(DefinitionNode node)

View File

@@ -2,4 +2,4 @@
namespace Syntax.Typing;
public record BoundSyntaxTree(string FilePath, string Namespace, List<BoundDefinitionNode> Definitions);
public record BoundSyntaxTree(string Namespace, List<BoundDefinitionNode> Definitions);