root/trunk/wenv/tests/source.lgt @ 5055

Revision 5055, 7.6 KB (checked in by pmoura, 15 months ago)

Updated text editor configuration files in order to remove references to the no longer used ".config" file name extension and to support syntax coloring and code completion of the multifile/1 and use_module/1-2 directives.

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-logtalk
Line 
1
2% this is a single-line comment
3
4/*
5this is
6a block
7comment
8*/
9
10
11:- encoding(Encoding).
12:- op(Precedence, Associativity, Operator).
13:- ensure_loaded(File).
14:- set_prolog_flag(Flag, Value).
15:- set_logtalk_flag(Flag, Value).
16
17
18:- object(prototype,
19    implements(protocol),
20    imports(category),
21    extends(parent)).
22
23    :- info([
24        version is 1.0,
25        author is 'Paulo Moura',
26        date is 2008/5/1,
27        comment is 'Sample prototype for testing syntax coloring.']).
28    :- threaded.
29    :- synchronized.
30    :- dynamic.
31    :- initialization(some_goal(X, Y)).
32    :- calls(some_other_protocol).
33    :- uses(another_object).
34
35    :- alias(set, member/2, set_member/2).
36    :- alias(words, singular//0, peculiar//0).
37
38    :- uses(list, [append/3, member/2]).
39    :- uses(queues, [new/1::new_queue/1]).
40
41    :- multifile(zzz/1).
42    :- multifile(module:zzz/1).
43    :- multifile(object::zzz/1).
44
45    :- use_module(module, [xxx/1, yyy/2, zzz/3]).
46
47    :- public(aaa/2).
48    :- meta_predicate(aaa(::, *)).
49    :- discontiguous(aaa/2).
50    :- mode(aaa(+callable, ?integer), zero_or_one).
51    :- info(position/2, [
52        comment is 'Predicate brief description.',
53        arguments is ['Arg1'-'Arg1 description', 'Arg2'-'Arg2 description']]).
54
55    :- protected(bbb/2).
56    :- synchronized(bbb/2).
57    :- mode(bbb(+integer, -float), one).
58    :- info(bbb/2, [
59        comment is 'Predicate brief description.',
60        argnames is ['Arg1', 'Arg2']]).
61
62    :- private(ccc/2).
63    :- dynamic(ccc/2).
64    :- mode(ccc(@atom, ?atom), one_or_more).
65    :- info(ccc/2, [
66        comment is 'Predicate brief description.',
67        argnames is ['Arg1', 'Arg2']]).
68
69    enumerating_entities(Object, Protocol, Category) :-
70        current_category(Category),
71        current_object(Object),
72        current_protocol(Protocol).
73
74    enumerating_properties :-
75        category_property(Category, Property),
76        object_property(Object, Property),
77        protocol_property(Protocol, Property).
78
79    creating_entities(Object, Protocol, Category) :-
80        create_category(Category, Relations, Directives, Clauses),
81        create_object(Object, Relations, Directives, Clauses),
82        create_protocol(Protocol, Relations, Directives).
83
84    abolishing_entities(Object, Protocol, Category) :-
85        abolish_category(Category),
86        abolish_object(Object),
87        abolish_protocol(Protocol).
88
89    entity_relations :-
90        extends_object(Prototype, Parent, Scope),
91        extends_protocol(Protocol1, Protocol2, Scope),
92        extends_category(Category1, Category2, Scope),
93        implements_protocol(Object, Protocol, Scope),
94        imports_category(Object, Category, Scope),
95        instantiates_class(Instance, Class, Scope),
96        specializes_class(Class, Superclass, Scope),
97        complements_object(Category, Object).
98
99    event_handling :-
100        abolish_events(Event, Object, Message, Sender, Monitor),
101        current_event(Event, Object, Message, Sender, Monitor),
102        define_events(Event, Object, Message, Sender, Monitor).
103
104    multi_threading :-
105        threaded(Goals),
106        threaded_call(Goal),
107        threaded_once(Goal),
108        threaded_ignore(Goal),
109        threaded_exit(Goal),
110        threaded_peek(Goal),
111        threaded_wait(Goal),
112        threaded_notify(Notification).
113
114    compiling_and_loading :-
115        logtalk_compile(File, Options),
116        logtalk_load(File, Options),
117        logtalk_library_path(Library, Path).
118
119    flags :-
120        current_logtalk_flag(Flag, Value),
121        set_logtalk_flag(Flag, Value).
122
123    execution_context_methods :-
124        parameter(N, Parameter),
125        self(Self),
126        sender(Sender),
127        this(This).
128
129    reflection_methods :-
130        current_predicate(Predicate),
131        predicate_property(Predicate, Property).
132
133    database_methods :-
134        abolish(Functor/Arity),
135        asserta(Clause),
136        assertz(Clause),
137        clause(Head, Body),
138        retract(Clause),
139        retractall(Head).
140
141    meta_call_methods :-
142        call(Goal).
143
144    all_solutions_methods :-
145        bagof(Term, Goal, List),
146        findall(Term, Goal, List),
147        forall(Generate, Test),
148        setof(Term, Goal, List).
149
150    event_handler_methods :-
151        before(Object, Message, Sender),
152        after(Object, Message, Sender).
153
154    dcg_rules_parsing_methods :-
155        phrase(NonTerminal, Input, Rest).
156
157    term_expansion_methods :-
158        expand_term(Term, Expanded),
159        expand_goal(Goal, Expanded),
160        term_expansion(Term, Expanded),
161        goal_expansion(Goal, Expanded).
162
163    message_sending :-
164        Object::Message,
165        ::Message,
166        ^^Message.
167
168    calling_external_code :-
169        {goal1, goal2, goal3}.
170
171    context_switching_calls :-
172        Object<<Goal.
173
174    direct_calls_of_category_predicates :-
175        :Goal.
176
177    if_then_else :-
178        (   If ->
179            Then
180        ;   Else
181        ).
182
183    numbers :-
184        X is 13,
185        Y is 13.13,
186        Z is 13.13e-23,
187        C1 is 0'A, C2 is 0'', C3 is 0'",
188        B is 0b1011101,
189        O is 0o1234560,
190        H is 0x1234567890abcDEF.
191
192    functions :-
193        A is atan(3.14) + sin(0.77) - cos(123.23),
194        B is sign(-12) * abs(35/78),
195        C is truncate(3.14) + round(-7.8) - ceiling(111.88),
196        D is exp(3.8) - log(123.98) / sqrt(33) * 23 ** 4,
197        E is rem(3, 2) + mod(5, 3) * 2 rem 2 // 5 mod 3,
198        F is float_fractional_part(3.14) + float_integer_part(3.14),
199        G is float(33) + floor(99.99).
200
201    bitwise :-
202        A is 16 >> 2,
203        B is 16 << 2,
204        C is 10 /\ 12,
205        D is 10 \/ 12,
206        E is \ 10.
207
208    term_unification :-
209        Term1 = Term2,
210        Term1 \= Term2,
211        unify_with_occurs_check(Term1, Term2).
212
213    term_testing :-
214        atom(Atom),
215        atomic(Atomic),
216        integer(Integer),
217        float(Float),
218        compound(Term),
219        nonvar(Term),
220        var(Term),
221        number(Number).
222
223    term_comparison :-
224        Term1 == Term2,
225        Term1 \== Term2,
226        Term1 @< Term2,
227        Term1 @=< Term2,
228        Term1 @>= Term2,
229        Term1 @> Term2.
230
231    term_creation_and_decomposition :-
232        functor(Term, Functor, Arity),
233        arg(N, Term, Arg),
234        Term =.. [Functor| Args],
235        copy_term(Term, Copy).
236
237    arithemtic_evaluation :-
238        X is Expression.
239
240    arithemtic_comparison :-
241        Exp1 =:= Exp2,
242        Exp1 =\= Exp2,
243        Exp1 < Exp2,
244        Exp1 =< Exp2,
245        Exp1 > Exp2,
246        Exp1 >= Exp2.
247
248    stream_selection_and_control :-
249        current_input(Stream),
250        current_output(Stream),
251        set_input(Stream),
252        set_output(Stream),
253        open(Source, Mode, Stream, Options),
254        close(Stream),
255        flush_output(Stream),
256        stream_property(Stream, Property),
257        at_end_of_stream(Stream),
258        set_stream_position(Stream, Position),
259        flush_output,
260        at_end_of_stream.
261
262    character_input_output :-
263        get_char(Char),
264        get_code(Code),
265        peek_char(Char),
266        peek_code(Code),
267        put_char(Char),
268        put_code(Code),
269        nl(Stream),
270        nl.
271
272    byte_input_output :-
273        get_byte(Byte),
274        peek_byte(Byte),
275        put_byte(Byte).
276
277    term_input_output :-
278        read(Term),
279        read_term(Term),
280        write(Term),
281        write(Term),
282        write_canonical(Term),
283        write_term(Stream, Term, Options),
284        current_op(Precedence, Associativity, Operator),
285        op(Precedence, Associativity, Operator),
286        current_char_conversion(InChar, OutChar),
287        char_conversion(InChar, OutChar).
288
289    logic_and_control :-
290        \+ Goal,
291        once(Goal),
292        repeat,
293        !.
294
295    atomic_term_processing :-
296        atom_length(Atom, Length),
297        atom_chars(Atom, Chars),
298        atom_codes(Atom, Codes),
299        atom_concat(Atom1, Atom2, Atom),
300        sub_atom(Atom, Before, Length, After, SubAtom),
301        char_code(Char, Code),
302        number_chars(Number, Chars),
303        number_codes(Number, Codes).
304
305    implementation_defined_hooks :-
306        current_prolog_flag(Flag, Value),
307        set_prolog_flag(Flag, Value),
308        halt(ExitCode),
309        halt.
310
311    number(C) --> "+", number(C).
312    number(C) --> "-", number(X), {C is -X}.
313    number(X) --> [C], {0'0 =< C, C =< 0'9, X is C - 0'0}.
314
315    escape_sequences :-
316        write('Quoted atom with a quote ('') inside.'),
317        write('Quoted atom with control escape sequences: \a \b \r \f \t \n \v'),
318        write('Quoted atom with an octal escape sequence: \123\.'),
319        write('Quoted atom with an hexa-decimal escape sequence: \x123f\.').
320
321:- end_object.
322
323
324
325:- object(class,
326    implements(protected::protocol),
327    imports(private::category),
328    instantiates(metaclass),
329    specializes(superclass)).
330
331
332:- end_object.
333
334
335
336:- object(parametric(Parameter, "String", 33.78),
337    implements(protocol),
338    imports(category),
339    extends(parent(Parameter))).
340
341
342:- end_object.
343
344
345
346:- category(category,
347    implements(protocol),
348    extends(other_category)).
349
350
351:- end_category.
352
353
354
355:- protocol(extended,
356    extends(minimal)).
357
358
359:- end_protocol.
Note: See TracBrowser for help on using the browser.