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