ocaml: character type — Char of int, #\a parser, all char primitives

- Char of int variant in sx_types.ml (Unicode codepoint)
- type_of → "char", inspect → #\a / #\space / #\newline notation
- #\ char literal reader in sx_parser.ml (named + single-char)
- make-char char? char->integer integer->char char-upcase char-downcase
- char=? char<? char>? char<=? char>=? comparators
- char-ci=? char-ci<? char-ci>? char-ci<=? char-ci>=? case-insensitive
- char-alphabetic? char-numeric? char-whitespace? char-upper-case? char-lower-case?
- string->list (returns Char values) and list->string (accepts Char values)
- fix get_val in sx_runtime.ml: add Integer n case for list indexing
- fix raw_serialize in sx_server.ml: Integer and Char variants
- 4493/4493 tests — +43 passing, zero regressions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-01 12:19:42 +00:00
parent 60f88ab4fe
commit b939becd86
5 changed files with 113 additions and 1 deletions

View File

@@ -1377,6 +1377,7 @@ let rec dispatch env cmd =
| Bool true -> "true"
| Bool false -> "false"
| Number n -> Sx_types.format_number n
| Integer n -> string_of_int n
| String s -> "\"" ^ escape_sx_string s ^ "\""
| Symbol s -> s
| Keyword k -> ":" ^ k
@@ -1390,6 +1391,7 @@ let rec dispatch env cmd =
| Island i -> "~" ^ i.i_name
| SxExpr s -> s
| RawHTML s -> "\"" ^ escape_sx_string s ^ "\""
| Char n -> Sx_types.inspect (Char n)
| _ -> "nil"
in
send_ok_raw (raw_serialize result)