#include #include #include #include #include #include #include namespace Pilang3 { using integer_type = int64_t; namespace exceptions { class langException : public std::exception {}; class BadInteger : public langException {}; class BadArgs : public langException {}; class NoSuchCommand : public langException {}; class NoSuchVariable : public langException {}; } class Environment; class Evaluation; struct Variable; using SharedVariable = std::shared_ptr; using SharedEvaluation = std::shared_ptr; struct Variable { enum Type { id_string, id_integer, id_reference, id_evaluation, id_type [[maybe_unused]], id_any [[maybe_unused]], id_null [[maybe_unused]] } type; using Data = std::variant; Data data; }; using Cmdargs = std::vector; using Cmdfnc = std::function; using Cmddesc = std::tuple, bool>; extern std::unordered_map builtinCmds; class Environment { public: std::unordered_map globalVars; void *anybuf = nullptr; }; class Evaluation { public: Cmdargs arguments; Cmdfnc command = nullptr; std::string command_name; ssize_t exprlen; Evaluation(Environment& env, const std::string &expression, const bool autoeval = true); Variable execute(Environment& env); }; };