The cross reference utility can be used to find a number of common Prolog programming errors. It can check for correct references of predicates across modules, and take into account extended predicates (LSXs) and compiled libraries.
It provides a full cross reference of predicates, indicating for each predicate both predicates called by the given predicate, and predicates that call the given predicate. The defining modules for the cross-referenced predicates are given as well, with notes for built-in and extended predicates.
The cross reference utility, axrf, checks for
The utility itself, axrf.plm, is in the abin folder. The entry point is xref/2 or xref/1.
xref(+SOURCE_LIST, +OUTPUT) - Cross reference the files in SOURCE_LIST and write the report to OUTPUT.
xref(+SOURCE_LIST) - Cross reference the files in SOURCE_LIST and write the report to the current output.
To use it from the listener, first load axrf.plm and then import it so you can access it from the listener. Then call axrf:xref.
For example, the following is a run from the program which finds a program error in duckym.pro regarding the call to instructions/0 from module rules.
?- load(axrf).
yes
?- import(axrf).
yes
?- axrf:xref(['duckym.pro']).
----- Warnings -----
Undefined: instructions/0 in module rules called from do/1
Unusedpredicate: user:main/0
----- Predicate Use -----
data:loc/2
no subgoals
called from:
rules:look_here/1
rules:look_have/1
rules:look/0
...
rules:chase/1
subgoals:
data:loc/2
rules:move/2
builtin:nl/0
builtin:write/1
called from:
rules:do/1
builtin:nl/0
For complex projects that depend on other modules you can set up the correct environment for the program and then run axrf. It is probably easiest to create a small test program that gets consulted and run in the listener. For example, here's a test file for a project with operator definitions that uses a library and an LSX. The output is sent to 'author.xrf'.
File runaxrf.pro:
:- load(axrf).
:- consult('..\\jigs\\kw_ops.pro').
:- load(list).
:- loadlsx('aosutils.lsx').
:- import(axrf).
main :- axrf:xref([
'author.pro',
'convert.pro',
'error_check.pro',
'find_replace.pro',
'utilities.pro',
'webls324.pro',
'xref.pro'],
'author.xrf').
To run it open the listener
?- consult(runaxrf). ?- main.
|
|
Copyright ©1995-2006 Amzi!
inc. All Rights Reserved. Privacy Policy.
Amzi!, KnowledgeWright and WebLS are registered
trademarks and Adventure in Prolog, Logic Server, Logic Explorer, Adventure
in Prolog and Subscription Plus are trademarks of Amzi! inc.