lib: drop non-Hare extras (ascii.digitval, bytes.copy, fmt.errpos)

ascii.digitval/isidstart/isidpart are lexer-private, not Hare-stdlib.
Moved into lib/ww/lex/lex.ww as fn (renamed digitval to hexval since
its sole job is the \\xHH escape decoder).

bytes.copy and fmt.errpos have no Hare counterpart and no external
callers; gone.
This commit is contained in:
2026-05-13 03:24:33 +09:00
parent f4743dc5d5
commit 9bc973dc96
8 changed files with 110 additions and 169 deletions

View File

@@ -473,33 +473,6 @@ export fn isxdigit(c: rune) bool = {
return false;
};
// digitval — value of `c` as a hex/decimal digit. void variant means
// `c` isn't a hex digit. Useful when scanning numeric literals.
export fn digitval(c: rune) (i32 | void) = {
if (isdigit(c)) { return (c - 48): i32; };
if (c >= 65) {
if (c <= 70) { return ((c - 65) + 10): i32; };
};
if (c >= 97) {
if (c <= 102) { return ((c - 97) + 10): i32; };
};
return;
};
// isidstart / isidpart — identifier classes used by the lexer.
// Alpha or '_' starts; alnum or '_' continues.
export fn isidstart(c: rune) bool = {
if (isalpha(c)) { return true; };
if (c == 95) { return true; }; // '_'
return false;
};
export fn isidpart(c: rune) bool = {
if (isalnum(c)) { return true; };
if (c == 95) { return true; };
return false;
};
// tolower / toupper — fold ASCII case. Non-letters pass through.
export fn tolower(c: rune) rune = {
if (isupper(c)) { return c + 32; };
@@ -654,14 +627,10 @@ export fn main() i32 = {
if (!ascii.isdigit(53)) { return 14; }; // '5'
if (ascii.isdigit(65)) { return 15; }; // 'A' is not a digit
if (!ascii.isalpha(122)) { return 16; }; // 'z'
if (!ascii.isidstart(95)) { return 17; }; // '_'
if (!ascii.isidpart(48)) { return 18; }; // '0' is part
let dv: (i32 | void) = ascii.digitval(70);
match (dv) {
case let v: i32 => { if (v != 15) { return 19; }; }; // 'F' = 15
case void => { return 19; };
};
if (ascii.tolower(65) != 97) { return 20; }; // 'A' -> 'a'
if (!ascii.isxdigit(70)) { return 17; }; // 'F'
if (ascii.isxdigit(71)) { return 18; }; // 'G' is not hex
if (ascii.tolower(65) != 97) { return 19; }; // 'A' -> 'a'
if (ascii.toupper(122) != 90) { return 20; }; // 'z' -> 'Z'
// Probe 7 — file open/read via the new os APIs. /proc/self/cmdline
// always exists on Linux, no write side, and is non-empty.

View File

@@ -140,14 +140,10 @@ export fn main() i32 = {
if (!ascii.isdigit(53)) { return 14; }; // '5'
if (ascii.isdigit(65)) { return 15; }; // 'A' is not a digit
if (!ascii.isalpha(122)) { return 16; }; // 'z'
if (!ascii.isidstart(95)) { return 17; }; // '_'
if (!ascii.isidpart(48)) { return 18; }; // '0' is part
let dv: (i32 | void) = ascii.digitval(70);
match (dv) {
case let v: i32 => { if (v != 15) { return 19; }; }; // 'F' = 15
case void => { return 19; };
};
if (ascii.tolower(65) != 97) { return 20; }; // 'A' -> 'a'
if (!ascii.isxdigit(70)) { return 17; }; // 'F'
if (ascii.isxdigit(71)) { return 18; }; // 'G' is not hex
if (ascii.tolower(65) != 97) { return 19; }; // 'A' -> 'a'
if (ascii.toupper(122) != 90) { return 20; }; // 'z' -> 'Z'
// Probe 7 — file open/read via the new os APIs. /proc/self/cmdline
// always exists on Linux, no write side, and is non-empty.