1 Char
share/lib/std/scalar/char.flx
open class Char
{
fun ord: char -> int = "(int)$1";
ctor[t in ints] char: t = "(char)$1";
fun toupper : char -> char requires C89_headers::ctype_h;
fun tolower : char -> char requires C89_headers::ctype_h;
fun isupper : char -> bool = "!!isupper($1)" requires C89_headers::ctype_h;
fun islower : char -> bool = "!!islower($1)" requires C89_headers::ctype_h;
fun isalnum : char -> bool = "!!isalnum($1)" requires C89_headers::ctype_h;
fun isalpha : char -> bool = "!!isalpha($1)" requires C89_headers::ctype_h;
fun isdigit : char -> bool = "!!isdigit($1)" requires C89_headers::ctype_h;
fun isxdigit : char -> bool = "!!isxdigit($1)" requires C89_headers::ctype_h;
fun iscntrl : char -> bool = "!!iscntrl($1)" requires C89_headers::ctype_h;
fun isspace : char -> bool = "!!isspace($1)" requires C89_headers::ctype_h;
fun isblank : char -> bool = "!!isblank($1)" requires C89_headers::ctype_h;
fun isprint : char -> bool = "!!isprint($1)" requires C89_headers::ctype_h;
fun ispunct : char -> bool = "!!ispunct($1)" requires C89_headers::ctype_h;
val upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
val lower = "abcdefghijklmnopqrstuvwxyz";
val letters = upper + lower;
val digits = "0123456789";
val alphanum = letters + digits;
val cidstart = letters + "_";
val cidcont= alphanum+"_";
val flxidcont= alphanum+"_-'";
val camlidcont= alphanum+"_'";
val numeric = digits + ".eEdD_";
fun isidstart(x:char) => match (find$ letters,x) with | Some _ => true | #None => false endmatch;
fun iscidstart(x:char) => match find$ cidstart,x with | Some _ => true | #None => false endmatch;
fun iscidcont(x:char) => match find$ cidcont,x with | Some _ => true | #None => false endmatch;
fun iscamlidcont(x:char) => match find$ camlidcont,x with | Some _ => true | #None => false endmatch;
fun isflxidcont(x:char) => match find$ flxidcont,x with | Some _ => true | #None => false endmatch;
fun isnumeric(x:char) => match find$ numeric,x with | Some _ => true | #None => false endmatch;
fun isalphanum(x:char) => isidstart x or isdigit x;
fun isletter (x:char) => match find$ letters, x with | Some _ => true | #None => false endmatch;
fun issq(x:char) => x == char "'";
fun isdq(x:char) => x == char '"';
fun isslosh(x:char) => x == char '\\';
fun isnull(x:char) => x == char "";
fun iseol(x:char) => x == char "\n";
}
instance[T in chars] Str[T] {
fun str: T -> string = "::flx::rtl::strutil::str<#1>($1)" requires package "flx_strutil";
}
instance[T in chars] Repr[T] {
fun repr[with Str[T]] (c:T) : string = {
val s = str c;
return
match s with
| "'" => "\\'"
| '\t' => '\\t'
| '\n' => '\\n'
| '\r' => '\\r'
| '\f' => '\\f'
| '\v' => '\\v'
| _ => s
endmatch
;
}
}
instance Tord[char]
{
fun < : char * char -> bool = "$1<$2";
}
open Tord[char];