Changeset View
Changeset View
Standalone View
Standalone View
autotests/folding/highlight.lgt.fold
- This file was added.
1 | <beginfold id='1'>/*</beginfold id='1'> | ||||
---|---|---|---|---|---|
2 | Highlighting test case for Logtalk | ||||
3 | | ||||
4 | Copied from the Logtalk distribution by the Logtalk copright holder | ||||
5 | and contributed using the Apache License 2.0 | ||||
6 | <endfold id='1'>*/</endfold id='1'> | ||||
7 | | ||||
8 | :- encoding(Encoding). % this is a single-line comment | ||||
9 | | ||||
10 | <beginfold id='1'>/*</beginfold id='1'> | ||||
11 | this is | ||||
12 | a block | ||||
13 | comment | ||||
14 | <endfold id='1'>*/</endfold id='1'> | ||||
15 | | ||||
16 | | ||||
17 | :- <beginfold id='3'>if</beginfold id='3'>(Goal). | ||||
18 | % conditional | ||||
19 | :- elif(Goal). | ||||
20 | % compilation | ||||
21 | :- else. | ||||
22 | % directives | ||||
23 | :- <endfold id='3'>endif.</endfold id='3'> | ||||
24 | | ||||
25 | | ||||
26 | :- initialization(Goal). | ||||
27 | :- op(Precedence, Associativity, Operator). | ||||
28 | :- ensure_loaded(File). | ||||
29 | :- include(File). | ||||
30 | :- set_prolog_flag(Flag, Value). | ||||
31 | :- set_logtalk_flag(Flag, Value). | ||||
32 | | ||||
33 | | ||||
34 | :- <beginfold id='4'>object</beginfold id='4'>(prototype, | ||||
35 | implements(protocol), | ||||
36 | imports(category), | ||||
37 | extends(parent)). | ||||
38 | | ||||
39 | :- info([ | ||||
40 | version is 1.43, | ||||
41 | author is 'Paulo Moura', | ||||
42 | date is 2018/08/03, | ||||
43 | comment is 'Sample prototype for testing syntax coloring.' | ||||
44 | ]). | ||||
45 | | ||||
46 | :- built_in. | ||||
47 | :- threaded. | ||||
48 | :- dynamic. | ||||
49 | :- initialization(some_goal(X, Y)). | ||||
50 | | ||||
51 | :- alias(set, [member/2 as set_member/2]). | ||||
52 | :- alias(words, [singular//0 as peculiar//0]). | ||||
53 | | ||||
54 | :- uses(list, [append/3, member/2]). | ||||
55 | :- uses(queues, [new/1 as new_queue/1]). | ||||
56 | | ||||
57 | :- use_module(module). | ||||
58 | :- use_module(module, [append/3, member/2]). | ||||
59 | | ||||
60 | :- multifile(zzz/1). | ||||
61 | :- multifile(module:zzz/1). | ||||
62 | :- multifile(object::zzz/1). | ||||
63 | | ||||
64 | :- coinductive(comember/1). | ||||
65 | | ||||
66 | :- use_module(module, [xxx/1, yyy/2, zzz/3]). | ||||
67 | :- export(bbb/3). | ||||
68 | :- reexport(cccc/4). | ||||
69 | | ||||
70 | :- public(aaa/2). | ||||
71 | :- meta_predicate(aaa(::, *)). | ||||
72 | :- discontiguous(aaa/2). | ||||
73 | :- mode(aaa(+callable, ?integer), zero_or_one). | ||||
74 | :- info(position/2, [ | ||||
75 | comment is 'Predicate brief description.', | ||||
76 | arguments is ['Arg1'-'Arg1 description', 'Arg2'-'Arg2 description'] | ||||
77 | ]). | ||||
78 | | ||||
79 | :- public(nt//2). | ||||
80 | :- meta_non_terminal(nt(1, *)). | ||||
81 | | ||||
82 | :- protected(bbb/2). | ||||
83 | :- synchronized(bbb/2). | ||||
84 | :- mode(bbb(+integer, -float), one). | ||||
85 | :- info(bbb/2, [ | ||||
86 | comment is 'Predicate brief description.', | ||||
87 | argnames is ['Arg1', 'Arg2'] | ||||
88 | ]). | ||||
89 | | ||||
90 | :- private(ccc/2). | ||||
91 | :- dynamic(ccc/2). | ||||
92 | :- mode(ccc(@atom, ?atom, ++list, --ground), one_or_more). | ||||
93 | :- info(ccc/2, [ | ||||
94 | comment is 'Predicate brief description.', | ||||
95 | argnames is ['Arg1', 'Arg2'] | ||||
96 | ]). | ||||
97 | | ||||
98 | enumerating_entities(Object, Protocol, Category) :- | ||||
99 | current_category(Category), | ||||
100 | current_object(Object), | ||||
101 | current_protocol(Protocol). | ||||
102 | | ||||
103 | enumerating_properties :- | ||||
104 | category_property(Category, Property), | ||||
105 | object_property(Object, Property), | ||||
106 | protocol_property(Protocol, Property). | ||||
107 | | ||||
108 | creating_entities(Object, Protocol, Category) :- | ||||
109 | create_category(Category, Relations, Directives, Clauses), | ||||
110 | create_object(Object, Relations, Directives, Clauses), | ||||
111 | create_protocol(Protocol, Relations, Directives). | ||||
112 | | ||||
113 | abolishing_entities(Object, Protocol, Category) :- | ||||
114 | abolish_category(Category), | ||||
115 | abolish_object(Object), | ||||
116 | abolish_protocol(Protocol). | ||||
117 | | ||||
118 | entity_relations :- | ||||
119 | extends_object(Prototype, Parent, Scope), | ||||
120 | extends_protocol(Protocol1, Protocol2, Scope), | ||||
121 | extends_category(Category1, Category2, Scope), | ||||
122 | implements_protocol(Object, Protocol, Scope), | ||||
123 | imports_category(Object, Category, Scope), | ||||
124 | instantiates_class(Instance, Class, Scope), | ||||
125 | specializes_class(Class, Superclass, Scope), | ||||
126 | complements_object(Category, Object), | ||||
127 | conforms_to_protocol(ObjOrCtg, Protocol, Scope). | ||||
128 | | ||||
129 | event_handling :- | ||||
130 | abolish_events(Event, Object, Message, Sender, Monitor), | ||||
131 | current_event(Event, Object, Message, Sender, Monitor), | ||||
132 | define_events(Event, Object, Message, Sender, Monitor). | ||||
133 | | ||||
134 | multi_threading :- | ||||
135 | threaded(Goals), | ||||
136 | threaded_call(Goal), | ||||
137 | threaded_once(Goal), | ||||
138 | threaded_ignore(Goal), | ||||
139 | threaded_exit(Goal), | ||||
140 | threaded_peek(Goal), | ||||
141 | threaded_wait(Notification), | ||||
142 | threaded_notify(Notification). | ||||
143 | | ||||
144 | engines :- | ||||
145 | threaded_engine(Engine), | ||||
146 | threaded_engine_create(AnswerTemplate, Goal, Engine), | ||||
147 | threaded_engine_destroy(Engine), | ||||
148 | threaded_engine_self(Engine), | ||||
149 | threaded_engine_next(Engine, Answer), | ||||
150 | threaded_engine_next_reified(Engine, Answer), | ||||
151 | threaded_engine_yield(Answer), | ||||
152 | threaded_engine_post(Engine, Term), | ||||
153 | threaded_engine_fetch(Term). | ||||
154 | | ||||
155 | compiling_and_loading :- | ||||
156 | logtalk_compile(File, Options), | ||||
157 | logtalk_load(File, Options), | ||||
158 | logtalk_library_path(Library, Path), | ||||
159 | logtalk_load_context(Key, Value), | ||||
160 | logtalk_make(Action), | ||||
161 | logtalk_make, | ||||
162 | logtalk_make_target_action(Target). | ||||
163 | | ||||
164 | flags :- | ||||
165 | current_logtalk_flag(Flag, Value), | ||||
166 | set_logtalk_flag(Flag, Value), | ||||
167 | create_logtalk_flag(Flag, Value, Options). | ||||
168 | | ||||
169 | execution_context_methods :- | ||||
170 | context(Context), | ||||
171 | parameter(N, Parameter), | ||||
172 | self(Self), | ||||
173 | sender(Sender), | ||||
174 | this(This). | ||||
175 | | ||||
176 | reflection_methods :- | ||||
177 | current_predicate(Predicate), | ||||
178 | predicate_property(Predicate, Property). | ||||
179 | | ||||
180 | database_methods :- | ||||
181 | abolish(Name/Arity), | ||||
182 | asserta(Clause), | ||||
183 | assertz(Clause), | ||||
184 | clause(Head, Body), | ||||
185 | retract(Clause), | ||||
186 | retractall(Head). | ||||
187 | | ||||
188 | exception_methods :- | ||||
189 | catch(Goal, Error, Catcher), | ||||
190 | throw(Error), | ||||
191 | instantiation_error, | ||||
192 | type_error(Type, Culprit), | ||||
193 | domain_error(Domain, Culprit), | ||||
194 | existence_error(Thing, Culprit), | ||||
195 | permission_error(Operation, Permission, Culprit), | ||||
196 | representation_error(Flag), | ||||
197 | evaluation_error(Exception), | ||||
198 | resource_error(Resource), | ||||
199 | syntax_error(Description), | ||||
200 | system_error. | ||||
201 | | ||||
202 | all_solutions_methods :- | ||||
203 | bagof(Term, Goal, List), | ||||
204 | bagof(Term, Var^Goal, List), | ||||
205 | findall(Term, Goal, List), | ||||
206 | forall(Generate, Test), | ||||
207 | setof(Term, Goal, List), | ||||
208 | setof(Term, Var1^Var2^Goal, List). | ||||
209 | | ||||
210 | event_handler_methods :- | ||||
211 | before(Object, Message, Sender), | ||||
212 | after(Object, Message, Sender). | ||||
213 | | ||||
214 | message_forwarding_method :- | ||||
215 | forward(Message). | ||||
216 | | ||||
217 | dcg_rules_parsing_methods :- | ||||
218 | phrase(NonTerminal, Input, Rest). | ||||
219 | | ||||
220 | term_expansion_methods :- | ||||
221 | expand_term(Term, Expanded), | ||||
222 | expand_goal(Goal, Expanded), | ||||
223 | term_expansion(Term, Expanded), | ||||
224 | goal_expansion(Goal, Expanded). | ||||
225 | | ||||
226 | message_sending :- | ||||
227 | Object::Message, | ||||
228 | ::Message, | ||||
229 | ^^Message. | ||||
230 | | ||||
231 | calling_external_code :- | ||||
232 | <beginfold id='2'>{</beginfold id='2'>goal1, goal2, goal3<endfold id='2'>}</endfold id='2'>. | ||||
233 | | ||||
234 | context_switching_calls :- | ||||
235 | Object<<Goal. | ||||
236 | | ||||
237 | lambda_expressions :- | ||||
238 | <beginfold id='2'>{</beginfold id='2'>X,Y,Z<endfold id='2'>}</endfold id='2'>/[P,Q]>>Goal. | ||||
239 | | ||||
240 | explicitly_qualified_module_calls :- | ||||
241 | Module:Goal. | ||||
242 | | ||||
243 | if_then_else :- | ||||
244 | ( If -> | ||||
245 | Then | ||||
246 | ; Else | ||||
247 | ). | ||||
248 | | ||||
249 | numbers :- | ||||
250 | X1 is 13, X2 is -13, X3 is +13, | ||||
251 | Y1 is 13.13, Y2 is -13.13, Y3 is +13.13, | ||||
252 | Z1 is 13.13e-23, Z2 is -13.13e-23, Z3 is +13.13e-23, | ||||
253 | C1 is 0'A, C2 is 0'', C3 is 0'", C4 is 0'%, | ||||
254 | C5 is 0'\n, C6 is 0'\\, C7 is 0'\', C8 is 0'\", C9 is 0'\`, | ||||
255 | B1 is 0b1011101, | ||||
256 | O1 is 0o1234560, | ||||
257 | H1 is 0x1234567890abcDEF. | ||||
258 | | ||||
259 | functions :- | ||||
260 | A is atan(3.14) + atan2(1, 0) + acos(0.5) + asin(0.5) + sin(0.77) - cos(123.23) - tan(0.33), | ||||
261 | B is sign(-12) * abs(35/78), | ||||
262 | C is truncate(3.14) + round(-7.8) - ceiling(111.88), | ||||
263 | D is exp(3.8) - log(123.98) / sqrt(33) * 23 ** 4 + 12345^2, | ||||
264 | E is rem(3, 2) + mod(5, 3) - div(8, 4) * 2 rem 2 // 5 mod 3 - 8 div 4 + pi * e, | ||||
265 | F is float_fractional_part(3.14) + float_integer_part(3.14), | ||||
266 | G is float(33) + floor(99.99), | ||||
267 | I is min(3,4) + max(4,5). | ||||
268 | | ||||
269 | bitwise :- | ||||
270 | A is 16 >> 2, | ||||
271 | B is 16 << 2, | ||||
272 | C is 10 /\ 12, | ||||
273 | D is 10 \/ 12, | ||||
274 | E is \ 10, | ||||
275 | F is xor(13, 7). | ||||
276 | | ||||
277 | term_unification :- | ||||
278 | Term1 = Term2, | ||||
279 | Term1 \= Term2, | ||||
280 | unify_with_occurs_check(Term1, Term2), | ||||
281 | subsumes_term(General, Specific). | ||||
282 | | ||||
283 | term_testing :- | ||||
284 | atom(Atom), | ||||
285 | atomic(Atomic), | ||||
286 | integer(Integer), | ||||
287 | float(Float), | ||||
288 | callable(Term), | ||||
289 | compound(Term), | ||||
290 | nonvar(Term), | ||||
291 | var(Term), | ||||
292 | number(Number), | ||||
293 | ground(Term), | ||||
294 | acyclic_term(Term). | ||||
295 | | ||||
296 | term_comparison :- | ||||
297 | compare(Order, Term1, Term2), | ||||
298 | Term1 == Term2, | ||||
299 | Term1 \== Term2, | ||||
300 | Term1 @< Term2, | ||||
301 | Term1 @=< Term2, | ||||
302 | Term1 @>= Term2, | ||||
303 | Term1 @> Term2. | ||||
304 | | ||||
305 | term_creation_and_decomposition :- | ||||
306 | functor(Term, Name, Arity), | ||||
307 | arg(N, Term, Arg), | ||||
308 | Term =.. [Functor| Args], | ||||
309 | copy_term(Term, Copy), | ||||
310 | numbervars(Term, Start, End), | ||||
311 | term_variables(Term, Variables). | ||||
312 | | ||||
313 | arithemtic_evaluation :- | ||||
314 | X is Expression. | ||||
315 | | ||||
316 | arithemtic_comparison :- | ||||
317 | Exp1 =:= Exp2, | ||||
318 | Exp1 =\= Exp2, | ||||
319 | Exp1 < Exp2, | ||||
320 | Exp1 =< Exp2, | ||||
321 | Exp1 > Exp2, | ||||
322 | Exp1 >= Exp2. | ||||
323 | | ||||
324 | stream_selection_and_control :- | ||||
325 | current_input(Stream), | ||||
326 | current_output(Stream), | ||||
327 | set_input(Stream), | ||||
328 | set_output(Stream), | ||||
329 | open(Source, Mode, Stream, Options), | ||||
330 | close(Stream), | ||||
331 | flush_output(Stream), | ||||
332 | stream_property(Stream, Property), | ||||
333 | at_end_of_stream(Stream), | ||||
334 | set_stream_position(Stream, Position), | ||||
335 | flush_output, | ||||
336 | at_end_of_stream. | ||||
337 | | ||||
338 | character_input_output :- | ||||
339 | get_char(Char), | ||||
340 | get_code(Code), | ||||
341 | peek_char(Char), | ||||
342 | peek_code(Code), | ||||
343 | put_char(Char), | ||||
344 | put_code(Code), | ||||
345 | nl(Stream), | ||||
346 | nl. | ||||
347 | | ||||
348 | byte_input_output :- | ||||
349 | get_byte(Byte), | ||||
350 | peek_byte(Byte), | ||||
351 | put_byte(Byte). | ||||
352 | | ||||
353 | term_input_output :- | ||||
354 | read(Term), | ||||
355 | read_term(Stream, Term, Options), | ||||
356 | write(Term), | ||||
357 | write(Term), | ||||
358 | write_canonical(Term), | ||||
359 | write_term(Stream, Term, Options), | ||||
360 | current_op(Precedence, Associativity, Operator), | ||||
361 | op(Precedence, Associativity, Operator), | ||||
362 | current_char_conversion(InChar, OutChar), | ||||
363 | char_conversion(InChar, OutChar). | ||||
364 | | ||||
365 | logic_and_control :- | ||||
366 | \+ Goal, | ||||
367 | call(Goal), | ||||
368 | once(Goal), | ||||
369 | ignore(Goal), | ||||
370 | true, | ||||
371 | fail, | ||||
372 | false, | ||||
373 | repeat, | ||||
374 | !. | ||||
375 | | ||||
376 | atomic_term_processing :- | ||||
377 | atom_length(Atom, Length), | ||||
378 | atom_chars(Atom, Chars), | ||||
379 | atom_codes(Atom, Codes), | ||||
380 | atom_concat(Atom1, Atom2, Atom), | ||||
381 | sub_atom(Atom, Before, Length, After, SubAtom), | ||||
382 | char_code(Char, Code), | ||||
383 | number_chars(Number, Chars), | ||||
384 | number_codes(Number, Codes). | ||||
385 | | ||||
386 | implementation_defined_hooks :- | ||||
387 | current_prolog_flag(Flag, Value), | ||||
388 | set_prolog_flag(Flag, Value), | ||||
389 | halt(ExitCode), | ||||
390 | halt. | ||||
391 | | ||||
392 | sorting :- | ||||
393 | keysort(List, Sorted), | ||||
394 | sort(List, Sorted). | ||||
395 | | ||||
396 | number(C) --> "+", number(C). | ||||
397 | number(C) --> "-", number(X), <beginfold id='2'>{</beginfold id='2'>C is -X<endfold id='2'>}</endfold id='2'>. | ||||
398 | number(X) --> [C], <beginfold id='2'>{</beginfold id='2'>0'0 =< C, C =< 0'9, X is C - 0'0<endfold id='2'>}</endfold id='2'>. | ||||
399 | | ||||
400 | escape_sequences :- | ||||
401 | write('Quoted atom with a quote ('') inside.'), | ||||
402 | write('Quoted atom with a backslash (\\) inside.'), | ||||
403 | write('Quoted atom with control escape sequences: \a \b \r \f \t \n \v'), | ||||
404 | write('Quoted atom with an octal escape sequence: \123\.'), | ||||
405 | write('Quoted atom with an hexadecimal escape sequence: \x123f\.'). | ||||
406 | | ||||
407 | :- <endfold id='4'>end_object.</endfold id='4'> | ||||
408 | | ||||
409 | | ||||
410 | :- <beginfold id='4'>object</beginfold id='4'>(class, | ||||
411 | implements(protected::protocol), | ||||
412 | imports(private::category), | ||||
413 | instantiates(metaclass), | ||||
414 | specializes(superclass)). | ||||
415 | | ||||
416 | :- <endfold id='4'>end_object.</endfold id='4'> | ||||
417 | | ||||
418 | | ||||
419 | :- <beginfold id='4'>object</beginfold id='4'>(parametric(Parameter, "String", 33.78), | ||||
420 | implements(protocol), | ||||
421 | imports(category), | ||||
422 | extends(parent(Parameter))). | ||||
423 | | ||||
424 | :- <endfold id='4'>end_object.</endfold id='4'> | ||||
425 | | ||||
426 | | ||||
427 | :- <beginfold id='4'>category</beginfold id='4'>(category, | ||||
428 | implements(protocol), | ||||
429 | extends(other_category)). | ||||
430 | | ||||
431 | :- <endfold id='4'>end_category.</endfold id='4'> | ||||
432 | | ||||
433 | | ||||
434 | :- <beginfold id='4'>protocol</beginfold id='4'>(extended, | ||||
435 | extends(minimal)). | ||||
436 | | ||||
437 | :- <endfold id='4'>end_protocol.</endfold id='4'> | ||||
438 | | ||||
439 | | ||||
440 | :- module(module, [foo/1, bar/2]). | ||||
441 | | ||||
442 | :- use_module(library). | ||||
443 | :- use_module(library, [baz/3]). | ||||
444 | | ||||
445 | :- reexport(library). | ||||
446 | :- reexport(library, [qux/4]). | ||||
447 | | ||||
448 | :- export(quux/5). |