Klammerset: the @@@klammerset construct, its search path, and const correctness

The @@@klammerset system command formally declares a klammerset — a
named, logically related group of klammer definitions — with an
operative, idempotent declaration (:requires and :files load in order
at the declaration point, relative to the declaring file). A bare
symbol given to ktext -k, kdesc --input, or :requires resolves to
x/x.k on the search path: the document's directory, then
KLAMMERTEXT_KLAMMERSETS, then KLAMMERTEXT_HOME; kdesc --klammerset
lists the available sets. sks/sks.k is the first declared klammerset,
so `-k sks` loads the SKS by name. The engine's lookup classes were
renamed *_set → *_registry to keep the two concepts apart, and the
whole C++ tree now follows standard const-correctness conventions.
tst/ gains klammerset_test.sh (18 cases).

(from dev 64b1abf23e56)
This commit is contained in:
2026-07-30 23:50:07 +02:00
parent c42981f7e2
commit ef77f03584
83 changed files with 1429 additions and 594 deletions

View File

@@ -5,7 +5,7 @@
std::regex Eval_python::statement_delimiter("\\s*;\\s*");
Eval_python::Eval_python(Machine& machine, Locator loc)
Eval_python::Eval_python(Machine& machine, const Locator& loc)
: m_machine(machine)
, m_loc(loc)
, m_globals(nullptr)
@@ -93,7 +93,7 @@ strings_t Eval_python::parse_modules(std::string code)
return modules;
}
void Eval_python::import_module(std::string module_name, bool verify)
void Eval_python::import_module(const std::string& module_name, bool verify)
{
(void)K::log(3, module_name);
@@ -176,12 +176,12 @@ std::string Eval_python::get_result(PyObject* result_object)
return result;
}
std::string Eval_python::eval_expression(std::string expression, bool import_modules)
std::string Eval_python::eval_expression(const std::string& expression, bool import_modules)
{
(void)K::log(3, expression);
// msg() << "expression: " << expression << "\n";
if (import_modules && expression.find('.') != std::string::npos) {
for (auto m : parse_modules(expression)) {
for (const auto& m : parse_modules(expression)) {
import_module(m);
}
}
@@ -191,7 +191,7 @@ std::string Eval_python::eval_expression(std::string expression, bool import_mod
Py_eval_input, m_globals, m_locals));
}
std::string Eval_python::eval_statements(std::string script)
std::string Eval_python::eval_statements(const std::string& script)
{
(void)K::log(3);
strings_t statements = regex_split(script, statement_delimiter);