This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/core/text/tokenizer_ucd.h
T
2026-10-04 12:02:41 +02:00

50 lines
1.9 KiB
C++

/* tokenizer_ucd.h -- the Unicode properties a pre-tokeniser pattern can name.
*
* The tables are generated (tools/gen_tokenizer_ucd.cpp) by asking Oniguruma, the engine
* HuggingFace tokenizers matches Split patterns with, what each property contains. A pattern in a
* tokenizer.json means whatever it means THERE, so that is the one definition this compiler has:
* the general categories at Oniguruma's Unicode version, its `\s`, `\d` and `\w`, its scripts, and
* its case-folding orbits for `(?i)`.
*/
#pragma once
#include <cstddef>
#include <cstdint>
namespace rad {
namespace ucd {
/* General category, in the generator's order. */
enum Gc : uint8_t {
Lu, Ll, Lt, Lm, Lo, Mn, Mc, Me, Nd, Nl, No,
Pc, Pd, Ps, Pe, Pi, Pf, Po, Sm, Sc, Sk, So,
Zs, Zl, Zp, Cc, Cf, Cs, Co, Cn,
kGcCount
};
/* A run of one category, from `first` to the next run's `first`. */
struct GcRun { uint32_t first; uint32_t gc; };
struct CpRange { uint32_t first, last; };
struct ScriptTable { const char* name; const CpRange* ranges; size_t n; };
extern const GcRun k_gc_runs[];
extern const size_t k_gc_runs_n;
extern const CpRange k_white_space[]; /* \s */
extern const size_t k_white_space_n;
extern const CpRange k_digit[]; /* \d */
extern const size_t k_digit_n;
extern const CpRange k_word[]; /* \w as an atom, and the word test of \b */
extern const size_t k_word_n;
extern const CpRange k_word_class[]; /* \w inside a bracket class */
extern const size_t k_word_class_n;
extern const ScriptTable k_scripts[];
extern const size_t k_scripts_n;
/* Case-folding orbits: each is its length followed by its members. */
extern const uint32_t k_case_orbits[];
extern const size_t k_case_orbits_n;
/* Codepoints that (?i) also matches against a multi-codepoint sequence. */
extern const uint32_t k_case_multi[];
extern const size_t k_case_multi_n;
} /* namespace ucd */
} /* namespace rad */