A simple scripting language in C++
Ferenc Szontágh
2025-04-18 fb8d8f9f5bb4a1f7736d927a346d4bf834a28ffa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// PrintModule.hpp
#ifndef MODULES_PRINTMODULE_HPP
#define MODULES_PRINTMODULE_HPP
 
#include <iostream>
#include "BaseModule.hpp"
#include "ModuleManager.hpp"
#include "Symbols/Value.hpp"
 
namespace Modules {
 
/**
 * @brief Module that provides a built-in print function.
 */
class PrintModule : public BaseModule {
  public:
    void registerModule() override {
        auto &mgr = ModuleManager::instance();
        mgr.registerFunction("print", [](const std::vector<Symbols::Value> &args) {
            for (const auto &v : args) {
                std::cout << Symbols::Value::to_string(v);
            }
            return Symbols::Value();
        });
    }
};
 
} // namespace Modules
#endif // MODULES_PRINTMODULE_HPP