A simple scripting language in C++
Ferenc Szontágh
2025-04-17 36ec04c00fa540fcee0f2cff1f7b81dd8a98101a
src/VoidScript.hpp
@@ -1,6 +1,5 @@
#ifndef VOIDSCRIPT_HPP
#define VOIDSCRIPT_HPP
#include <filesystem>
#include <fstream>
#include <string>
@@ -42,21 +41,24 @@
    int run() {
        try {
            while (!files.empty()) {
                std::string file = files.back();
                std::string       file         = files.back();
                const std::string file_content = readFile(file);
                files.pop_back();
                std::string _default_namespace_ = file;
                std::replace(_default_namespace_.begin(), _default_namespace_.end(), '.', '_');
                Symbols::SymbolContainer::instance()->create(_default_namespace_);
                const std::string ns = Symbols::SymbolContainer::instance()->currentScopeName();
                this->lexer->addNamespaceInput(ns, file_content);
                const auto tokens = this->lexer->tokenizeNamespace(ns);
                // dump tokens
                std::cout << "--- Tokens ---\n";
                for (const auto & token : tokens) {
                    token.print();
                }
                std::cout << Operations::Container::dump() << "\n";
@@ -69,11 +71,8 @@
            }  // while (!files.empty())
            return 0;
        } catch (const Parser::SyntaxError & e) {
            std::cerr << "Syntax Error during parsing: " << e.what() << '\n';
            return 1;
        } catch (const std::exception & e) {
            std::cerr << "An error occurred: " << e.what() << '\n';
            std::cerr  << e.what() << '\n';
            return 1;
        }
        return 1;