2026-07-18 18:48:23 +02:00
|
|
|
#include <iostream>
|
|
|
|
|
#include <iomanip>
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
#include <utility>
|
2026-09-21 22:37:13 +02:00
|
|
|
#include <stdexcept>
|
2026-07-18 18:48:23 +02:00
|
|
|
|
|
|
|
|
#include "locator.h"
|
|
|
|
|
#include "ktype.h"
|
|
|
|
|
#include "log.h"
|
|
|
|
|
#include "file.h"
|
|
|
|
|
#include "show.h"
|
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
bool is_error(katom_t t)
|
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
t == katom_t::undefined ||
|
|
|
|
|
t == katom_t::no_matching_end ||
|
|
|
|
|
t == katom_t::no_matching_begin ||
|
|
|
|
|
t == katom_t::karg_error ||
|
|
|
|
|
t == katom_t::klammer_definition_type_error ||
|
|
|
|
|
t == katom_t::eval_error;
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
bool is_active(katom_t type)
|
|
|
|
|
{
|
|
|
|
|
return type != katom_t::ignored
|
|
|
|
|
&& type != katom_t::replaced;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool is_printable(katom_t type)
|
|
|
|
|
{
|
|
|
|
|
return printable_katom_types.find(type) != printable_katom_types.end();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool is_deftype(katom_t type)
|
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
type == katom_t::klammer_definition ||
|
|
|
|
|
type == katom_t::klammer_instance ||
|
|
|
|
|
type == katom_t::klammer_override ||
|
|
|
|
|
type == katom_t::klammer_default;
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-21 22:37:13 +02:00
|
|
|
const Ktype& type_to_katom_instance(katom_t type)
|
2026-07-18 18:48:23 +02:00
|
|
|
{
|
2026-09-21 22:37:13 +02:00
|
|
|
auto var = std::find_if(katom_types.begin(), katom_types.end(),
|
|
|
|
|
[&] (const Ktype& t) { return t.m_type == type; });
|
|
|
|
|
if (var == katom_types.end()) {
|
|
|
|
|
throw std::logic_error(
|
|
|
|
|
"type_to_katom_instance: katom type " +
|
|
|
|
|
std::to_string(static_cast<int>(type)) +
|
|
|
|
|
" has no entry in katom_types. See file mac/ktype.h.");
|
2026-07-18 18:48:23 +02:00
|
|
|
}
|
2026-09-21 22:37:13 +02:00
|
|
|
return *var;
|
2026-07-18 18:48:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string type_to_name(katom_t type)
|
|
|
|
|
{
|
2026-09-21 22:37:13 +02:00
|
|
|
return type_to_katom_instance(type).m_name;
|
2026-07-18 18:48:23 +02:00
|
|
|
}
|