11 val text_of: source -> Symbol_Pos.text |
11 val text_of: source -> Symbol_Pos.text |
12 val pos_of: source -> Position.T |
12 val pos_of: source -> Position.T |
13 val range_of: source -> Position.range |
13 val range_of: source -> Position.range |
14 val source: bool -> Symbol_Pos.text -> Position.range -> source |
14 val source: bool -> Symbol_Pos.text -> Position.range -> source |
15 val string: string -> source |
15 val string: string -> source |
|
16 val reset_pos: source -> source |
16 val source_explode: source -> Symbol_Pos.T list |
17 val source_explode: source -> Symbol_Pos.T list |
17 val source_content: source -> string |
18 val source_content: source -> string |
18 val equal_content: source * source -> bool |
19 val equal_content: source * source -> bool |
19 end; |
20 end; |
20 |
21 |
22 struct |
23 struct |
23 |
24 |
24 abstype source = Source of {delimited: bool, text: Symbol_Pos.text, range: Position.range} |
25 abstype source = Source of {delimited: bool, text: Symbol_Pos.text, range: Position.range} |
25 with |
26 with |
26 |
27 |
|
28 |
|
29 (* source *) |
|
30 |
27 fun is_delimited (Source {delimited, ...}) = delimited; |
31 fun is_delimited (Source {delimited, ...}) = delimited; |
28 fun text_of (Source {text, ...}) = text; |
32 fun text_of (Source {text, ...}) = text; |
29 fun pos_of (Source {range = (pos, _), ...}) = pos; |
33 fun pos_of (Source {range = (pos, _), ...}) = pos; |
30 fun range_of (Source {range, ...}) = range; |
34 fun range_of (Source {range, ...}) = range; |
31 |
35 |
32 fun source delimited text range = |
36 fun source delimited text range = |
33 Source {delimited = delimited, text = text, range = range}; |
37 Source {delimited = delimited, text = text, range = range}; |
34 |
38 |
35 fun string text = source true text Position.no_range; |
39 fun string text = source true text Position.no_range; |
|
40 |
|
41 fun reset_pos (Source {delimited, text, ...}) = source delimited text Position.no_range; |
|
42 |
|
43 |
|
44 (* content *) |
36 |
45 |
37 fun source_explode (Source {text, range = (pos, _), ...}) = |
46 fun source_explode (Source {text, range = (pos, _), ...}) = |
38 Symbol_Pos.explode (text, pos); |
47 Symbol_Pos.explode (text, pos); |
39 |
48 |
40 val source_content = source_explode #> Symbol_Pos.content; |
49 val source_content = source_explode #> Symbol_Pos.content; |