1 % (c) 2018-2025 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
2 % Heinrich Heine Universitaet Duesseldorf
3 % This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
4
5
6 :- module(tools_matching,
7 [fuzzy_match_codes_lower_case/2,
8 fuzzy_match_codes/2,
9 codes_to_lower_case/2, % to lower case, also performs Unicode simplifications
10 get_current_keywords/1, get_current_expr_keywords/1,
11 is_b_keyword/2, is_rules_dsl_keyword/2,
12 get_all_svg_classes/1, is_svg_shape_class/1,
13 get_all_svg_attributes/1, is_svg_number_attribute/2, is_svg_color_attribute/1,
14 is_svg_attribute/1, is_virtual_svg_attribute/1,
15 is_svg_color_name/1,
16 is_html_tag/1, is_html_attribute/1,
17 get_all_dot_attributes/1, is_dot_attribute/1,
18 dot2svg_synonym/2,
19 get_possible_preferences/1, get_possible_preferences_matches_msg/2,
20 get_possible_top_level_event_matches_msg/2,
21 get_possible_fuzzy_matches_msg/3,
22 get_possible_completions_msg/3,
23 get_possible_fuzzy_matches_and_completions_msg/3 % both in one
24 ]).
25
26 :- use_module(error_manager).
27 :- use_module(self_check).
28 :- use_module(library(lists)).
29
30 :- use_module(module_information).
31
32 :- module_info(group,infrastructure).
33 :- module_info(description,'A few utilities for fuzzy matching and completion.').
34
35 :- set_prolog_flag(double_quotes, codes).
36
37
38 :- assert_must_succeed(tools_matching:fuzzy_match_codes_lower_case("a","A")).
39 :- assert_must_succeed(tools_matching:fuzzy_match_codes_lower_case("aBcD","ABCd")).
40 :- assert_must_succeed(tools_matching:fuzzy_match_codes_lower_case("aBcD","ABxCd")).
41 :- assert_must_succeed(tools_matching:fuzzy_match_codes_lower_case("aBxcD","ABCd")).
42 :- assert_must_succeed(tools_matching:fuzzy_match_codes_lower_case("aBcD","ABCdx")).
43 :- assert_must_succeed(tools_matching:fuzzy_match_codes_lower_case("aBcDx","ABCd")).
44 :- assert_must_succeed(tools_matching:fuzzy_match_codes_lower_case("a_Bc_D","AB__Cd")).
45 %:- assert_must_succeed(tools_matching:fuzzy_match_codes_lower_case("äÄ","aA")).
46 :- assert_must_fail(tools_matching:fuzzy_match_codes_lower_case("abc","cba")).
47
48
49 fuzzy_match_codes_lower_case(Codes1,Codes2) :-
50 codes_to_lower_case(Codes1,LCodes1),
51 codes_to_lower_case(Codes2,LCodes2),
52 fuzzy_match_codes(LCodes1,LCodes2).
53
54 :- assert_must_succeed(tools_matching:fuzzy_match_codes("aBcD","aBcD")).
55 :- assert_must_succeed(tools_matching:fuzzy_match_codes("aBxcD","aBcD")).
56 :- assert_must_succeed(tools_matching:fuzzy_match_codes("aBcD","aBcxD")).
57 :- assert_must_succeed(tools_matching:fuzzy_match_codes("aBcD","aBcDx")).
58 :- assert_must_succeed(tools_matching:fuzzy_match_codes("xaBcD","aBcD")).
59 :- assert_must_succeed(tools_matching:fuzzy_match_codes("aBcD","xaBcD")).
60 :- assert_must_succeed(tools_matching:fuzzy_match_codes("version","verison")).
61 :- assert_must_fail(tools_matching:fuzzy_match_codes("abc","ABC")).
62
63 fuzzy_match_codes([],[]).
64 ?fuzzy_match_codes([H|T1],[H|T2]) :- !,fuzzy_match_codes(T1,T2).
65 fuzzy_match_codes([_|T],[_|T]) :- !. % one character rewritten
66 fuzzy_match_codes([H1|T1],L2) :- possible_skip_char(H1),!, % underscore _
67 fuzzy_match_codes(T1,L2).
68 fuzzy_match_codes(L1,[H2|T2]) :- possible_skip_char(H2),!,
69 fuzzy_match_codes(L1,T2).
70 fuzzy_match_codes([_|T],T) :- !. % one character too much
71 fuzzy_match_codes(T,[_|T]) :- !. % one character too few
72 fuzzy_match_codes([H1,H2|T],[H2,H1|T]) :- !. % swapping of two characters
73
74
75 %:- assert_must_succeed(tools_matching:codes_to_lower_case("äÄöAa","aaoaa")).
76
77 codes_to_lower_case(Codes,LC) :- maplist(code_to_lower_case,Codes,LC).
78 % TO DO: normalise more UNICODE symbols, ...
79
80 code_to_lower_case(Char,LC_Char) :- Char >= 65, Char =< 90,!, LC_Char is Char+32.
81 code_to_lower_case(Char,LC_Char) :- Char >= 8320, Char =< 8329,!, LC_Char is Char-8272. % Unicode Subscripts
82 code_to_lower_case(8242,R) :- !, R=8242. % Unicode Prime
83 code_to_lower_case(8216,R) :- !, R=8242.
84 code_to_lower_case(8217,R) :- !, R=8242.
85 code_to_lower_case(Char,R) :- Char >= 192, Char =< 197,!, R=97. % upper-case a
86 code_to_lower_case(Char,R) :- Char >= 224, Char =< 229,!, R=97. % lower-case a
87 code_to_lower_case(Char,R) :- Char >= 200, Char =< 203,!, R=101. % upper-case e
88 code_to_lower_case(Char,R) :- Char >= 232, Char =< 235,!, R=101. % lower-case e
89 code_to_lower_case(Char,R) :- Char >= 204, Char =< 207,!, R=105. % upper-case i
90 code_to_lower_case(Char,R) :- Char >= 236, Char =< 239,!, R=105. % lower-case i
91 code_to_lower_case(Char,R) :- Char >= 210, Char =< 214,!, R=111. % upper-case o
92 code_to_lower_case(Char,R) :- Char >= 242, Char =< 246,!, R=111. % lower-case o
93 code_to_lower_case(Char,R) :- Char >= 217, Char =< 220,!, R=117. % upper-case u
94 code_to_lower_case(Char,R) :- Char >= 249, Char =< 252,!, R=117. % lower-case u
95 code_to_lower_case(253,R) :- !, R=121. % ý -> y
96 code_to_lower_case(209,R) :- !, R=110. % Ñ -> n
97 code_to_lower_case(241,R) :- !, R=110. % ñ -> n
98 code_to_lower_case(231,R) :- !, R=99. % ç -> c
99 code_to_lower_case(223,R) :- !, R=115. % ß -> s
100 code_to_lower_case(C,C).
101
102 % use_module(library(between)), between(150,255,R), atom_codes(A,[R]), format("~w : ~w~n",[R,A]),fail.
103
104 possible_skip_char(95). % _
105
106 :- use_module(specfile,[b_or_z_mode/0, csp_mode/0, xtl_mode/0, animation_minor_mode/1, classical_b_mode/0]).
107
108 get_current_expr_keywords(List) :-
109 get_current_keywords([expr,external_funs,pragma,predicate],List).
110 get_current_keywords(List) :-
111 get_current_keywords([expr,external_funs,pragma,predicate,prob_definitions,section,subst],List).
112
113 get_current_keywords(Types,List) :- b_or_z_mode,!,
114 (animation_minor_mode(Minor)
115 -> (classical_b_mode
116 % e.g., for rules_dsl allow both B and rules_dsl keywords at the moment, TODO: remove sections
117 % TODO: we should also ensure this is active for VisB expressions or when the REPL is classical B mode
118 -> get_keywords(Minor,Types,List1),
119 get_keywords(b,Types,List2),
120 append(List1,List2,List)
121 ; get_keywords(Minor,Types,List))
122 ; get_keywords(b,Types,List)).
123 get_current_keywords(_,List) :- csp_mode,!,
124 findall(Def,csp_keyword(Def),List).
125 get_current_keywords(_,List) :- xtl_mode,!,
126 findall(Def,xtl_keyword(Def),List).
127 get_current_keywords(_,[]).
128
129 % -----------------
130
131 csp_keyword(and).
132 csp_keyword(card).
133 csp_keyword(channel).
134 csp_keyword(datatype).
135 csp_keyword(diff).
136 csp_keyword(elem).
137 csp_keyword(empty).
138 csp_keyword(false).
139 csp_keyword(head).
140 csp_keyword(inter).
141 csp_keyword(length).
142 csp_keyword(let).
143 csp_keyword(member).
144 csp_keyword(mod).
145 csp_keyword(nametype).
146 csp_keyword(not).
147 csp_keyword(null).
148 csp_keyword(or).
149 csp_keyword(set).
150 csp_keyword(subtype).
151 csp_keyword(tail).
152 csp_keyword(true).
153 csp_keyword(union).
154 csp_keyword(within).
155 csp_keyword('CHAOS').
156 csp_keyword('Inter').
157 csp_keyword('Seq').
158 csp_keyword('Set').
159 csp_keyword('SKIP').
160 csp_keyword('STOP').
161 csp_keyword('Union').
162
163
164 xtl_keyword(prop).
165 xtl_keyword(start).
166 xtl_keyword(trans).
167 xtl_keyword(animation_image).
168 xtl_keyword(animation_image_click_transition).
169 xtl_keyword(animation_image_right_click_transition).
170 xtl_keyword(animation_function_result).
171 xtl_keyword(heuristic_function_active).
172 xtl_keyword(heuristic_function_result).
173 xtl_keyword(prob_game_info).
174 xtl_keyword(prob_pragma_string).
175
176 % -----------------
177
178 get_keywords(Mode,Types,List) :-
179 (Mode=b,select(prob_definitions,Types,Types1)
180 -> findall(Def,prob_special_def(Def),Ids1)
181 ; Ids1=[], Types1=Types
182 ),
183 ? (Mode=b,select(external_funs,Types1,Types2)
184 -> findall(Def,prob_external_fun(Def),Ids2,Ids1)
185 ; Ids2=Ids1, Types2=Types1
186 ),
187 findall(ID,(keyword(ID,Type,Modes), member(Mode,Modes), member(Type,Types2)),Ids,Ids2),
188 sort(Ids,List).
189
190 :- use_module(external_function_declarations,[external_function_library/2]).
191 ?prob_external_fun(Fun) :- external_function_library(Fun,File),
192 member(File,['LibraryStrings.def']). % ideally we want to only show the included libraries
193
194 prob_special_def(Def) :- special_definitions(Def,_).
195 prob_special_def(Def) :- set_pref_keyword(Def,_).
196 prob_special_def(Def) :- operation_pref_keyword(Def).
197
198 special_definitions('ASSERT_CTL',model_check).
199 special_definitions('ASSERT_LTL',model_check).
200 special_definitions('GOAL',model_check).
201 special_definitions('HEURISTIC_FUNCTION',model_check).
202 special_definitions('SCOPE',model_check).
203 special_definitions('CUSTOM_GRAPH',dot).
204 special_definitions('CUSTOM_GRAPH_EDGES',dot).
205 special_definitions('CUSTOM_GRAPH_NODES',dot).
206 special_definitions('VISB_DEFINITIONS_FILE',visb).
207 special_definitions('VISB_JSON_FILE',visb).
208 special_definitions('VISB_SVG_BOX',visb).
209 special_definitions('VISB_SVG_CONTENTS',visb).
210 special_definitions('VISB_SVG_EVENTS',visb).
211 special_definitions('VISB_SVG_FILE',visb).
212 special_definitions('VISB_SVG_HOVERS',visb).
213 special_definitions('VISB_SVG_OBJECTS',visb).
214 special_definitions('VISB_SVG_UPDATES',visb).
215 % this is a local identifier available inside event predicates: VISB_CLICK_META_INFOS
216 special_definitions('ANIMATION_CLICK',tkanim).
217 special_definitions('ANIMATION_EXPRESSION',tkanim).
218 special_definitions('ANIMATION_FUNCTION',tkanim).
219 special_definitions('ANIMATION_FUNCTION_DEFAULT',tkanim).
220 special_definitions('ANIMATION_IMG',tkanim).
221 special_definitions('ANIMATION_RIGHT_CLICK',tkanim).
222 special_definitions('ANIMATION_STR',tkanim).
223 special_definitions('ANIMATION_STR_JUSTIFY_LEFT',tkanim).
224 special_definitions('ANIMATION_STR_JUSTIFY_RIGHT',tkanim).
225 special_definitions('GAME_MCTS_RUNS',mcts).
226 special_definitions('GAME_MCTS_TIMEOUT',mcts).
227 special_definitions('GAME_MCTS_CACHE_LAST_TREE',mcts).
228 special_definitions('GAME_OVER',mcts).
229 special_definitions('GAME_PLAYER',mcts).
230 special_definitions('GAME_VALUE',mcts).
231 special_definitions('PROB_REQUIRED_VERSION',general).
232 % TODO: scope_, FORCE_SYMMETRY_, for sets
233
234 :- use_module(bmachine,[b_top_level_operation/1]).
235 operation_pref_keyword(OpPrefAtom) :-
236 b_top_level_operation(Top),
237 op_prefix(Prefix),
238 atom_concat(Prefix,Top,OpPrefAtom).
239 op_prefix('MAX_OPERATIONS_').
240 op_prefix('OPERATION_REUSE_OFF_').
241 op_prefix('SEQUENCE_CHART_').
242
243 set_pref_keyword(SetPrefAtom,Pref) :-
244 get_possible_preferences(Prefs),
245 member(Pref,Prefs),
246 atom_concat('SET_PREF_',Pref,SetPrefAtom).
247
248 is_b_keyword(ID,Type) :- keyword(ID,Type,L), member(b,L).
249 is_rules_dsl_keyword(ID,Type) :- keyword(ID,Type,L), member(rules_dsl,L).
250
251 % list of language specific and context specific keywords
252 keyword(not,predicate,[b,eventb]).
253 keyword(or,predicate,[b,eventb]).
254 keyword('true',expr,[eventb]). % truth in Rodin parser
255 keyword('false',expr,[eventb]). % falsity in Rodin parser
256 keyword('TRUE',expr,[b,eventb,tla]).
257 keyword('FALSE',expr,[b,eventb,tla]).
258 keyword('BOOL',expr,[b,eventb]).
259 keyword('bool',expr,[b,eventb]).
260 keyword('POW',expr,[b,eventb]).
261 keyword('POW1',expr,[b,eventb]).
262 keyword('FIN',expr,[b]). % not available in Event-B
263 keyword('FIN1',expr,[b]). % ditto
264 keyword('union',expr,[b,eventb]).
265 keyword('inter',expr,[b,eventb]).
266 keyword('UNION',expr,[b,eventb]).
267 keyword('INTER',expr,[b,eventb]).
268 keyword('INTEGER',expr,[b]).
269 keyword('NATURAL',expr,[b]).
270 keyword('NATURAL1',expr,[b]).
271 keyword('INT',expr,[b,eventb]).
272 keyword('NAT',expr,[b,eventb]).
273 keyword('NAT1',expr,[b,eventb]).
274 keyword('MININT',expr,[b]).
275 keyword('MAXINT',expr,[b]).
276 keyword('min',expr,[b,eventb]).
277 keyword('max',expr,[b,eventb]).
278 keyword('SIGMA',expr,[b]).
279 keyword('PI',expr,[b]).
280 keyword('STRING',expr,[b,tla]).
281 keyword('card',expr,[b,eventb]).
282 keyword('finite',expr,[eventb]).
283 keyword('@finite',expr,[b]).
284 keyword('dom',expr,[b,eventb]).
285 keyword('ran',expr,[b,eventb]).
286 keyword('id',expr,[b,eventb]).
287 keyword('@partition',expr,[b]).
288 keyword('partition',expr,[eventb]).
289 keyword('prj1',expr,[b,eventb]).
290 keyword('prj2',expr,[b,eventb]).
291 keyword('@prj1',expr,[b]).
292 keyword('@prj2',expr,[b]).
293 keyword('pred',expr,[b,eventb]).
294 keyword('succ',expr,[b,eventb]).
295 keyword('closure',expr,[b]).
296 keyword('closure1',expr,[b]).
297 keyword('iterate',expr,[b]).
298 keyword('fnc',expr,[b]). % also Event-B ?
299 keyword('rel',expr,[b]).
300
301 keyword('seq',expr,[b]).
302 keyword('seq1',expr,[b]).
303 keyword('iseq',expr,[b]).
304 keyword('iseq1',expr,[b]).
305 keyword('perm',expr,[b]).
306 keyword('size',expr,[b]).
307 keyword('rev',expr,[b]).
308 keyword('first',expr,[b]).
309 keyword('last',expr,[b]).
310 keyword('front',expr,[b]).
311 keyword('tail',expr,[b]).
312 keyword('conc',expr,[b]).
313 keyword('struct',expr,[b]).
314 keyword('rec',expr,[b]).
315 keyword('STRING',expr,[b]).
316
317 % TREE keywords
318 keyword('arity',expr,[b]).
319 keyword('bin',expr,[b]).
320 keyword('btree',expr,[b]).
321 keyword('const',expr,[b]).
322 keyword('father',expr,[b]).
323 keyword('infix',expr,[b]).
324 keyword('left',expr,[b]).
325 keyword('mirror',expr,[b]).
326 keyword('prefix',expr,[b]).
327 keyword('postfix',expr,[b]).
328 keyword('rank',expr,[b]).
329 keyword('right',expr,[b]).
330 keyword('sizet',expr,[b]).
331 keyword('son',expr,[b]).
332 keyword('sons',expr,[b]).
333 keyword('subtree',expr,[b]).
334 keyword('top',expr,[b]).
335 keyword('tree',expr,[b]).
336
337
338 % REAL keywords
339 keyword('floor',expr,[b]).
340 keyword('ceiling',expr,[b]).
341 keyword('real',expr,[b]).
342 keyword('REAL',expr,[b]).
343 keyword('FLOAT',expr,[b]).
344
345 % ---
346
347 keyword('btrue',predicate,[b]).
348 keyword('bfalse',predicate,[b]).
349
350 keyword('skip',subst,[b]).
351 keyword('ANY',subst,[b]).
352 keyword('ASSERT',subst,[b]).
353 keyword('BEGIN',subst,[b]).
354 keyword('CASE',subst,[b,tla]).
355 keyword('CHOICE',subst,[b]).
356 keyword('DO',subst,[b]).
357 keyword('EITHER',subst,[b]).
358 keyword('OR',subst,[b]).
359 keyword('OF',subst,[b]).
360 keyword('PRE',subst,[b]).
361 keyword('SELECT',subst,[b]).
362 keyword('WHERE',subst,[b]).
363 keyword('WHILE',subst,[b]).
364 keyword('WITH',subst,[b,tla]).
365
366 % --
367
368 keyword('ABSTRACT_CONSTANTS',section,[b]).
369 keyword('ABSTRACT_VARIABLES',section,[b]).
370 keyword('ASSERTIONS',section,[b]).
371 keyword('CONCRETE_CONSTANTS',section,[b]).
372 keyword('CONCRETE_VARIABLES',section,[b]).
373 keyword('CONSTANTS',section,[b,tla]).
374 keyword('CONSTRAINTS',section,[b]).
375 keyword('DEFINITIONS',section,[b]).
376 keyword('EVENT',section,[b]).
377 keyword('EXTENDS',section,[b,tla]).
378 keyword('FREETYPES',section,[b]).
379 keyword('IMPLEMENTATION',section,[b]).
380 keyword('IMPORTS',section,[b]).
381 keyword('INCLUDES',section,[b]).
382 keyword('INITIALISATION',section,[b]).
383 keyword('INITIALIZATION',section,[b]).
384 keyword('INVARIANT',section,[b]).
385 keyword('LOCAL_OPERATIONS',section,[b]).
386 keyword('MACHINE',section,[b]).
387 keyword('MODEL',section,[b]).
388 keyword('OPERATIONS',section,[b]).
389 keyword('PROMOTES',section,[b]).
390 keyword('PROPERTIES',section,[b]).
391 keyword('REFINEMENT',section,[b]).
392 keyword('REFINES',section,[b]).
393 keyword('SEES',section,[b]).
394 keyword('SETS',section,[b]).
395 keyword('SYSTEM',section,[b]).
396 keyword('USES',section,[b]).
397 keyword('VALUES',section,[b]).
398 keyword('VARIABLES',section,[b,tla]).
399 keyword('VARIANT',section,[b]).
400
401 % rules-dsl sections
402 keyword('ACTIVATION',section,[rules_dsl]).
403 keyword('BODY',section,[rules_dsl]).
404 keyword('CLASSIFICATION',section,[rules_dsl]).
405 keyword('COMPUTATION',section,[rules_dsl]).
406 keyword('COUNTEREXAMPLE',section,[rules_dsl]).
407 keyword('DEPENDS_ON_COMPUTATION',section,[rules_dsl]).
408 keyword('DEPENDS_ON_RULE',section,[rules_dsl]).
409 keyword('DEFINE',section,[rules_dsl]).
410 keyword('DUMMY_VALUE',section,[rules_dsl]).
411 keyword('ERROR_TYPE',section,[rules_dsl]).
412 keyword('ERROR_TYPES',section,[rules_dsl]).
413 keyword('FOR',section,[rules_dsl]).
414 keyword('FUNCTION',section,[rules_dsl]).
415 keyword('ON_SUCCESS',section,[rules_dsl]).
416 keyword('POSTCONDITION',section,[rules_dsl]).
417 keyword('PRECONDITION',section,[rules_dsl]).
418 keyword('REFERENCES',section,[rules_dsl]).
419 keyword('REPLACES',section,[rules_dsl]).
420 keyword('RULE_FAIL',section,[rules_dsl]).
421 keyword('RULE_FORALL',section,[rules_dsl]).
422 keyword('RULE',section,[rules_dsl]).
423 keyword('RULEID',section,[rules_dsl]).
424 keyword('RULES_MACHINE',section,[rules_dsl]).
425 keyword('TAGS',section,[rules_dsl]).
426 keyword('TYPE',section,[rules_dsl]).
427 keyword('UNCHECKED',section,[rules_dsl]).
428 keyword('VALUE',section,[rules_dsl]).
429
430
431 % TODO: check if these below are available within expressions:
432 keyword('DISABLED_RULE',section,[rules_dsl]).
433 keyword('FAILED_RULE',section,[rules_dsl]).
434 keyword('FAILED_RULE_ERROR_TYPE',section,[rules_dsl]).
435 keyword('FAILED_RULE_ALL_ERROR_TYPES',section,[rules_dsl]).
436 keyword('GET_RULE_COUNTEREXAMPLES',section,[rules_dsl]).
437 keyword('NOT_CHECKED_RULE',section,[rules_dsl]).
438 keyword('STRING_FORMAT',section,[rules_dsl]).
439 keyword('SUCCEEDED_RULE',section,[rules_dsl]).
440 keyword('SUCCEEDED_RULE_ERROR_TYPE',section,[rules_dsl]).
441
442
443 keyword('@desc',pragma,[b]).
444 keyword('@file',pragma,[b]).
445 keyword('@generated',pragma,[b]).
446 keyword('@import-package',pragma,[b]).
447 keyword('@label',pragma,[b]).
448 keyword('@package',pragma,[b]).
449 keyword('@symbolic',pragma,[b]).
450
451 % TLA sections
452 keyword('ASSUME',section,[tla]).
453 keyword('ASSUMPTION',section,[tla]).
454 keyword('AXIOM',section,[tla]).
455 keyword('CONSTANT',section,[tla]).
456 keyword('LOCAL',section,[tla]).
457 keyword('INSTANCE',section,[b,tla]).
458 keyword('MODULE',section,[tla]).
459 keyword('THEOREM',section,[tla]).
460
461 keyword('IF',_,[b,tla]).
462 keyword('THEN',_,[b,tla]).
463 keyword('ELSE',_,[b,tla]).
464 keyword('ELSIF',_,[b]).
465 keyword('LET',_,[b,tla]).
466 keyword('BE',_,[b]).
467 keyword('IN',_,[b,tla]).
468 keyword('END',_,[b,tla]).
469
470 % TLA expression keywords
471 keyword('BOOLEAN',expr,[tla]).
472 keyword('Cardinality',expr,[tla]).
473 keyword('CHOOSE',expr,[tla]).
474 keyword('DOMAIN',expr,[tla]).
475 keyword('ENABLED',expr,[tla]).
476 keyword('EXCEPT',expr,[tla]).
477 keyword('SUBSET',expr,[tla]).
478 keyword('UNCHANGED',expr,[tla]).
479 keyword('UNION',expr,[tla]).
480
481 % Alloy sections
482 keyword('abstract',section,[alloy]).
483 keyword('assert',section,[alloy]).
484 keyword('check',section,[alloy]).
485 keyword('extends',section,[alloy]).
486 keyword('fact',section,[alloy]).
487 keyword('fun',section,[alloy]).
488 keyword('module',section,[alloy]).
489 keyword('open',section,[alloy]).
490 keyword('pred',section,[alloy]).
491 keyword('run',section,[alloy]).
492 keyword('sig',section,[alloy]).
493
494
495 keyword('div',expr,[alloy]).
496 keyword('minus',expr,[alloy]).
497 keyword('else',expr,[alloy]).
498 keyword('iden',expr,[alloy]).
499 keyword('let',expr,[alloy]).
500 keyword('mul',expr,[alloy]).
501 keyword('plus',expr,[alloy]).
502 keyword('rem',expr,[alloy]).
503 keyword('sum',expr,[alloy]).
504 keyword('univ',expr,[alloy]).
505
506 keyword('all',predicate,[alloy]).
507 keyword('disjoint',predicate,[alloy]).
508 keyword('iff',predicate,[alloy]).
509 keyword('implies',predicate,[alloy]).
510 keyword('lone',predicate,[alloy]).
511 keyword('not',predicate,[alloy]).
512 keyword('no',predicate,[alloy]).
513 keyword('none',predicate,[alloy]).
514 keyword('one',predicate,[alloy]).
515 keyword('or',predicate,[alloy]).
516 keyword('some',predicate,[alloy]).
517 keyword('set',expr,[alloy]).
518
519 % SVG
520
521 get_all_svg_classes(SList) :- findall(A,is_svg_shape_class(A),List), sort(List,SList).
522
523 is_svg_shape_class(a).
524 is_svg_shape_class(animate). % can be a child of other elements
525 is_svg_shape_class(animateMotion). % can be a child of other elements
526 is_svg_shape_class(animateTransform). % can be a child of other elements
527 is_svg_shape_class(circle).
528 is_svg_shape_class(clipPath).
529 is_svg_shape_class(defs).
530 is_svg_shape_class(desc).
531 is_svg_shape_class(ellipse).
532 is_svg_shape_class(filter).
533 is_svg_shape_class(foreignObject). % can have HTML as children, body, table, tr, th, td
534 is_svg_shape_class(g). % group
535 is_svg_shape_class(image). % SVG files displayed with <image> cannot be interactive, include dynamic elements with <use>
536 is_svg_shape_class(line).
537 is_svg_shape_class(marker).
538 is_svg_shape_class(mask).
539 is_svg_shape_class(mpath).
540 is_svg_shape_class(path).
541 is_svg_shape_class(pattern).
542 is_svg_shape_class(polygon).
543 is_svg_shape_class(polyline).
544 is_svg_shape_class(rect).
545 is_svg_shape_class(script).
546 is_svg_shape_class(set).
547 is_svg_shape_class(style).
548 is_svg_shape_class(svg).
549 is_svg_shape_class(symbol).
550 is_svg_shape_class(text).
551 is_svg_shape_class(title). % useful when adding as children to other objects
552 is_svg_shape_class(tspan).
553 is_svg_shape_class(use).
554 is_svg_shape_class(view).
555 is_svg_shape_class(viewport).
556 % Note: one can also create <svg>, ... and HTML tags such as with document.createElementNS
557 % Note: script and title are also HTML tags
558
559 get_all_svg_attributes(SList) :- findall(A,is_svg_attribute(A),List), sort(List,SList).
560
561 % virtual attributes processed by VisB
562 is_virtual_svg_attribute(children).
563 is_virtual_svg_attribute(group_id). % also works like parent_id and can be used to attach animate objects
564 is_virtual_svg_attribute(hovers).
565 is_virtual_svg_attribute(svg_class).
566 is_virtual_svg_attribute(text).
567 is_virtual_svg_attribute(title).
568
569 % first list of svg attributes which are not number or color attributes
570 is_svg_attribute('alignment-baseline'). % auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | top | center | bottom
571 is_svg_attribute(attributeName). % from animate
572 is_svg_attribute(attributeType). % from animate
573 is_svg_attribute(children). % virtual attribute of VisB
574 is_svg_attribute(class).
575 is_svg_attribute('clip-path').
576 is_svg_attribute('clip-rule').
577 is_svg_attribute('color-rendering').
578 is_svg_attribute(cursor).
579 is_svg_attribute(d). % path
580 is_svg_attribute(display).
581 is_svg_attribute(dur). % from animate
582 is_svg_attribute('dominant-baseline'). % auto | text-bottom | alphabetic | ideographic | middle | central | mathematical | hanging | text-top
583 is_svg_attribute('fill-opacity').
584 is_svg_attribute('fill-rule').
585 is_svg_attribute('filter').
586 is_svg_attribute('flood-opacity').
587 is_svg_attribute('font-family').
588 % font-size is below under number attributes
589 is_svg_attribute('font-style'). % normal | italic | oblique
590 is_svg_attribute('font-variant').
591 is_svg_attribute('font-weight'). % normal | bold | bolder | lighter | <number>
592 is_svg_attribute(from).
593 is_svg_attribute(group_id). % virtual attribute of VisB
594 is_svg_attribute(hovers). % virtual attribute of VisB
595 is_svg_attribute('href'). % use
596 is_svg_attribute(id).
597 is_svg_attribute('marker-end').
598 is_svg_attribute('marker-start').
599 is_svg_attribute(mask).
600 % Note: name is a deprecated SVG attribute
601 is_svg_attribute(path).
602 is_svg_attribute('pointer-events').
603 is_svg_attribute(points). % polyline, polygon
604 is_svg_attribute(preserveAspectRatio).
605 is_svg_attribute(radius).
606 is_svg_attribute(repeatDur).
607 is_svg_attribute(repeatCount). % from animate
608 is_svg_attribute(restart).
609 is_svg_attribute(rotate).
610 is_svg_attribute(scale).
611 is_svg_attribute(seed).
612 is_svg_attribute('shape-rendering').
613 is_svg_attribute(startoffset).
614 is_svg_attribute(stdDeviation).
615 is_svg_attribute(stitchTiles).
616 is_svg_attribute(stroke).
617 is_svg_attribute('stroke-dasharray').
618 is_svg_attribute('stroke-dashoffset').
619 is_svg_attribute('stroke-linecap'). % butt (default), round, square
620 is_svg_attribute('stroke-linejoin').
621 is_svg_attribute('stroke-miterlimit').
622 is_svg_attribute(style).
623 is_svg_attribute(surfaceScale).
624 is_svg_attribute(svg_class). % virtual attribute of VisB
625 is_svg_attribute(systemLanguage).
626 is_svg_attribute(tableValues).
627 is_svg_attribute(text). % specially processed by VisB as well
628 is_svg_attribute('text-anchor'). % start | middle | end
629 is_svg_attribute('text-decoration'). % underline | line-through, ....
630 is_svg_attribute('text-rendering'). % auto | optimizeSpeed | optimizeLegibility | geometricPrecision
631 is_svg_attribute(textLength).
632 is_svg_attribute(title). % virtual attribute of VisB
633 is_svg_attribute(to).
634 is_svg_attribute(transform).
635 is_svg_attribute(type).
636 is_svg_attribute(values). % from animate
637 is_svg_attribute(visibility).
638 is_svg_attribute('vector-effect').
639 is_svg_attribute('word-spacing').
640 is_svg_attribute('xlink:href').
641 is_svg_attribute(X) :- is_svg_number_attribute(X,_).
642 is_svg_attribute(X) :- is_svg_color_attribute(X).
643 % TODO: complete
644
645 is_svg_color_attribute(color). % can be applied to any element; provides currentcolor value
646 is_svg_color_attribute(fill). % can be applied to [circle,ellipse,path,polygon,polyline,rect,text,tref,tspan]).
647 is_svg_color_attribute(stroke). % can also be applied to all shapes we use circle, ...
648 is_svg_color_attribute('flood-color').
649 is_svg_color_attribute('lighting-color').
650 is_svg_color_attribute('stop-color').
651
652 is_svg_number_attribute(cx,[circle, ellipse, radialGradient]).
653 is_svg_number_attribute(cy,[circle, ellipse, radialGradient]).
654 is_svg_number_attribute(dx,_).
655 is_svg_number_attribute(dy,_).
656 is_svg_number_attribute(opacity,_).
657 is_svg_number_attribute(pathLength,_).
658 is_svg_number_attribute(x,[foreignObject,image,rect,svg,text,tspan,use]). % many more: cursor, image, mask, pattern, ...
659 is_svg_number_attribute(y,[foreignObject,image,rect,svg,text,tspan,use]).
660 is_svg_number_attribute(x1,[line,linearGradient]).
661 is_svg_number_attribute(x2,[line,linearGradient]).
662 is_svg_number_attribute(y1,[line,linearGradient]).
663 is_svg_number_attribute(y2,[line,linearGradient]).
664 is_svg_number_attribute('font-size',_).
665 is_svg_number_attribute('stop-opacity',_).
666 is_svg_number_attribute('stroke-opacity',_).
667 is_svg_number_attribute('stroke-width',_).
668 is_svg_number_attribute(height,[foreignObject,image,rect,svg]). % others like mask ,...
669 is_svg_number_attribute(width, [foreignObject,image,rect,svg]).
670 is_svg_number_attribute(r,[circle, radialGradient]).
671 is_svg_number_attribute(rx,[ellipse,rect]).
672 is_svg_number_attribute(ry,[ellipse,rect]).
673 is_svg_number_attribute(tabindex,_).
674 is_svg_number_attribute(z,_).
675
676 is_svg_color_name(aliceblue).
677 is_svg_color_name(antiquewhite).
678 is_svg_color_name(aqua).
679 is_svg_color_name(aquamarine).
680 is_svg_color_name(azure).
681 is_svg_color_name(beige).
682 is_svg_color_name(bisque).
683 is_svg_color_name(black).
684 is_svg_color_name(blanchedalmond).
685 is_svg_color_name(blue).
686 is_svg_color_name(blueviolet).
687 is_svg_color_name(brown).
688 is_svg_color_name(burlywood).
689 is_svg_color_name(cadetblue).
690 is_svg_color_name(chartreuse).
691 is_svg_color_name(chocolate).
692 is_svg_color_name(coral).
693 is_svg_color_name(cornflowerblue).
694 is_svg_color_name(cornsilk).
695 is_svg_color_name(crimson).
696 is_svg_color_name(cyan).
697 is_svg_color_name(darkblue).
698 is_svg_color_name(darkcyan).
699 is_svg_color_name(darkgoldenrod).
700 is_svg_color_name(darkgray).
701 is_svg_color_name(darkgreen).
702 is_svg_color_name(darkgrey).
703 is_svg_color_name(darkkhaki).
704 is_svg_color_name(darkmagenta).
705 is_svg_color_name(darkolivegreen).
706 is_svg_color_name(darkorange).
707 is_svg_color_name(darkorchid).
708 is_svg_color_name(darkred).
709 is_svg_color_name(darksalmon).
710 is_svg_color_name(darkseagreen).
711 is_svg_color_name(darkslateblue).
712 is_svg_color_name(darkslategray).
713 is_svg_color_name(darkslategrey).
714 is_svg_color_name(darkturquoise).
715 is_svg_color_name(darkviolet).
716 is_svg_color_name(deeppink).
717 is_svg_color_name(deepskyblue).
718 is_svg_color_name(dimgray).
719 is_svg_color_name(dimgrey).
720 is_svg_color_name(dodgerblue).
721 is_svg_color_name(firebrick).
722 is_svg_color_name(floralwhite).
723 is_svg_color_name(forestgreen).
724 is_svg_color_name(fuchsia).
725 is_svg_color_name(gainsboro).
726 is_svg_color_name(ghostwhite).
727 is_svg_color_name(gold).
728 is_svg_color_name(goldenrod).
729 is_svg_color_name(gray).
730 is_svg_color_name(green).
731 is_svg_color_name(greenyellow).
732 is_svg_color_name(grey).
733 is_svg_color_name(honeydew).
734 is_svg_color_name(hotpink).
735 is_svg_color_name(indianred).
736 is_svg_color_name(indigo).
737 is_svg_color_name(ivory).
738 is_svg_color_name(khaki).
739 is_svg_color_name(lavender).
740 is_svg_color_name(lavenderblush).
741 is_svg_color_name(lawngreen).
742 is_svg_color_name(lemonchiffon).
743 is_svg_color_name(lightblue).
744 is_svg_color_name(lightcoral).
745 is_svg_color_name(lightcyan).
746 is_svg_color_name(lightgoldenrodyellow).
747 is_svg_color_name(lightgray).
748 is_svg_color_name(lightgreen).
749 is_svg_color_name(lightgrey).
750 is_svg_color_name(lightpink).
751 is_svg_color_name(lightsalmon).
752 is_svg_color_name(lightseagreen).
753 is_svg_color_name(lightskyblue).
754 is_svg_color_name(lightslategray).
755 is_svg_color_name(lightslategrey).
756 is_svg_color_name(lightsteelblue).
757 is_svg_color_name(lightyellow).
758 is_svg_color_name(lime).
759 is_svg_color_name(limegreen).
760 is_svg_color_name(linen).
761 is_svg_color_name(magenta).
762 is_svg_color_name(maroon).
763 is_svg_color_name(mediumaquamarine).
764 is_svg_color_name(mediumblue).
765 is_svg_color_name(mediumorchid).
766 is_svg_color_name(mediumpurple).
767 is_svg_color_name(mediumseagreen).
768 is_svg_color_name(mediumslateblue).
769 is_svg_color_name(mediumspringgreen).
770 is_svg_color_name(mediumturquoise).
771 is_svg_color_name(mediumvioletred).
772 is_svg_color_name(midnightblue).
773 is_svg_color_name(mintcream).
774 is_svg_color_name(mistyrose).
775 is_svg_color_name(moccasin).
776 is_svg_color_name(navajowhite).
777 is_svg_color_name(navy).
778 is_svg_color_name(oldlace).
779 is_svg_color_name(olive).
780 is_svg_color_name(olivedrab).
781 is_svg_color_name(orange).
782 is_svg_color_name(orangered).
783 is_svg_color_name(orchid).
784 is_svg_color_name(palegoldenrod).
785 is_svg_color_name(palegreen).
786 is_svg_color_name(paleturquoise).
787 is_svg_color_name(palevioletred).
788 is_svg_color_name(papayawhip).
789 is_svg_color_name(peachpuff).
790 is_svg_color_name(peru).
791 is_svg_color_name(pink).
792 is_svg_color_name(plum).
793 is_svg_color_name(powderblue).
794 is_svg_color_name(purple).
795 is_svg_color_name(red).
796 is_svg_color_name(rosybrown).
797 is_svg_color_name(royalblue).
798 is_svg_color_name(saddlebrown).
799 is_svg_color_name(salmon).
800 is_svg_color_name(sandybrown).
801 is_svg_color_name(seagreen).
802 is_svg_color_name(seashell).
803 is_svg_color_name(sienna).
804 is_svg_color_name(silver).
805 is_svg_color_name(skyblue).
806 is_svg_color_name(slateblue).
807 is_svg_color_name(slategray).
808 is_svg_color_name(slategrey).
809 is_svg_color_name(snow).
810 is_svg_color_name(springgreen).
811 is_svg_color_name(steelblue).
812 is_svg_color_name(tan).
813 is_svg_color_name(teal).
814 is_svg_color_name(thistle).
815 is_svg_color_name(tomato).
816 is_svg_color_name(turquoise).
817 is_svg_color_name(violet).
818 is_svg_color_name(wheat).
819 is_svg_color_name(white).
820 is_svg_color_name(whitesmoke).
821 is_svg_color_name(yellow).
822 is_svg_color_name(yellowgreen).
823
824 % ----------------------------
825
826 % DOT
827 get_all_dot_attributes(SList) :- findall(A,is_dot_attribute(A),List), sort(List,SList).
828
829 % list of known synonyms of Dot attributes and how to translate them to SVG object attributes
830 dot2svg_synonym(fillcolor,color).
831 dot2svg_synonym(fontname,'font-family').
832 dot2svg_synonym(fontcolor,fill). % one should probably use fill to colour text
833 dot2svg_synonym(fontcolour,fill).
834 dot2svg_synonym('font-color',fill). % not really a dot attribute, but a
835 dot2svg_synonym('font-colour',fill).
836 dot2svg_synonym(visible,visibility). % typical error
837
838 % see https://graphviz.org/docs/nodes/, comments taken from there
839 is_dot_attribute(area).
840 is_dot_attribute(class). % Classnames to attach to the node, edge, graph, or cluster's SVG element. For svg only.
841 is_dot_attribute(color). % Basic drawing color for graphics, not text.
842 is_dot_attribute(colorscheme). % A color scheme namespace: the context for interpreting color names.
843 is_dot_attribute(comment). % Comments are inserted into output.
844 is_dot_attribute(distortion). % Distortion factor for shape=polygon.
845 is_dot_attribute(fillcolor). % Color used to fill the background of a node or cluster.
846 is_dot_attribute(fixedsize).
847 is_dot_attribute(fontcolor). % Color used for text.
848 is_dot_attribute(fontname). % Font used for text.
849 is_dot_attribute(fontsize). % Font size, in points, used for text.
850 is_dot_attribute(gradientangle). % If a gradient fill is being used, this determines the angle of the fill.
851 is_dot_attribute(group). % Name for a group of nodes, for bundling edges avoiding crossings. For dot only.
852 is_dot_attribute(height). % Height of node, in inches.
853 is_dot_attribute(href). % Synonym for URL. For map, postscript, svg only.
854 is_dot_attribute(id). % Identifier for graph objects. For map, postscript, svg only.
855 is_dot_attribute(image).
856 is_dot_attribute(imagepos).
857 is_dot_attribute(imagescale).
858 is_dot_attribute(label). % Text label attached to objects.
859 is_dot_attribute(labelloc). % Vertical placement of labels for nodes, root graphs and clusters.
860 is_dot_attribute(layer). % Specifies layers in which the node, edge or cluster is present.
861 %is_dot_attribute(margin). % For graphs, this sets x and y margins of canvas, in inches.
862 is_dot_attribute(nojustify). % Whether to justify multiline text vs the previous text line (rather than the side of the container).
863 is_dot_attribute(ordering). % default, out, in Constrains the left-to-right ordering of node edges. For dot only.
864 is_dot_attribute(orientation).% node shape rotation angle, or graph orientation.
865 is_dot_attribute(penwidth). % Specifies the width of the pen, in points, used to draw lines and curves.
866 is_dot_attribute(peripheries). % Set number of peripheries used in polygonal shapes and cluster boundaries.
867 is_dot_attribute(pin).
868 is_dot_attribute(pos).
869 is_dot_attribute(rects).
870 is_dot_attribute(regular).
871 is_dot_attribute(root).
872 is_dot_attribute(samplepoints). % Gives the number of points used for a circle/ellipse node.
873 is_dot_attribute(shape). % Sets the shape of a node.
874 is_dot_attribute(shapefile).
875 is_dot_attribute(showboxes). % Print guide boxes for debugging. For dot only.
876 is_dot_attribute(style). % Set style information for components of the graph.
877 is_dot_attribute(skew). % Skew factor for shape=polygon.
878 is_dot_attribute(sides). % Number of sides when shape=polygon.
879 is_dot_attribute(sortv). % Sort order of graph components for ordering packmode packing.
880 is_dot_attribute(target). % If the object has a URL, this attribute determines which window of the browser is used for the URL. For map, svg only.
881 is_dot_attribute(tooltip). % Tooltip (mouse hover text) attached to the node, edge, cluster, or graph
882 is_dot_attribute('URL').
883 is_dot_attribute(vertices).
884 is_dot_attribute(width). % Width of node, in inches.
885 is_dot_attribute(xlabel). % External label for a node or edge.
886 is_dot_attribute(xlp). % Position of an exterior label, in points. For write only.
887 is_dot_attribute(z). % Z-coordinate value for 3D layouts and displays.
888
889 % additional edge attributes from https://graphviz.org/docs/edges/
890 is_dot_attribute(arrowhead). % Style of arrowhead on the head node of an edge.
891 is_dot_attribute(arrowsize). % Multiplicative scale factor for arrowheads.
892 is_dot_attribute(arrowtail). % Style of arrowhead on the tail node of an edge.
893 is_dot_attribute(constraint). % If false, the edge is not used in ranking the nodes. For dot only.
894 is_dot_attribute(decorate). % Whether to connect the edge label to the edge with a line.
895 is_dot_attribute(dir). % Edge type for drawing arrowheads. (forward, back, both, none)
896 is_dot_attribute(headlabel). % Text label to be placed near head of edge.
897 is_dot_attribute(headport). % Indicates where on the head node to attach the head of the edge.
898 is_dot_attribute(labelangle).
899 is_dot_attribute(labeldistance).
900 is_dot_attribute(labelfloat).
901 is_dot_attribute(labelfontcolor). % Color used for headlabel and taillabel.
902 is_dot_attribute(labelfontname). % Font for headlabel and taillabel.
903 is_dot_attribute(labelfontsize). % Font size of headlabel and taillabel.
904 is_dot_attribute(len).
905 is_dot_attribute(lhead). % Logical head of an edge. For dot only.
906 is_dot_attribute(minlen). % Minimum edge length (rank difference between head and tail). For dot only.
907 is_dot_attribute(taillabel). % Text label to be placed near tail of edge.
908 is_dot_attribute(tailport). % Indicates where on the tail node to attach the tail of the edge.
909 is_dot_attribute(weight). % Weight of edge. In dot, the heavier the weight, the shorter, straighter and more vertical the edge is.
910
911 % for graphs:
912 is_dot_attribute(bgcolor).
913 % https://graphviz.org/doc/info/colors.html#brewer
914 % ex: accent8, blue9, brbg11, bugn9, bupu9, dark28, gnbu9, greeens9, greys9, oranges9, set312, set39, spectral11
915 % does not work as graph attribute, needs to be set as default node/edge attribute or added to nodes/edges
916 is_dot_attribute(compound). % If true, allow edges between clusters. For dot only, relevant for lhead/ltail edge attrs
917 is_dot_attribute(concentrate). % If true, use edge concentrators.
918 is_dot_attribute(landscape). % If true, the graph is rendered in landscape mode.
919 is_dot_attribute(layout). % Which layout engine to use. dot, neato, circo, fdp, sfdp, twopi, patchwork, nop, nop2
920 is_dot_attribute(mode). % Technique for optimizing the layout
921 %is_dot_attribute(ordering). % declared for nodes above, Constrains the left-to-right ordering of node edges. For dot only. out, in
922 %is_dot_attribute(orientation). % declared for nodes above, node shape rotation angle, or graph orientation
923 is_dot_attribute(outputorder). % Specify order in which nodes and edges are drawn
924 is_dot_attribute(overlap). % Determines if and how node overlaps should be removed
925 is_dot_attribute(rankdir). % Sets direction of graph layout. For dot only. TB, BT, LR, RL
926 is_dot_attribute(ranksep). % Specifies separation between ranks. For dot, twopi only.
927 is_dot_attribute(ratio). % Sets the aspect ratio (drawing height/drawing width) for the drawing.
928 is_dot_attribute(scale). % Scales layout by the given factor after the initial layout
929 is_dot_attribute(size). % Maximum width and height of drawing, in inches
930 is_dot_attribute(splines).
931
932 is_dot_attribute(directed). % virtual attribute -> influences whether dot_graph_generator writes digraph or graph
933 is_dot_attribute(strict). % virtual attribute -> influences whether dot_graph_generator writes strict digraph/graph
934
935 % -------------
936
937
938 % HTML tags can e.g. appear as children of foreign_objects in SVG
939 is_html_tag(a).
940 is_html_tag(abbr).
941 is_html_tag(acronym).
942 is_html_tag(address).
943 is_html_tag(applet).
944 is_html_tag(area).
945 is_html_tag(article).
946 is_html_tag(aside).
947 is_html_tag(audio).
948 is_html_tag(b). % bold
949 is_html_tag(base).
950 is_html_tag(basefont).
951 is_html_tag(bdi).
952 is_html_tag(bdo).
953 is_html_tag(big).
954 is_html_tag(blockquote).
955 is_html_tag(body).
956 is_html_tag(br).
957 is_html_tag(button). % clickable button
958 is_html_tag(canvas).
959 is_html_tag(caption).
960 is_html_tag(center).
961 is_html_tag(cite).
962 is_html_tag(code).
963 is_html_tag(col).
964 is_html_tag(colgroup).
965 is_html_tag(data).
966 is_html_tag(datalist).
967 is_html_tag(dd).
968 is_html_tag(del). % deleted text
969 is_html_tag(details).
970 is_html_tag(dialog). % dialog or window
971 is_html_tag(div).
972 is_html_tag(dfn).
973 is_html_tag(dl). % description list
974 is_html_tag(dt).
975 is_html_tag(em).
976 is_html_tag(embed).
977 is_html_tag(fieldset).
978 is_html_tag(figcaption).
979 is_html_tag(figure).
980 is_html_tag(font).
981 is_html_tag(footer).
982 is_html_tag(form).
983 is_html_tag(frame).
984 is_html_tag(frameset).
985 is_html_tag(h1).
986 is_html_tag(h2).
987 is_html_tag(h3).
988 is_html_tag(h4).
989 is_html_tag(h5).
990 is_html_tag(h6).
991 is_html_tag(head).
992 is_html_tag(header).
993 is_html_tag(hgroup).
994 is_html_tag(hr). % horizontal rule
995 is_html_tag(i). % italic
996 is_html_tag(html).
997 is_html_tag(iframe).
998 is_html_tag(img).
999 is_html_tag(input). % input field
1000 is_html_tag(ins). % inserted text
1001 is_html_tag(kbd). % keyboard input
1002 is_html_tag(label).
1003 is_html_tag(legend).
1004 is_html_tag(li).
1005 is_html_tag(link).
1006 is_html_tag(main).
1007 is_html_tag(map).
1008 is_html_tag(mark). % highlight text
1009 is_html_tag(meta).
1010 is_html_tag(metre). % shows scalar measurement within a range
1011 is_html_tag(nav).
1012 is_html_tag(noframes).
1013 is_html_tag(noscript).
1014 is_html_tag(object).
1015 is_html_tag(ol). % ordered list
1016 is_html_tag(optgroup).
1017 is_html_tag(option). % option in a select list
1018 is_html_tag(output).
1019 is_html_tag(p).
1020 is_html_tag(param).
1021 is_html_tag(picture).
1022 is_html_tag(pre).
1023 is_html_tag(progress). % shows completion progress of a task
1024 is_html_tag(q).
1025 is_html_tag(rp).
1026 is_html_tag(rt).
1027 is_html_tag(ruby).
1028 is_html_tag(s). % strikethrough
1029 is_html_tag(samp). % sample output
1030 is_html_tag(script).
1031 is_html_tag(section).
1032 is_html_tag(select). % dropdown list
1033 is_html_tag(small).
1034 is_html_tag(source).
1035 is_html_tag(span).
1036 is_html_tag(strike).
1037 is_html_tag(strong).
1038 is_html_tag(style).
1039 is_html_tag(summary).
1040 is_html_tag(sub). % subscript
1041 is_html_tag(sup). % superscript
1042 is_html_tag(svg).
1043 is_html_tag(table).
1044 is_html_tag(tbody).
1045 is_html_tag(td). % table data
1046 is_html_tag(template).
1047 is_html_tag(textarea). % multiline text input
1048 is_html_tag(tfoot).
1049 is_html_tag(th). % table header
1050 is_html_tag(thead).
1051 is_html_tag(time). % shows specific period in time or a range of time
1052 is_html_tag(title).
1053 is_html_tag(tr). % table row
1054 is_html_tag(track).
1055 is_html_tag(tt). % not supported in HTML 5
1056 is_html_tag(u). % underline
1057 is_html_tag(ul). % unordered list
1058 is_html_tag(var). % variables
1059 is_html_tag(video).
1060 is_html_tag(wbr).
1061
1062 % completely incomplete list :
1063 is_html_attribute(accesskey).
1064 is_html_attribute(class).
1065 is_html_attribute(contenteditable).
1066 is_html_attribute(contextmenu).
1067 is_html_attribute(dir).
1068 is_html_attribute(disabled). % for option,...
1069 is_html_attribute(draggable).
1070 is_html_attribute(enterkeyhing).
1071 is_html_attribute(hidden).
1072 is_html_attribute(href).
1073 is_html_attribute(id).
1074 is_html_attribute(inert).
1075 is_html_attribute(inputmode).
1076 is_html_attribute(label). % for option,...
1077 is_html_attribute(lang).
1078 is_html_attribute(media).
1079 is_html_attribute(onchange). % for Event attribute, e.g., for select
1080 is_html_attribute(onerror).
1081 is_html_attribute(onhaschange).
1082 is_html_attribute(onload).
1083 is_html_attribute(onmessage).
1084 is_html_attribute(popover).
1085 is_html_attribute(rel).
1086 is_html_attribute(selected). % for option,...
1087 is_html_attribute(spellcheck).
1088 is_html_attribute(style).
1089 is_html_attribute(tabindex).
1090 is_html_attribute(target). % for a
1091 is_html_attribute(title).
1092 is_html_attribute(translate).
1093 is_html_attribute(type). % for a
1094 is_html_attribute(value). % for option,...
1095
1096 % -------------
1097
1098 % some errors one could make, with a possible corrected id/keyword:
1099
1100 %suggested_alternative_id('RGAUSS','RNORMAL').
1101 %suggested_alternative_id('GAUSS','RNORMAL').
1102
1103 % -------------
1104
1105
1106 % translate_keywords:classical_b_keyword(K), \+ tools_matching:keyword(K,_,_). % Note: items is not a B keyword
1107 % TO DO: complete keywords for Alloy, TLA, Z minor modes; possibly add VisB/SVG and CUSTOM_GRAPH/GraphViz attributes
1108
1109 :- use_module(preferences,[eclipse_preference/2]).
1110 get_possible_preferences(SPrefs) :-
1111 findall(Pref,eclipse_preference(Pref,_),P),
1112 sort(P,SPrefs).
1113
1114 get_possible_preferences_matches_msg(String,FuzzyMatchMsg) :-
1115 get_possible_preferences(Prefs),
1116 if(get_possible_fuzzy_matches_and_completions_msg(String,Prefs,FuzzyMatchMsg),
1117 true,
1118 get_possible_inner_matches_msg(String,Prefs,FuzzyMatchMsg)). % also look for inner matches
1119
1120 :- use_module(specfile,[get_possible_language_specific_top_level_event/3]).
1121 :- use_module(bmachine,[b_is_operation_name/1]).
1122 get_possible_top_level_event_matches_msg(String,FuzzyMatchMsg) :-
1123 findall(Op,get_possible_language_specific_top_level_event(Op,_,_),Ops), sort(Ops,SOps),
1124 if(get_possible_fuzzy_matches_and_completions_msg(String,SOps,FuzzyMatchMsg),
1125 true,
1126 get_possible_inner_matches_msg(String,SOps,FuzzyMatchMsg)). % also look for inner matches
1127
1128
1129 get_possible_fuzzy_matches_and_completions_msg(String,AllIds,FuzzyMatchMsg) :-
1130 (get_possible_fuzzy_matches_msg(String,AllIds,FuzzyMatchMsg) ;
1131 get_possible_completions_msg(String,AllIds,FuzzyMatchMsg)).
1132
1133 get_possible_fuzzy_matches(ID,AllIDs,FuzzyMatches) :- atom(ID),!,
1134 atom_codes(ID,IDCodes),
1135 findall(Target,(member(Target,AllIDs),atom_codes(Target,TargetCodes),
1136 fuzzy_match_codes_lower_case(IDCodes,TargetCodes)),FuzzyMatches).
1137 get_possible_fuzzy_matches(ID,_,_) :-
1138 add_internal_error('Not an atom: ',get_possible_fuzzy_matches(ID,_,_)),fail.
1139
1140 % get possible matches as atom which can be used after phrase: Did you mean:
1141 get_possible_fuzzy_matches_msg(ID,AllIDs,Msg) :-
1142 get_possible_fuzzy_matches(ID,AllIDs,FuzzyMatches),
1143 get_match_msg(FuzzyMatches,Msg).
1144
1145 get_match_msg(FuzzyMatches,Msg) :-
1146 length(FuzzyMatches,Nr), Nr>0,
1147 get_msg(FuzzyMatches,Nr,Msg).
1148
1149 :- use_module(tools_strings,[ajoin/2,ajoin_with_sep/3]).
1150 get_msg([Match],1,Res) :- !, Res=Match.
1151 get_msg(List,Nr,Msg) :- Nr < 6, !,
1152 ajoin_with_sep(List,',',Msg).
1153 get_msg([First|_],Nr,Msg) :- N1 is Nr-1,
1154 ajoin([First,' (',N1,' more matches)'],Msg).
1155
1156
1157
1158 % get possible completions as atom which can be used after phrase: Did you mean:
1159 get_possible_completions_msg(ID,SortedAllIDs,Msg) :-
1160 atom_codes(ID,IDCodes0),
1161 codes_to_lower_case(IDCodes0,IDCodes),
1162 findall(Target,(member(Target,SortedAllIDs),atom_codes(Target,TargetCodes),
1163 codes_to_lower_case(TargetCodes,TC2),
1164 prefix(TC2,IDCodes) % IDCodes is a prefix of the target
1165 ),Completions),
1166 get_match_msg(Completions,Msg).
1167
1168
1169 % get possible interior matches as atom which can be used after phrase: Did you mean:
1170 get_possible_inner_matches_msg(ID,SortedAllIDs,Msg) :-
1171 atom_codes(ID,IDCodes0),
1172 length(IDCodes0,Len), Len>3, % only do this if the string is long enough
1173 codes_to_lower_case(IDCodes0,IDCodes),
1174 findall(Target,(member(Target,SortedAllIDs),atom_codes(Target,TargetCodes),
1175 codes_to_lower_case(TargetCodes,TC2),
1176 % format('Looking for ~s inside ~s or vice-versa~n',[IDCodes,TC2]),
1177 (sublist(IDCodes,TC2,_Before) -> true
1178 ; sublist(TC2,IDCodes,_))
1179 ),Completions),
1180 get_match_msg(Completions,Msg).
1181
1182