A simple scripting language in C++
Ferenc Szontágh
2025-04-18 3d9e8a26930930a4b63143f800bfa28e5d3caaf6
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
30
31
// PrintLnModule.hpp
#ifndef MODULES_PRINTLNMODULE_HPP
#define MODULES_PRINTLNMODULE_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 PrintNlModule : public BaseModule {
  public:
    void registerModule() override {
        auto & mgr = ModuleManager::instance();
        mgr.registerFunction("printnl", [](const std::vector<Symbols::Value> & args) {
            for (const auto & v : args) {
                std::cout << Symbols::Value::to_string(v);
            }
            std::cout << "\n";
            return Symbols::Value();
        });
    }
};
 
}  // namespace Modules
#endif  // MODULES_PrintLnModule_HPP