[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Readable Prolog tracing



The usual printing routine for arguments to spied Prolog predicates
displays lists and terms in some incomprehensible notation I still
haven't figured out.  I altered the tracing routines in
>prolog>trace.lisp to use the write predicate, which makes things nice
and readable.  These changes make it a whole lot easier to use Symbolics
Prolog.

--David Gadbois
--cgs.gadbois@r20.utexas.edu

____________________________

;;; -*- Mode: LISP; Syntax: Common-Lisp; Package: Prolog-Compiler; Lowercase: T -*-


(defun prolog-call-trace (functor args)
  (send *terminal-io* :fresh-line)
  (loop repeat *trace-level* do (send *terminal-io* :string-out " "))
  (incf *trace-level*)
  (send *terminal-io* :string-out "CALL: ")
  (send *terminal-io* :string-out (string functor))
  (loop for arg in args
	do (send *terminal-io* :string-out " ")
	   ;; Use prolog-write instead of prolog-lisp-print-internal
	   (prolog-write arg))
  (send *terminal-io* :fresh-line))

(defun prolog-redo-trace (functor args)
  (send *terminal-io* :fresh-line)
  (loop repeat *trace-level* do (send *terminal-io* :string-out " "))
; The following form was in the source code, but apparently not in the
; compiled code, since the indentation of tracing is correct.
;  (incf *trace-level*)
  (send *terminal-io* :string-out "REDO: ")
  (send *terminal-io* :string-out (string functor))
  (loop for arg in args
	do (send *terminal-io* :string-out " ")
	   ;; Use prolog-write instead of prolog-lisp-print-internal
	   (prolog-write arg))
  (send *terminal-io* :fresh-line))

(defun prolog-fail-trace (functor args)
  (send *terminal-io* :fresh-line)
  (decf *trace-level*)
  (loop repeat *trace-level* do (send *terminal-io* :string-out " "))
  (send *terminal-io* :string-out "FAIL: ")
  (send *terminal-io* :string-out (string functor))
  (loop for arg in args
	do (send *terminal-io* :string-out " ")
	   ;; Use prolog-write instead of prolog-lisp-print-internal
	   (prolog-write arg))
  (send *terminal-io* :fresh-line))

(defun prolog-exit-trace (functor args)
  (send *terminal-io* :fresh-line)
  (decf *trace-level*)
  (loop repeat *trace-level* do (send *terminal-io* :string-out " "))
  (send *terminal-io* :string-out "EXIT: ")
  (send *terminal-io* :string-out (string functor))
  (loop for arg in args
	do (send *terminal-io* :string-out " ")
	   ;; Use prolog-write instead of prolog-lisp-print-internal
	   (prolog-write arg))
  (send *terminal-io* :fresh-line))
-------