Files
klammertext/mac/target_registry.h
T
ack e4f1307aa9 Characters that killed a render, what may sit next to a klammer, and ref/
A character written in the ^...^ mnemonic form -- ^oe^, ^zz^, ^hello^ --
used to kill ktext outright: no message, no output, and an exit status
that looked like a crash because it was one.  Only the forms that happen
to spell hexadecimal digits escaped, and they were right by luck rather
than by reading.  Any caret form that names no character is now a located
error that quotes what was written.

A klammer may now sit inside square brackets and braces as it already
could inside parentheses, and may be followed by the punctuation that
ends a sentence: [@i word@], {@b word@}, @i word@'s.  The rule is a fixed
list of characters, because none of them can occur inside a klammer name
and so none of them is ambiguous next to a delimiter.  A letter still
cannot: "x@" is the named closing delimiter, so a letter before "@" has
two readings and no rule can separate them.

The abbreviations an author writes -- the hyphen form @i-word, a klammer
glued to its neighbouring punctuation -- are now recognised as author
conveniences only.  They are not applied to @@ definitions or @@@ system
commands, which are written by someone who needs no such shorthand and
whose forms are already whole.

Also fixed, each of them silent: an exported shell function in the
environment broke every @eval in the document; a line break written with
@nl was destroyed when it passed through a klammer that generates a
table, printing as \textbackslash{}newline in the finished PDF; and
"kdesc --coverage" shortened its file column by comparing the spelling of
a path rather than the path, so a klammer set reached by a symbolic link
showed a full path where its neighbours showed a short one.

New in the distribution: ref/, a small klammerset that describes the
Klammermachine's own tables in Klammertext.  It currently provides the
character tables -- the diacritics and the extended Latin letters -- as
klammers that render to any target, so the documentation of what can be
written cannot drift from what the machine accepts.  It is early, and
will grow.

The Klammertext taxonomy now has a section on targets, describes the
@@@klammerset system command alongside the other three, and states the
precedence of "^" -- what a caret means before a letter, a digit, a
punctuation character, and a quote, in one ordered list.

(from dev 6594c7ff8c1f)
2026-09-07 22:37:05 +02:00

84 lines
2.8 KiB
C++

#pragma once
#include <map>
#include <string>
#include "target.h"
#include "argument_set.h"
#include "katom.h"
#include "katomize.h"
#include "file.h"
class Target_registry
{
public:
static std::string declare_name;
static std::string general_name;
// The pseudo-target of an option set declaration (@@name.o), reserved in
// the target namespace exactly as "k" is: both declare an interface and
// document it, and neither produces output for any target.
static std::string optionset_name;
Target_registry();
void add(Target target);
void add(std::vector<Katom>::iterator begin, std::vector<Katom>::iterator end, std::vector<Katom>& katoms);
void check_for_previous_definition(const std::string& name, const Locator& loc) const;
/*
void add_transforms(std::string target_name, std::string transforms);
void add_transforms(
std::string target_name,
std::vector<std::pair<std::string, std::string>> transforms);
*/
bool has(const std::string& target_name) const;
Target get(const std::string& target_name, const Locator& loc) const;
void transform(const std::string& target_name, std::vector<Katom>& katoms) const;
std::vector<std::string> user_defined() const;
std::vector<std::string> applicable() const;
// `defined_outside`: list only targets declared in a file not in the list.
// The three pseudo-targets (k, o, *) are built in and always shown -- they
// are the language's, not any klammerset's.
std::string describe(int margin=2, bool long_format=false,
const strings_t& defined_outside = {}) const;
//Argtype_registry m_argtypes {};
std::map<std::string, Target> m_targets {};
std::vector<std::string> m_names {};
Parameter_set m_parameters {};
/*
std::string m_parameters_spec {"name | desc :after_apply :after_write :includes :escape :resolve | transforms.rest"};
Parameter_set m_parameters =
katomize_lines(line_split(m_parameters_spec), Locator().str());
*/
//Parameter_set m_parameters =
// Parameter_set(katomize({"name :desc | transforms.rest"}, "target_registry"));
/*
// Targets(Statevar_set& statevars);
target_ptr check_target_existence(
std::string name, Locator loc, bool should_exist);
void add(std::string name, std::string desc, std::string include,
// Statevar_set& statevars,
std::string transform,
std::string before_apply, std::string after_apply, std::string after_write,
Locator loc);
target_ptr check_target_name(
std::string target, bool allow_all, Locator loc);
std::map<std::string, target_ptr> targets {};
std::vector<std::string> names {};
void describe_suffixes();
void describe();
*/
};