38 val is_error: T -> bool |
38 val is_error: T -> bool |
39 val is_space: T -> bool |
39 val is_space: T -> bool |
40 val is_blank: T -> bool |
40 val is_blank: T -> bool |
41 val is_newline: T -> bool |
41 val is_newline: T -> bool |
42 val inner_syntax_of: T -> string |
42 val inner_syntax_of: T -> string |
43 val source_position_of: T -> Symbol_Pos.text * Position.T |
43 val source_position_of: T -> Symbol_Pos.source |
44 val content_of: T -> string |
44 val content_of: T -> string |
45 val markup: T -> Markup.T * string |
45 val markup: T -> Markup.T * string |
46 val unparse: T -> string |
46 val unparse: T -> string |
47 val print: T -> string |
47 val print: T -> string |
48 val text_of: T -> string * string |
48 val text_of: T -> string * string |
125 | InternalValue => "internal value" |
125 | InternalValue => "internal value" |
126 | Error _ => "bad input" |
126 | Error _ => "bad input" |
127 | Sync => "sync marker" |
127 | Sync => "sync marker" |
128 | EOF => "end-of-input"; |
128 | EOF => "end-of-input"; |
129 |
129 |
|
130 val delimited_kind = member (op =) [String, AltString, Verbatim, Cartouche, Comment]; |
|
131 |
130 |
132 |
131 (* position *) |
133 (* position *) |
132 |
134 |
133 fun pos_of (Token ((_, (pos, _)), _, _)) = pos; |
135 fun pos_of (Token ((_, (pos, _)), _, _)) = pos; |
134 fun end_pos_of (Token ((_, (_, pos)), _, _)) = pos; |
136 fun end_pos_of (Token ((_, (_, pos)), _, _)) = pos; |
204 | is_newline _ = false; |
206 | is_newline _ = false; |
205 |
207 |
206 |
208 |
207 (* token content *) |
209 (* token content *) |
208 |
210 |
209 fun inner_syntax_of (Token ((source, (pos, _)), (_, x), _)) = |
211 fun inner_syntax_of (Token ((source, (pos, _)), (kind, x), _)) = |
210 if YXML.detect x then x |
212 if YXML.detect x then x |
211 else YXML.string_of (XML.Elem (Markup.token (Position.properties_of pos), [XML.Text source])); |
213 else |
212 |
214 let |
213 fun source_position_of (Token ((source, (pos, _)), _, _)) = (source, pos); |
215 val delimited = delimited_kind kind; |
|
216 val tree = XML.Elem (Markup.token delimited (Position.properties_of pos), [XML.Text source]); |
|
217 in YXML.string_of tree end; |
|
218 |
|
219 fun source_position_of (Token ((source, (pos, _)), (kind, _), _)) = |
|
220 {delimited = delimited_kind kind, text = source, pos = pos}; |
214 |
221 |
215 fun content_of (Token (_, (_, x), _)) = x; |
222 fun content_of (Token (_, (_, x), _)) = x; |
216 |
223 |
217 |
224 |
218 (* markup *) |
225 (* markup *) |