src/Pure/General/position.ML
changeset 29307 3a0b38b7fbb4
parent 28122 3d099ce624e7
child 30669 6de7ef888aa3
equal deleted inserted replaced
29306:2c764235e041 29307:3a0b38b7fbb4
     1 (*  Title:      Pure/General/position.ML
     1 (*  Title:      Pure/General/position.ML
     2     ID:         $Id$
       
     3     Author:     Markus Wenzel, TU Muenchen
     2     Author:     Markus Wenzel, TU Muenchen
     4 
     3 
     5 Source positions: counting Isabelle symbols -- starting from 1.
     4 Source positions: counting Isabelle symbols, starting from 1.
     6 *)
     5 *)
     7 
     6 
     8 signature POSITION =
     7 signature POSITION =
     9 sig
     8 sig
    10   type T
     9   type T
    17   val none: T
    16   val none: T
    18   val start: T
    17   val start: T
    19   val file: string -> T
    18   val file: string -> T
    20   val line: int -> T
    19   val line: int -> T
    21   val line_file: int -> string -> T
    20   val line_file: int -> string -> T
       
    21   val id: string -> T
    22   val get_id: T -> string option
    22   val get_id: T -> string option
    23   val put_id: string -> T -> T
    23   val put_id: string -> T -> T
    24   val of_properties: Properties.T -> T
    24   val of_properties: Properties.T -> T
    25   val properties_of: T -> Properties.T
    25   val properties_of: T -> Properties.T
    26   val default_properties: T -> Properties.T -> Properties.T
    26   val default_properties: T -> Properties.T -> Properties.T
    84 (* make position *)
    84 (* make position *)
    85 
    85 
    86 val none = Pos ((0, 0, 0), []);
    86 val none = Pos ((0, 0, 0), []);
    87 val start = Pos ((1, 1, 1), []);
    87 val start = Pos ((1, 1, 1), []);
    88 
    88 
       
    89 
    89 fun file_name "" = []
    90 fun file_name "" = []
    90   | file_name name = [(Markup.fileN, name)];
    91   | file_name name = [(Markup.fileN, name)];
    91 
    92 
    92 fun file name = Pos ((1, 1, 1), file_name name);
    93 fun file name = Pos ((1, 1, 1), file_name name);
    93 
    94 
    94 fun line_file i name = Pos ((i, 0, 0), file_name name);
    95 fun line_file i name = Pos ((i, 0, 0), file_name name);
    95 fun line i = line_file i "";
    96 fun line i = line_file i "";
    96 
    97 
    97 
    98 
    98 (* markup properties *)
    99 fun id id = Pos ((0, 0, 1), [(Markup.idN, id)]);
    99 
   100 
   100 fun get_id (Pos (_, props)) = Properties.get props Markup.idN;
   101 fun get_id (Pos (_, props)) = Properties.get props Markup.idN;
   101 fun put_id id (Pos (count, props)) = Pos (count, Properties.put (Markup.idN, id) props);
   102 fun put_id id (Pos (count, props)) = Pos (count, Properties.put (Markup.idN, id) props);
       
   103 
       
   104 
       
   105 (* markup properties *)
   102 
   106 
   103 fun of_properties props =
   107 fun of_properties props =
   104   let
   108   let
   105     fun get name =
   109     fun get name =
   106       (case Properties.get props name of
   110       (case Properties.get props name of