Store src data in tokens

This commit is contained in:
nub31
2025-05-24 21:12:44 +02:00
parent 1ff434e1c3
commit 26906ea689
9 changed files with 44 additions and 44 deletions

View File

@@ -54,25 +54,25 @@ internal static class Program
return 0;
}
private static List<ModuleNode> RunFrontend(string path)
private static List<ModuleNode> RunFrontend(string rootFilePath)
{
List<ModuleNode> modules = [];
RunFrontend(path, modules);
RunFrontend(rootFilePath, modules);
return modules;
}
private static void RunFrontend(string path, List<ModuleNode> modules)
private static void RunFrontend(string rootFilePath, List<ModuleNode> modules)
{
var files = Directory.EnumerateFiles(path, "*.nub", SearchOption.TopDirectoryOnly);
var filePaths = Directory.EnumerateFiles(rootFilePath, "*.nub", SearchOption.TopDirectoryOnly);
List<Token> tokens = [];
foreach (var file in files)
foreach (var filePath in filePaths)
{
var src = File.ReadAllText(file);
tokens.AddRange(Lexer.Lex(src));
var src = File.ReadAllText(filePath);
tokens.AddRange(Lexer.Lex(src, filePath));
}
var module = Parser.ParseModule(tokens, path);
var module = Parser.ParseModule(tokens, rootFilePath);
modules.Add(module);
foreach (var import in module.Imports)