|
Revision 4601, 1.0 KB
(checked in by pmoura, 7 weeks ago)
|
|
Added svn:mime-type property to source files (set to text/x-logtalk).
|
-
Property svn:mime-type set to
text/x-logtalk
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
| Line | |
|---|
| 1 | |
|---|
| 2 | :- object(hook, |
|---|
| 3 | implements(expanding)). % built-in protocol for term and goal expansion methods |
|---|
| 4 | |
|---|
| 5 | :- info([ |
|---|
| 6 | version is 1.1, |
|---|
| 7 | author is 'Paulo Moura', |
|---|
| 8 | date is 2007/12/3, |
|---|
| 9 | comment is 'Example of an object defining compiler hook predicates.']). |
|---|
| 10 | |
|---|
| 11 | % the term_expansion/2 predicate is called for every term in the source file: |
|---|
| 12 | term_expansion((:- info(Original)), [(:- info(New))]) :- |
|---|
| 13 | expand_author(Original, New). |
|---|
| 14 | |
|---|
| 15 | % the goal_expansion/2 predicate is called for every goal in predicate clause |
|---|
| 16 | % bodies in the source file: |
|---|
| 17 | goal_expansion( |
|---|
| 18 | write(Term), |
|---|
| 19 | (numbervars(Term, 0, _), write_term(Term, [quoted(true), numbervars(true)]))). |
|---|
| 20 | |
|---|
| 21 | expand_author([], []). |
|---|
| 22 | expand_author([Info| Infos], [ExpInfo| ExpInfos]) :- |
|---|
| 23 | ( Info = (author is Abbreviation) -> |
|---|
| 24 | author(Abbreviation, FullName), |
|---|
| 25 | ExpInfo = (author is FullName), |
|---|
| 26 | ExpInfos = Infos |
|---|
| 27 | ; ExpInfo = Info, |
|---|
| 28 | expand_author(Infos, ExpInfos) |
|---|
| 29 | ). |
|---|
| 30 | |
|---|
| 31 | author(pm, 'Paulo Moura, pmoura@logtalk.org'). |
|---|
| 32 | |
|---|
| 33 | :- end_object. |
|---|