more tolerant Symbol.decode;
authorwenzelm
Mon, 20 Jun 2011 23:21:24 +0200
changeset 43485 33a24212a72d
parent 43484 51b8043a8cf5
child 43486 4a1ef71fbf5f
more tolerant Symbol.decode;
src/Pure/General/symbol.ML
src/Pure/Thy/latex.ML
src/Tools/WWW_Find/unicode_symbols.ML
--- a/src/Pure/General/symbol.ML	Mon Jun 20 23:19:38 2011 +0200
+++ b/src/Pure/General/symbol.ML	Mon Jun 20 23:21:24 2011 +0200
@@ -43,7 +43,7 @@
   val encode_raw: string -> string
   datatype sym =
     Char of string | UTF8 of string | Sym of string | Ctrl of string | Raw of string |
-    Malformed of string
+    Malformed of string | EOF
   val decode: symbol -> sym
   datatype kind = Letter | Digit | Quasi | Blank | Other
   val kind: symbol -> kind
@@ -222,10 +222,11 @@
 
 datatype sym =
   Char of string | UTF8 of string | Sym of string | Ctrl of string | Raw of string |
-  Malformed of string;
+  Malformed of string | EOF;
 
 fun decode s =
-  if is_char s then Char s
+  if s = "" then EOF
+  else if is_char s then Char s
   else if is_utf8 s then UTF8 s
   else if is_raw s then Raw (decode_raw s)
   else if is_malformed s then Malformed s
--- a/src/Pure/Thy/latex.ML	Mon Jun 20 23:19:38 2011 +0200
+++ b/src/Pure/Thy/latex.ML	Mon Jun 20 23:21:24 2011 +0200
@@ -102,7 +102,8 @@
       if known_ctrl s then literal sym ^ "{}" ^ enclose "\\isactrl" " " s
       else output_chrs sym
   | Symbol.Raw s => s
-  | Symbol.Malformed s => error (Symbol.malformed_msg s));
+  | Symbol.Malformed s => error (Symbol.malformed_msg s)
+  | Symbol.EOF => error "Bad EOF symbol");
 
 in
 
--- a/src/Tools/WWW_Find/unicode_symbols.ML	Mon Jun 20 23:19:38 2011 +0200
+++ b/src/Tools/WWW_Find/unicode_symbols.ML	Mon Jun 20 23:21:24 2011 +0200
@@ -88,11 +88,10 @@
   >> token Comment;
 
 fun is_sym s =
-  Symbol.not_eof s andalso
-    (case Symbol.decode s of
-      Symbol.Sym _ => true
-    | Symbol.Ctrl _ => true
-    | _ => false);
+  (case Symbol.decode s of
+    Symbol.Sym _ => true
+  | Symbol.Ctrl _ => true
+  | _ => false);
 
 fun tokenize syms =
   let