Logtalk 2.28.2 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1713 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
2d7ccc1278
commit
3ac73c8881
13
Logtalk/examples/threads/NOTES.txt
Normal file
13
Logtalk/examples/threads/NOTES.txt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
This folder contains some examples of multi-threading programming.
|
||||||
|
Multi-threading programming is only supported on some Prolog compilers.
|
||||||
|
Currently this includes SWI-Prolog and YAP. Moreover, multi-threading
|
||||||
|
is turned off by default. In order to run the examples, you will need
|
||||||
|
to first turn on multi-threading support on the Prolog config files.
|
19
Logtalk/examples/threads/atomic/NOTES.txt
Normal file
19
Logtalk/examples/threads/atomic/NOTES.txt
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
To load this example and for sample queries, please see the SCRIPT file.
|
||||||
|
|
||||||
|
This folder contains a simple multi-threading example illustrating the
|
||||||
|
use of the "atomic" option on threaded_call/2 calls to cope with methods
|
||||||
|
that have side-effects.
|
||||||
|
|
||||||
|
The object defined in the example source file, "atomic.lgt", defines a
|
||||||
|
predicate named waste_time/0 that is used to delay the execuion of goals
|
||||||
|
in order to better illustrate the semantics of the "atomic" option. This
|
||||||
|
predicate uses a counter that you might need to adjust, depending on your
|
||||||
|
Prolog compiler and computer performance.
|
71
Logtalk/examples/threads/atomic/SCRIPT.txt
Normal file
71
Logtalk/examples/threads/atomic/SCRIPT.txt
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
% start by loading the loading the example:
|
||||||
|
|
||||||
|
| ?- logtalk_load(atomic(loader)).
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
% send three asynchronous messages whose corresponding methods perform output operations:
|
||||||
|
|
||||||
|
| ?- threaded_call(nasty1::io(alpha), [noreply]), threaded_call(nasty1::io(digit), [noreply]), threaded_call(nasty1::io(alpha), [noreply]).
|
||||||
|
|
||||||
|
a0ab1bc2c3ddefef45gg6hh7ii8jkjk9
|
||||||
|
llmmnnopopqqrrsstztzyyxxwwuv
|
||||||
|
uv
|
||||||
|
|
||||||
|
Yes
|
||||||
|
|
||||||
|
|
||||||
|
% the same three asynchronous messages but making them atomic for the receiver object:
|
||||||
|
|
||||||
|
| ?- threaded_call(nasty1::io(alpha), [atomic, noreply]), threaded_call(nasty1::io(digit), [atomic, noreply]), threaded_call(nasty1::io(alpha), [atomic, noreply]).
|
||||||
|
|
||||||
|
abcdefghijklmnopqrstzyxwuv
|
||||||
|
0123456789
|
||||||
|
abcdefghijklmnopqrstzyxwuv
|
||||||
|
|
||||||
|
Yes
|
||||||
|
|
||||||
|
|
||||||
|
% send three asynchronous messages whose corresponding methods perform database updates
|
||||||
|
% (this may or may not work, most likely will throw an exception):
|
||||||
|
|
||||||
|
| ?- threaded_call(nasty1::update_db(_), [noreply]), threaded_call(nasty1::update_db(_), [noreply]), threaded_call(nasty1::update_db(_), [noreply]).
|
||||||
|
|
||||||
|
No
|
||||||
|
|
||||||
|
|
||||||
|
% the same three asynchronous messages but making them atomic for the receiver object
|
||||||
|
% (this should always work):
|
||||||
|
|
||||||
|
| ?- threaded_call(nasty1::update_db(_), [atomic, noreply]), threaded_call(nasty1::update_db(_), [atomic, noreply]), threaded_call(nasty1::update_db(_), [atomic, noreply]).
|
||||||
|
|
||||||
|
Yes
|
||||||
|
|
||||||
|
|
||||||
|
% a better solution is to declare predicates that need to be thread syncronized as "atomic",
|
||||||
|
% as exemplified in object "nasty2":
|
||||||
|
|
||||||
|
| ?- nasty2::(io(alpha), io(digit), io(alpha)).
|
||||||
|
|
||||||
|
abcdefghijklmnopqrstzyxwuv
|
||||||
|
0123456789
|
||||||
|
abcdefghijklmnopqrstzyxwuv
|
||||||
|
|
||||||
|
Yes
|
||||||
|
|
||||||
|
|
||||||
|
| ?- nasty2::(update_db(X), update_db(Y), update_db(Z)).
|
||||||
|
|
||||||
|
X = 1
|
||||||
|
Y = 2
|
||||||
|
Z = 3
|
||||||
|
|
||||||
|
Yes
|
121
Logtalk/examples/threads/atomic/atomic.lgt
Normal file
121
Logtalk/examples/threads/atomic/atomic.lgt
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
|
||||||
|
:- object(nasty1).
|
||||||
|
|
||||||
|
:- info([
|
||||||
|
version is 1.0,
|
||||||
|
author is 'Paulo Moura',
|
||||||
|
date is 2006/04/14,
|
||||||
|
comment is 'Simple example for using the "atomic" option for multi-threading calls with side-effects.']).
|
||||||
|
|
||||||
|
:- threaded.
|
||||||
|
|
||||||
|
:- public(update_db/1).
|
||||||
|
:- mode(update_db(-integer), one).
|
||||||
|
:- info(update_db/1, [
|
||||||
|
comment is 'Perform a database update with a long delay between retracting the old information and asserting the new one.',
|
||||||
|
argnames is ['New']]).
|
||||||
|
|
||||||
|
:- private(db/1).
|
||||||
|
:- dynamic(db/1).
|
||||||
|
|
||||||
|
:- public(io/1).
|
||||||
|
:- mode(io(+atom), one).
|
||||||
|
:- info(io/1, [
|
||||||
|
comment is 'Write some characters to the standard output stream with a long delay between each write operation.',
|
||||||
|
argnames is ['Chars']]).
|
||||||
|
|
||||||
|
db(0).
|
||||||
|
|
||||||
|
update_db(New) :-
|
||||||
|
retract(db(Old)),
|
||||||
|
waste_time,
|
||||||
|
New is Old + 1,
|
||||||
|
waste_time,
|
||||||
|
assertz(db(New)).
|
||||||
|
|
||||||
|
io(alpha) :-
|
||||||
|
write(a), waste_time, write(b), waste_time, write(c), waste_time, write(d), waste_time, write(e),
|
||||||
|
write(f), waste_time, write(g), waste_time, write(h), waste_time, write(i), waste_time, write(j),
|
||||||
|
write(k), waste_time, write(l), waste_time, write(m), waste_time, write(n), waste_time, write(o),
|
||||||
|
write(p), waste_time, write(q), waste_time, write(r), waste_time, write(s), waste_time, write(t),
|
||||||
|
write(z), waste_time, write(y), waste_time, write(x), waste_time, write(w), waste_time, write(u),
|
||||||
|
write(v), nl.
|
||||||
|
|
||||||
|
io(digit) :-
|
||||||
|
write(0), waste_time, write(1), waste_time, write(2), waste_time, write(3), waste_time, write(4),
|
||||||
|
write(5), waste_time, write(6), waste_time, write(7), waste_time, write(8), waste_time, write(9), nl.
|
||||||
|
|
||||||
|
waste_time :-
|
||||||
|
between(1, 10000, _),
|
||||||
|
fail.
|
||||||
|
waste_time.
|
||||||
|
|
||||||
|
between(Lower, _, Lower).
|
||||||
|
between(Lower, Upper, Integer) :-
|
||||||
|
Lower < Upper,
|
||||||
|
Next is Lower + 1,
|
||||||
|
between(Next, Upper, Integer).
|
||||||
|
|
||||||
|
:- end_object.
|
||||||
|
|
||||||
|
|
||||||
|
:- object(nasty2).
|
||||||
|
|
||||||
|
:- info([
|
||||||
|
version is 1.0,
|
||||||
|
author is 'Paulo Moura',
|
||||||
|
date is 2006/04/14,
|
||||||
|
comment is 'Simple example for using the "atomic" option for multi-threading calls with side-effects.']).
|
||||||
|
|
||||||
|
:- threaded.
|
||||||
|
|
||||||
|
:- public(update_db/1).
|
||||||
|
:- atomic(update_db/1).
|
||||||
|
:- mode(update_db(-integer), one).
|
||||||
|
:- info(update_db/1, [
|
||||||
|
comment is 'Perform a database update with a long delay between retracting the old information and asserting the new one.',
|
||||||
|
argnames is ['New']]).
|
||||||
|
|
||||||
|
:- private(db/1).
|
||||||
|
:- dynamic(db/1).
|
||||||
|
|
||||||
|
:- public(io/1).
|
||||||
|
:- atomic(io/1).
|
||||||
|
:- mode(io(+atom), one).
|
||||||
|
:- info(io/1, [
|
||||||
|
comment is 'Write some characters to the standard output stream with a long delay between each write operation.',
|
||||||
|
argnames is ['Chars']]).
|
||||||
|
|
||||||
|
db(0).
|
||||||
|
|
||||||
|
update_db(New) :-
|
||||||
|
retract(db(Old)),
|
||||||
|
waste_time,
|
||||||
|
New is Old + 1,
|
||||||
|
waste_time,
|
||||||
|
assertz(db(New)).
|
||||||
|
|
||||||
|
io(alpha) :-
|
||||||
|
write(a), waste_time, write(b), waste_time, write(c), waste_time, write(d), waste_time, write(e),
|
||||||
|
write(f), waste_time, write(g), waste_time, write(h), waste_time, write(i), waste_time, write(j),
|
||||||
|
write(k), waste_time, write(l), waste_time, write(m), waste_time, write(n), waste_time, write(o),
|
||||||
|
write(p), waste_time, write(q), waste_time, write(r), waste_time, write(s), waste_time, write(t),
|
||||||
|
write(z), waste_time, write(y), waste_time, write(x), waste_time, write(w), waste_time, write(u),
|
||||||
|
write(v), nl.
|
||||||
|
|
||||||
|
io(digit) :-
|
||||||
|
write(0), waste_time, write(1), waste_time, write(2), waste_time, write(3), waste_time, write(4),
|
||||||
|
write(5), waste_time, write(6), waste_time, write(7), waste_time, write(8), waste_time, write(9), nl.
|
||||||
|
|
||||||
|
waste_time :-
|
||||||
|
between(1, 100000, _),
|
||||||
|
fail.
|
||||||
|
waste_time.
|
||||||
|
|
||||||
|
between(Lower, _, Lower).
|
||||||
|
between(Lower, Upper, Integer) :-
|
||||||
|
Lower < Upper,
|
||||||
|
Next is Lower + 1,
|
||||||
|
between(Next, Upper, Integer).
|
||||||
|
|
||||||
|
:- end_object.
|
13
Logtalk/examples/threads/atomic/loader.lgt
Normal file
13
Logtalk/examples/threads/atomic/loader.lgt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
:- initialization(
|
||||||
|
logtalk_load(
|
||||||
|
atomic)).
|
||||||
|
|
||||||
|
/*
|
||||||
|
If you intend to use the FOP XSL:FO processor for generating PDF documenting
|
||||||
|
files, comment the directive above and uncomment the directive below
|
||||||
|
|
||||||
|
:- initialization(
|
||||||
|
logtalk_load(
|
||||||
|
atomic, [xmlsref(standalone)])).
|
||||||
|
*/
|
12
Logtalk/examples/threads/birthdays/NOTES.txt
Normal file
12
Logtalk/examples/threads/birthdays/NOTES.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
To load this example and for sample queries, please see the SCRIPT file.
|
||||||
|
|
||||||
|
This folder contains a simple multi-threading example with agents and
|
||||||
|
their birthdays.
|
52
Logtalk/examples/threads/birthdays/SCRIPT.txt
Normal file
52
Logtalk/examples/threads/birthdays/SCRIPT.txt
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
% start by loading the "event_handlersp" protocol:
|
||||||
|
|
||||||
|
| ?- logtalk_load(library(event_handlersp)).
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
% now you are ready for loading the example:
|
||||||
|
|
||||||
|
| ?- logtalk_load(birthdays(loader)).
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
% create two new agents, Paul and Nathalie:
|
||||||
|
|
||||||
|
| ?- agent::(new(paul, 40, male), new(nathalie, 32, female)).
|
||||||
|
|
||||||
|
Yes
|
||||||
|
|
||||||
|
|
||||||
|
% make them friends:
|
||||||
|
|
||||||
|
| ?- paul::new_friend(nathalie).
|
||||||
|
|
||||||
|
Yes
|
||||||
|
|
||||||
|
|
||||||
|
% it's birthday for Nathalie:
|
||||||
|
|
||||||
|
| ?- nathalie::birthday.
|
||||||
|
|
||||||
|
Happy birthday from paul!
|
||||||
|
Thanks! Here, have a slice of cake, paul.
|
||||||
|
Thanks for the cake nathalie!
|
||||||
|
|
||||||
|
Yes
|
||||||
|
|
||||||
|
|
||||||
|
% tell Paul to ask Nathalie her age:
|
||||||
|
|
||||||
|
| ?- paul::ask_age(nathalie, Age).
|
||||||
|
|
||||||
|
Age = 33
|
||||||
|
|
||||||
|
Yes
|
90
Logtalk/examples/threads/birthdays/birthdays.lgt
Normal file
90
Logtalk/examples/threads/birthdays/birthdays.lgt
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
|
||||||
|
:- object(agent,
|
||||||
|
implements(event_handlersp)).
|
||||||
|
|
||||||
|
:- info([
|
||||||
|
version is 1.0,
|
||||||
|
author is 'Peter Robinson and Paulo Moura',
|
||||||
|
date is 2006/04/09,
|
||||||
|
comment is 'Simple multi-threading example with agents and their birthdays.']).
|
||||||
|
|
||||||
|
:- threaded.
|
||||||
|
|
||||||
|
:- public(new/3).
|
||||||
|
:- mode(new(+atom, +integer, +atom), one).
|
||||||
|
:- info(new/3, [
|
||||||
|
comment is 'Creates a new agent given its name, age, and gender.',
|
||||||
|
argnames is ['Name', 'Age', 'Gender']]).
|
||||||
|
|
||||||
|
:- public(age/1).
|
||||||
|
:- dynamic(age/1).
|
||||||
|
:- mode(age(?integer), zero_or_one).
|
||||||
|
:- info(age/1, [
|
||||||
|
comment is 'Agent age.']).
|
||||||
|
|
||||||
|
:- public(ask_age/2).
|
||||||
|
:- mode(ask_age(+atom, ?integer), zero_or_one).
|
||||||
|
:- info(ask_age/2, [
|
||||||
|
comment is 'Ask a friend his/her age.',
|
||||||
|
argnames is ['Name', 'Age']]).
|
||||||
|
|
||||||
|
:- public(gender/1).
|
||||||
|
:- dynamic(gender/1).
|
||||||
|
:- mode(gender(?integer), zero_or_one).
|
||||||
|
:- info(gender/1, [
|
||||||
|
comment is 'Agent gender.']).
|
||||||
|
|
||||||
|
:- public(birthday/0).
|
||||||
|
:- mode(birthday, one).
|
||||||
|
:- info(birthday/0, [
|
||||||
|
comment is 'Increments an agent age, an unfortunate side-effect of its birthday.']).
|
||||||
|
|
||||||
|
:- public(happy_birthday/1).
|
||||||
|
:- mode(happy_birthday(+object_identifier), one).
|
||||||
|
:- info(happy_birthday/1, [
|
||||||
|
comment is 'Happy birthday message from a friend.',
|
||||||
|
argnames is ['From']]).
|
||||||
|
|
||||||
|
:- public(cake_slice/1).
|
||||||
|
:- mode(cake_slice(+object_identifier), one).
|
||||||
|
:- info(cake_slice/1, [
|
||||||
|
comment is 'Offer a slice of birthday cake to a friend.',
|
||||||
|
argnames is ['From']]).
|
||||||
|
|
||||||
|
:- public(new_friend/1).
|
||||||
|
:- mode(new_friend(+object_identifier), one).
|
||||||
|
:- info(new_friend/1, [
|
||||||
|
comment is 'New friend, watch out for his/her birthday.',
|
||||||
|
argnames is ['Name']]).
|
||||||
|
|
||||||
|
new(Name, Age, Gender) :-
|
||||||
|
this(This),
|
||||||
|
create_object(Name, [extends(This)], [threaded], [age(Age), gender(Gender)]).
|
||||||
|
|
||||||
|
ask_age(Friend, Age) :-
|
||||||
|
threaded_call(Friend::age(Age)),
|
||||||
|
threaded_exit(Friend::age(Age)).
|
||||||
|
|
||||||
|
birthday :-
|
||||||
|
::retract(age(Old)),
|
||||||
|
New is Old + 1,
|
||||||
|
::assertz(age(New)).
|
||||||
|
|
||||||
|
happy_birthday(From) :-
|
||||||
|
self(Self),
|
||||||
|
write('Happy birthday from '), write(From), write('!'), nl,
|
||||||
|
write('Thanks! Here, have a slice of cake, '), write(From), write('.'), nl,
|
||||||
|
threaded_call(From::cake_slice(Self), [noreply]).
|
||||||
|
|
||||||
|
cake_slice(From) :-
|
||||||
|
write('Thanks for the cake '), write(From), write('!'), nl.
|
||||||
|
|
||||||
|
new_friend(Friend) :-
|
||||||
|
self(Self),
|
||||||
|
define_events(after, Friend, birthday, _, Self).
|
||||||
|
|
||||||
|
after(Friend, birthday, _) :-
|
||||||
|
self(Self),
|
||||||
|
threaded_call(Friend::happy_birthday(Self), [noreply]).
|
||||||
|
|
||||||
|
:- end_object.
|
13
Logtalk/examples/threads/birthdays/loader.lgt
Normal file
13
Logtalk/examples/threads/birthdays/loader.lgt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
:- initialization(
|
||||||
|
logtalk_load(
|
||||||
|
[birthdays], [events(on)])).
|
||||||
|
|
||||||
|
/*
|
||||||
|
If you intend to use the FOP XSL:FO processor for generating PDF documenting
|
||||||
|
files, comment the directive above and uncomment the directive below
|
||||||
|
|
||||||
|
:- initialization(
|
||||||
|
logtalk_load(
|
||||||
|
[birthdays], [events(on), xmlsref(standalone)])).
|
||||||
|
*/
|
14
Logtalk/examples/threads/functions/NOTES.txt
Normal file
14
Logtalk/examples/threads/functions/NOTES.txt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
To load this example and for sample queries, please see the SCRIPT file.
|
||||||
|
|
||||||
|
This folder contains a simple multi-threading example illustrating how
|
||||||
|
to create threads for competing goals, which one performing the same
|
||||||
|
task using diferent methods. The first goal to complete leads to the
|
||||||
|
immediate termination of the threads running the remaining goals.
|
65
Logtalk/examples/threads/functions/SCRIPT.txt
Normal file
65
Logtalk/examples/threads/functions/SCRIPT.txt
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
% start by loading the loading the example:
|
||||||
|
|
||||||
|
| ?- logtalk_load(functions(loader)).
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
% find the roots of some functions using each one of provided methods:
|
||||||
|
|
||||||
|
| ?- bisection::find_root(f1, 1.0, 2.3, 1e-15, Zero).
|
||||||
|
|
||||||
|
Zero = 2.0
|
||||||
|
yes
|
||||||
|
|
||||||
|
| ?- newton::find_root(f1, 1.0, 2.3, 1e-15, Zero).
|
||||||
|
|
||||||
|
Zero = 2.0
|
||||||
|
yes
|
||||||
|
| ?- muller::find_root(f1, 1.0, 2.3, 1e-15, Zero).
|
||||||
|
|
||||||
|
Zero = 2.0
|
||||||
|
yes
|
||||||
|
|
||||||
|
| ?- bisection::find_root(f2, 1.0, 1.3, 1e-15, Zero).
|
||||||
|
|
||||||
|
Zero = 1.25809265664599
|
||||||
|
yes
|
||||||
|
|
||||||
|
| ?- newton::find_root(f2, 1.0, 1.3, 1e-15, Zero).
|
||||||
|
|
||||||
|
Zero = 1.25809265664599
|
||||||
|
yes
|
||||||
|
|
||||||
|
| ?- muller::find_root(f2, 1.0, 1.3, 1e-15, Zero).
|
||||||
|
|
||||||
|
Zero = 1.25809265664599
|
||||||
|
yes
|
||||||
|
|
||||||
|
|
||||||
|
% find the roots of some functions running all methods at once using multi-threading:
|
||||||
|
|
||||||
|
| ?- function_root::find_root(f1, 1.0, 2.3, 1e-15, Zero, Method).
|
||||||
|
|
||||||
|
Zero = 2.0
|
||||||
|
Method = bisection
|
||||||
|
yes
|
||||||
|
|
||||||
|
| ?- function_root::find_root(f2, 1.0, 1.3, 1e-15, Zero, Method).
|
||||||
|
|
||||||
|
Zero = 1.25809265664599
|
||||||
|
Method = newton
|
||||||
|
yes
|
||||||
|
|
||||||
|
| ?- function_root::find_root(f3, 0.0, 3.0, 1e-15, Zero, Method).
|
||||||
|
|
||||||
|
Zero = 1.4142135623731
|
||||||
|
Method = newton
|
||||||
|
yes
|
268
Logtalk/examples/threads/functions/functions.lgt
Normal file
268
Logtalk/examples/threads/functions/functions.lgt
Normal file
@ -0,0 +1,268 @@
|
|||||||
|
|
||||||
|
:- protocol(find_rootp).
|
||||||
|
|
||||||
|
:- info([
|
||||||
|
version is 1.0,
|
||||||
|
date is 2006/4/21,
|
||||||
|
author is 'Paulo Nunes',
|
||||||
|
comment is 'Default protocol for root find algorithms.']).
|
||||||
|
|
||||||
|
:- public(find_root/5).
|
||||||
|
:- mode(find_root(+object_identifier, +float, +float, +float, -float), one).
|
||||||
|
:- info(find_root/5, [
|
||||||
|
comment is 'Find the root of a function in the interval [A, B] given a maximum aproximation error.',
|
||||||
|
argnames is ['Function', 'A', 'B', 'Error', 'Zero']]).
|
||||||
|
|
||||||
|
:- public(find_root/6).
|
||||||
|
:- mode(find_root(+object_identifier, +float, +float, +float, -float, -object_identifier), one).
|
||||||
|
:- info(find_root/6, [
|
||||||
|
comment is 'Find the root of a function in the interval [A, B] given a maximum aproximation error. Return the method used.',
|
||||||
|
argnames is ['Function', 'A', 'B', 'Error', 'Zero', 'Method']]).
|
||||||
|
|
||||||
|
:- end_protocol.
|
||||||
|
|
||||||
|
|
||||||
|
:- protocol(functionp).
|
||||||
|
|
||||||
|
:- info([
|
||||||
|
version is 1.0,
|
||||||
|
date is 2006/4/21,
|
||||||
|
author is 'Paulo Nunes',
|
||||||
|
comment is 'Default protocol for real functions of a single real variable.']).
|
||||||
|
|
||||||
|
:- public(eval/2).
|
||||||
|
:- mode(eval(+float, -float), one).
|
||||||
|
:- info(eval/2, [
|
||||||
|
comment is 'Calculate the function value.',
|
||||||
|
argnames is ['X', 'Fx']]).
|
||||||
|
|
||||||
|
:- public(evald/2).
|
||||||
|
:- mode(evald(+float, -float), one).
|
||||||
|
:- info(evald/2, [
|
||||||
|
comment is 'Calculate the value of the function derivative.',
|
||||||
|
argnames is ['X', 'DFx']]).
|
||||||
|
|
||||||
|
:- end_protocol.
|
||||||
|
|
||||||
|
|
||||||
|
:- object(f1,
|
||||||
|
implements(functionp)).
|
||||||
|
|
||||||
|
% x^2 - 4
|
||||||
|
% 2.0
|
||||||
|
|
||||||
|
eval(X, Y) :-
|
||||||
|
Y is X * X - 4.
|
||||||
|
evald(X, Y) :-
|
||||||
|
Y is 2 * X.
|
||||||
|
|
||||||
|
:- end_object.
|
||||||
|
|
||||||
|
|
||||||
|
:- object(f2,
|
||||||
|
implements(functionp)).
|
||||||
|
|
||||||
|
% x^7 + 9x^5 - 13x - 17
|
||||||
|
% 1.29999999999945448
|
||||||
|
|
||||||
|
eval(X, Y) :-
|
||||||
|
Y is X**7 + 9*X**5 - 13*X - 17.
|
||||||
|
|
||||||
|
evald(X, Y) :-
|
||||||
|
Y is 7*X**6 + 45*X**4 - 13.
|
||||||
|
|
||||||
|
:- end_object.
|
||||||
|
|
||||||
|
|
||||||
|
:- object(f3,
|
||||||
|
implements(functionp)).
|
||||||
|
|
||||||
|
% (x - sqrt(2))^7
|
||||||
|
% 1.41421356237309537
|
||||||
|
|
||||||
|
eval(X, Y) :-
|
||||||
|
Y is (X - sqrt(2.0))**8.
|
||||||
|
|
||||||
|
evald(X, Y) :-
|
||||||
|
Y is 8*(X - sqrt(2.0))**7.
|
||||||
|
|
||||||
|
:- end_object.
|
||||||
|
|
||||||
|
|
||||||
|
:- object(function_root,
|
||||||
|
implements(find_rootp)).
|
||||||
|
|
||||||
|
:- info([
|
||||||
|
version is 1.0,
|
||||||
|
date is 2006/4/21,
|
||||||
|
author is 'Paulo Nunes',
|
||||||
|
comment is 'Multi-threading interface to root finding algorithms.']).
|
||||||
|
|
||||||
|
:- threaded.
|
||||||
|
|
||||||
|
find_root(Function, A, B, Error, Zero) :-
|
||||||
|
find_root(Function, A, B, Error, Zero, _).
|
||||||
|
|
||||||
|
find_root(Function, A, B, Error, Zero, Algorithm) :-
|
||||||
|
threaded_call(
|
||||||
|
( try_method(bisection, Function, A, B, Error, Zero)
|
||||||
|
; try_method(newton, Function, A, B, Error, Zero)
|
||||||
|
; try_method(muller, Function, A, B, Error, Zero)
|
||||||
|
)),
|
||||||
|
threaded_exit(try_method(Algorithm, Function, A, B, Error, Zero)).
|
||||||
|
|
||||||
|
try_method(Algorithm, Function, A, B, Error, Zero) :-
|
||||||
|
Algorithm::find_root(Function, A, B, Error, Zero).
|
||||||
|
|
||||||
|
:- end_object.
|
||||||
|
|
||||||
|
|
||||||
|
:- object(bisection,
|
||||||
|
implements(find_rootp)).
|
||||||
|
|
||||||
|
:- info([
|
||||||
|
version is 1.0,
|
||||||
|
date is 2006/4/21,
|
||||||
|
author is 'Paulo Nunes',
|
||||||
|
comment is 'Bisection algorithm.']).
|
||||||
|
|
||||||
|
find_root(Function, A, B, Error, Zero) :-
|
||||||
|
Function::eval(A, Fa),
|
||||||
|
Function::eval(B, Fb),
|
||||||
|
( Fa > 0.0, Fb < 0.0 ->
|
||||||
|
true
|
||||||
|
; Fa < 0.0, Fb > 0.0
|
||||||
|
),
|
||||||
|
X0 is (A + B) / 2,
|
||||||
|
Function::eval(X0, F0),
|
||||||
|
bisection(Function, A, B, X0, F0, Error, Zero).
|
||||||
|
|
||||||
|
bisection(_, _, _, Xn1, 0.0, _, Xn1) :-
|
||||||
|
!.
|
||||||
|
|
||||||
|
bisection(_, Xn1, Xn, _, _, Error, Xn1) :-
|
||||||
|
abs(Xn1 - Xn) < Error,
|
||||||
|
!.
|
||||||
|
|
||||||
|
bisection(Function, An, Bn, _, _, Error, Zero) :-
|
||||||
|
Xn1 is (An + Bn) / 2,
|
||||||
|
Function::eval(Xn1, Fn1),
|
||||||
|
Function::eval(An, FAn),
|
||||||
|
( Fn1*FAn < 0.0 ->
|
||||||
|
An1 is An,
|
||||||
|
Bn1 is Xn1
|
||||||
|
; An1 is Xn1,
|
||||||
|
Bn1 is Bn
|
||||||
|
),
|
||||||
|
bisection(Function, An1, Bn1, Xn1, Fn1, Error, Zero).
|
||||||
|
|
||||||
|
:- end_object.
|
||||||
|
|
||||||
|
|
||||||
|
:- object(newton,
|
||||||
|
implements(find_rootp)).
|
||||||
|
|
||||||
|
:- info([
|
||||||
|
version is 1.0,
|
||||||
|
date is 2006/4/21,
|
||||||
|
author is 'Paulo Nunes',
|
||||||
|
comment is 'Newton algorithm.']).
|
||||||
|
|
||||||
|
find_root(Function, Xa, Xb, Deviation, Zero) :-
|
||||||
|
X0 is (Xa + Xb) / 2,
|
||||||
|
newton(Function, X0, Deviation, Zero).
|
||||||
|
|
||||||
|
newton(Function, X0, Deviation, Zero) :-
|
||||||
|
Xn1 is X0,
|
||||||
|
Function::eval(Xn1, Fn1),
|
||||||
|
Function::evald(Xn1, DFn1),
|
||||||
|
Ac is -(Fn1 / DFn1),
|
||||||
|
newton(Function, Xn1, Deviation, Fn1, Ac, Zero).
|
||||||
|
|
||||||
|
% test deviation
|
||||||
|
newton(_, Xn1, Deviation, _, Ac, Xn1) :-
|
||||||
|
abs(Ac) < Deviation,
|
||||||
|
!.
|
||||||
|
|
||||||
|
% test solution
|
||||||
|
newton(_, Xn1, _, 0.0, _, Xn1) :-
|
||||||
|
!.
|
||||||
|
|
||||||
|
% calc
|
||||||
|
newton(Function, Xn, Deviation, _, Ac, Zero) :-
|
||||||
|
Xn1 is Xn + Ac,
|
||||||
|
Function::eval(Xn1, Fn1),
|
||||||
|
Function::evald(Xn1, DFn1),
|
||||||
|
Ac1 is (-(Fn1 / DFn1)),
|
||||||
|
newton(Function, Xn1, Deviation, Fn1, Ac1, Zero).
|
||||||
|
|
||||||
|
:- end_object.
|
||||||
|
|
||||||
|
|
||||||
|
:- object(muller,
|
||||||
|
implements(find_rootp)).
|
||||||
|
|
||||||
|
:- info([
|
||||||
|
version is 1.0,
|
||||||
|
date is 2006/4/21,
|
||||||
|
author is 'Paulo Nunes',
|
||||||
|
comment is 'Muller algorithm.']).
|
||||||
|
|
||||||
|
find_root(Function, Xa, Xb, Deviation, Zero) :-
|
||||||
|
Xc is (Xa + Xb) / 2,
|
||||||
|
muller(Function, Xa, Xc, Xb, Deviation, Zero).
|
||||||
|
|
||||||
|
muller(Function, Xa, Xb, Xc, Deviation, Zero) :-
|
||||||
|
Function::eval(Xa, Ya),
|
||||||
|
Function::eval(Xb, Yb),
|
||||||
|
Function::eval(Xc, Yc),
|
||||||
|
H1 is (Xb - Xa),
|
||||||
|
DDba is ((Yb - Ya) / H1),
|
||||||
|
Ac is (Deviation + 1),
|
||||||
|
muller(Function, Xa, Xb, Xc, Deviation, Ya, Yb, Yc, Ac, H1, DDba, Zero).
|
||||||
|
|
||||||
|
% complex
|
||||||
|
muller(_, _, _, complex, _, _, _, _, _, _, _, complex) :-
|
||||||
|
!.
|
||||||
|
|
||||||
|
% test deviation
|
||||||
|
muller(_, _, _, Xc, Deviation, _, _, _, Ac, _, _, Xc) :-
|
||||||
|
abs(Ac) < Deviation,
|
||||||
|
!.
|
||||||
|
|
||||||
|
% test solution
|
||||||
|
muller(_, _, _, Xc, _, _, _, 0.0, _, _, _, Xc) :-
|
||||||
|
!.
|
||||||
|
|
||||||
|
% calc
|
||||||
|
muller(Function, Xa, Xb, Xc, Deviation, _, Yb, Yc, _, _, DDba, Zero) :-
|
||||||
|
H2n is (Xc - Xb),
|
||||||
|
DDcbn is ((Yc - Yb) / H2n),
|
||||||
|
Cn is ((DDcbn - DDba) / (Xc - Xa)),
|
||||||
|
Bn is (DDcbn + H2n * Cn),
|
||||||
|
Rn is (Bn * Bn - 4.0 * Yc * Cn),
|
||||||
|
% complex
|
||||||
|
% write(Rn),
|
||||||
|
( Rn < 0.0 ->
|
||||||
|
muller(Function, _, _, complex, Deviation, _, _, _, _, _, _, Zero),
|
||||||
|
!, fail
|
||||||
|
; V is sqrt(Rn)
|
||||||
|
),
|
||||||
|
( Bn > 0.0 ->
|
||||||
|
Dn is (Bn + V)
|
||||||
|
; Dn is (Bn - V)
|
||||||
|
),
|
||||||
|
Acn is (-(2 * Yc / Dn)),
|
||||||
|
Xan is Xb,
|
||||||
|
Xbn is Xc,
|
||||||
|
Xcn is Xc + Acn,
|
||||||
|
|
||||||
|
Yan is Yb,
|
||||||
|
Ybn is Yc,
|
||||||
|
Function::eval(Xcn, Ycn),
|
||||||
|
|
||||||
|
H1n is H2n,
|
||||||
|
DDban is DDcbn,
|
||||||
|
muller(Function, Xan, Xbn, Xcn, Deviation, Yan, Ybn, Ycn, Acn, H1n, DDban, Zero).
|
||||||
|
|
||||||
|
:- end_object.
|
13
Logtalk/examples/threads/functions/loader.lgt
Normal file
13
Logtalk/examples/threads/functions/loader.lgt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
:- initialization(
|
||||||
|
logtalk_load(
|
||||||
|
functions)).
|
||||||
|
|
||||||
|
/*
|
||||||
|
If you intend to use the FOP XSL:FO processor for generating PDF documenting
|
||||||
|
files, comment the directive above and uncomment the directive below
|
||||||
|
|
||||||
|
:- initialization(
|
||||||
|
logtalk_load(
|
||||||
|
functions, [xmlsref(standalone)])).
|
||||||
|
*/
|
15
Logtalk/examples/threads/nondet/NOTES.txt
Normal file
15
Logtalk/examples/threads/nondet/NOTES.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
To load this example and for sample queries, please see the SCRIPT file.
|
||||||
|
|
||||||
|
This folder contains a simple multi-threading example with calculating
|
||||||
|
prime numbers on a given interval. Try to run the example in single and
|
||||||
|
multi-processor (or multi-core) computers and compare the results. Most
|
||||||
|
Prolog compilers allows you to measure the time taken for proving a goal
|
||||||
|
using proprietary predicates.
|
29
Logtalk/examples/threads/nondet/SCRIPT.txt
Normal file
29
Logtalk/examples/threads/nondet/SCRIPT.txt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
% start by loading the loading the example:
|
||||||
|
|
||||||
|
| ?- logtalk_load(nondet(loader)).
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
% make a threaded call with a non-deterministic goal:
|
||||||
|
|
||||||
|
| ?- threaded_call(lists::member(X, [1,2,3])).
|
||||||
|
|
||||||
|
X = _G189
|
||||||
|
yes
|
||||||
|
|
||||||
|
% retrieve through backtracking all solutions for the non-deterministic goal:
|
||||||
|
|
||||||
|
| ?- threaded_exit(lists::member(X, [1,2,3])).
|
||||||
|
|
||||||
|
X = 1 ;
|
||||||
|
X = 2 ;
|
||||||
|
X = 3 ;
|
||||||
|
no
|
13
Logtalk/examples/threads/nondet/loader.lgt
Normal file
13
Logtalk/examples/threads/nondet/loader.lgt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
:- initialization(
|
||||||
|
logtalk_load(
|
||||||
|
nondet)).
|
||||||
|
|
||||||
|
/*
|
||||||
|
If you intend to use the FOP XSL:FO processor for generating PDF documenting
|
||||||
|
files, comment the directive above and uncomment the directive below
|
||||||
|
|
||||||
|
:- initialization(
|
||||||
|
logtalk_load(
|
||||||
|
nondet, [xmlsref(standalone)])).
|
||||||
|
*/
|
12
Logtalk/examples/threads/nondet/nondet.lgt
Normal file
12
Logtalk/examples/threads/nondet/nondet.lgt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
|
||||||
|
:- object(lists).
|
||||||
|
|
||||||
|
:- threaded.
|
||||||
|
|
||||||
|
:- public(member/2).
|
||||||
|
|
||||||
|
member(H, [H| _]).
|
||||||
|
member(H, [_| T]) :-
|
||||||
|
member(H, T).
|
||||||
|
|
||||||
|
:- end_object.
|
15
Logtalk/examples/threads/primes/NOTES.txt
Normal file
15
Logtalk/examples/threads/primes/NOTES.txt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
To load this example and for sample queries, please see the SCRIPT file.
|
||||||
|
|
||||||
|
This folder contains a simple multi-threading example with calculating
|
||||||
|
prime numbers on a given interval. Try to run the example in single and
|
||||||
|
multi-processor (or multi-core) computers and compare the results. Most
|
||||||
|
Prolog compilers allows you to measure the time taken for proving a goal
|
||||||
|
using proprietary predicates.
|
31
Logtalk/examples/threads/primes/SCRIPT.txt
Normal file
31
Logtalk/examples/threads/primes/SCRIPT.txt
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
% start by loading the loading the example:
|
||||||
|
|
||||||
|
| ?- logtalk_load(primes(loader)).
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
% calculate the prime numbers in a given interval using a single thread:
|
||||||
|
|
||||||
|
| ?- primes::st_prime_numbers(1, 200000, Primes).
|
||||||
|
|
||||||
|
Primes = [199999, 199967, 199961, 199933, 199931, 199921, 199909, 199889, 199877|...]
|
||||||
|
|
||||||
|
Yes
|
||||||
|
|
||||||
|
|
||||||
|
% calculate the prime numbers in a given interval by splitting the interval
|
||||||
|
% in two sub-intervals and using a thread pere interval:
|
||||||
|
|
||||||
|
| ?- primes::mt_prime_numbers(1, 200000, Primes).
|
||||||
|
|
||||||
|
Primes = [199999, 199967, 199961, 199933, 199931, 199921, 199909, 199889, 199877|...]
|
||||||
|
|
||||||
|
Yes
|
13
Logtalk/examples/threads/primes/loader.lgt
Normal file
13
Logtalk/examples/threads/primes/loader.lgt
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
:- initialization(
|
||||||
|
logtalk_load(
|
||||||
|
primes)).
|
||||||
|
|
||||||
|
/*
|
||||||
|
If you intend to use the FOP XSL:FO processor for generating PDF documenting
|
||||||
|
files, comment the directive above and uncomment the directive below
|
||||||
|
|
||||||
|
:- initialization(
|
||||||
|
logtalk_load(
|
||||||
|
primes, [xmlsref(standalone)])).
|
||||||
|
*/
|
62
Logtalk/examples/threads/primes/primes.lgt
Normal file
62
Logtalk/examples/threads/primes/primes.lgt
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
|
||||||
|
:- object(primes).
|
||||||
|
|
||||||
|
:- info([
|
||||||
|
version is 1.0,
|
||||||
|
author is 'Paulo Moura',
|
||||||
|
date is 2006/04/14,
|
||||||
|
comment is 'Simple example for comparing single and multi-threading calculation of prime numbers.']).
|
||||||
|
|
||||||
|
:- threaded.
|
||||||
|
|
||||||
|
:- public(st_prime_numbers/3).
|
||||||
|
:- mode(st_prime_numbers(+integer, +integer, -list), one).
|
||||||
|
:- info(st_prime_numbers/3, [
|
||||||
|
comment is 'Returns all prime numbers in the given interval using a single calculation thread.',
|
||||||
|
argnames is ['Inf', 'Sup', 'Primes']]).
|
||||||
|
|
||||||
|
:- public(mt_prime_numbers/3).
|
||||||
|
:- mode(mt_prime_numbers(+integer, +integer, -list), one).
|
||||||
|
:- info(mt_prime_numbers/3, [
|
||||||
|
comment is 'Returns all prime numbers in the given interval using two calculation threads.',
|
||||||
|
argnames is ['Inf', 'Sup', 'Primes']]).
|
||||||
|
|
||||||
|
st_prime_numbers(N, M, Primes) :-
|
||||||
|
M > N,
|
||||||
|
prime_numbers(N, M, [], Primes).
|
||||||
|
|
||||||
|
mt_prime_numbers(N, M, Primes) :-
|
||||||
|
M > N,
|
||||||
|
N1 is N + (M - N) // 2,
|
||||||
|
N2 is N1 + 1,
|
||||||
|
threaded_call(prime_numbers(N, N1, [], Acc)),
|
||||||
|
threaded_call(prime_numbers(N2, M, Acc, Primes)),
|
||||||
|
threaded_exit(prime_numbers(N, N1, [], Acc)),
|
||||||
|
threaded_exit(prime_numbers(N2, M, Acc, Primes)).
|
||||||
|
|
||||||
|
prime_numbers(N, M, Primes, Primes) :-
|
||||||
|
N > M,
|
||||||
|
!.
|
||||||
|
prime_numbers(N, M, Acc, Primes) :-
|
||||||
|
( is_prime(N) ->
|
||||||
|
Acc2 = [N| Acc]
|
||||||
|
; Acc2 = Acc),
|
||||||
|
N2 is N + 1,
|
||||||
|
prime_numbers(N2, M, Acc2, Primes).
|
||||||
|
|
||||||
|
is_prime(2) :- !.
|
||||||
|
is_prime(Prime):-
|
||||||
|
Prime > 2,
|
||||||
|
Prime mod 2 =:= 1,
|
||||||
|
Sqrt is sqrt(Prime),
|
||||||
|
is_prime(3, Sqrt, Prime).
|
||||||
|
|
||||||
|
is_prime(N, Sqrt, Prime):-
|
||||||
|
( N > Sqrt ->
|
||||||
|
true
|
||||||
|
; Prime mod N > 0,
|
||||||
|
N2 is N + 2,
|
||||||
|
is_prime(N2, Sqrt, Prime)
|
||||||
|
).
|
||||||
|
|
||||||
|
:- end_object.
|
57
Logtalk/wenv/context/Logtalk.chl
Normal file
57
Logtalk/wenv/context/Logtalk.chl
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// Logtalk highlighter
|
||||||
|
// Paulo Moura
|
||||||
|
//
|
||||||
|
// http://logtalk.org/
|
||||||
|
//
|
||||||
|
// Last updated on: October, 16 2006
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Language: Logtalk
|
||||||
|
|
||||||
|
Filter: Logtalk files (*.lgt)|*.lgt
|
||||||
|
|
||||||
|
HelpFile:
|
||||||
|
|
||||||
|
CaseSensitive: 1
|
||||||
|
|
||||||
|
LineComment: %
|
||||||
|
|
||||||
|
BlockCommentBeg: /*
|
||||||
|
BlockCommentEnd: */
|
||||||
|
|
||||||
|
IdentifierBegChars:
|
||||||
|
IdentifierChars:
|
||||||
|
|
||||||
|
NumConstBegChars:
|
||||||
|
NumConstChars:
|
||||||
|
|
||||||
|
EscapeChar: \
|
||||||
|
|
||||||
|
|
||||||
|
KeyWords1: :: ^^ { }
|
||||||
|
|
||||||
|
|
||||||
|
StringBegChar: "
|
||||||
|
StringEndChar: "
|
||||||
|
MultilineStrings: 0
|
||||||
|
|
||||||
|
UsePreprocessor: 0
|
||||||
|
|
||||||
|
CurrLineHighlighted: 0
|
||||||
|
|
||||||
|
|
||||||
|
SpaceCol: clWindowText clWindow
|
||||||
|
Keyword1Col: clNavy clWindow B
|
||||||
|
IdentifierCol: clBlue clWindow
|
||||||
|
CommentCol: clGray clWindow I
|
||||||
|
NumberCol: clWindowText clWindow
|
||||||
|
StringCol: clMaroon clWindow
|
||||||
|
SymbolCol: clPurple clWindow
|
||||||
|
PreprocessorCol: clBlue clWindow
|
||||||
|
SelectionCol: clWhite clNavy
|
||||||
|
CurrentLineCol: clBlack clYellow
|
20
Logtalk/wenv/context/NOTES.txt
Normal file
20
Logtalk/wenv/context/NOTES.txt
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
This directory contains files that provides basic syntax coloring for
|
||||||
|
editing Logtalk source files with the text editor Context 0.98.3 or
|
||||||
|
later version:
|
||||||
|
|
||||||
|
http://www.context.cx/
|
||||||
|
|
||||||
|
To install copy the file "Logtalk.chl" to the Highlighters folder of
|
||||||
|
your ConTEXT folder (e.g. C:\Program Files\ConTEXT\Highlighters). If
|
||||||
|
ConTEXT is running, restart it to update its list of highlighters.
|
||||||
|
|
||||||
|
|
||||||
|
THESE SYNTAX COLORING SUPPORT FILES ARE UNDER DEVELOPMENT.
|
24
Logtalk/wenv/npp/NOTES.txt
Normal file
24
Logtalk/wenv/npp/NOTES.txt
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
This directory contains files that provides basic syntax coloring and
|
||||||
|
code completion for editing Logtalk source files with the text editor
|
||||||
|
Notepad++ 3.9 or later version:
|
||||||
|
|
||||||
|
http://notepad-plus.sourceforge.net/
|
||||||
|
|
||||||
|
Install the supporting files by performing the following steps:
|
||||||
|
|
||||||
|
1. Copy the file "userDefineLang.xml" to the folder "%APPDATA%\Notepad++".
|
||||||
|
If the file already exists, merge the contents of the two files.
|
||||||
|
|
||||||
|
2. In order to use auto-completion, copy the file "logtalk.api" to the
|
||||||
|
directory YOUR_NPP_INSTALL_DIR\plugins\APIs.
|
||||||
|
|
||||||
|
|
||||||
|
THESE SYNTAX COLORING SUPPORT FILES ARE UNDER DEVELOPMENT.
|
138
Logtalk/wenv/npp/logtalk.api
Normal file
138
Logtalk/wenv/npp/logtalk.api
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
abolish
|
||||||
|
abolish_category
|
||||||
|
abolish_events
|
||||||
|
abolish_object
|
||||||
|
abolish_protocol
|
||||||
|
after
|
||||||
|
alias
|
||||||
|
arg
|
||||||
|
asserta
|
||||||
|
assertz
|
||||||
|
atom
|
||||||
|
atomic
|
||||||
|
atom_chars
|
||||||
|
atom_chars
|
||||||
|
atom_codes
|
||||||
|
atom_codes
|
||||||
|
atom_concat
|
||||||
|
atom_concat
|
||||||
|
atom_length
|
||||||
|
at_end_of_stream
|
||||||
|
bagof
|
||||||
|
before
|
||||||
|
call
|
||||||
|
calls
|
||||||
|
catch
|
||||||
|
category
|
||||||
|
category_property
|
||||||
|
char_code
|
||||||
|
char_conversion
|
||||||
|
clause
|
||||||
|
close
|
||||||
|
compound
|
||||||
|
copy_term
|
||||||
|
create_category
|
||||||
|
create_object
|
||||||
|
create_protocol
|
||||||
|
current_category
|
||||||
|
current_char_conversion
|
||||||
|
current_event
|
||||||
|
current_input
|
||||||
|
current_logtalk_flag
|
||||||
|
current_object
|
||||||
|
current_op
|
||||||
|
current_output
|
||||||
|
current_predicate
|
||||||
|
current_prolog_flag
|
||||||
|
current_protocol
|
||||||
|
define_events
|
||||||
|
discontiguous
|
||||||
|
dynamic
|
||||||
|
encoding
|
||||||
|
end_category
|
||||||
|
end_object
|
||||||
|
end_protocol
|
||||||
|
expand_term
|
||||||
|
extends
|
||||||
|
extends_object
|
||||||
|
extends_protocol
|
||||||
|
fail
|
||||||
|
findall
|
||||||
|
float
|
||||||
|
flush_output
|
||||||
|
forall
|
||||||
|
functor
|
||||||
|
get_byte
|
||||||
|
get_char
|
||||||
|
get_code
|
||||||
|
halt
|
||||||
|
implements
|
||||||
|
implements_protocol
|
||||||
|
imports
|
||||||
|
imports_category
|
||||||
|
info
|
||||||
|
initialization
|
||||||
|
instantiates
|
||||||
|
instantiates_class
|
||||||
|
integer
|
||||||
|
logtalk_compile
|
||||||
|
logtalk_library_path
|
||||||
|
logtalk_load
|
||||||
|
meta_predicate
|
||||||
|
mode
|
||||||
|
nl
|
||||||
|
nonvar
|
||||||
|
number
|
||||||
|
number_chars
|
||||||
|
number_chars
|
||||||
|
number_codes
|
||||||
|
number_codes
|
||||||
|
object
|
||||||
|
object_property
|
||||||
|
once
|
||||||
|
op
|
||||||
|
open
|
||||||
|
parameter
|
||||||
|
peek_byte
|
||||||
|
peek_char
|
||||||
|
peek_code
|
||||||
|
phrase
|
||||||
|
predicate_property
|
||||||
|
private
|
||||||
|
protected
|
||||||
|
protocol
|
||||||
|
protocol_property
|
||||||
|
public
|
||||||
|
put_byte
|
||||||
|
put_char
|
||||||
|
put_code
|
||||||
|
read
|
||||||
|
read_term
|
||||||
|
repeat
|
||||||
|
retract
|
||||||
|
retractall
|
||||||
|
self
|
||||||
|
sender
|
||||||
|
setof
|
||||||
|
set_input
|
||||||
|
set_logtalk_flag
|
||||||
|
set_output
|
||||||
|
set_prolog_flag
|
||||||
|
set_stream_position
|
||||||
|
specializes
|
||||||
|
specializes_class
|
||||||
|
stream_property
|
||||||
|
sub_atom
|
||||||
|
term_expansion
|
||||||
|
this
|
||||||
|
threaded
|
||||||
|
threaded_call
|
||||||
|
threaded_exit
|
||||||
|
throw
|
||||||
|
true
|
||||||
|
unify_with_occurs_check
|
||||||
|
uses
|
||||||
|
var
|
||||||
|
write
|
||||||
|
writeq
|
||||||
|
write_canonical
|
36
Logtalk/wenv/npp/userDefineLang.xml
Normal file
36
Logtalk/wenv/npp/userDefineLang.xml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<NotepadPlus>
|
||||||
|
<UserLang name="Logtalk" ext="lgt">
|
||||||
|
<Settings>
|
||||||
|
<Global caseIgnored="no" />
|
||||||
|
<TreatAsSymbol comment="yes" commentLine="yes" />
|
||||||
|
<Prefix words1="no" words2="no" words3="no" words4="no" />
|
||||||
|
</Settings>
|
||||||
|
<KeywordLists>
|
||||||
|
<Keywords name="Delimiters">"'0"'0</Keywords>
|
||||||
|
<Keywords name="Folder+">:-</Keywords>
|
||||||
|
<Keywords name="Folder-">:-</Keywords>
|
||||||
|
<Keywords name="Operators">^</Keywords>
|
||||||
|
<Keywords name="Comment">1/* 2*/ 0%</Keywords>
|
||||||
|
<Keywords name="Words1">:-</Keywords>
|
||||||
|
<Keywords name="Words2">::</Keywords>
|
||||||
|
<Keywords name="Words3"></Keywords>
|
||||||
|
<Keywords name="Words4"></Keywords>
|
||||||
|
</KeywordLists>
|
||||||
|
<Styles>
|
||||||
|
<WordsStyle name="DEFAULT" styleID="11" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
|
||||||
|
<WordsStyle name="FOLDEROPEN" styleID="12" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
|
||||||
|
<WordsStyle name="FOLDERCLOSE" styleID="13" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
|
||||||
|
<WordsStyle name="KEYWORD1" styleID="5" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="1" />
|
||||||
|
<WordsStyle name="KEYWORD2" styleID="6" fgColor="000000" bgColor="FFFF00" fontName="" fontStyle="1" />
|
||||||
|
<WordsStyle name="KEYWORD3" styleID="7" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
|
||||||
|
<WordsStyle name="KEYWORD4" styleID="8" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
|
||||||
|
<WordsStyle name="COMMENT" styleID="1" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="2" />
|
||||||
|
<WordsStyle name="COMMENT LINE" styleID="2" fgColor="0000FF" bgColor="FFFFFF" fontName="" fontStyle="2" />
|
||||||
|
<WordsStyle name="NUMBER" styleID="4" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" fontSize="11" />
|
||||||
|
<WordsStyle name="OPERATOR" styleID="10" fgColor="FF0080" bgColor="FFFFFF" fontName="" fontStyle="1" />
|
||||||
|
<WordsStyle name="DELIMINER1" styleID="14" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
|
||||||
|
<WordsStyle name="DELIMINER2" styleID="15" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
|
||||||
|
<WordsStyle name="DELIMINER3" styleID="16" fgColor="000000" bgColor="FFFFFF" fontName="" fontStyle="0" />
|
||||||
|
</Styles>
|
||||||
|
</UserLang>
|
||||||
|
</NotepadPlus>
|
29
Logtalk/wenv/smultron/NOTES.txt
Normal file
29
Logtalk/wenv/smultron/NOTES.txt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
This directory contains the Logtalk.plist file that provides basic syntax
|
||||||
|
coloring, code completion, and entity index (using the "function" list)
|
||||||
|
for editing Logtalk source files with the Smultron 2.2 text editor:
|
||||||
|
|
||||||
|
http://smultron.sourceforge.net/
|
||||||
|
|
||||||
|
To install:
|
||||||
|
|
||||||
|
1. Copy the file "logtalk.plist" to the application bundle (ctrl-click on
|
||||||
|
Smultron and choose Show Package Contents and then navigate to the folder
|
||||||
|
Contents/Resources/Syntax Definitions/).
|
||||||
|
|
||||||
|
2. Copy the file "SyntaxDefinitions.plist" to the folder:
|
||||||
|
|
||||||
|
~/Library/Application Support/Smultron
|
||||||
|
|
||||||
|
If the file already exists, merge the contents of the two files.
|
||||||
|
|
||||||
|
Logtalk source files (including the programming examples) are usually
|
||||||
|
formatted using four-spaces tabs; you may set the tab width on the
|
||||||
|
editor preference panel.
|
14
Logtalk/wenv/smultron/SyntaxDefinitions.plist
Normal file
14
Logtalk/wenv/smultron/SyntaxDefinitions.plist
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Logtalk</string>
|
||||||
|
<key>file</key>
|
||||||
|
<string>logtalk</string>
|
||||||
|
<key>extensions</key>
|
||||||
|
<string>lgt config</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</plist>
|
183
Logtalk/wenv/smultron/logtalk.plist
Normal file
183
Logtalk/wenv/smultron/logtalk.plist
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>autocompleteWords</key>
|
||||||
|
<array>
|
||||||
|
<string>encoding</string>
|
||||||
|
<string>calls</string>
|
||||||
|
<string>category</string>
|
||||||
|
<string>dynamic</string>
|
||||||
|
<string>end_category</string>
|
||||||
|
<string>end_object</string>
|
||||||
|
<string>end_protocol</string>
|
||||||
|
<string>info</string>
|
||||||
|
<string>initialization</string>
|
||||||
|
<string>object</string>
|
||||||
|
<string>protocol</string>
|
||||||
|
<string>threaded</string>
|
||||||
|
<string>uses</string>
|
||||||
|
<string>alias</string>
|
||||||
|
<string>discontiguous</string>
|
||||||
|
<string>meta_predicate</string>
|
||||||
|
<string>mode</string>
|
||||||
|
<string>op</string>
|
||||||
|
<string>private</string>
|
||||||
|
<string>protected</string>
|
||||||
|
<string>public</string>
|
||||||
|
<string>current_object</string>
|
||||||
|
<string>current_protocol</string>
|
||||||
|
<string>current_category</string>
|
||||||
|
<string>object_property</string>
|
||||||
|
<string>protocol_property</string>
|
||||||
|
<string>category_property</string>
|
||||||
|
<string>create_object</string>
|
||||||
|
<string>create_protocol</string>
|
||||||
|
<string>create_category</string>
|
||||||
|
<string>abolish_object</string>
|
||||||
|
<string>abolish_protocol</string>
|
||||||
|
<string>abolish_category</string>
|
||||||
|
<string>extends_object</string>
|
||||||
|
<string>extends_protocol</string>
|
||||||
|
<string>implements_protocol</string>
|
||||||
|
<string>imports_category</string>
|
||||||
|
<string>instantiates_class</string>
|
||||||
|
<string>specializes_class</string>
|
||||||
|
<string>abolish_events</string>
|
||||||
|
<string>current_event</string>
|
||||||
|
<string>define_events</string>
|
||||||
|
<string>logtalk_load</string>
|
||||||
|
<string>logtalk_compile</string>
|
||||||
|
<string>logtalk_library_path</string>
|
||||||
|
<string>current_logtalk_flag</string>
|
||||||
|
<string>set_logtalk_flag</string>
|
||||||
|
<string>threaded_call</string>
|
||||||
|
<string>threaded_exit</string>
|
||||||
|
<string>self</string>
|
||||||
|
<string>this</string>
|
||||||
|
<string>sender</string>
|
||||||
|
<string>parameter</string>
|
||||||
|
<string>before</string>
|
||||||
|
<string>after</string>
|
||||||
|
<string>phrase</string>
|
||||||
|
<string>expand_term</string>
|
||||||
|
<string>term_expansion</string>
|
||||||
|
<string>true</string>
|
||||||
|
<string>fail</string>
|
||||||
|
<string>call</string>
|
||||||
|
<string>catch</string>
|
||||||
|
<string>throw</string>
|
||||||
|
<string>unify_with_occurs_check</string>
|
||||||
|
<string>var</string>
|
||||||
|
<string>atom</string>
|
||||||
|
<string>integer</string>
|
||||||
|
<string>float</string>
|
||||||
|
<string>atomic</string>
|
||||||
|
<string>compound</string>
|
||||||
|
<string>nonvar</string>
|
||||||
|
<string>number</string>
|
||||||
|
<string>arg</string>
|
||||||
|
<string>copy_term</string>
|
||||||
|
<string>functor</string>
|
||||||
|
<string>current_predicate</string>
|
||||||
|
<string>predicate_property</string>
|
||||||
|
<string>abolish</string>
|
||||||
|
<string>assertz</string>
|
||||||
|
<string>asserta</string>
|
||||||
|
<string>clause</string>
|
||||||
|
<string>retract</string>
|
||||||
|
<string>retractall</string>
|
||||||
|
<string>bagof</string>
|
||||||
|
<string>findall</string>
|
||||||
|
<string>forall</string>
|
||||||
|
<string>setof</string>
|
||||||
|
<string>current_input</string>
|
||||||
|
<string>current_output</string>
|
||||||
|
<string>set_input</string>
|
||||||
|
<string>set_output</string>
|
||||||
|
<string>open</string>
|
||||||
|
<string>close</string>
|
||||||
|
<string>flush_output</string>
|
||||||
|
<string>stream_property</string>
|
||||||
|
<string>at_end_of_stream</string>
|
||||||
|
<string>set_stream_position</string>
|
||||||
|
<string>get_char</string>
|
||||||
|
<string>get_code</string>
|
||||||
|
<string>peek_char</string>
|
||||||
|
<string>peek_code</string>
|
||||||
|
<string>put_char</string>
|
||||||
|
<string>put_code</string>
|
||||||
|
<string>nl</string>
|
||||||
|
<string>get_byte</string>
|
||||||
|
<string>peek_byte</string>
|
||||||
|
<string>put_byte</string>
|
||||||
|
<string>read</string>
|
||||||
|
<string>read_term</string>
|
||||||
|
<string>write</string>
|
||||||
|
<string>writeq</string>
|
||||||
|
<string>write_canonical</string>
|
||||||
|
<string>atom_chars</string>
|
||||||
|
<string>atom_codes</string>
|
||||||
|
<string>atom_concat</string>
|
||||||
|
<string>number_chars</string>
|
||||||
|
<string>number_codes</string>
|
||||||
|
<string>current_op</string>
|
||||||
|
<string>char_conversion</string>
|
||||||
|
<string>current_char_conversion</string>
|
||||||
|
<string>once</string>
|
||||||
|
<string>repeat</string>
|
||||||
|
<string>atom_length</string>
|
||||||
|
<string>atom_concat</string>
|
||||||
|
<string>sub_atom</string>
|
||||||
|
<string>atom_chars</string>
|
||||||
|
<string>atom_codes</string>
|
||||||
|
<string>char_code</string>
|
||||||
|
<string>number_chars</string>
|
||||||
|
<string>number_codes</string>
|
||||||
|
<string>set_prolog_flag</string>
|
||||||
|
<string>current_prolog_flag</string>
|
||||||
|
<string>halt</string>
|
||||||
|
</array>
|
||||||
|
<key>beginCommand</key>
|
||||||
|
<string></string>
|
||||||
|
<key>beginFirstMultiLineComment</key>
|
||||||
|
<string>/*</string>
|
||||||
|
<key>beginInstruction</key>
|
||||||
|
<string></string>
|
||||||
|
<key>beginSecondMultiLineComment</key>
|
||||||
|
<string></string>
|
||||||
|
<key>beginVariable</key>
|
||||||
|
<string></string>
|
||||||
|
<key>endCommand</key>
|
||||||
|
<string></string>
|
||||||
|
<key>endFirstMultiLineComment</key>
|
||||||
|
<string>*/</string>
|
||||||
|
<key>endInstruction</key>
|
||||||
|
<string></string>
|
||||||
|
<key>endSecondMultiLineComment</key>
|
||||||
|
<string></string>
|
||||||
|
<key>endVariable</key>
|
||||||
|
<string></string>
|
||||||
|
<key>firstSingleLineComment</key>
|
||||||
|
<string>%</string>
|
||||||
|
<key>firstString</key>
|
||||||
|
<string>"</string>
|
||||||
|
<key>functionDefinition</key>
|
||||||
|
<string>((?<=:-\sobject\()|(?<=:-\sprotocol\()|(?<=:-\scategory\())[a-z][a-zA-Z_]*</string>
|
||||||
|
<key>removeFromFunction</key>
|
||||||
|
<string></string>
|
||||||
|
<key>keywords</key>
|
||||||
|
<array>
|
||||||
|
<string>::</string>
|
||||||
|
<string>^^</string>
|
||||||
|
</array>
|
||||||
|
<key>keywordsCaseSensitive</key>
|
||||||
|
<true/>
|
||||||
|
<key>recolourKeywordIfAlreadyColoured</key>
|
||||||
|
<true/>
|
||||||
|
<key>secondSingleLineComment</key>
|
||||||
|
<string></string>
|
||||||
|
<key>secondString</key>
|
||||||
|
<string>'</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
44
Logtalk/wenv/superedi/Logtalk.col
Normal file
44
Logtalk/wenv/superedi/Logtalk.col
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
[NormalText]
|
||||||
|
BkColor=FFFFFF
|
||||||
|
TextColor=000000
|
||||||
|
|
||||||
|
[SelectedText]
|
||||||
|
[MatchingBracket]
|
||||||
|
|
||||||
|
[Whitespace]
|
||||||
|
BkColor=FFFFFF
|
||||||
|
|
||||||
|
[SelectionMargin]
|
||||||
|
[Preprocessor]
|
||||||
|
|
||||||
|
[Comment]
|
||||||
|
TextColor=008000
|
||||||
|
|
||||||
|
[Keyword 1]
|
||||||
|
BkColor=FFFFFF
|
||||||
|
TextColor=000000
|
||||||
|
|
||||||
|
[Keyword 2]
|
||||||
|
BkColor=FFFFFF
|
||||||
|
TextColor=000000
|
||||||
|
|
||||||
|
[Keyword 3]
|
||||||
|
BkColor=FFFFFF
|
||||||
|
TextColor=000000
|
||||||
|
|
||||||
|
[Keyword 4]
|
||||||
|
BkColor=FFFFFF
|
||||||
|
TextColor=000000
|
||||||
|
|
||||||
|
[Keyword 5]
|
||||||
|
BkColor=FFFFFF
|
||||||
|
TextColor=000000
|
||||||
|
|
||||||
|
[Keyword 6]
|
||||||
|
BkColor=FFFFFF
|
||||||
|
TextColor=000000
|
||||||
|
|
||||||
|
[Number]
|
||||||
|
[Operator]
|
||||||
|
[Char]
|
||||||
|
[String]
|
322
Logtalk/wenv/superedi/Logtalk.syn
Normal file
322
Logtalk/wenv/superedi/Logtalk.syn
Normal file
@ -0,0 +1,322 @@
|
|||||||
|
; Superedi syntax definitions for Logtalk (http://logtalk.org/)
|
||||||
|
;
|
||||||
|
; Author: Paulo Moura
|
||||||
|
; Last changed in: October 16, 2006
|
||||||
|
|
||||||
|
|
||||||
|
C=1
|
||||||
|
|
||||||
|
[Syntax]
|
||||||
|
Namespace1 = 6
|
||||||
|
IgnoreCase = NO
|
||||||
|
InitKeyWordChars =
|
||||||
|
KeyWordChars = a-zA-Z0-9_:^;*+,-./;<=>?@[\]^{|}
|
||||||
|
KeyWordLength =
|
||||||
|
BracketChars =
|
||||||
|
OperatorChars = <=>?@[\]|
|
||||||
|
PreprocStart =
|
||||||
|
SyntaxStart =
|
||||||
|
SyntaxEnd =
|
||||||
|
HexPrefix = 0x
|
||||||
|
CommentStart = /*
|
||||||
|
CommentEnd = */
|
||||||
|
CommentStartAlt =
|
||||||
|
CommentEndAlt =
|
||||||
|
SingleComment = %
|
||||||
|
SingleCommentCol =
|
||||||
|
SingleCommentAlt =
|
||||||
|
SingleCommentColAlt =
|
||||||
|
SingleCommentEsc =
|
||||||
|
StringsSpanLines = Yes
|
||||||
|
StringStart = "
|
||||||
|
StringEnd = "
|
||||||
|
StringAlt =
|
||||||
|
StringEsc = \
|
||||||
|
CharStart = '
|
||||||
|
CharEnd = '
|
||||||
|
CharEsc = \
|
||||||
|
|
||||||
|
|
||||||
|
[FunctionList]
|
||||||
|
Object = ^\s*:-\sobject[(]{[a-z][a-zA-Z_]+}
|
||||||
|
Interface = ^\s*:-\sprotocol[(]{[a-z][a-zA-Z_]+}
|
||||||
|
Item = ^\s*:-\scategory[(]{[a-z][a-zA-Z_]+}
|
||||||
|
|
||||||
|
|
||||||
|
[Keywords 1]
|
||||||
|
|
||||||
|
; Logtalk message sending operators
|
||||||
|
|
||||||
|
^^
|
||||||
|
:-
|
||||||
|
.
|
||||||
|
,
|
||||||
|
;
|
||||||
|
::
|
||||||
|
|
||||||
|
|
||||||
|
; Logtalk external call
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Keywords 2]
|
||||||
|
|
||||||
|
; Logtalk opening entity directives
|
||||||
|
object
|
||||||
|
protocol
|
||||||
|
category
|
||||||
|
module
|
||||||
|
|
||||||
|
|
||||||
|
; Logtalk closing entity directives
|
||||||
|
end_object
|
||||||
|
end_protocol
|
||||||
|
end_category
|
||||||
|
|
||||||
|
; Logtalk entity relations
|
||||||
|
instantiates
|
||||||
|
specializes
|
||||||
|
extends
|
||||||
|
imports
|
||||||
|
implements
|
||||||
|
|
||||||
|
|
||||||
|
[Keywords 3]
|
||||||
|
|
||||||
|
; Logtalk directives
|
||||||
|
alias
|
||||||
|
encoding
|
||||||
|
export
|
||||||
|
initialization
|
||||||
|
info
|
||||||
|
mode
|
||||||
|
dynamic
|
||||||
|
discontiguous
|
||||||
|
multifile
|
||||||
|
public
|
||||||
|
protected
|
||||||
|
private
|
||||||
|
meta_predicate
|
||||||
|
op
|
||||||
|
calls
|
||||||
|
uses
|
||||||
|
use_module
|
||||||
|
threaded
|
||||||
|
|
||||||
|
|
||||||
|
[Keywords 4]
|
||||||
|
|
||||||
|
; Logtalk built-in predicates
|
||||||
|
current_object
|
||||||
|
current_protocol
|
||||||
|
current_category
|
||||||
|
create_object
|
||||||
|
create_protocol
|
||||||
|
create_category
|
||||||
|
object_property
|
||||||
|
protocol_property
|
||||||
|
category_property
|
||||||
|
abolish_object
|
||||||
|
abolish_protocol
|
||||||
|
abolish_category
|
||||||
|
extends_object
|
||||||
|
extends_protocol
|
||||||
|
implements_protocol
|
||||||
|
instantiates_class
|
||||||
|
specializes_class
|
||||||
|
imports_category
|
||||||
|
abolish_events
|
||||||
|
current_event
|
||||||
|
define_events
|
||||||
|
current_logtalk_flag
|
||||||
|
set_logtalk_flag
|
||||||
|
logtalk_compile
|
||||||
|
logtalk_load
|
||||||
|
logtalk_library_path
|
||||||
|
forall
|
||||||
|
retractall
|
||||||
|
|
||||||
|
|
||||||
|
[Keywords 5]
|
||||||
|
|
||||||
|
; Logtalk built-in methods
|
||||||
|
parameter
|
||||||
|
self
|
||||||
|
sender
|
||||||
|
this
|
||||||
|
current_predicate
|
||||||
|
predicate_property
|
||||||
|
abolish
|
||||||
|
asserta
|
||||||
|
assertz
|
||||||
|
clause
|
||||||
|
retract
|
||||||
|
retractall
|
||||||
|
bagof
|
||||||
|
findall
|
||||||
|
forall
|
||||||
|
setof
|
||||||
|
before
|
||||||
|
after
|
||||||
|
expand_term
|
||||||
|
term_expansion
|
||||||
|
phrase
|
||||||
|
threaded_call
|
||||||
|
threaded_exit
|
||||||
|
|
||||||
|
; Mode operators
|
||||||
|
?
|
||||||
|
@
|
||||||
|
|
||||||
|
; Control constructs
|
||||||
|
true
|
||||||
|
fail
|
||||||
|
call
|
||||||
|
!
|
||||||
|
,
|
||||||
|
;
|
||||||
|
-->
|
||||||
|
->
|
||||||
|
catch
|
||||||
|
throw
|
||||||
|
|
||||||
|
; Term unification
|
||||||
|
=
|
||||||
|
unify_with_occurs_check
|
||||||
|
\=
|
||||||
|
|
||||||
|
; Term testing
|
||||||
|
var
|
||||||
|
atom
|
||||||
|
integer
|
||||||
|
float
|
||||||
|
atomic
|
||||||
|
compound
|
||||||
|
nonvar
|
||||||
|
number
|
||||||
|
|
||||||
|
; Term comparison
|
||||||
|
@=<
|
||||||
|
==
|
||||||
|
\==
|
||||||
|
@<
|
||||||
|
@>
|
||||||
|
@>=
|
||||||
|
|
||||||
|
; Term creation and decomposition
|
||||||
|
functor
|
||||||
|
arg
|
||||||
|
=..
|
||||||
|
copy_term
|
||||||
|
|
||||||
|
; Arithemtic evaluation
|
||||||
|
is
|
||||||
|
|
||||||
|
; Arithemtic comparison
|
||||||
|
=:=
|
||||||
|
=\=
|
||||||
|
<
|
||||||
|
=<
|
||||||
|
>
|
||||||
|
>=
|
||||||
|
|
||||||
|
; Stream selection and control
|
||||||
|
current_input
|
||||||
|
current_output
|
||||||
|
set_input
|
||||||
|
set_output
|
||||||
|
open
|
||||||
|
close
|
||||||
|
flush_output
|
||||||
|
stream_property
|
||||||
|
at_end_of_stream
|
||||||
|
set_stream_position
|
||||||
|
|
||||||
|
; Character input/output
|
||||||
|
get_char
|
||||||
|
get_code
|
||||||
|
peek_char
|
||||||
|
peek_code
|
||||||
|
put_char
|
||||||
|
put_code
|
||||||
|
nl
|
||||||
|
|
||||||
|
; Byte input/output
|
||||||
|
get_byte
|
||||||
|
peek_byte
|
||||||
|
put_byte
|
||||||
|
|
||||||
|
; Term input/output
|
||||||
|
read_term
|
||||||
|
read
|
||||||
|
write_term
|
||||||
|
write
|
||||||
|
writeq
|
||||||
|
write_canonical
|
||||||
|
op
|
||||||
|
current_op
|
||||||
|
char_conversion
|
||||||
|
current_char_conversion
|
||||||
|
|
||||||
|
; Logic and control
|
||||||
|
\+
|
||||||
|
once
|
||||||
|
repeat
|
||||||
|
|
||||||
|
; Atomic term processing
|
||||||
|
atom_length
|
||||||
|
atom_concat
|
||||||
|
sub_atom
|
||||||
|
atom_chars
|
||||||
|
atom_codes
|
||||||
|
char_code
|
||||||
|
number_chars
|
||||||
|
number_codes
|
||||||
|
|
||||||
|
; Implementation defined hooks functions
|
||||||
|
set_prolog_flag
|
||||||
|
current_prolog_flag
|
||||||
|
halt
|
||||||
|
|
||||||
|
; Evaluable functors
|
||||||
|
+
|
||||||
|
-
|
||||||
|
*
|
||||||
|
//
|
||||||
|
/
|
||||||
|
rem
|
||||||
|
mod
|
||||||
|
abs
|
||||||
|
sign
|
||||||
|
float_integer_part
|
||||||
|
float_fractional_part
|
||||||
|
float
|
||||||
|
floor
|
||||||
|
truncate
|
||||||
|
round
|
||||||
|
ceiling
|
||||||
|
|
||||||
|
; Other arithemtic functors
|
||||||
|
**
|
||||||
|
sin
|
||||||
|
cos
|
||||||
|
atan
|
||||||
|
exp
|
||||||
|
log
|
||||||
|
sqrt
|
||||||
|
|
||||||
|
; Bitwise functors
|
||||||
|
>>
|
||||||
|
<<
|
||||||
|
/\
|
||||||
|
\/
|
||||||
|
\
|
||||||
|
|
||||||
|
; Logtalk end-of-clause
|
||||||
|
.
|
||||||
|
|
||||||
|
; Logtalk list operator
|
||||||
|
|
|
||||||
|
|
||||||
|
|
28
Logtalk/wenv/superedi/NOTES.txt
Normal file
28
Logtalk/wenv/superedi/NOTES.txt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
This directory contains files that provides basic syntax coloring,
|
||||||
|
entity index, and code completion for editing Logtalk source files
|
||||||
|
with the text editor SuperEdi 3.8.1 or later version:
|
||||||
|
|
||||||
|
http://www.wolosoft.com/en/superedi/index.html
|
||||||
|
|
||||||
|
Install the supporting files by performing the following steps:
|
||||||
|
|
||||||
|
1. Copy the file "Logtalk.syn" to the "Syntax" directory in your
|
||||||
|
SuperEdi installation directory (replacing any existing older file).
|
||||||
|
|
||||||
|
2. Copy the file "Logtalk.col" to the "Syntax" directory in your
|
||||||
|
SuperEdi installation directory (replacing any existing older file).
|
||||||
|
|
||||||
|
3. Go to the Tools/Options dialog and create a new file type named
|
||||||
|
"Logtalk". Set the file extension to "lgt" and the syntax and color
|
||||||
|
scheme to "Logtalk". Set the tab size to "4".
|
||||||
|
|
||||||
|
|
||||||
|
THESE SYNTAX COLORING SUPPORT FILES ARE UNDER DEVELOPMENT.
|
9
Logtalk/wenv/textwrangler/NOTES.txt
Normal file
9
Logtalk/wenv/textwrangler/NOTES.txt
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
=================================================================
|
||||||
|
Logtalk - Object oriented extension to Prolog
|
||||||
|
Release 2.28.2
|
||||||
|
|
||||||
|
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||||
|
=================================================================
|
||||||
|
|
||||||
|
|
||||||
|
See the ../bbedit folder.
|
138
Logtalk/wenv/vim/completion/logtalk.dict
Normal file
138
Logtalk/wenv/vim/completion/logtalk.dict
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
encoding
|
||||||
|
calls
|
||||||
|
category
|
||||||
|
dynamic
|
||||||
|
end_category
|
||||||
|
end_object
|
||||||
|
end_protocol
|
||||||
|
info
|
||||||
|
initialization
|
||||||
|
object
|
||||||
|
protocol
|
||||||
|
threaded
|
||||||
|
uses
|
||||||
|
alias
|
||||||
|
discontiguous
|
||||||
|
meta_predicate
|
||||||
|
mode
|
||||||
|
op
|
||||||
|
private
|
||||||
|
protected
|
||||||
|
public
|
||||||
|
current_object
|
||||||
|
current_protocol
|
||||||
|
current_category
|
||||||
|
object_property
|
||||||
|
protocol_property
|
||||||
|
category_property
|
||||||
|
create_object
|
||||||
|
create_protocol
|
||||||
|
create_category
|
||||||
|
abolish_object
|
||||||
|
abolish_protocol
|
||||||
|
abolish_category
|
||||||
|
extends
|
||||||
|
extends_object
|
||||||
|
extends_protocol
|
||||||
|
implements
|
||||||
|
implements_protocol
|
||||||
|
imports
|
||||||
|
imports_category
|
||||||
|
instantiates
|
||||||
|
instantiates_class
|
||||||
|
specializes
|
||||||
|
specializes_class
|
||||||
|
abolish_events
|
||||||
|
current_event
|
||||||
|
define_events
|
||||||
|
logtalk_load
|
||||||
|
logtalk_compile
|
||||||
|
logtalk_library_path
|
||||||
|
current_logtalk_flag
|
||||||
|
set_logtalk_flag
|
||||||
|
threaded_call
|
||||||
|
threaded_exit
|
||||||
|
self
|
||||||
|
this
|
||||||
|
sender
|
||||||
|
parameter
|
||||||
|
before
|
||||||
|
after
|
||||||
|
phrase
|
||||||
|
expand_term
|
||||||
|
term_expansion
|
||||||
|
true
|
||||||
|
fail
|
||||||
|
call
|
||||||
|
catch
|
||||||
|
throw
|
||||||
|
unify_with_occurs_check
|
||||||
|
var
|
||||||
|
atom
|
||||||
|
integer
|
||||||
|
float
|
||||||
|
atomic
|
||||||
|
compound
|
||||||
|
nonvar
|
||||||
|
number
|
||||||
|
arg
|
||||||
|
copy_term
|
||||||
|
functor
|
||||||
|
current_predicate
|
||||||
|
predicate_property
|
||||||
|
abolish
|
||||||
|
assertz
|
||||||
|
asserta
|
||||||
|
clause
|
||||||
|
retract
|
||||||
|
retractall
|
||||||
|
bagof
|
||||||
|
findall
|
||||||
|
forall
|
||||||
|
setof
|
||||||
|
current_input
|
||||||
|
current_output
|
||||||
|
set_input
|
||||||
|
set_output
|
||||||
|
open
|
||||||
|
close
|
||||||
|
flush_output
|
||||||
|
stream_property
|
||||||
|
at_end_of_stream
|
||||||
|
set_stream_position
|
||||||
|
get_char
|
||||||
|
get_code
|
||||||
|
peek_char
|
||||||
|
peek_code
|
||||||
|
put_char
|
||||||
|
put_code
|
||||||
|
nl
|
||||||
|
get_byte
|
||||||
|
peek_byte
|
||||||
|
put_byte
|
||||||
|
read
|
||||||
|
read_term
|
||||||
|
write
|
||||||
|
writeq
|
||||||
|
write_canonical
|
||||||
|
atom_chars
|
||||||
|
atom_codes
|
||||||
|
atom_concat
|
||||||
|
number_chars
|
||||||
|
number_codes
|
||||||
|
current_op
|
||||||
|
char_conversion
|
||||||
|
current_char_conversion
|
||||||
|
once
|
||||||
|
repeat
|
||||||
|
atom_length
|
||||||
|
atom_concat
|
||||||
|
sub_atom
|
||||||
|
atom_chars
|
||||||
|
atom_codes
|
||||||
|
char_code
|
||||||
|
number_chars
|
||||||
|
number_codes
|
||||||
|
set_prolog_flag
|
||||||
|
current_prolog_flag
|
||||||
|
halt
|
61
Logtalk/wenv/vim/indent/logtalk.vim
Normal file
61
Logtalk/wenv/vim/indent/logtalk.vim
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
" Maintainer: Paulo Moura <pmoura@logtalk.org>
|
||||||
|
" Revised on: 2006.10.22
|
||||||
|
" Language: Logtalk
|
||||||
|
|
||||||
|
" This Logtalk indent file is a modified version of the Prolog
|
||||||
|
" indent file written by Gergely Kontra
|
||||||
|
|
||||||
|
" Only load this indent file when no other was loaded.
|
||||||
|
if exists("b:did_indent")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
let b:did_indent = 1
|
||||||
|
|
||||||
|
setlocal indentexpr=GetLogtalkIndent()
|
||||||
|
setlocal indentkeys-=:,0#
|
||||||
|
setlocal indentkeys+=0%,-,0;,>,0)
|
||||||
|
|
||||||
|
" Only define the function once.
|
||||||
|
"if exists("*GetLogtalkIndent")
|
||||||
|
" finish
|
||||||
|
"endif
|
||||||
|
|
||||||
|
function! GetLogtalkIndent()
|
||||||
|
" Find a non-blank line above the current line.
|
||||||
|
let pnum = prevnonblank(v:lnum - 1)
|
||||||
|
" Hit the start of the file, use zero indent.
|
||||||
|
if pnum == 0
|
||||||
|
return 0
|
||||||
|
endif
|
||||||
|
let line = getline(v:lnum)
|
||||||
|
let pline = getline(pnum)
|
||||||
|
|
||||||
|
let ind = indent(pnum)
|
||||||
|
" Previous line was comment -> use previous line's indent
|
||||||
|
if pline =~ '^\s*%'
|
||||||
|
retu ind
|
||||||
|
endif
|
||||||
|
" Check for entity opening directive on previous line
|
||||||
|
if pline =~ '^\s*:-\s\(object\|protocol\|category\)\ze(.*,$'
|
||||||
|
let ind = ind + &sw
|
||||||
|
" Check for clause head on previous line
|
||||||
|
elseif pline =~ ':-\s*\(%.*\)\?$'
|
||||||
|
let ind = ind + &sw
|
||||||
|
" Check for entity closing directive on previous line
|
||||||
|
elseif pline =~ '^\s*:-\send_\(object\|protocol\|category\)\.\(%.*\)\?$'
|
||||||
|
let ind = ind - &sw
|
||||||
|
" Check for end of clause on previous line
|
||||||
|
elseif pline =~ '\.\s*\(%.*\)\?$'
|
||||||
|
let ind = ind - &sw
|
||||||
|
endif
|
||||||
|
" Check for opening conditional on previous line
|
||||||
|
if pline =~ '^\s*\([(;]\|->\)'
|
||||||
|
let ind = ind + &sw
|
||||||
|
endif
|
||||||
|
" Check for closing an unclosed paren, or middle ; or ->
|
||||||
|
if line =~ '^\s*\([);]\|->\)'
|
||||||
|
let ind = ind - &sw
|
||||||
|
endif
|
||||||
|
return ind
|
||||||
|
endfunction
|
397
Logtalk/wenv/vim/syntax/logtalk.vim
Normal file
397
Logtalk/wenv/vim/syntax/logtalk.vim
Normal file
@ -0,0 +1,397 @@
|
|||||||
|
" Vim syntax file
|
||||||
|
"
|
||||||
|
" Language: Logtalk
|
||||||
|
" Maintainer: Paulo Moura <pmoura@logtalk.org>
|
||||||
|
" Last Change: September 17, 2006
|
||||||
|
|
||||||
|
|
||||||
|
" Quit when a syntax file was already loaded:
|
||||||
|
|
||||||
|
if version < 600
|
||||||
|
syntax clear
|
||||||
|
elseif exists("b:current_syntax")
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk is case sensitive:
|
||||||
|
|
||||||
|
syn case match
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk variables
|
||||||
|
|
||||||
|
syn match logtalkVariable "\<\(\u\|_\)\(\w\)*\>"
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk clause functor
|
||||||
|
|
||||||
|
syn match logtalkOperator ":-"
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk quoted atoms and strings
|
||||||
|
|
||||||
|
syn region logtalkString start=+"+ skip=+\\"+ end=+"+
|
||||||
|
syn region logtalkAtom start=+'+ skip=+\\'+ end=+'+
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk message sending operators
|
||||||
|
|
||||||
|
syn match logtalkOperator "::"
|
||||||
|
syn match logtalkOperator "\^\^"
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk external call
|
||||||
|
|
||||||
|
syn region logtalkExtCall matchgroup=logtalkExtCallTag start="{" matchgroup=logtalkExtCallTag end="}" contains=ALL
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk opening entity directives
|
||||||
|
|
||||||
|
syn region logtalkOpenEntityDir matchgroup=logtalkOpenEntityDirTag start=":- object(" matchgroup=logtalkOpenEntityDirTag end=")\." contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator,logtalkEntityRel
|
||||||
|
syn region logtalkOpenEntityDir matchgroup=logtalkOpenEntityDirTag start=":- protocol(" matchgroup=logtalkOpenEntityDirTag end=")\." contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator,logtalkEntityRel
|
||||||
|
syn region logtalkOpenEntityDir matchgroup=logtalkOpenEntityDirTag start=":- category(" matchgroup=logtalkOpenEntityDirTag end=")\." contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator,logtalkEntityRel
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk closing entity directives
|
||||||
|
|
||||||
|
syn match logtalkCloseEntityDir ":- end_object\."
|
||||||
|
syn match logtalkCloseEntityDir ":- end_protocol\."
|
||||||
|
syn match logtalkCloseEntityDir ":- end_category\."
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk entity relations
|
||||||
|
|
||||||
|
syn region logtalkEntityRel matchgroup=logtalkEntityRelTag start="instantiates(" matchgroup=logtalkEntityRelTag end=")" contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator contained
|
||||||
|
syn region logtalkEntityRel matchgroup=logtalkEntityRelTag start="specializes(" matchgroup=logtalkEntityRelTag end=")" contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator contained
|
||||||
|
syn region logtalkEntityRel matchgroup=logtalkEntityRelTag start="extends(" matchgroup=logtalkEntityRelTag end=")" contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator contained
|
||||||
|
syn region logtalkEntityRel matchgroup=logtalkEntityRelTag start="imports(" matchgroup=logtalkEntityRelTag end=")" contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator contained
|
||||||
|
syn region logtalkEntityRel matchgroup=logtalkEntityRelTag start="implements(" matchgroup=logtalkEntityRelTag end=")" contains=logtalkEntity,logtalkVariable,logtalkNumber,logtalkOperator contained
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk directives
|
||||||
|
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- alias(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- atomic(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- encoding(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- initialization(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- info(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- mode(" matchgroup=logtalkDirTag end=")\." contains=logtalkOperator, logtalkAtom
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- dynamic(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn match logtalkDirTag ":- dynamic\."
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- discontiguous(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- multifile(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- public(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- protected(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- private(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- meta_predicate(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- op(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- calls(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- uses(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn match logtalkDirTag ":- threaded\."
|
||||||
|
|
||||||
|
|
||||||
|
" Module directives
|
||||||
|
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- module(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- export(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
syn region logtalkDir matchgroup=logtalkDirTag start=":- use_module(" matchgroup=logtalkDirTag end=")\." contains=ALL
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk built-in predicates
|
||||||
|
|
||||||
|
syn match logtalkBuiltIn "\<\(abolish\|c\(reate\|urrent\)\)_\(object\|protocol\|category\)\ze("
|
||||||
|
|
||||||
|
syn match logtalkBuiltIn "\<\(object\|protocol\|category\)_property\ze("
|
||||||
|
|
||||||
|
syn match logtalkBuiltIn "\<extends_\(object\|protocol\)\ze("
|
||||||
|
syn match logtalkBuiltIn "\<imp\(orts_category\|lements_protocol\)\ze("
|
||||||
|
syn match logtalkBuiltIn "\<\(instantiates\|specializes\)_class\ze("
|
||||||
|
|
||||||
|
syn match logtalkBuiltIn "\<\(abolish\|define\)_events\ze("
|
||||||
|
syn match logtalkBuiltIn "\<current_event\ze("
|
||||||
|
|
||||||
|
syn match logtalkBuiltIn "\<\(current\|set\)_logtalk_flag\ze("
|
||||||
|
|
||||||
|
syn match logtalkBuiltIn "\<logtalk_\(compile\|l\(ibrary_path\|oad\)\)\ze("
|
||||||
|
|
||||||
|
syn match logtalkBuiltIn "\<\(for\|retract\)all\ze("
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk built-in methods
|
||||||
|
|
||||||
|
syn match logtalkBuiltInMethod "\<parameter\ze("
|
||||||
|
syn match logtalkBuiltInMethod "\<se\(lf\|nder\)\ze("
|
||||||
|
syn match logtalkBuiltInMethod "\<this\ze("
|
||||||
|
|
||||||
|
syn match logtalkBuiltInMethod "\<current_predicate\ze("
|
||||||
|
syn match logtalkBuiltInMethod "\<predicate_property\ze("
|
||||||
|
|
||||||
|
syn match logtalkBuiltInMethod "\<a\(bolish\|ssert\(a\|z\)\)\ze("
|
||||||
|
syn match logtalkBuiltInMethod "\<clause\ze("
|
||||||
|
syn match logtalkBuiltInMethod "\<retract\(all\)\?\ze("
|
||||||
|
|
||||||
|
syn match logtalkBuiltInMethod "\<\(bag\|set\)of\ze("
|
||||||
|
syn match logtalkBuiltInMethod "\<f\(ind\|or\)all\ze("
|
||||||
|
|
||||||
|
syn match logtalkBuiltInMethod "\<before\ze("
|
||||||
|
syn match logtalkBuiltInMethod "\<after\ze("
|
||||||
|
|
||||||
|
syn match logtalkBuiltInMethod "\<expand_term\ze("
|
||||||
|
syn match logtalkBuiltInMethod "\<term_expansion\ze("
|
||||||
|
syn match logtalkBuiltInMethod "\<phrase\ze("
|
||||||
|
|
||||||
|
syn match logtalkBuiltInMethod "\<threaded_\(call\|exit\)\ze("
|
||||||
|
|
||||||
|
|
||||||
|
" Mode operators
|
||||||
|
|
||||||
|
syn match logtalkOperator "?"
|
||||||
|
syn match logtalkOperator "@"
|
||||||
|
|
||||||
|
|
||||||
|
" Control constructs
|
||||||
|
|
||||||
|
syn match logtalkKeyword "\<true\>"
|
||||||
|
syn match logtalkKeyword "\<fail\>"
|
||||||
|
syn match logtalkKeyword "\<ca\(ll\|tch\)\ze("
|
||||||
|
syn match logtalkOperator "!"
|
||||||
|
" syn match logtalkOperator ","
|
||||||
|
syn match logtalkOperator ";"
|
||||||
|
syn match logtalkOperator "-->"
|
||||||
|
syn match logtalkOperator "->"
|
||||||
|
syn match logtalkKeyword "\<throw\ze("
|
||||||
|
|
||||||
|
|
||||||
|
" Term unification
|
||||||
|
|
||||||
|
syn match logtalkOperator "="
|
||||||
|
syn match logtalkKeyword "\<unify_with_occurs_check\ze("
|
||||||
|
syn match logtalkOperator "\\="
|
||||||
|
|
||||||
|
|
||||||
|
" Term testing
|
||||||
|
|
||||||
|
syn match logtalkKeyword "\<var\ze("
|
||||||
|
syn match logtalkKeyword "\<atom\(ic\)\?\ze("
|
||||||
|
syn match logtalkKeyword "\<integer\ze("
|
||||||
|
syn match logtalkKeyword "\<float\ze("
|
||||||
|
syn match logtalkKeyword "\<compound\ze("
|
||||||
|
syn match logtalkKeyword "\<n\(onvar\|umber\)\ze("
|
||||||
|
|
||||||
|
|
||||||
|
" Term comparison
|
||||||
|
|
||||||
|
syn match logtalkOperator "@=<"
|
||||||
|
syn match logtalkOperator "=="
|
||||||
|
syn match logtalkOperator "\\=="
|
||||||
|
syn match logtalkOperator "@<"
|
||||||
|
syn match logtalkOperator "@>"
|
||||||
|
syn match logtalkOperator "@>="
|
||||||
|
|
||||||
|
|
||||||
|
" Term creation and decomposition
|
||||||
|
|
||||||
|
syn match logtalkKeyword "\<functor\ze("
|
||||||
|
syn match logtalkKeyword "\<arg\ze("
|
||||||
|
syn match logtalkOperator "=\.\."
|
||||||
|
syn match logtalkKeyword "\<copy_term\ze("
|
||||||
|
|
||||||
|
|
||||||
|
" Arithemtic evaluation
|
||||||
|
|
||||||
|
syn match logtalkOperator "\<is\>"
|
||||||
|
|
||||||
|
|
||||||
|
" Arithemtic comparison
|
||||||
|
|
||||||
|
syn match logtalkOperator "=:="
|
||||||
|
syn match logtalkOperator "=\\="
|
||||||
|
syn match logtalkOperator "<"
|
||||||
|
syn match logtalkOperator "=<"
|
||||||
|
syn match logtalkOperator ">"
|
||||||
|
syn match logtalkOperator ">="
|
||||||
|
|
||||||
|
|
||||||
|
" Stream selection and control
|
||||||
|
|
||||||
|
syn match logtalkKeyword "\<\(current\|set\)_\(in\|out\)put\ze("
|
||||||
|
syn match logtalkKeyword "\<open\ze("
|
||||||
|
syn match logtalkKeyword "\<close\ze("
|
||||||
|
syn match logtalkKeyword "\<flush_output\ze("
|
||||||
|
syn match logtalkKeyword "\<flush_output\>"
|
||||||
|
syn match logtalkKeyword "\<stream_property\ze("
|
||||||
|
syn match logtalkKeyword "\<at_end_of_stream\ze("
|
||||||
|
syn match logtalkKeyword "\<at_end_of_stream\>"
|
||||||
|
syn match logtalkKeyword "\<set_stream_position\ze("
|
||||||
|
|
||||||
|
|
||||||
|
" Character and byte input/output
|
||||||
|
|
||||||
|
syn match logtalkKeyword "\<\(get\|p\(eek\|ut\)\)_\(c\(har\|ode\)\|byte\)\ze("
|
||||||
|
syn match logtalkKeyword "\<nl\ze("
|
||||||
|
syn match logtalkKeyword "\<nl\>"
|
||||||
|
|
||||||
|
|
||||||
|
" Term input/output
|
||||||
|
|
||||||
|
syn match logtalkKeyword "\<read\(_term\)\?\ze("
|
||||||
|
syn match logtalkKeyword "\<write\(q\|_\(canonical\|term\)\)\?\ze("
|
||||||
|
syn match logtalkKeyword "\<\(current_\)\?op\ze("
|
||||||
|
syn match logtalkKeyword "\<\(current\)\?char_conversion\ze("
|
||||||
|
|
||||||
|
|
||||||
|
" Logic and control
|
||||||
|
|
||||||
|
syn match logtalkOperator "\\+"
|
||||||
|
syn match logtalkKeyword "\<once\ze("
|
||||||
|
syn match logtalkKeyword "\<repeat\>"
|
||||||
|
|
||||||
|
|
||||||
|
" Atomic term processing
|
||||||
|
|
||||||
|
syn match logtalkKeyword "\<atom_\(length\|c\(hars\|o\(ncat\|des\)\)\)\ze("
|
||||||
|
syn match logtalkKeyword "\<sub_atom\ze("
|
||||||
|
syn match logtalkKeyword "\<char_code\ze("
|
||||||
|
syn match logtalkKeyword "\<number_\(c\(hars\|odes\)\)\ze("
|
||||||
|
|
||||||
|
|
||||||
|
" Implementation defined hooks functions
|
||||||
|
|
||||||
|
syn match logtalkKeyword "\<\(current\|set\)_prolog_flag\ze("
|
||||||
|
syn match logtalkKeyword "\<halt\ze("
|
||||||
|
syn match logtalkKeyword "\<halt\>"
|
||||||
|
|
||||||
|
|
||||||
|
" Evaluable functors
|
||||||
|
|
||||||
|
syn match logtalkOperator "+"
|
||||||
|
syn match logtalkOperator "-"
|
||||||
|
syn match logtalkOperator "\*"
|
||||||
|
syn match logtalkOperator "//"
|
||||||
|
syn match logtalkOperator "/"
|
||||||
|
syn match logtalkKeyword "\<r\(ound\|em\)\ze("
|
||||||
|
syn match logtalkKeyword "\<rem\>"
|
||||||
|
syn match logtalkKeyword "\<mod\ze("
|
||||||
|
syn match logtalkKeyword "\<mod\>"
|
||||||
|
syn match logtalkKeyword "\<abs\ze("
|
||||||
|
syn match logtalkKeyword "\<sign\ze("
|
||||||
|
syn match logtalkKeyword "\<flo\(or\|at\(_\(integer\|fractional\)_part\)\?\)\ze("
|
||||||
|
syn match logtalkKeyword "\<truncate\ze("
|
||||||
|
syn match logtalkKeyword "\<ceiling\ze("
|
||||||
|
|
||||||
|
|
||||||
|
" Other arithemtic functors
|
||||||
|
|
||||||
|
syn match logtalkOperator "\*\*"
|
||||||
|
syn match logtalkKeyword "\<s\(in\|qrt\)\ze("
|
||||||
|
syn match logtalkKeyword "\<cos\ze("
|
||||||
|
syn match logtalkKeyword "\<atan\ze("
|
||||||
|
syn match logtalkKeyword "\<exp\ze("
|
||||||
|
syn match logtalkKeyword "\<log\ze("
|
||||||
|
|
||||||
|
|
||||||
|
" Bitwise functors
|
||||||
|
|
||||||
|
syn match logtalkOperator ">>"
|
||||||
|
syn match logtalkOperator "<<"
|
||||||
|
syn match logtalkOperator "/\\"
|
||||||
|
syn match logtalkOperator "\\/"
|
||||||
|
syn match logtalkOperator "\\"
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk list operator
|
||||||
|
|
||||||
|
syn match logtalkOperator "|"
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk numbers
|
||||||
|
|
||||||
|
syn match logtalkNumber "\<\d\+\>"
|
||||||
|
syn match logtalkNumber "\<\d\+\.\d\+\>"
|
||||||
|
syn match logtalkNumber "\<\d\+[eE][-+]\=\d\+\>"
|
||||||
|
syn match logtalkNumber "\<\d\+\.\d\+[eE][-+]\=\d\+\>"
|
||||||
|
syn match logtalkNumber "\<0'.\>"
|
||||||
|
syn match logtalkNumber "\<0b[0-1]\+\>"
|
||||||
|
syn match logtalkNumber "\<0o\o\+\>"
|
||||||
|
syn match logtalkNumber "\<0x\x\+\>"
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk end-of-clause
|
||||||
|
|
||||||
|
syn match logtalkOperator "\."
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk comments
|
||||||
|
|
||||||
|
syn region logtalkBlockComment start="/\*" end="\*/" fold
|
||||||
|
syn match logtalkLineComment "%.*"
|
||||||
|
|
||||||
|
|
||||||
|
" Logtalk entity folding
|
||||||
|
|
||||||
|
syn region logtalkEntity transparent fold keepend start=":- object(" end=":- end_object\." contains=ALL
|
||||||
|
syn region logtalkEntity transparent fold keepend start=":- protocol(" end=":- end_protocol\." contains=ALL
|
||||||
|
syn region logtalkEntity transparent fold keepend start=":- category(" end=":- end_category\." contains=ALL
|
||||||
|
|
||||||
|
|
||||||
|
syn sync ccomment logtalkBlockComment maxlines=50
|
||||||
|
|
||||||
|
|
||||||
|
" Define the default highlighting.
|
||||||
|
" For version 5.7 and earlier: only when not done already
|
||||||
|
" For version 5.8 and later: only when an item doesn't have highlighting yet
|
||||||
|
|
||||||
|
if version >= 508 || !exists("did_logtalk_syn_inits")
|
||||||
|
if version < 508
|
||||||
|
let did_logtalk_syn_inits = 1
|
||||||
|
command -nargs=+ HiLink hi link <args>
|
||||||
|
else
|
||||||
|
command -nargs=+ HiLink hi def link <args>
|
||||||
|
endif
|
||||||
|
|
||||||
|
HiLink logtalkBlockComment Comment
|
||||||
|
HiLink logtalkLineComment Comment
|
||||||
|
|
||||||
|
HiLink logtalkOpenEntityDir Normal
|
||||||
|
HiLink logtalkOpenEntityDirTag PreProc
|
||||||
|
|
||||||
|
HiLink logtalkEntity Normal
|
||||||
|
|
||||||
|
HiLink logtalkEntityRel Normal
|
||||||
|
HiLink logtalkEntityRelTag PreProc
|
||||||
|
|
||||||
|
HiLink logtalkCloseEntityDir PreProc
|
||||||
|
|
||||||
|
HiLink logtalkDir Normal
|
||||||
|
HiLink logtalkDirTag PreProc
|
||||||
|
|
||||||
|
HiLink logtalkAtom String
|
||||||
|
HiLink logtalkString String
|
||||||
|
|
||||||
|
HiLink logtalkNumber Number
|
||||||
|
|
||||||
|
HiLink logtalkKeyword Keyword
|
||||||
|
|
||||||
|
HiLink logtalkBuiltIn Keyword
|
||||||
|
HiLink logtalkBuiltInMethod Keyword
|
||||||
|
|
||||||
|
HiLink logtalkOperator Operator
|
||||||
|
|
||||||
|
HiLink logtalkExtCall Normal
|
||||||
|
HiLink logtalkExtCallTag Operator
|
||||||
|
|
||||||
|
HiLink logtalkVariable Identifier
|
||||||
|
|
||||||
|
delcommand HiLink
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
|
let b:current_syntax = "logtalk"
|
||||||
|
|
||||||
|
setlocal ts=4
|
||||||
|
setlocal sw=4
|
||||||
|
setlocal fdm=syntax
|
||||||
|
setlocal fdc=2
|
||||||
|
setlocal autoindent
|
Reference in New Issue
Block a user