src/Pure/ML/ml_lex.ML
changeset 45666 d83797ef0d2d
parent 44736 c2a3f1c84179
child 48743 a72f8ffecf31
equal deleted inserted replaced
45665:129db1416717 45666:d83797ef0d2d
   102 (* markup *)
   102 (* markup *)
   103 
   103 
   104 local
   104 local
   105 
   105 
   106 val token_kind_markup =
   106 val token_kind_markup =
   107  fn Keyword   => Markup.ML_keyword
   107  fn Keyword   => Isabelle_Markup.ML_keyword
   108   | Ident     => Markup.empty
   108   | Ident     => Markup.empty
   109   | LongIdent => Markup.empty
   109   | LongIdent => Markup.empty
   110   | TypeVar   => Markup.ML_tvar
   110   | TypeVar   => Isabelle_Markup.ML_tvar
   111   | Word      => Markup.ML_numeral
   111   | Word      => Isabelle_Markup.ML_numeral
   112   | Int       => Markup.ML_numeral
   112   | Int       => Isabelle_Markup.ML_numeral
   113   | Real      => Markup.ML_numeral
   113   | Real      => Isabelle_Markup.ML_numeral
   114   | Char      => Markup.ML_char
   114   | Char      => Isabelle_Markup.ML_char
   115   | String    => Markup.ML_string
   115   | String    => Isabelle_Markup.ML_string
   116   | Space     => Markup.empty
   116   | Space     => Markup.empty
   117   | Comment   => Markup.ML_comment
   117   | Comment   => Isabelle_Markup.ML_comment
   118   | Error _   => Markup.ML_malformed
   118   | Error _   => Isabelle_Markup.ML_malformed
   119   | EOF       => Markup.empty;
   119   | EOF       => Markup.empty;
   120 
   120 
   121 fun token_markup kind x =
   121 fun token_markup kind x =
   122   if kind = Keyword andalso exists_string (not o Symbol.is_ascii_letter) x
   122   if kind = Keyword andalso exists_string (not o Symbol.is_ascii_letter) x
   123   then Markup.ML_delimiter
   123   then Isabelle_Markup.ML_delimiter
   124   else token_kind_markup kind;
   124   else token_kind_markup kind;
   125 
   125 
   126 in
   126 in
   127 
   127 
   128 fun report_of_token (Token ((pos, _), (kind, x))) = (pos, token_markup kind x);
   128 fun report_of_token (Token ((pos, _), (kind, x))) = (pos, token_markup kind x);
   276 
   276 
   277 val tokenize = Source.of_string #> Symbol.source #> source #> Source.exhaust;
   277 val tokenize = Source.of_string #> Symbol.source #> source #> Source.exhaust;
   278 
   278 
   279 fun read pos txt =
   279 fun read pos txt =
   280   let
   280   let
   281     val _ = Position.report pos Markup.ML_source;
   281     val _ = Position.report pos Isabelle_Markup.ML_source;
   282     val syms = Symbol_Pos.explode (txt, pos);
   282     val syms = Symbol_Pos.explode (txt, pos);
   283     val termination =
   283     val termination =
   284       if null syms then []
   284       if null syms then []
   285       else
   285       else
   286         let
   286         let