diff options
author | Adam Chlipala <adamc@hcoop.net> | 2010-01-12 16:09:13 -0500 |
---|---|---|
committer | Adam Chlipala <adamc@hcoop.net> | 2010-01-12 16:09:13 -0500 |
commit | 7ed5deb4aa0f7c9a61133a489f0d00e73d95c225 (patch) | |
tree | e4130a31cf93875c66cb452ebcf893a4d2254f25 | |
parent | 3d4fdaf97e3ed4a0f1904be5079f8e71784a4cd5 (diff) |
Allow escaped backslashes in literals; conversion betwixt int and char
-rw-r--r-- | include/urweb.h | 3 | ||||
-rw-r--r-- | lib/ur/basis.urs | 3 | ||||
-rw-r--r-- | lib/ur/char.ur | 3 | ||||
-rw-r--r-- | lib/ur/char.urs | 3 | ||||
-rw-r--r-- | src/c/urweb.c | 8 | ||||
-rw-r--r-- | src/urweb.lex | 1 |
6 files changed, 20 insertions, 1 deletions
diff --git a/include/urweb.h b/include/urweb.h index 84da7694..b62adce1 100644 --- a/include/urweb.h +++ b/include/urweb.h @@ -258,6 +258,9 @@ uw_Basis_bool uw_Basis_isxdigit(uw_context, uw_Basis_char); 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 --git a/lib/ur/basis.urs b/lib/ur/basis.urs index d61763af..ea50b0b3 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -68,7 +68,8 @@ val isupper : char -> bool val isxdigit : char -> bool val tolower : char -> char val toupper : char -> char - +val ord : char -> int +val chr : int -> char (** String operations *) diff --git a/lib/ur/char.ur b/lib/ur/char.ur index 29e181e6..d2890bea 100644 --- a/lib/ur/char.ur +++ b/lib/ur/char.ur @@ -14,3 +14,6 @@ val isUpper = Basis.isupper val isXdigit = Basis.isxdigit val toLower = Basis.tolower val toUpper = Basis.toupper + +val toInt = Basis.ord +val fromInt = Basis.chr diff --git a/lib/ur/char.urs b/lib/ur/char.urs index 02e55632..c185af92 100644 --- a/lib/ur/char.urs +++ b/lib/ur/char.urs @@ -14,3 +14,6 @@ val isUpper : t -> bool val isXdigit : t -> bool val toLower : t -> t val toUpper : t -> t + +val toInt : t -> int +val fromInt : int -> t diff --git a/src/c/urweb.c b/src/c/urweb.c index 006e2e28..8ccecdaa 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -3375,6 +3375,14 @@ uw_Basis_char uw_Basis_toupper(uw_context ctx, uw_Basis_char c) { 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 --git a/src/urweb.lex b/src/urweb.lex index d2227d16..45f555dd 100644 --- a/src/urweb.lex +++ b/src/urweb.lex @@ -198,6 +198,7 @@ xint = x[0-9a-fA-F][0-9a-fA-F]; <STRING,CHAR> "\\\"" => (str := #"\"" :: !str; continue()); <STRING,CHAR> "\\'" => (str := #"'" :: !str; continue()); <STRING,CHAR> "\\n" => (str := #"\n" :: !str; continue()); +<STRING,CHAR> "\\\\" => (str := #"\\" :: !str; continue()); <STRING,CHAR> "\\t" => (str := #"\t" :: !str; continue()); <STRING,CHAR> "\n" => (newline yypos; str := #"\n" :: !str; continue()); |