1 : |
dbm |
597 |
signature SOURCE_MAP =
|
2 : |
|
|
sig
|
3 : |
|
|
|
4 : |
|
|
type charpos = int
|
5 : |
|
|
(* char position in a file *)
|
6 : |
|
|
|
7 : |
|
|
type region = charpos * charpos
|
8 : |
|
|
(* region between two character positions, where it is assumed that
|
9 : |
|
|
* the first charpos is less than the second *)
|
10 : |
|
|
|
11 : |
|
|
datatype location
|
12 : |
|
|
= LOC of
|
13 : |
|
|
{srcFile : string,
|
14 : |
|
|
beginLine : int,
|
15 : |
|
|
beginCol : int,
|
16 : |
|
|
endLine : int,
|
17 : |
|
|
endCol : int}
|
18 : |
|
|
| UNKNOWN
|
19 : |
|
|
(* encodes the information used to record locations in input sources.
|
20 : |
|
|
* a location designates a region within a (single) source file *)
|
21 : |
|
|
|
22 : |
|
|
type sourcemap
|
23 : |
|
|
(* a data structure maintaining a mapping between character positions
|
24 : |
|
|
* in an input source and locations.
|
25 : |
|
|
* This handles multiple source files, which can happen if the input
|
26 : |
|
|
* has been passed through the C preprocessor.
|
27 : |
|
|
*)
|
28 : |
|
|
|
29 : |
|
|
val newmap : {srcFile : string} -> sourcemap
|
30 : |
|
|
(* creates a new sourcemap with an initial source file name srcFile *)
|
31 : |
|
|
|
32 : |
|
|
val newline : sourcemap -> charpos -> unit
|
33 : |
|
|
(* records a line break in the input source *)
|
34 : |
|
|
|
35 : |
|
|
val resynch : sourcemap -> {pos:charpos, srcFile:string option, line:int} -> unit
|
36 : |
|
|
(* switch source file names in response to a directive created by
|
37 : |
|
|
* an include *)
|
38 : |
|
|
|
39 : |
|
|
val parseDirective : sourcemap -> charpos * string -> unit
|
40 : |
|
|
(* parse a C preprocessor directive to reset src file name and line number *)
|
41 : |
|
|
|
42 : |
|
|
val location : sourcemap -> region -> location
|
43 : |
|
|
(* maps a region to a location *)
|
44 : |
|
|
|
45 : |
|
|
val currPos : sourcemap -> charpos
|
46 : |
|
|
(* returns the current character position in the source represented
|
47 : |
|
|
* by the sourcemap *)
|
48 : |
|
|
|
49 : |
|
|
val locToString : location -> string
|
50 : |
|
|
(* format a location as a string *)
|
51 : |
|
|
|
52 : |
|
|
end
|
53 : |
|
|
|
54 : |
|
|
|