Warning, /frameworks/syntax-highlighting/autotests/input/highlight.lgt is written in an unsupported language. File is not indexed.
0001 /*
0002 Highlighting test case for Logtalk
0003
0004 Copied from the Logtalk distribution by the Logtalk copright holder
0005 and contributed using the Apache License 2.0
0006 */
0007
0008 :- encoding(Encoding). % this is a single-line comment
0009
0010 /*
0011 this is
0012 a block
0013 comment
0014 */
0015
0016
0017 :- if(Goal).
0018 % conditional
0019 :- elif(Goal).
0020 % compilation
0021 :- else.
0022 % directives
0023 :- endif.
0024
0025
0026 :- initialization(Goal).
0027 :- op(Precedence, Associativity, Operator).
0028 :- ensure_loaded(File).
0029 :- include(File).
0030 :- set_prolog_flag(Flag, Value).
0031 :- set_logtalk_flag(Flag, Value).
0032
0033
0034 :- object(prototype,
0035 implements(protocol),
0036 imports(category),
0037 extends(parent)).
0038
0039 :- info([
0040 version is 1:47:0,
0041 author is 'Paulo Moura',
0042 date is 2019-09-18,
0043 comment is 'Sample prototype for testing syntax coloring.'
0044 ]).
0045
0046 :- built_in.
0047 :- threaded.
0048 :- dynamic.
0049
0050 :- initialization(some_goal(X, Y)).
0051
0052 :- uses([
0053 foobar as fb
0054 ]).
0055
0056 :- alias(set, [member/2 as set_member/2]).
0057 :- alias(words, [singular//0 as peculiar//0]).
0058
0059 :- uses(list, [append/3, member/2]).
0060 :- uses(queues, [new/1 as new_queue/1]).
0061
0062 :- use_module(module).
0063 :- use_module(module, [append/3, member/2]).
0064
0065 :- multifile(zzz/1).
0066 :- multifile(module:zzz/1).
0067 :- multifile(object::zzz/1).
0068
0069 :- coinductive(comember/1).
0070
0071 :- use_module(module, [xxx/1, yyy/2, zzz/3]).
0072 :- export(bbb/3).
0073 :- reexport(cccc/4).
0074
0075 :- public(aaa/2).
0076 :- meta_predicate(aaa(::, *)).
0077 :- discontiguous(aaa/2).
0078 :- mode(aaa(+callable, ?integer), zero_or_one).
0079 :- info(position/2, [
0080 comment is 'Predicate brief description.',
0081 arguments is ['Arg1'-'Arg1 description', 'Arg2'-'Arg2 description']
0082 ]).
0083
0084 :- public(nt//2).
0085 :- meta_non_terminal(nt(1, *)).
0086
0087 :- protected(bbb/2).
0088 :- synchronized(bbb/2).
0089 :- mode(bbb(+integer, -float), one).
0090 :- info(bbb/2, [
0091 comment is 'Predicate brief description.',
0092 argnames is ['Arg1', 'Arg2']
0093 ]).
0094
0095 :- private(ccc/2).
0096 :- dynamic(ccc/2).
0097 :- mode(ccc(@atom, ?atom, ++list, --ground), one_or_more).
0098 :- info(ccc/2, [
0099 comment is 'Predicate brief description.',
0100 argnames is ['Arg1', 'Arg2']
0101 ]).
0102
0103 enumerating_entities(Object, Protocol, Category) :-
0104 current_category(Category),
0105 current_object(Object),
0106 current_protocol(Protocol).
0107
0108 enumerating_properties :-
0109 category_property(Category, Property),
0110 object_property(Object, Property),
0111 protocol_property(Protocol, Property).
0112
0113 creating_entities(Object, Protocol, Category) :-
0114 create_category(Category, Relations, Directives, Clauses),
0115 create_object(Object, Relations, Directives, Clauses),
0116 create_protocol(Protocol, Relations, Directives).
0117
0118 abolishing_entities(Object, Protocol, Category) :-
0119 abolish_category(Category),
0120 abolish_object(Object),
0121 abolish_protocol(Protocol).
0122
0123 entity_relations :-
0124 extends_object(Prototype, Parent, Scope),
0125 extends_protocol(Protocol1, Protocol2, Scope),
0126 extends_category(Category1, Category2, Scope),
0127 implements_protocol(Object, Protocol, Scope),
0128 imports_category(Object, Category, Scope),
0129 instantiates_class(Instance, Class, Scope),
0130 specializes_class(Class, Superclass, Scope),
0131 complements_object(Category, Object),
0132 conforms_to_protocol(ObjOrCtg, Protocol, Scope).
0133
0134 event_handling :-
0135 abolish_events(Event, Object, Message, Sender, Monitor),
0136 current_event(Event, Object, Message, Sender, Monitor),
0137 define_events(Event, Object, Message, Sender, Monitor).
0138
0139 multi_threading :-
0140 threaded(Goals),
0141 threaded_call(Goal),
0142 threaded_call(Goal, Tag),
0143 threaded_once(Goal),
0144 threaded_once(Goal, Tag),
0145 threaded_ignore(Goal),
0146 threaded_exit(Goal),
0147 threaded_exit(Goal, Tag),
0148 threaded_peek(Goal),
0149 threaded_peek(Goal, Tag),
0150 threaded_cancel(Tag),
0151 threaded_wait(Notification),
0152 threaded_notify(Notification).
0153
0154 engines :-
0155 threaded_engine(Engine),
0156 threaded_engine_create(AnswerTemplate, Goal, Engine),
0157 threaded_engine_destroy(Engine),
0158 threaded_engine_self(Engine),
0159 threaded_engine_next(Engine, Answer),
0160 threaded_engine_next_reified(Engine, Answer),
0161 threaded_engine_yield(Answer),
0162 threaded_engine_post(Engine, Term),
0163 threaded_engine_fetch(Term).
0164
0165 compiling_and_loading :-
0166 logtalk_compile(File, Options),
0167 logtalk_load(File, Options),
0168 logtalk_library_path(Library, Path),
0169 logtalk_load_context(Key, Value),
0170 logtalk_make(Action),
0171 logtalk_make,
0172 logtalk_make_target_action(Target).
0173
0174 flags :-
0175 current_logtalk_flag(Flag, Value),
0176 set_logtalk_flag(Flag, Value),
0177 create_logtalk_flag(Flag, Value, Options).
0178
0179 execution_context_methods :-
0180 context(Context),
0181 parameter(N, Parameter),
0182 self(Self),
0183 sender(Sender),
0184 this(This).
0185
0186 reflection_methods :-
0187 current_predicate(Predicate),
0188 predicate_property(Predicate, Property).
0189
0190 database_methods :-
0191 abolish(Name/Arity),
0192 asserta(Clause),
0193 assertz(Clause),
0194 clause(Head, Body),
0195 retract(Clause),
0196 retractall(Head).
0197
0198 exception_methods :-
0199 catch(Goal, Error, Catcher),
0200 throw(Error),
0201 instantiation_error,
0202 type_error(Type, Culprit),
0203 domain_error(Domain, Culprit),
0204 existence_error(Thing, Culprit),
0205 permission_error(Operation, Permission, Culprit),
0206 representation_error(Flag),
0207 evaluation_error(Exception),
0208 resource_error(Resource),
0209 syntax_error(Description),
0210 system_error.
0211
0212 all_solutions_methods :-
0213 bagof(Term, Goal, List),
0214 bagof(Term, Var^Goal, List),
0215 findall(Term, Goal, List),
0216 forall(Generate, Test),
0217 setof(Term, Goal, List),
0218 setof(Term, Var1^Var2^Goal, List).
0219
0220 event_handler_methods :-
0221 before(Object, Message, Sender),
0222 after(Object, Message, Sender).
0223
0224 message_forwarding_method :-
0225 forward(Message).
0226
0227 dcg_rules_parsing_methods :-
0228 phrase(NonTerminal, Input, Rest).
0229
0230 term_expansion_methods :-
0231 expand_term(Term, Expanded),
0232 expand_goal(Goal, Expanded),
0233 term_expansion(Term, Expanded),
0234 goal_expansion(Goal, Expanded).
0235
0236 message_sending :-
0237 Object::Message,
0238 ::Message,
0239 ^^Message.
0240
0241 calling_external_code :-
0242 {goal1, goal2, goal3}.
0243
0244 context_switching_calls :-
0245 Object<<Goal.
0246
0247 lambda_expressions :-
0248 {X,Y,Z}/[P,Q]>>Goal.
0249
0250 explicitly_qualified_module_calls :-
0251 Module:Goal.
0252
0253 if_then_else :-
0254 ( If ->
0255 Then
0256 ; Else
0257 ).
0258
0259 numbers :-
0260 X1 is 13, X2 is -13, X3 is +13,
0261 Y1 is 13.13, Y2 is -13.13, Y3 is +13.13,
0262 Z1 is 13.13e-23, Z2 is -13.13e-23, Z3 is +13.13e-23,
0263 C1 is 0'A, C2 is 0'', C3 is 0'", C4 is 0'%,
0264 C5 is 0'\n, C6 is 0'\\, C7 is 0'\', C8 is 0'\", C9 is 0'\`,
0265 B1 is 0b1011101,
0266 O1 is 0o1234560,
0267 H1 is 0x1234567890abcDEF.
0268
0269 functions :-
0270 A is atan(3.14) + atan2(1, 0) + acos(0.5) + asin(0.5) + sin(0.77) - cos(123.23) - tan(0.33),
0271 B is sign(-12) * abs(35/78),
0272 C is truncate(3.14) + round(-7.8) - ceiling(111.88),
0273 D is exp(3.8) - log(123.98) / sqrt(33) * 23 ** 4 + 12345^2,
0274 E is rem(3, 2) + mod(5, 3) - div(8, 4) * 2 rem 2 // 5 mod 3 - 8 div 4 + pi * e,
0275 F is float_fractional_part(3.14) + float_integer_part(3.14),
0276 G is float(33) + floor(99.99),
0277 I is min(3,4) + max(4,5).
0278
0279 bitwise :-
0280 A is 16 >> 2,
0281 B is 16 << 2,
0282 C is 10 /\ 12,
0283 D is 10 \/ 12,
0284 E is \ 10,
0285 F is xor(13, 7).
0286
0287 term_unification :-
0288 Term1 = Term2,
0289 Term1 \= Term2,
0290 unify_with_occurs_check(Term1, Term2),
0291 subsumes_term(General, Specific).
0292
0293 term_testing :-
0294 atom(Atom),
0295 atomic(Atomic),
0296 integer(Integer),
0297 float(Float),
0298 callable(Term),
0299 compound(Term),
0300 nonvar(Term),
0301 var(Term),
0302 number(Number),
0303 ground(Term),
0304 acyclic_term(Term).
0305
0306 term_comparison :-
0307 compare(Order, Term1, Term2),
0308 Term1 == Term2,
0309 Term1 \== Term2,
0310 Term1 @< Term2,
0311 Term1 @=< Term2,
0312 Term1 @>= Term2,
0313 Term1 @> Term2.
0314
0315 term_creation_and_decomposition :-
0316 functor(Term, Name, Arity),
0317 arg(N, Term, Arg),
0318 Term =.. [Functor| Args],
0319 copy_term(Term, Copy),
0320 numbervars(Term, Start, End),
0321 term_variables(Term, Variables).
0322
0323 arithmetic_evaluation :-
0324 X is Expression.
0325
0326 arithmetic_comparison :-
0327 Exp1 =:= Exp2,
0328 Exp1 =\= Exp2,
0329 Exp1 < Exp2,
0330 Exp1 =< Exp2,
0331 Exp1 > Exp2,
0332 Exp1 >= Exp2.
0333
0334 stream_selection_and_control :-
0335 current_input(Stream),
0336 current_output(Stream),
0337 set_input(Stream),
0338 set_output(Stream),
0339 open(Source, Mode, Stream, Options),
0340 close(Stream),
0341 flush_output(Stream),
0342 stream_property(Stream, Property),
0343 at_end_of_stream(Stream),
0344 set_stream_position(Stream, Position),
0345 flush_output,
0346 at_end_of_stream.
0347
0348 character_input_output :-
0349 get_char(Char),
0350 get_code(Code),
0351 peek_char(Char),
0352 peek_code(Code),
0353 put_char(Char),
0354 put_code(Code),
0355 nl(Stream),
0356 nl.
0357
0358 byte_input_output :-
0359 get_byte(Byte),
0360 peek_byte(Byte),
0361 put_byte(Byte).
0362
0363 term_input_output :-
0364 read(Term),
0365 read_term(Stream, Term, Options),
0366 write(Term),
0367 write(Term),
0368 write_canonical(Term),
0369 write_term(Stream, Term, Options),
0370 current_op(Precedence, Associativity, Operator),
0371 op(Precedence, Associativity, Operator),
0372 current_char_conversion(InChar, OutChar),
0373 char_conversion(InChar, OutChar).
0374
0375 logic_and_control :-
0376 \+ Goal,
0377 call(Goal),
0378 once(Goal),
0379 ignore(Goal),
0380 true,
0381 fail,
0382 false,
0383 repeat,
0384 !.
0385
0386 atomic_term_processing :-
0387 atom_length(Atom, Length),
0388 atom_chars(Atom, Chars),
0389 atom_codes(Atom, Codes),
0390 atom_concat(Atom1, Atom2, Atom),
0391 sub_atom(Atom, Before, Length, After, SubAtom),
0392 char_code(Char, Code),
0393 number_chars(Number, Chars),
0394 number_codes(Number, Codes).
0395
0396 implementation_defined_hooks :-
0397 current_prolog_flag(Flag, Value),
0398 set_prolog_flag(Flag, Value),
0399 halt(ExitCode),
0400 halt.
0401
0402 sorting :-
0403 keysort(List, Sorted),
0404 sort(List, Sorted).
0405
0406 number(C) --> "+", number(C).
0407 number(C) --> "-", number(X), {C is -X}.
0408 number(X) --> [C], {0'0 =< C, C =< 0'9, X is C - 0'0}.
0409
0410 escape_sequences :-
0411 write('Quoted atom with a quote ('') inside.'),
0412 write('Quoted atom with a quote (\') inside using a control escape sequence.'),
0413 write('Quoted atom with a backslash (\\) inside.'),
0414 write('Quoted atom with control escape sequences: \a \b \r \f \t \n \v'),
0415 write('Quoted atom with an octal escape sequence: \123\.'),
0416 write('Quoted atom with an hexadecimal escape sequence: \x123f\.').
0417
0418 % nothing in the following predicate definition should be highlighted
0419 sort :-
0420 forall,
0421 object,
0422 write,
0423 number.
0424
0425 :- end_object.
0426
0427
0428 :- object(class,
0429 implements(protected::protocol),
0430 imports(private::category),
0431 instantiates(metaclass),
0432 specializes(superclass)).
0433
0434 :- end_object.
0435
0436
0437 :- object(parametric(Parameter, "String", 33.78),
0438 implements(protocol),
0439 imports(category),
0440 extends(parent(Parameter))).
0441
0442 :- end_object.
0443
0444
0445 :- category(category,
0446 implements(protocol),
0447 extends(other_category)).
0448
0449 :- end_category.
0450
0451
0452 :- protocol(extended,
0453 extends(minimal)).
0454
0455 :- end_protocol.
0456
0457
0458 :- module(module, [foo/1, bar/2]).
0459
0460 :- use_module(library).
0461 :- use_module(library, [baz/3]).
0462
0463 :- reexport(library).
0464 :- reexport(library, [qux/4]).
0465
0466 :- export(quux/5).