#include <Parser/Parser.hpp>
#include <iostream>

int main()
{
    using namespace Fig;

    String        fileName = "test.fig";
    String        filePath = "T:/Files/Maker/Code/MyCodingLanguage/The Fig Project/Fig/test.fig";

    SourceManager srcManager(filePath);

    String source = srcManager.Read();
    if (!srcManager.read)
    {
        std::cerr << "Couldn't read file";
        return 1;
    }

    Lexer  lexer(source, fileName);

    Diagnostics diagnostics;
    Parser parser(lexer, srcManager, fileName, diagnostics);

    auto   result = parser.Parse();
    if (!result)
    {
        ReportError(result.error(), srcManager);
        return 1;
    }

    diagnostics.EmitAll(srcManager);

    Program *program = *result;
    for (Stmt *stmt : program->nodes)
    {
        std::cout << stmt->toString() << '\n';
    }
}