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 @@
#include "show.h"
#include "log.h"
#include "katom.h"
#include "argtype_set.h"
#include "argtype_registry.h"
#include "argument_set.h"
#include "util.h"
@@ -36,7 +36,7 @@ std::regex parameter_regex(bool optional=false)
// rest(2): the base type is copied, its type parameter set, and its
// display name extended, so kdesc signatures show rows.rest(2).
static Argtype resolve_argtype(
const std::string& type_text, const Argtype_set& argtypes, const Locator& loc)
const std::string& type_text, const Argtype_registry& argtypes, const Locator& loc)
{
static const std::regex parameterized(R"((\w+)\((\d+)\))");
std::smatch match {};
@@ -58,7 +58,7 @@ static bool is_rest(const Argtype& argtype)
Parameter_set::Parameter_set(const std::string parameter_string)
{
(void)K::log(3);
Argtype_set argtypes {};
Argtype_registry argtypes {};
parse_parameters(
katomize(line_split(parameter_string), Locator().str()),
argtypes);
@@ -69,11 +69,11 @@ Parameter_set::Parameter_set(const std::vector<Katom>& katoms)
: m_katoms(katoms)
{
(void)K::log(3);
Argtype_set argtypes {};
Argtype_registry argtypes {};
parse_parameters(m_katoms, argtypes);
}
Parameter_set::Parameter_set(const std::vector<Katom>& katoms, const Argtype_set& argtypes)
Parameter_set::Parameter_set(const std::vector<Katom>& katoms, const Argtype_registry& argtypes)
: m_katoms(katoms)
{
(void)K::log(3);
@@ -82,7 +82,7 @@ Parameter_set::Parameter_set(const std::vector<Katom>& katoms, const Argtype_set
// Parameter parsing
Parameter parse_positional_parameter(const katom_list& katoms, const Argtype_set& argtypes)
Parameter parse_positional_parameter(const katom_list& katoms, const Argtype_registry& argtypes)
{
// (void)K::log(3, katoms);
if (katoms.size() > 1) {
@@ -110,7 +110,7 @@ Parameter parse_positional_parameter(const katom_list& katoms, const Argtype_set
}
Parameter parse_optional_parameter(const katom_list& katoms, const Argtype_set& argtypes)
Parameter parse_optional_parameter(const katom_list& katoms, const Argtype_registry& argtypes)
{
//(void)K::log(3);
Katom k = katoms[0];
@@ -242,7 +242,7 @@ parameter_split(katom_list::const_iterator kbegin, katom_list::const_iterator ke
return {positional, optional};
}
void Parameter_set::parse_parameters(const katom_list& katoms, const Argtype_set& argtypes)
void Parameter_set::parse_parameters(const katom_list& katoms, const Argtype_registry& argtypes)
{
(void)K::log(3, trim(katoms));
if (katoms.empty()) {
@@ -274,10 +274,10 @@ void Parameter_set::parse_parameters(const katom_list& katoms, const Argtype_set
}
void describe_arguments(
std::string label,
std::vector<std::vector<Katom>> positional,
std::vector<std::vector<Katom>> optional,
std::vector<Katom> rest)
const std::string& label,
const std::vector<std::vector<Katom>>& positional,
const std::vector<std::vector<Katom>>& optional,
const std::vector<Katom>& rest)
{
std::cout << label << ":\n"
<< " positional: " << positional << "\n"