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 Source

Text conversion (L551, L555 correction)

Scope: text NAME "..." declarations in the baseline converter (tools/bridge c|python, modes C/P of src/toc.om). The seeded frontends (tools/bridge-seeded, all other modes) refuse a text line with error 24 before reading its bytes. Only src/toc.om implements conversion.

  1. Lexing. A quote starts a text token only while parse_tx reads a declaration value (qtext), so note lines, cabi directives and every other line keep their earlier tokens. The span rules match the pinned seed's tok_text: the text ends at an unescaped quote on the same line; a raw LF, end of input inside the quotes or a non-blank byte right after the closing quote is error 22. Any further token on the declaration line is error 16 (the seed refuses it first, error 5). The token kind is 5 (kind 4 is a seeded float literal).
  2. Decoding. Exactly \n, \t, \\ and \" are decoded; any other escape is error 22. Raw NUL, CR, tab and bytes 128-255 are kept. Decoded bytes go into one fixed 32,768-byte pool; overflow is error 14. Texts share the eight-entry global table with global arrays (error 14 beyond), each with its pool offset, uchar element type, exact length and a read-only flag. Empty text has length zero.
  3. Access. get, len, write and readonly view arguments are accepted. put, read and edit arguments are refused (error 20), after the seed already refused them with the same code. Inline quoted expressions are refused by the seed (error 16) before the converter runs.
  4. C output. static const uint8_t gN[n]={b0,b1,...,}; with decimal initializers only, so no source byte reaches target syntax, and static const uint64_t gN_n=n;, so neither the bytes nor the bound that o_get checks can be changed or linked from outside the unit. Empty text uses a one-byte placeholder {0} with logical length gN_n=0, never an implicit terminator. Readonly view parameters (internal and exported) are const void *.
  5. Python output. gN=bytes((b0,b1,...,)). An exported function's readonly view uchar parameter accepts bytes or bytearray; an edit parameter still requires bytearray; other widths still require a list of valid values; length mismatches still return (8, None).
  6. Notes. Outside cabi library modes, tok skips a note body untokenized (skipline), as the seed does, so note bytes such as raw NUL no longer cause a converter-only error 16. Cabi library modes still read their note cabi directives token by token.
  7. Names and indices (L555 whole-core review). The converter itself refuses what the seed's topname and s_fn refuse, even when build/bridge runs without the seed in front: a text or global name longer than eight bytes (13); a text, global, function, parameter or local name that is a keyword (16; table kwlist: the seed's 66 words from omc.om 29b12760 fn kw in every mode, the seeded frontend's 93 further words from omega-mv e5b32567 fn kw in seeded modes, and the 6 words draft-1049 adds in its modes E and J; OM-2-only and target-conditional words are left to the seeded frontend, which runs first in tools/bridge-seeded); a text, global or function name that repeats another one in either order (10); and words after a global's count (16; the seed says 5). A parameter name is at most eight bytes (13) and may not repeat another parameter, a global or text declared above it, or any function (10, checked after the name scan and reported at that function's line, so cabi header and map modes refuse it too); a global or text declared below may share it, as in the seed. A literal index at or past a sized array's length is 21: get on any text (an empty one included) or global array, and put on a global array (put into a text stays 20). Length 0 marks an unsized runtime view only for locals. Known conservative differences, unchanged: a local named like a global declared below its function is refused 7 (the seed accepts it); baseline function names of 9 to 63 bytes are refused 13.

Verification: python3 tests/text.py (native/C/Python byte and status agreement for 380 sources, two targets each; 85 direct converter runs that bypass the seed: three accepted programs and 33 refusals in both baseline targets, a seeded-mode text refusal (24) and a seeded keyword parameter (16, accepted in the baseline target) in seeded targets, a draft-1049 keyword parameter (16 in E, accepted in D), and the cabi fixture accepted and a parameter named like a later function refused (10 at the function's line) in library modes L, M and V; 16 controls: valid compiled emitter mutants, emitted-storage and length mutants and library callers), tools/test.sh (runs it), the seeded suites, evidence/text-native/ and the parent qualification in evidence/text-parent-qualification/.