# HG changeset patch # User Adam Chlipala # Date 1263330553 18000 # Node ID e1cf925e20740330d46e50dd2ef170e454383d9b # Parent f93dc2ea30c1d0f3d18763ef537ac0e26d3ad472 Allow escaped backslashes in literals; conversion betwixt int and char diff -r f93dc2ea30c1 -r e1cf925e2074 include/urweb.h --- a/include/urweb.h Tue Jan 12 11:19:02 2010 -0500 +++ b/include/urweb.h Tue Jan 12 16:09:13 2010 -0500 @@ -258,6 +258,9 @@ uw_Basis_char uw_Basis_tolower(uw_context, uw_Basis_char); uw_Basis_char uw_Basis_toupper(uw_context, uw_Basis_char); +uw_Basis_int uw_Basis_ord(uw_context, uw_Basis_char); +uw_Basis_char uw_Basis_chr(uw_context, uw_Basis_int); + uw_Basis_string uw_Basis_currentUrl(uw_context); void uw_set_currentUrl(uw_context, char *); diff -r f93dc2ea30c1 -r e1cf925e2074 lib/ur/basis.urs --- a/lib/ur/basis.urs Tue Jan 12 11:19:02 2010 -0500 +++ b/lib/ur/basis.urs Tue Jan 12 16:09:13 2010 -0500 @@ -68,7 +68,8 @@ val isxdigit : char -> bool val tolower : char -> char val toupper : char -> char - +val ord : char -> int +val chr : int -> char (** String operations *) diff -r f93dc2ea30c1 -r e1cf925e2074 lib/ur/char.ur --- a/lib/ur/char.ur Tue Jan 12 11:19:02 2010 -0500 +++ b/lib/ur/char.ur Tue Jan 12 16:09:13 2010 -0500 @@ -14,3 +14,6 @@ val isXdigit = Basis.isxdigit val toLower = Basis.tolower val toUpper = Basis.toupper + +val toInt = Basis.ord +val fromInt = Basis.chr diff -r f93dc2ea30c1 -r e1cf925e2074 lib/ur/char.urs --- a/lib/ur/char.urs Tue Jan 12 11:19:02 2010 -0500 +++ b/lib/ur/char.urs Tue Jan 12 16:09:13 2010 -0500 @@ -14,3 +14,6 @@ val isXdigit : t -> bool val toLower : t -> t val toUpper : t -> t + +val toInt : t -> int +val fromInt : int -> t diff -r f93dc2ea30c1 -r e1cf925e2074 src/c/urweb.c --- a/src/c/urweb.c Tue Jan 12 11:19:02 2010 -0500 +++ b/src/c/urweb.c Tue Jan 12 16:09:13 2010 -0500 @@ -3375,6 +3375,14 @@ return toupper(c); } +uw_Basis_int uw_Basis_ord(uw_context ctx, uw_Basis_char c) { + return (unsigned char)c; +} + +uw_Basis_char uw_Basis_chr(uw_context ctx, uw_Basis_int n) { + return n; +} + uw_Basis_string uw_Basis_currentUrl(uw_context ctx) { return ctx->current_url; } diff -r f93dc2ea30c1 -r e1cf925e2074 src/urweb.lex --- a/src/urweb.lex Tue Jan 12 11:19:02 2010 -0500 +++ b/src/urweb.lex Tue Jan 12 16:09:13 2010 -0500 @@ -198,6 +198,7 @@ "\\\"" => (str := #"\"" :: !str; continue()); "\\'" => (str := #"'" :: !str; continue()); "\\n" => (str := #"\n" :: !str; continue()); + "\\\\" => (str := #"\\" :: !str; continue()); "\\t" => (str := #"\t" :: !str; continue()); "\n" => (newline yypos; str := #"\n" :: !str; continue());