annotate lisp/psgml/psgml-debug.el @ 142:1856695b1fa9 r20-2b5

Import from CVS: tag r20-2b5
author cvs
date Mon, 13 Aug 2007 09:33:18 +0200
parents 131b0175ea99
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;;;\filename dump.el
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
2 ;;;\Last edited: Sun Mar 24 19:17:42 1996 by lenst@triton.lstaflin.pp.se (Lennart Staflin)
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 2
diff changeset
3 ;;;\RCS $Id: psgml-debug.el,v 1.1.1.1 1996/12/18 22:43:36 steve Exp $
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;;;\author {Lennart Staflin}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;;;\maketitle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;;\begin{codeseg}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 (provide 'psgml-debug)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 (require 'psgml)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 (require 'psgml-parse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 (require 'psgml-edit)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
12 (require 'psgml-dtd)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 (autoload 'sgml-translate-model "psgml-dtd" "" nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;;;; Debugging
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 (define-key sgml-mode-map "\C-c," 'sgml-goto-cache)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 (define-key sgml-mode-map "\C-c\C-x" 'sgml-dump-tree)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
19 (define-key sgml-mode-map "\C-c." 'sgml-shortref-identify)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 (defun sgml-this-element ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 (let ((tree (sgml-find-element-of (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 (sgml-dump-rec tree)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 (defun sgml-goto-cache ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 (setq sgml-dtd-info (sgml-pstate-dtd sgml-buffer-parse-state)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 sgml-top-tree (sgml-pstate-top-tree sgml-buffer-parse-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 (sgml-find-start-point (point))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
31 (message "%s" (sgml-dump-node sgml-current-tree)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 (defun sgml-dump-tree (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 (when arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (sgml-parse-to-here))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 (with-output-to-temp-buffer "*Dump*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (sgml-dump-rec (sgml-pstate-top-tree sgml-buffer-parse-state))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
40 (defun sgml-auto-dump ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
41 (let ((standard-output (get-buffer-create "*Dump*"))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
42 (cb (current-buffer)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
43
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
44 (when sgml-buffer-parse-state
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
45 (unwind-protect
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
46 (progn (set-buffer standard-output)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
47 (erase-buffer))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
48 (set-buffer cb))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
49
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
50 (sgml-dump-rec (sgml-pstate-top-tree sgml-buffer-parse-state))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
51
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
52 ))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
53 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
54
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
55 (defun sgml-start-auto-dump ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
56 (interactive)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
57 (add-hook 'post-command-hook
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
58 (function sgml-auto-dump)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
59 'append))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
60
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (defun sgml-comepos (epos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (if (sgml-strict-epos-p epos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (format "%s:%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (sgml-entity-name (sgml-eref-entity (sgml-epos-eref epos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (sgml-epos-pos epos))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (format "%s" epos)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
68 (defun sgml-dump-node (u)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
69 (format
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
70 "%s%s start:%s(%s) end:%s(%s) epos:%s/%s net:%s\n"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
71 (make-string (sgml-tree-level u) ?. )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
72 (sgml-element-gi u)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
73 (sgml-element-start u) (sgml-tree-stag-len u)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
74 (if (sgml-tree-etag-epos u) (sgml-tree-end u)) (sgml-tree-etag-len u)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
75 (sgml-comepos (sgml-tree-stag-epos u))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
76 (sgml-comepos (sgml-tree-etag-epos u))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
77 (sgml-tree-net-enabled u)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
78
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (defun sgml-dump-rec (u)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (while u
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
81 (princ (sgml-dump-node u))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (sgml-dump-rec (sgml-tree-content u))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 (setq u (sgml-tree-next u))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
84
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
85 (defun sgml-shortref-identify ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
86 (interactive)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
87 (sgml-find-context-of (point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
88 (let* ((nobol (eq (point) sgml-rs-ignore-pos))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
89 (tem (sgml-deref-shortmap sgml-current-shortmap nobol)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
90 (message "%s (%s)" tem nobol)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
91
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
92 (defun sgml-lookup-shortref-name (table map)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
93 (car (rassq map (cdr table))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
94
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
95 (defun sgml-show-current-map ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
96 (interactive)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
97 (sgml-find-context-of (point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
98 (let ((name (sgml-lookup-shortref-name
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
99 (sgml-dtd-shortmaps sgml-dtd-info)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
100 sgml-current-shortmap)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
101 (message "Current map: %s"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
102 (or name "#EMPTY"))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;;; For edebug
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;(put 'when 'edebug-form-hook t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;(put 'unless 'edebug-form-hook t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;;(put 'push 'edebug-form-hook '(form sexp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;(put 'setf 'edebug-form-hook '(sexp form))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
111 (setq edebug-print-level 3
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
112 edebug-print-length 5
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
113 edebug-print-circle nil
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
114 )
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
115
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (eval-when (load)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
117 (unless sgml-running-xemacs
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
118 (def-edebug-spec sgml-with-parser-syntax (&rest form))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
119 (def-edebug-spec sgml-skip-upto (sexp))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
120 (def-edebug-spec sgml-check-delim (sexp &optional sexp))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
121 (def-edebug-spec sgml-parse-delim (sexp &optional sexp))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
122 (def-edebug-spec sgml-is-delim (sexp &optional sexp sexp sexp))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;;;; dump
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (defun sgml-dump-dtd (&optional dtd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (interactive )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (unless dtd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (setq dtd (sgml-pstate-dtd sgml-buffer-parse-state)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 (with-output-to-temp-buffer "*DTD dump*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (princ (format "Dependencies: %S\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (sgml-dtd-dependencies dtd)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (loop for et being the symbols of (sgml-dtd-eltypes dtd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 do (sgml-dp-element et))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (defun sgml-dump-element (el-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (list (completing-read "Element: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (sgml-dtd-eltypes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (sgml-pstate-dtd sgml-buffer-parse-state))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (with-output-to-temp-buffer "*Element dump*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (sgml-dp-element (sgml-lookup-eltype el-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defun sgml-dp-element (el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ((sgml-eltype-defined el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 (princ (format "Element %s %s %s%s:\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 (sgml-eltype-name el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (if (sgml-eltype-stag-optional el) "O" "-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (if (sgml-eltype-etag-optional el) "O" "-")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (if (sgml-eltype-mixed el) " mixed" "")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ((sgml-model-group-p (sgml-eltype-model el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (sgml-dp-model (sgml-eltype-model el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (prin1 (sgml-eltype-model el))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (terpri)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (princ (format "Exeptions: +%S -%S\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (sgml-eltype-includes el)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (sgml-eltype-excludes el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (princ (format "Attlist: %S\n" (sgml-eltype-attlist el)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (princ (format "Plist: %S\n" (symbol-plist el))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (princ (format "Undefined element %s\n" (sgml-eltype-name el)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (terpri))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (defun sgml-dp-model (model &optional indent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (or indent (setq indent 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (let ((sgml-code-xlate (sgml-translate-model model)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 for i from 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 for x in sgml-code-xlate do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (cond ((sgml-normal-state-p (car x))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (princ (format "%s%d: opts=%s reqs=%s\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (make-string indent ? ) i
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (sgml-untangel-moves (sgml-state-opts (car x)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (sgml-untangel-moves (sgml-state-reqs (car x))))))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
180 (t ; and-node
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
181 (princ (format "%s%d: and-node next=%d\n"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (make-string indent ? ) i
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
183 (sgml-code-xlate (sgml-and-node-next (car x)))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
184 (loop for m in (sgml-and-node-dfas (car x))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 do (sgml-dp-model m (+ indent 2))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (defun sgml-untangel-moves (moves)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 (loop for m in moves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 collect (list (sgml-move-token m)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (sgml-code-xlate (sgml-move-dest m)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
193 ;;;; Dump state
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
194
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
195 (defun sgml-dump-state ()
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
196 (interactive)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
197 (with-output-to-temp-buffer "*State dump*"
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
198 (sgml-dp-state sgml-current-state)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
199
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
200 (defun sgml-dp-state (state &optional indent)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
201 (or indent (setq indent 0))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
202 (cond
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
203 ((sgml-normal-state-p state)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
204 (sgml-dp-model state indent))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
205 (t
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
206 (princ (format "%sand-state\n" (make-string indent ? )))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
207 (sgml-dp-state (sgml-and-state-substate state) (+ 2 indent))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
208 (princ (format "%s--next\n" (make-string indent ? )))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
209 (sgml-dp-state (sgml-and-state-next state) (+ 2 indent))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
210 (princ (format "%s--dfas\n" (make-string indent ? )))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
211 (loop for m in (sgml-and-state-dfas state)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
212 do (sgml-dp-model m (+ indent 2))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
213 (princ (format "%s--\n" (make-string indent ? )))))))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
214
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
215
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;;;; Build autoloads for all interactive functions in psgml-parse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 (defun sgml-build-autoloads ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (with-output-to-temp-buffer "*autoload*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 for file in '("psgml-parse" "psgml-edit" "psgml-dtd"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 "psgml-info" "psgml-charent")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (set-buffer (find-file-noselect (concat file ".el")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (while (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (re-search-forward "^(defun +\\([^ ]+\\)" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (let ((name (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (forward-sexp 1) ; skip argument list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (skip-chars-forward " \n\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (when (eq ?\" (following-char)) ; doc string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (setq doc (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (progn (forward-sexp 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (skip-chars-forward " \n\t")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (when (looking-at "(interactive")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (if (null doc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (message "No doc for %s" name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (princ (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 "(autoload '%s \"%s\" %s t)\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 name file doc))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 ;;;; Test psgml with sgmls test cases
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (defun test-sgml (start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (interactive "p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (let (file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (sgml-show-warnings t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (with-output-to-temp-buffer "*Testing psgml*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (setq file (format "/usr/local/src/sgmls-1.1/test/test%03d.sgm"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (file-exists-p file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (princ (format "*** File test%03d ***\n" start))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (find-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (condition-case errcode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (sgml-parse-prolog)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;;(sgml-next-trouble-spot)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (sgml-parse-until-end-of nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (princ errcode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (terpri)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (if (get-buffer sgml-log-buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (princ (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (set-buffer sgml-log-buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (buffer-string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (terpri)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (setq start (1+ start))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;;;; Profiling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (defun profile-sgml (&optional file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (interactive)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
285 (or file (setq file (expand-file-name "~/src/psgml/0/test/shortref.sgml")))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (find-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (sgml-need-dtd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (sgml-instrument-parser)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (elp-reset-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (dotimes (i 20)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (garbage-collect)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (sgml-reparse-buffer (function sgml-handle-shortref)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (elp-results))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (defun sgml-instrument-parser ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (require 'elp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (setq elp-function-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (elp-restore-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (setq elp-function-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 sgml-parse-to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 sgml-parser-loop
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 sgml-parse-markup-declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 sgml-do-processing-instruction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 sgml-pop-entity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 sgml-tree-net-enabled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 sgml-do-end-tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 sgml-do-data
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 sgml-deref-shortmap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 sgml-handle-shortref
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 sgml-do-start-tag
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 sgml-do-general-entity-ref
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 sgml-set-face-for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 sgml-pcdata-move
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 sgml-shortmap-skipstring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (elp-instrument-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (defun sgml-instrument-dtd-parser ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (require 'elp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (setq elp-function-list nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (elp-restore-all)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (setq elp-function-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 '(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 sgml-parse-prolog
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 sgml-skip-ds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 sgml-parse-markup-declaration
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 sgml-check-doctype-body
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 sgml-check-dtd-subset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 sgml-parse-ds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 sgml-declare-attlist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 sgml-declare-entity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 sgml-declare-element
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 sgml-declare-shortref
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 sgml-parse-parameter-literal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 sgml-check-element-type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 sgml-check-primitive-content-token
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 sgml-check-model-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;; In sgml-check-model-group
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 sgml-parse-modifier
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 sgml-make-pcdata
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 sgml-skip-ts
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 sgml-make-opt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 sgml-make-*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 sgml-make-+
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 sgml-reduce-,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 sgml-reduce-|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 sgml-make-&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 sgml-make-conc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 sgml-copy-moves
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 ;; is ps*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 sgml-do-parameter-entity-ref
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 sgml-make-primitive-content-token
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 sgml-push-to-entity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 sgml-lookup-entity
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 sgml-lookup-eltype
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 sgml-one-final-state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 sgml-remove-redundant-states-1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (elp-instrument-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 ;¤¤\end{codeseg}