2026-07-18 18:48:23 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <limits>
|
|
|
|
|
#include <tuple>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include "katom.h"
|
|
|
|
|
#include "argument.h"
|
|
|
|
|
#include "locator.h"
|
|
|
|
|
|
|
|
|
|
class Argtype_set;
|
|
|
|
|
|
|
|
|
|
std::tuple<std::vector<std::vector<Katom>>,std::vector<std::vector<Katom>>,std::vector<Katom>>
|
|
|
|
|
argument_split(std::vector<Katom>::const_iterator kbegin, std::vector<Katom>::const_iterator kend,
|
|
|
|
|
long unsigned int positional_limit = std::numeric_limits<int>::max());
|
|
|
|
|
|
|
|
|
|
class Parameter_set
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Parameter_set() {};
|
|
|
|
|
~Parameter_set() = default;
|
|
|
|
|
Parameter_set(const std::string parameter_string);
|
|
|
|
|
Parameter_set(const std::vector<Katom>& katoms);
|
|
|
|
|
Parameter_set(const std::vector<Katom>& katoms, const Argtype_set& argtypes);
|
|
|
|
|
|
|
|
|
|
void parse_parameters(const std::vector<Katom>& katoms, const Argtype_set& argtypes);
|
|
|
|
|
void describe_parameters();
|
|
|
|
|
|
|
|
|
|
void check_positional(
|
|
|
|
|
const std::vector<std::vector<Katom>>& positional_arguments, const Locator& loc);
|
|
|
|
|
std::map<std::string, std::string> check_optional(
|
|
|
|
|
const std::vector<std::vector<Katom>>& optional_arguments, const Locator& loc);
|
|
|
|
|
const std::map<std::string, std::string> value_map(
|
|
|
|
|
const std::vector<std::vector<Katom>>& positional,
|
|
|
|
|
const std::vector<std::vector<Katom>>& optional,
|
|
|
|
|
const std::vector<Katom>& rest,
|
|
|
|
|
const Locator& loc);
|
Typed arguments, calculated tables, spans, closed-world fonts, top-level fnt/ and env/
Sync with klammertext-dev through b90b0e09:
- Argument types end to end: :python_cast values are applied (Python
@eval receives real bools/numbers/lists), argument values are
validated against their argtype patterns with the argtype's
description as the error message, argtypes can declare :default
(overridable per declaration), and parameterized type families are
supported: rest(N) casts a rest argument to an N-dimensional list
(bar-count = dimension).
- Unified indexed_range syntax (selector with parenthesized subsets,
composable mnemonic names) for table lines and spans.
- Table klammer: caption fonts fixed in both targets, :column_width /
:leading / :colsep wired, :colspan and :rowspan render (HTML
attributes; \multicolumn / \multirow), calculated cell values (:calc)
with prefix operators, display-precision semantics, :calc_format and
:decimal period|comma.
- Fonts: closed-world resolution on the Klammertext font store
(infrastructure in mac/font_store; no Google Fonts links or fetch).
Default fonts live in the top-level fnt/; additional fonts install
into KLAMMERTEXT_FONTS directories via kdesc --font (list, samples,
preview, install — classification by font metadata). CSS font family
names are quoted (digit-initial families were silently lost).
- Environment files moved from mac/env/ to the top-level env/; shell
profiles source env/runtime.env. Dead per-host variants removed.
- Container: fnt/ ships in the image; curl removed (no network use).
2026-07-22 18:17:43 +02:00
|
|
|
const Parameter* find(const std::string& name) const;
|
|
|
|
|
static void validate(
|
|
|
|
|
const Parameter& parameter, const std::string& value, const Locator& loc);
|
2026-07-18 18:48:23 +02:00
|
|
|
bool empty() const { return m_katoms.size() == 0; };
|
|
|
|
|
|
|
|
|
|
std::vector<Katom> m_katoms {};
|
|
|
|
|
//Argtype_set m_argtypes {};
|
|
|
|
|
std::vector<Parameter> m_positional {};
|
|
|
|
|
std::vector<Parameter> m_optional {};
|
|
|
|
|
std::vector<std::string> m_optional_names {};
|
|
|
|
|
std::vector<Parameter> m_rest {};
|
|
|
|
|
size_t m_positional_count = std::numeric_limits<int>::max();
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
bool operator==(Parameter_set lhs, Parameter_set rhs);
|
|
|
|
|
|
|
|
|
|
// The Argument_set alias is used at application sites, where the set
|
|
|
|
|
// describes arguments rather than parameters. See argument.h.
|
|
|
|
|
using Argument_set = Parameter_set;
|
|
|
|
|
|
|
|
|
|
void describe_arguments(
|
|
|
|
|
std::string label,
|
|
|
|
|
std::vector<std::vector<Katom>> positional,
|
|
|
|
|
std::vector<std::vector<Katom>> optional,
|
|
|
|
|
std::vector<Katom> rest);
|
|
|
|
|
|
|
|
|
|
std::string replace_arguments(
|
|
|
|
|
const std::map<std::string, std::string>& values,
|
|
|
|
|
const std::string& parameterized_text, const Locator& loc);
|