Logtalk 2.27.0 files.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1539 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
13
Logtalk/examples/hooks/NOTES
Normal file
13
Logtalk/examples/hooks/NOTES
Normal file
@@ -0,0 +1,13 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.27.0
|
||||
|
||||
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 very simple example of using the Logtalk compiler
|
||||
hook to expand author abbreviations in info/1 directives into full names
|
||||
and email addresses.
|
15
Logtalk/examples/hooks/SCRIPT
Normal file
15
Logtalk/examples/hooks/SCRIPT
Normal file
@@ -0,0 +1,15 @@
|
||||
=================================================================
|
||||
Logtalk - Object oriented extension to Prolog
|
||||
Release 2.27.0
|
||||
|
||||
Copyright (c) 1998-2006 Paulo Moura. All Rights Reserved.
|
||||
=================================================================
|
||||
|
||||
|
||||
% start by loading the example:
|
||||
|
||||
| ?- logtalk_load(hooks(loader)).
|
||||
...
|
||||
|
||||
|
||||
% check the XML documenting file generated for "object"
|
30
Logtalk/examples/hooks/hook.lgt
Normal file
30
Logtalk/examples/hooks/hook.lgt
Normal file
@@ -0,0 +1,30 @@
|
||||
|
||||
:- object(hook).
|
||||
|
||||
:- info([
|
||||
version is 1.0,
|
||||
author is 'Paulo Moura',
|
||||
date is 2006/01/29,
|
||||
comment is 'Example of an object defining compiler hook predicates.']).
|
||||
|
||||
:- public(hook/2).
|
||||
:- mode(hook(@nonvar, -list), zero_or_one).
|
||||
:- info(hook/2, [
|
||||
comment is 'Compiler hook predicate.',
|
||||
arguments is ['Term'-'Source file term', 'Terms'-'Resulting list of terms']]).
|
||||
|
||||
hook((:- info(Original)), [(:- info(New))]) :-
|
||||
expand_author(Original, New).
|
||||
|
||||
expand_author([], []).
|
||||
expand_author([Info| Infos], [Info2| Infos2]) :-
|
||||
( Info = (author is Abbreviation) ->
|
||||
author(Abbreviation, FullName),
|
||||
Info2 = (author is FullName)
|
||||
; Info = Info2
|
||||
),
|
||||
expand_author(Infos, Infos2).
|
||||
|
||||
author(pm, 'Paulo Moura, pmoura@logtalk.org').
|
||||
|
||||
:- end_object.
|
11
Logtalk/examples/hooks/loader.lgt
Normal file
11
Logtalk/examples/hooks/loader.lgt
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
:- initialization(
|
||||
(logtalk_load(hook),
|
||||
logtalk_load(object, [hook(hook::hook), xmldocs(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(hooks, [hook(hook::hook), xmldocs(on), xmlsref(standalone)])).
|
||||
*/
|
10
Logtalk/examples/hooks/object.lgt
Normal file
10
Logtalk/examples/hooks/object.lgt
Normal file
@@ -0,0 +1,10 @@
|
||||
|
||||
:- object(object).
|
||||
|
||||
:- info([
|
||||
version is 1.0,
|
||||
author is pm,
|
||||
date is 2006/01/29,
|
||||
comment is 'Example object for illustrating the use of compiler hooks.']).
|
||||
|
||||
:- end_object.
|
Reference in New Issue
Block a user