2026-07-18 18:48:23 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2026-09-07 22:37:05 +02:00
|
|
|
// THE READ-TIME PASSES: katoms in, katoms out. What Machine::process_katoms()
|
|
|
|
|
// runs over a katom list once it exists -- encoding the ^-character forms,
|
|
|
|
|
// assembling ^UUUU UUUU^ sequences, marking literal and removed regions,
|
|
|
|
|
// hiding the quoted specials, finding spans, and delimiting @cond and
|
|
|
|
|
// klammer applications.
|
|
|
|
|
//
|
|
|
|
|
// Renamed from katom_list.{h,cpp} on 2026-09-02, which said "a list of
|
|
|
|
|
// katoms" and so described a data structure this file barely touches. It
|
|
|
|
|
// is named for the function it serves, which adds no vocabulary: text is
|
|
|
|
|
// KATOMIZED into KATOMs (katomize.{h,cpp}), and then PROCESSED here.
|
|
|
|
|
//
|
|
|
|
|
// The neighbours, and the line between them: katom.{h,cpp} is the katom
|
|
|
|
|
// itself and operations on a list of them; katomize.{h,cpp} turns text into
|
|
|
|
|
// katoms -- the one place a character stream enters. Nothing here takes
|
|
|
|
|
// characters, which is why none of it belongs there.
|
|
|
|
|
|
2026-07-18 18:48:23 +02:00
|
|
|
#include "katom.h"
|
|
|
|
|
#include "state.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string to_string(std::vector<Katom>::const_iterator begin, std::vector<Katom>::const_iterator end, bool trim_result=false);
|
|
|
|
|
std::string to_string(const std::vector<Katom>& katoms, bool trim_result=false);
|
|
|
|
|
|
|
|
|
|
// std::vector<Katom> process_katoms(
|
|
|
|
|
// const std::string& s, State& state, const std::string& source,
|
|
|
|
|
// bool nonascii=true, bool literal=true, bool ignore=true, bool whitespace=true,
|
|
|
|
|
// bool klammers=true, bool eval=true, bool cond=true, bool read=true);
|
|
|
|
|
|
|
|
|
|
bool level_increase(const Katom& k);
|
|
|
|
|
bool level_decrease(const Katom& k);
|
|
|
|
|
|
|
|
|
|
const katom_list::iterator
|
|
|
|
|
find_katom_named(const katom_list::iterator begin, const katom_list::iterator end, std::string name);
|
|
|
|
|
|
|
|
|
|
const std::vector<Katom>::iterator
|
|
|
|
|
find_katom(const std::vector<Katom>::iterator begin, const std::vector<Katom>::iterator end, size_t index);
|
|
|
|
|
|
|
|
|
|
std::vector<std::pair<Katom, Katom>>
|
|
|
|
|
find_spans(std::vector<Katom>::iterator begin, std::vector<Katom>::iterator end,
|
2026-07-30 23:50:07 +02:00
|
|
|
const std::function<bool(const Katom&)>& level_inc,
|
|
|
|
|
const std::function<bool(const Katom&)>& level_dec,
|
2026-07-18 18:48:23 +02:00
|
|
|
bool error_exit,
|
2026-07-30 23:50:07 +02:00
|
|
|
const std::string& name);
|
2026-07-18 18:48:23 +02:00
|
|
|
|
|
|
|
|
std::vector<std::pair<Katom, Katom>>
|
|
|
|
|
find_spans(std::vector<Katom>& katoms,
|
2026-07-30 23:50:07 +02:00
|
|
|
const std::function<bool(const Katom&)>& level_inc,
|
|
|
|
|
const std::function<bool(const Katom&)>& level_dec,
|
2026-07-18 18:48:23 +02:00
|
|
|
bool error_exit=true,
|
2026-07-30 23:50:07 +02:00
|
|
|
const std::string& name="all");
|
2026-07-18 18:48:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void describe_spans(const std::vector<Katom>& katoms);
|
|
|
|
|
|
|
|
|
|
std::pair<std::vector<Katom>::iterator, std::vector<Katom>::iterator>
|
|
|
|
|
find_span_katoms(std::vector<Katom>& katoms, const Katom& begin, const Katom& end);
|
|
|
|
|
|
|
|
|
|
std::pair<std::vector<Katom>::iterator, std::vector<Katom>::iterator>
|
|
|
|
|
find_span_katoms(
|
|
|
|
|
std::vector<Katom>::iterator kbegin, std::vector<Katom>::iterator kend, const Katom& begin, const Katom& end);
|
|
|
|
|
|
|
|
|
|
void encode_nonascii_characters(std::vector<Katom>& katoms);
|
2026-08-25 23:30:55 +02:00
|
|
|
void process_unicode_sequences(std::vector<Katom>& katoms);
|
2026-07-18 18:48:23 +02:00
|
|
|
void mark_literal_katoms(std::vector<Katom>& katoms);
|
2026-07-25 21:16:21 +02:00
|
|
|
void hide_special_katoms(std::vector<Katom>& katoms);
|
2026-07-18 18:48:23 +02:00
|
|
|
void mark_ignored_katoms(std::vector<Katom>& katoms);
|
|
|
|
|
|
|
|
|
|
void process_klammer_katoms(std::vector<Katom>& katoms);
|