interplane.Get Omega
Read in your language

omega-bridge

Omega-first language interoperability: checked conversion backends and native language bindings

Brought by drakestapleton

branch main Branches Tags History

omega-bridge / docs / TEXT-CONVERSION.md

58 lines · 4913 bytes Raw Blame History Rendered
1# Text conversion (L551, L555 correction)
2
3Scope: `text NAME "..."` declarations in the baseline converter (`tools/bridge c|python`,
4modes `C`/`P` of `src/toc.om`). The seeded frontends (`tools/bridge-seeded`, all other modes)
5refuse a text line with error 24 before reading its bytes. Only `src/toc.om` implements conversion.
6
71. Lexing. A quote starts a text token only while `parse_tx` reads a declaration value
8 (`qtext`), so note lines, cabi directives and every other line keep their earlier tokens.
9 The span rules match the pinned seed's `tok_text`: the text ends at an unescaped quote on the
10 same line; a raw LF, end of input inside the quotes or a non-blank byte right after the closing
11 quote is error 22. Any further token on the declaration line is error 16 (the seed refuses it
12 first, error 5). The token kind is 5 (kind 4 is a seeded float literal).
132. Decoding. Exactly `\n`, `\t`, `\\` and `\"` are decoded; any other escape is error 22. Raw
14 NUL, CR, tab and bytes 128-255 are kept. Decoded bytes go into one fixed 32,768-byte pool;
15 overflow is error 14. Texts share the eight-entry global table with global arrays (error 14
16 beyond), each with its pool offset, uchar element type, exact length and a read-only flag.
17 Empty text has length zero.
183. Access. `get`, `len`, `write` and readonly `view` arguments are accepted. `put`, `read` and
19 `edit` arguments are refused (error 20), after the seed already refused them with the same code.
20 Inline quoted expressions are refused by the seed (error 16) before the converter runs.
214. C output. `static const uint8_t gN[n]={b0,b1,...,};` with decimal initializers only, so no
22 source byte reaches target syntax, and `static const uint64_t gN_n=n;`, so neither the bytes nor
23 the bound that `o_get` checks can be changed or linked from outside the unit. Empty text uses a
24 one-byte placeholder `{0}` with logical length `gN_n=0`, never an implicit terminator. Readonly
25 view parameters (internal and exported) are `const void *`.
265. Python output. `gN=bytes((b0,b1,...,))`. An exported function's readonly `view uchar` parameter
27 accepts `bytes` or `bytearray`; an `edit` parameter still requires `bytearray`; other widths
28 still require a list of valid values; length mismatches still return `(8, None)`.
296. Notes. Outside cabi library modes, `tok` skips a note body untokenized (`skipline`), as the seed
30 does, so note bytes such as raw NUL no longer cause a converter-only error 16. Cabi library
31 modes still read their `note cabi` directives token by token.
327. Names and indices (L555 whole-core review). The converter itself refuses what the seed's
33 `topname` and `s_fn` refuse, even when `build/bridge` runs without the seed in front: a text or
34 global name longer than eight bytes (13); a text, global, function, parameter or local name that
35 is a keyword (16; table `kwlist`: the seed's 66 words from omc.om 29b12760 `fn kw` in every mode,
36 the seeded frontend's 93 further words from omega-mv e5b32567 `fn kw` in seeded modes, and the 6
37 words draft-1049 adds in its modes E and J; OM-2-only and target-conditional words are left to the
38 seeded frontend, which runs first in `tools/bridge-seeded`); a
39 text, global or function name that repeats another one in either order (10); and words after a
40 global's count (16; the seed says 5). A parameter name is at most eight bytes (13) and may not
41 repeat another parameter, a global or text declared above it, or any function (10, checked after
42 the name scan and reported at that function's line, so cabi header and map modes refuse it too);
43 a global or text declared below may
44 share it, as in the seed. A literal index at or past a sized array's length is 21: `get` on any
45 text (an empty one included) or global array, and `put` on a global array (`put` into a text
46 stays 20). Length 0 marks an unsized runtime view only for locals. Known conservative
47 differences, unchanged: a local named like a global declared below its function is refused 7
48 (the seed accepts it); baseline function names of 9 to 63 bytes are refused 13.
49
50Verification: `python3 tests/text.py` (native/C/Python byte and status agreement for 380 sources,
51two targets each; 85 direct converter runs that bypass the seed: three accepted programs and 33
52refusals in both baseline targets, a seeded-mode text refusal (24) and a seeded keyword parameter
53(16, accepted in the baseline target) in seeded targets, a draft-1049 keyword parameter (16 in E,
54accepted in D), and the cabi fixture accepted and a parameter named like a later function refused
55(10 at the function's line) in library modes L, M and V; 16 controls:
56valid compiled emitter mutants, emitted-storage and length mutants and library callers),
57`tools/test.sh` (runs it), the seeded suites, `evidence/text-native/` and the parent qualification
58in `evidence/text-parent-qualification/`.