Files

70 lines
3.1 KiB
C++
Raw Permalink Normal View History

#pragma once
// 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.
#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,
const std::function<bool(const Katom&)>& level_inc,
const std::function<bool(const Katom&)>& level_dec,
bool error_exit,
const std::string& name);
std::vector<std::pair<Katom, Katom>>
find_spans(std::vector<Katom>& katoms,
const std::function<bool(const Katom&)>& level_inc,
const std::function<bool(const Katom&)>& level_dec,
bool error_exit=true,
const std::string& name="all");
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);
void process_unicode_sequences(std::vector<Katom>& katoms);
void mark_literal_katoms(std::vector<Katom>& katoms);
2026-07-25 21:16:21 +02:00
void hide_special_katoms(std::vector<Katom>& katoms);
void mark_ignored_katoms(std::vector<Katom>& katoms);
void process_klammer_katoms(std::vector<Katom>& katoms);