summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-12-08 10:46:50 -0500
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-12-08 10:46:50 -0500
commit778b73af8cd74791c5d2f8cc520d82e3b4e1f5de (patch)
tree7a41d068fbf90d72aa9a1aea897a2143c247f276 /lib
parentc1d821782a8d7948c52d01863508eabe42bd89e9 (diff)
Context globals; ctype functions
Diffstat (limited to 'lib')
-rw-r--r--lib/js/urweb.js14
-rw-r--r--lib/ur/basis.urs18
-rw-r--r--lib/ur/char.ur16
-rw-r--r--lib/ur/char.urs16
4 files changed, 64 insertions, 0 deletions
diff --git a/lib/js/urweb.js b/lib/js/urweb.js
index 863271d9..15c9df7e 100644
--- a/lib/js/urweb.js
+++ b/lib/js/urweb.js
@@ -23,6 +23,20 @@ function mod(x, y) { return x % y; }
function lt(x, y) { return x < y; }
function le(x, y) { return x <= y; }
+// Characters
+
+function isLower(c) { return c >= 'a' && c <= 'z'; }
+function isUpper(c) { return c >= 'A' && c <= 'Z'; }
+function isAlpha(c) { return isLower(c) || isUpper(c); }
+function isDigit(c) { return c >= '0' && c <= '9'; }
+function isAlnum(c) { return isAlpha(c) || isDigit(c); }
+function isBlank(c) { return c == ' ' || c == '\t'; }
+function isSpace(c) { return isBlank(c) || c == '\r' || c == '\n'; }
+function isXdigit(c) { return isDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); }
+function toLower(c) { return c.toLowercase(); }
+function toUpper(c) { return c.toUppercase(); }
+
+
// Lists
function cons(v, ls) {
diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs
index 31aa4cdd..200d9896 100644
--- a/lib/ur/basis.urs
+++ b/lib/ur/basis.urs
@@ -52,6 +52,24 @@ val ord_time : ord time
val mkOrd : t ::: Type -> {Lt : t -> t -> bool, Le : t -> t -> bool} -> ord t
+(** Character operations *)
+
+val isalnum : char -> bool
+val isalpha : char -> bool
+val isblank : char -> bool
+val iscntrl : char -> bool
+val isdigit : char -> bool
+val isgraph : char -> bool
+val islower : char -> bool
+val isprint : char -> bool
+val ispunct : char -> bool
+val isspace : char -> bool
+val isupper : char -> bool
+val isxdigit : char -> bool
+val tolower : char -> char
+val toupper : char -> char
+
+
(** String operations *)
val strlen : string -> int
diff --git a/lib/ur/char.ur b/lib/ur/char.ur
new file mode 100644
index 00000000..29e181e6
--- /dev/null
+++ b/lib/ur/char.ur
@@ -0,0 +1,16 @@
+type t = char
+
+val isAlnum = Basis.isalnum
+val isAlpha = Basis.isalpha
+val isBlank = Basis.isblank
+val isCntrl = Basis.iscntrl
+val isDigit = Basis.isdigit
+val isGraph = Basis.isgraph
+val isLower = Basis.islower
+val isPrint = Basis.isprint
+val isPunct = Basis.ispunct
+val isSpace = Basis.isspace
+val isUpper = Basis.isupper
+val isXdigit = Basis.isxdigit
+val toLower = Basis.tolower
+val toUpper = Basis.toupper
diff --git a/lib/ur/char.urs b/lib/ur/char.urs
new file mode 100644
index 00000000..02e55632
--- /dev/null
+++ b/lib/ur/char.urs
@@ -0,0 +1,16 @@
+type t = char
+
+val isAlnum : t -> bool
+val isAlpha : t -> bool
+val isBlank : t -> bool
+val isCntrl : t -> bool
+val isDigit : t -> bool
+val isGraph : t -> bool
+val isLower : t -> bool
+val isPrint : t -> bool
+val isPunct : t -> bool
+val isSpace : t -> bool
+val isUpper : t -> bool
+val isXdigit : t -> bool
+val toLower : t -> t
+val toUpper : t -> t