feat(text): generate the Unicode tables and read them in the case natives #368
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/36-unicode-tables"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #36
Slice 1 of the full Unicode tables: pinned data, a reproducible generator, and the six natives reading the tables.
What changes
tools/fetch-unicode.shdownloads the pinned Unicode 17.0.0 files and verifies them againsttools/unicode/SHA256SUMS(kept inbuild/unicode/, not committed).tools/unicode/generate.trbwritesruntime/unicode_data.candruntime/include/torb_unicode_data.h. Running it twice gives byte-identical files.runtime/unicode.c:Char.isLetter,Char.isWhitespace,Char.toUpperCase,Char.toLowerCase(simple mappings),String.toUpperCase,String.toLowerCase(full default conversion: unconditional SpecialCasing mappings plus the Final_Sigma rule, no locale).tests/conformance/character-case.trbis rewritten and extended; the native build output matches the expected file.runtime/tests/unicode_test.cchecks the generated tables for every code point againstUnicodeData.txtwhen present (runtime/build.shfetches it, best effort) and against the committed excerptruntime/tests/unicode-excerpt.txtotherwise.text_test.cruns the same check through the natives, plus White_Space for every code point, special casing and Final_Sigma.tests/lexer-casespasses as is). One diagnostic changes with the exactisLetter: a digit of another script (count٣) was a "letter" by the old approximation and is now an unexpected character;compiler/tests/lexer.test.trbis updated with it.tests/conformance/character-case.allocationsgoes from 90 to 270 blocks: the extended program converts and compares many more texts.docs/standard-library/text.md,docs/BACKEND.md,docs/design/RELEASE.md,runtime/README.md, and the regeneratedskills/.docs/design/TEXT-FORMATS.mdis untouched.Deviations from the issue
DerivedCoreProperties.txt. Cased and Case_Ignorable are derived properties, needed by Final_Sigma. Its hash is pinned with the other three.top2176 entries,middle3296,leaves12128, 223 records of 12 bytes. Total table object ~25.8 KiB.unicode. The driver linksunicode.candunicode_data.conly when the emitted C names one of the six (or the program hosts the VM, which calls every native); otherwise it definesTORB_WITHOUT_UNICODE, and the generated thunks panic with "not linked into this program" (same pattern as TLS). A seed driver that links all*.cand defines no macro keeps working. Nothing underseed/, no syntax change, no new native.Size (hello world,
--release, native binary)unicode_data.o: 26456 B rodata;unicode.o~2.1 KiB. A program that never uses a table-backed native does not grow (limit 4 KiB).Verification
-Wall -Wextra -Wpedantic -Werror): 36 tests, 0 failed, both with the wholeUnicodeData.txtand with the excerpt.torb test compiler/tests/natives.test.trb: 18 passed.torb format --checkclean on the touched files;torb docs skill docs skills --checkup to date.a96ba0b77d0f81fc19b70f81fc19b73f4da233f23f4da233f2c3eee74a31Approved at
c3eee74. Checklist:unicode_test.c,text_test.c) check every code point againstUnicodeData.txtor the committed excerpt, plus White_Space, special casing and Final_Sigma;natives.test.trbcovers the part/driver detection; conformancecharacter-caseextended. CI (gates, bootstrap, tier A/B, same-C, playground, pdisc) is green on this head; the other-platform jobs are skipped by the workflow, not failed.tools/unicode/SHA256SUMSmatch the files at unicode.org for 17.0.0 (I fetched and hashed them); the fetch script never keeps a download with another hash, and the input is validated as digits and dots.String.toUpperCasecan now be longer than its input.Non-blocking: none.