69227
|
1 |
{- generated by Isabelle -}
|
69226
|
2 |
|
69225
|
3 |
{- Title: Haskell/Tools/Markup.hs
|
|
4 |
Author: Makarius
|
|
5 |
LICENSE: BSD 3-clause (Isabelle)
|
|
6 |
|
|
7 |
Quasi-abstract markup elements.
|
69280
|
8 |
|
|
9 |
See also "$ISABELLE_HOME/src/Pure/PIDE/markup.ML".
|
69225
|
10 |
-}
|
|
11 |
|
69234
|
12 |
module Isabelle.Markup (
|
|
13 |
T, empty, is_empty, properties,
|
|
14 |
|
|
15 |
nameN, name, xnameN, xname, kindN,
|
|
16 |
|
69288
|
17 |
completionN, completion, no_completionN, no_completion,
|
|
18 |
|
69234
|
19 |
lineN, end_lineN, offsetN, end_offsetN, fileN, idN, positionN, position,
|
|
20 |
|
69248
|
21 |
markupN, consistentN, unbreakableN, indentN, widthN,
|
|
22 |
blockN, block, breakN, break, fbreakN, fbreak, itemN, item,
|
|
23 |
|
69234
|
24 |
wordsN, words, no_wordsN, no_words,
|
|
25 |
|
|
26 |
tfreeN, tfree, tvarN, tvar, freeN, free, skolemN, skolem, boundN, bound, varN, var,
|
|
27 |
numeralN, numeral, literalN, literal, delimiterN, delimiter, inner_stringN, inner_string,
|
|
28 |
inner_cartoucheN, inner_cartouche, inner_commentN, inner_comment,
|
|
29 |
token_rangeN, token_range,
|
|
30 |
sortingN, sorting, typingN, typing, class_parameterN, class_parameter,
|
|
31 |
|
|
32 |
antiquotedN, antiquoted, antiquoteN, antiquote,
|
|
33 |
|
|
34 |
paragraphN, paragraph, text_foldN, text_fold,
|
|
35 |
|
|
36 |
keyword1N, keyword1, keyword2N, keyword2, keyword3N, keyword3, quasi_keywordN, quasi_keyword,
|
|
37 |
improperN, improper, operatorN, operator, stringN, string, alt_stringN, alt_string,
|
|
38 |
verbatimN, verbatim, cartoucheN, cartouche, commentN, comment,
|
|
39 |
|
|
40 |
writelnN, writeln, stateN, state, informationN, information, tracingN, tracing,
|
|
41 |
warningN, warning, legacyN, legacy, errorN, error, reportN, report, no_reportN, no_report,
|
|
42 |
|
|
43 |
intensifyN, intensify,
|
|
44 |
Output, no_output)
|
69225
|
45 |
where
|
|
46 |
|
69248
|
47 |
import Prelude hiding (words, error, break)
|
69234
|
48 |
|
|
49 |
import Isabelle.Library
|
69225
|
50 |
import qualified Isabelle.Properties as Properties
|
69248
|
51 |
import qualified Isabelle.Value as Value
|
69225
|
52 |
|
|
53 |
|
69234
|
54 |
{- basic markup -}
|
|
55 |
|
69225
|
56 |
type T = (String, Properties.T)
|
|
57 |
|
|
58 |
empty :: T
|
|
59 |
empty = ("", [])
|
|
60 |
|
|
61 |
is_empty :: T -> Bool
|
|
62 |
is_empty ("", _) = True
|
|
63 |
is_empty _ = False
|
|
64 |
|
69234
|
65 |
properties :: Properties.T -> T -> T
|
|
66 |
properties more_props (elem, props) =
|
|
67 |
(elem, fold_rev Properties.put more_props props)
|
|
68 |
|
|
69 |
markup_elem name = (name, (name, []) :: T)
|
|
70 |
|
|
71 |
|
|
72 |
{- misc properties -}
|
|
73 |
|
|
74 |
nameN :: String
|
|
75 |
nameN = "name"
|
|
76 |
|
|
77 |
name :: String -> T -> T
|
|
78 |
name a = properties [(nameN, a)]
|
|
79 |
|
|
80 |
xnameN :: String
|
|
81 |
xnameN = "xname"
|
|
82 |
|
|
83 |
xname :: String -> T -> T
|
|
84 |
xname a = properties [(xnameN, a)]
|
|
85 |
|
|
86 |
kindN :: String
|
|
87 |
kindN = "kind"
|
|
88 |
|
|
89 |
|
69288
|
90 |
{- completion -}
|
|
91 |
|
|
92 |
completionN :: String; completion :: T
|
|
93 |
(completionN, completion) = markup_elem "completion"
|
|
94 |
|
|
95 |
no_completionN :: String; no_completion :: T
|
|
96 |
(no_completionN, no_completion) = markup_elem "no_completion"
|
|
97 |
|
|
98 |
|
69234
|
99 |
{- position -}
|
|
100 |
|
|
101 |
lineN, end_lineN :: String
|
|
102 |
lineN = "line"
|
|
103 |
end_lineN = "end_line"
|
|
104 |
|
|
105 |
offsetN, end_offsetN :: String
|
|
106 |
offsetN = "offset"
|
|
107 |
end_offsetN = "end_offset"
|
|
108 |
|
|
109 |
fileN, idN :: String
|
|
110 |
fileN = "file"
|
|
111 |
idN = "id"
|
|
112 |
|
|
113 |
positionN :: String; position :: T
|
|
114 |
(positionN, position) = markup_elem "position"
|
|
115 |
|
|
116 |
|
69248
|
117 |
{- pretty printing -}
|
|
118 |
|
|
119 |
markupN, consistentN, unbreakableN, indentN :: String
|
|
120 |
markupN = "markup";
|
|
121 |
consistentN = "consistent";
|
|
122 |
unbreakableN = "unbreakable";
|
|
123 |
indentN = "indent";
|
|
124 |
|
|
125 |
widthN :: String
|
|
126 |
widthN = "width"
|
|
127 |
|
|
128 |
blockN :: String
|
|
129 |
blockN = "block"
|
|
130 |
block :: Bool -> Int -> T
|
|
131 |
block c i =
|
|
132 |
(blockN,
|
|
133 |
(if c then [(consistentN, Value.print_bool c)] else []) ++
|
|
134 |
(if i /= 0 then [(indentN, Value.print_int i)] else []))
|
|
135 |
|
|
136 |
breakN :: String
|
|
137 |
breakN = "break"
|
|
138 |
break :: Int -> Int -> T
|
|
139 |
break w i =
|
|
140 |
(breakN,
|
|
141 |
(if w /= 0 then [(widthN, Value.print_int w)] else []) ++
|
|
142 |
(if i /= 0 then [(indentN, Value.print_int i)] else []))
|
|
143 |
|
|
144 |
fbreakN :: String; fbreak :: T
|
|
145 |
(fbreakN, fbreak) = markup_elem "fbreak"
|
|
146 |
|
|
147 |
itemN :: String; item :: T
|
|
148 |
(itemN, item) = markup_elem "item"
|
|
149 |
|
|
150 |
|
69234
|
151 |
{- text properties -}
|
|
152 |
|
|
153 |
wordsN :: String; words :: T
|
|
154 |
(wordsN, words) = markup_elem "words"
|
|
155 |
|
|
156 |
no_wordsN :: String; no_words :: T
|
|
157 |
(no_wordsN, no_words) = markup_elem "no_words"
|
|
158 |
|
|
159 |
|
|
160 |
{- inner syntax -}
|
|
161 |
|
|
162 |
tfreeN :: String; tfree :: T
|
|
163 |
(tfreeN, tfree) = markup_elem "tfree"
|
|
164 |
|
|
165 |
tvarN :: String; tvar :: T
|
|
166 |
(tvarN, tvar) = markup_elem "tvar"
|
|
167 |
|
|
168 |
freeN :: String; free :: T
|
|
169 |
(freeN, free) = markup_elem "free"
|
|
170 |
|
|
171 |
skolemN :: String; skolem :: T
|
|
172 |
(skolemN, skolem) = markup_elem "skolem"
|
|
173 |
|
|
174 |
boundN :: String; bound :: T
|
|
175 |
(boundN, bound) = markup_elem "bound"
|
|
176 |
|
|
177 |
varN :: String; var :: T
|
|
178 |
(varN, var) = markup_elem "var"
|
|
179 |
|
|
180 |
numeralN :: String; numeral :: T
|
|
181 |
(numeralN, numeral) = markup_elem "numeral"
|
|
182 |
|
|
183 |
literalN :: String; literal :: T
|
|
184 |
(literalN, literal) = markup_elem "literal"
|
|
185 |
|
|
186 |
delimiterN :: String; delimiter :: T
|
|
187 |
(delimiterN, delimiter) = markup_elem "delimiter"
|
|
188 |
|
|
189 |
inner_stringN :: String; inner_string :: T
|
|
190 |
(inner_stringN, inner_string) = markup_elem "inner_string"
|
|
191 |
|
|
192 |
inner_cartoucheN :: String; inner_cartouche :: T
|
|
193 |
(inner_cartoucheN, inner_cartouche) = markup_elem "inner_cartouche"
|
|
194 |
|
|
195 |
inner_commentN :: String; inner_comment :: T
|
|
196 |
(inner_commentN, inner_comment) = markup_elem "inner_comment"
|
|
197 |
|
|
198 |
|
|
199 |
token_rangeN :: String; token_range :: T
|
|
200 |
(token_rangeN, token_range) = markup_elem "token_range"
|
|
201 |
|
|
202 |
|
|
203 |
sortingN :: String; sorting :: T
|
|
204 |
(sortingN, sorting) = markup_elem "sorting"
|
|
205 |
|
|
206 |
typingN :: String; typing :: T
|
|
207 |
(typingN, typing) = markup_elem "typing"
|
|
208 |
|
|
209 |
class_parameterN :: String; class_parameter :: T
|
|
210 |
(class_parameterN, class_parameter) = markup_elem "class_parameter"
|
|
211 |
|
|
212 |
|
|
213 |
{- antiquotations -}
|
|
214 |
|
|
215 |
antiquotedN :: String; antiquoted :: T
|
|
216 |
(antiquotedN, antiquoted) = markup_elem "antiquoted"
|
|
217 |
|
|
218 |
antiquoteN :: String; antiquote :: T
|
|
219 |
(antiquoteN, antiquote) = markup_elem "antiquote"
|
|
220 |
|
|
221 |
|
|
222 |
{- text structure -}
|
|
223 |
|
|
224 |
paragraphN :: String; paragraph :: T
|
|
225 |
(paragraphN, paragraph) = markup_elem "paragraph"
|
|
226 |
|
|
227 |
text_foldN :: String; text_fold :: T
|
|
228 |
(text_foldN, text_fold) = markup_elem "text_fold"
|
|
229 |
|
|
230 |
|
|
231 |
{- outer syntax -}
|
|
232 |
|
|
233 |
keyword1N :: String; keyword1 :: T
|
|
234 |
(keyword1N, keyword1) = markup_elem "keyword1"
|
|
235 |
|
|
236 |
keyword2N :: String; keyword2 :: T
|
|
237 |
(keyword2N, keyword2) = markup_elem "keyword2"
|
|
238 |
|
|
239 |
keyword3N :: String; keyword3 :: T
|
|
240 |
(keyword3N, keyword3) = markup_elem "keyword3"
|
|
241 |
|
|
242 |
quasi_keywordN :: String; quasi_keyword :: T
|
|
243 |
(quasi_keywordN, quasi_keyword) = markup_elem "quasi_keyword"
|
|
244 |
|
|
245 |
improperN :: String; improper :: T
|
|
246 |
(improperN, improper) = markup_elem "improper"
|
|
247 |
|
|
248 |
operatorN :: String; operator :: T
|
|
249 |
(operatorN, operator) = markup_elem "operator"
|
|
250 |
|
|
251 |
stringN :: String; string :: T
|
|
252 |
(stringN, string) = markup_elem "string"
|
|
253 |
|
|
254 |
alt_stringN :: String; alt_string :: T
|
|
255 |
(alt_stringN, alt_string) = markup_elem "alt_string"
|
|
256 |
|
|
257 |
verbatimN :: String; verbatim :: T
|
|
258 |
(verbatimN, verbatim) = markup_elem "verbatim"
|
|
259 |
|
|
260 |
cartoucheN :: String; cartouche :: T
|
|
261 |
(cartoucheN, cartouche) = markup_elem "cartouche"
|
|
262 |
|
|
263 |
commentN :: String; comment :: T
|
|
264 |
(commentN, comment) = markup_elem "comment"
|
|
265 |
|
|
266 |
|
|
267 |
{- messages -}
|
|
268 |
|
|
269 |
writelnN :: String; writeln :: T
|
|
270 |
(writelnN, writeln) = markup_elem "writeln"
|
|
271 |
|
|
272 |
stateN :: String; state :: T
|
|
273 |
(stateN, state) = markup_elem "state"
|
|
274 |
|
|
275 |
informationN :: String; information :: T
|
|
276 |
(informationN, information) = markup_elem "information"
|
|
277 |
|
|
278 |
tracingN :: String; tracing :: T
|
|
279 |
(tracingN, tracing) = markup_elem "tracing"
|
|
280 |
|
|
281 |
warningN :: String; warning :: T
|
|
282 |
(warningN, warning) = markup_elem "warning"
|
|
283 |
|
|
284 |
legacyN :: String; legacy :: T
|
|
285 |
(legacyN, legacy) = markup_elem "legacy"
|
|
286 |
|
|
287 |
errorN :: String; error :: T
|
|
288 |
(errorN, error) = markup_elem "error"
|
|
289 |
|
|
290 |
reportN :: String; report :: T
|
|
291 |
(reportN, report) = markup_elem "report"
|
|
292 |
|
|
293 |
no_reportN :: String; no_report :: T
|
|
294 |
(no_reportN, no_report) = markup_elem "no_report"
|
|
295 |
|
|
296 |
intensifyN :: String; intensify :: T
|
|
297 |
(intensifyN, intensify) = markup_elem "intensify"
|
|
298 |
|
|
299 |
|
|
300 |
{- output -}
|
69225
|
301 |
|
|
302 |
type Output = (String, String)
|
|
303 |
|
|
304 |
no_output :: Output
|
|
305 |
no_output = ("", "")
|