2026-07-18 18:48:23 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
|
#include <iomanip>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
#include "katom.h"
|
|
|
|
|
#include "locator.h"
|
|
|
|
|
|
|
|
|
|
class Target
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Target() = default;
|
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)
2026-07-30 23:50:07 +02:00
|
|
|
// Target(std::vector<Katom>::iterator begin, std::vector<Katom>::iterator end, Argtype_registry argtypes);
|
|
|
|
|
Target(const std::string& name, const std::string& desc, const Locator& loc)
|
2026-07-18 18:48:23 +02:00
|
|
|
: m_name(name)
|
|
|
|
|
, m_desc(desc)
|
|
|
|
|
, m_loc(loc)
|
|
|
|
|
{};
|
|
|
|
|
|
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)
2026-07-30 23:50:07 +02:00
|
|
|
void add_transform(const std::string& original, const std::string& transformed);
|
|
|
|
|
void add_transforms(const std::string& transforms);
|
|
|
|
|
void add_transforms(const std::vector<std::pair<std::string, std::string>>& transforms);
|
|
|
|
|
void transform(std::vector<Katom>& katoms) const;
|
2026-07-18 18:48:23 +02:00
|
|
|
|
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)
2026-07-30 23:50:07 +02:00
|
|
|
void add_escapes(const std::string& escape_spec);
|
2026-07-18 18:48:23 +02:00
|
|
|
std::string escape_text(std::string text) const;
|
|
|
|
|
std::string unescape_text(std::string text) const;
|
|
|
|
|
std::string resolve_escapes(std::string text) const;
|
|
|
|
|
static std::string escape_marker(const std::string& ch);
|
|
|
|
|
|
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)
2026-07-30 23:50:07 +02:00
|
|
|
void add_after_apply(const std::string& function_specs);
|
2026-07-18 18:48:23 +02:00
|
|
|
|
|
|
|
|
std::string m_name {};
|
|
|
|
|
std::string m_desc {};
|
|
|
|
|
std::vector<std::string> m_includes {};
|
|
|
|
|
std::vector<std::string> m_provides {};
|
|
|
|
|
std::vector<std::string> m_after_apply {};
|
|
|
|
|
|
|
|
|
|
Locator m_loc {};
|
|
|
|
|
std::vector<std::pair<std::string, std::string>> m_transforms {};
|
|
|
|
|
std::vector<std::pair<std::string, std::string>> m_escapes {};
|
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)
2026-07-30 23:50:07 +02:00
|
|
|
// Argtype_registry m_argtypes {};
|
2026-07-18 18:48:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::vector<std::pair<std::string, std::string>>
|
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)
2026-07-30 23:50:07 +02:00
|
|
|
parse_transforms(const std::string& transform_string);
|
2026-07-25 21:16:21 +02:00
|
|
|
|
|
|
|
|
// Decode every KTESC<hex>KTESC marker in text back to its original
|
|
|
|
|
// characters. Used for the final output (after target-declared escapes have
|
|
|
|
|
// been resolved to their replacements) and for programmatic use of argument
|
|
|
|
|
// values. The Python counterpart is unescape_ktesc() in klammer_base.py.
|
|
|
|
|
std::string ktesc_resolve(std::string text);
|
|
|
|
|
|
|
|
|
|
// Replace each Klammertext structural character (@ | # ^ : *) in s with its
|
|
|
|
|
// KTESC marker, so text that has already been interpreted once (quoted
|
|
|
|
|
// specials, ^'...'^ literal content) survives re-katomization by
|
|
|
|
|
// sub-Machines and the @eval result read-back. Resolved by ktesc_resolve()
|
|
|
|
|
// at final processing.
|
|
|
|
|
std::string hide_structural_characters(const std::string& s);
|