src/Pure/ML-Systems/ml_positions.ML
author wenzelm
Sun, 27 Jul 2014 15:40:19 +0200
changeset 57821 f11f3d7589b1
parent 56437 b14bd153a753
permissions -rw-r--r--
Added tag Isabelle2014-RC1 for changeset c0fd03d13d28
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
56435
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/ML-Systems/ml_positions.ML
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
     3
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
     4
Approximate ML antiquotation @{here} for Isabelle/Pure bootstrap.
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
     5
*)
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
     6
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
     7
fun ml_positions start_line name txt =
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
     8
  let
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
     9
    fun positions line (#"@" :: #"{" :: #"h" :: #"e" :: #"r" :: #"e" :: #"}" :: cs) res =
56437
b14bd153a753 clarified position: no offset here;
wenzelm
parents: 56435
diff changeset
    10
          let val s = "(Position.line_file_only " ^ Int.toString line ^ " \"" ^ name ^ "\")"
56435
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
    11
          in positions line cs (s :: res) end
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
    12
      | positions line (c :: cs) res =
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
    13
          positions (if c = #"\n" then line + 1 else line) cs (str c :: res)
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
    14
      | positions _ [] res = rev res;
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
    15
  in String.concat (positions start_line (String.explode txt) []) end;
28b34e8e4a80 approximate ML antiquotation @{here} for Isabelle/Pure bootstrap;
wenzelm
parents:
diff changeset
    16