further clarification of malformed symbols;
authorwenzelm
Sat, 11 Aug 2012 21:10:36 +0200
changeset 48774 c4bd5bb3ae69
parent 48773 0e1bab274672
child 48775 92ceb058391f
further clarification of malformed symbols;
src/Pure/General/symbol.ML
src/Pure/General/symbol.scala
--- a/src/Pure/General/symbol.ML	Sat Aug 11 20:54:06 2012 +0200
+++ b/src/Pure/General/symbol.ML	Sat Aug 11 21:10:36 2012 +0200
@@ -115,7 +115,10 @@
 
 fun is_regular s = not_eof s andalso s <> sync;
 
-fun is_malformed s = String.isPrefix "\\<" s andalso not (String.isSuffix ">" s);
+fun is_malformed s =
+  String.isPrefix "\\<" s andalso not (String.isSuffix ">" s)
+  orelse s = "\\<>" orelse s = "\\<^>";
+
 fun malformed_msg s = "Malformed symbolic character: " ^ quote s;
 
 
@@ -436,9 +439,8 @@
   Scan.one is_utf8 ::: Scan.many is_utf8_trailer >> implode_pseudo_utf8 ||
   scan_encoded_newline ||
   ($$ "\\" ^^ $$ "<" ^^
-    (($$ "^" ^^ (scan_raw || scan_id) || scan_id) ^^ Scan.optional ($$ ">") "")) ||
-  Scan.this_string "\\<^" ||
-  Scan.this_string "\\<" ||
+    (($$ "^" ^^ Scan.optional (scan_raw || scan_id) "" || Scan.optional scan_id "") ^^
+      Scan.optional ($$ ">") "")) ||
   Scan.one not_eof;
 
 in
--- a/src/Pure/General/symbol.scala	Sat Aug 11 20:54:06 2012 +0200
+++ b/src/Pure/General/symbol.scala	Sat Aug 11 21:10:36 2012 +0200
@@ -56,7 +56,7 @@
         val c1 = s(0)
         val c2 = s(1)
         !(c1 == '\r' && c2 == '\n' || Character.isSurrogatePair(c1, c2))
-      case _ => !s.endsWith(">")
+      case _ => !s.endsWith(">") || s == "\\<>" || s == "\\<^>"
     }
 
   def is_physical_newline(s: Symbol): Boolean =