1signature locn = sig 2 3 (* a type representing a point in the source file *) 4 datatype locn_point = LocP of int (* fragment (0-origin) *) 5 * int (* line (0-origin) *) 6 * int (* character (0-origin) *) 7 | LocA of int (* absolute line number in file (0-origin) *) 8 * int (* absolute column number in file (0-origin) *) 9 | LocPBeg of int (* beginning of fragment *) 10 | LocPEnd of int (* end of fragment *) 11 12 val locn_point_toString : locn_point -> string 13 14 (* add a line,char pair to a relative location point *) 15 val rel_to_abs : int -> int -> locn_point -> locn_point 16 17 (* a type representing a location (region) in the source file *) 18 datatype locn = Loc of locn_point * locn_point (* start and end character *) 19 | Loc_None (* compiler-generated *) 20 | Loc_Unknown 21 | Loc_Near of locn 22 23 (* if there are multiple QUOTE fragments in a row, they may be 24 concatenated and given the number of the first fragment; the 25 numbers of subsequent fragments do not change however. *) 26 27 (* an ANTIQUOTE fragment has no characters, so no start and end 28 positions *) 29 30 (* when a token is put back, eg with qbuf.replace_current, we 31 claim the new token is near where the old one was *) 32 33 val toString : locn -> string 34 val toShortString : locn -> string (* less verbose form *) 35 36 (* single-point region *) 37 val locp : locn_point -> locn 38 (* whole fragment *) 39 val locfrag : int -> locn 40 41 (* adjusting locations *) 42 val move_start : int -> locn -> locn 43 val split_at : int -> locn -> (locn * locn) 44 val near : locn -> locn 45 46 (* merging locations *) 47 val between : locn -> locn -> locn 48 49 type 'a located = 'a * locn 50 51end 52