* changed the treatment of dynamic vs. static variable declaration with the same name(exprimental).
* added a little tool which displays a term structure as graph ('show term graph').
tswd
10 years ago
1122 | 1122 | (with-output-chaos-warning () |
1123 | 1123 | (princ "no current term to display.")))) |
1124 | 1124 | ("term" |
1125 | (let* ((target (if (not (equal (second dat) "tree")) | |
1125 | (let* ((target (if (not (or (equal (second dat) "tree") | |
1126 | (equal (second dat) "graph"))) | |
1126 | 1127 | (second dat) |
1127 | 1128 | nil)) |
1128 | 1129 | (tree? (if target |
1229 | 1230 | (princ " show [all] rules [<Modexp>] .") (terpri) |
1230 | 1231 | ;; (princ " show abbrev [<Modexp>] .") (terpri) |
1231 | 1232 | (princ " show tree") (terpri) |
1232 | (princ " show term [let-variable] [tree]") (terpri) | |
1233 | (princ " show term [let-variable] [tree | graph]") (terpri) | |
1233 | 1234 | (princ " show subterm [tree]") (terpri) |
1234 | 1235 | (princ " show let") (terpri) |
1235 | 1236 | (princ " show selection") (terpri) |
558 | 558 | (defun print-term-graph (tree &optional (show-sort nil) (stream *standard-output*)) |
559 | 559 | (!print-term-tree tree show-sort stream t)) |
560 | 560 | |
561 | (defun !print-term-tree (tree show-sort stream show-as-graph) | |
561 | (defun !print-term-tree (tree show-sort stream &optional (show-as-graph t)) | |
562 | 562 | (let* ((*show-sort* show-sort) |
563 | 563 | (leaf? |
564 | 564 | #'(lambda (tree) (or (term-is-variable? tree) |
222 | 222 | (setq res (list (info-for-special-builtins token)))) |
223 | 223 | ;; normal token |
224 | 224 | (t (setq res (dictionary-get-token-info (dictionary-table dictionary) |
225 | token)) | |
225 | token)) | |
226 | 226 | ;; blocked let variable? |
227 | 227 | ;; *TODO* |
228 | 228 | |
235 | 235 | (push (simple-copy-term-sharing-variables |
236 | 236 | val dictionary) |
237 | 237 | res))))) |
238 | ;;---- | |
239 | ;; (when res (return-from collect nil)) | |
240 | ;;---- | |
241 | ||
242 | 238 | ;; try other possiblities. |
243 | 239 | ;; variable ? |
244 | 240 | (let ((res2 (assoc (intern token) *parse-variables*))) |
252 | 248 | (t |
253 | 249 | ;; check sort qualified variable reference |
254 | 250 | ;; = on-the-fly (dynamic) variable declaration. |
255 | ;; | |
256 | 251 | (let ((q-pos (position #\: (the simple-string token) |
257 | 252 | :from-end t))) |
258 | 253 | (declare (type (or null fixnum) q-pos)) |
293 | 288 | (princ ".") |
294 | 289 | (terpri)))) |
295 | 290 | ;; |
291 | #|| | |
296 | 292 | (let ((gv (dictionary-get-token-info |
297 | 293 | (dictionary-table dictionary) |
298 | 294 | var-name))) |
302 | 298 | 'variable) |
303 | 299 | (with-output-chaos-error ('already-used-name) |
304 | 300 | (format t "~&on the fly variable name ~A is already used for static variable declaration..." var-name)))))) |
305 | ;; OK | |
301 | ||# | |
306 | 302 | (setq var-name (intern var-name)) |
303 | ||
307 | 304 | ;; success parsing it as a variable declaration. |
308 | 305 | ;; checks if there alredy a variable with the same |
309 | 306 | ;; name. |
315 | 312 | (unless (sort= (variable-sort (cdr old-var)) |
316 | 313 | sort) |
317 | 314 | (with-output-chaos-error () |
318 | (format t "on the fly variable ~A has been declared as sort ~A, but now being redefined as sort ~A.~%" | |
315 | (format t "variable ~A has been declared as sort ~A, but now being redefined as sort ~A.~%" | |
319 | 316 | (string var-name) |
320 | 317 | (string (sort-id |
321 | 318 | (variable-sort (cdr |
346 | 343 | *current-module*))) |
347 | 344 | ||# |
348 | 345 | ) |
349 | (progn | |
346 | (let ((svar (assoc var res :test #'equal))) | |
347 | (when *on-parse-debug* | |
348 | (format t "~%!res = ~s" res)) | |
349 | (when svar | |
350 | (with-output-chaos-error () | |
351 | (format t "Static variable ~s already used before in the same context" var-name))) | |
352 | ||
350 | 353 | (push var res) |
351 | 354 | #|| |
352 | 355 | (when (err-sort-p (variable-sort var)) |
443 | 446 | (when *on-parse-debug* |
444 | 447 | (format t "~& : sort constraint = ") |
445 | 448 | (print-chaos-object sort-constraint) |
446 | (format t "~& : result info = ") | |
449 | (format t "~& : result info = ~s" res) | |
447 | 450 | (print-chaos-object res)) |
448 | 451 | ;; (values (delete-duplicates res :test #'equal) (car mod-token)) |
449 | 452 | (values res (car mod-token)) |
1175 | 1178 | ;; Note: a variable is referenced by *ONE* token--always ! |
1176 | 1179 | ((variable builtin lisp-form normal-term) |
1177 | 1180 | ;; return a list of only one solution (precedence level is ): |
1181 | (when (eq (object-syntactic-type op-var) 'variable) | |
1182 | (push (cons (variable-name op-var) op-var) *parse-variables*)) | |
1178 | 1183 | (list (cons (cons op-var parser-min-precedence) token-list))) |
1179 | 1184 | |
1180 | 1185 | ;; 2. Antefix |
153 | 153 | (defun show-term (target tree?) |
154 | 154 | (when (and tree? |
155 | 155 | (not (equal tree? ".")) |
156 | (not (equal tree? "tree"))) | |
156 | (not (equal tree? "tree")) | |
157 | (not (equal tree? "graph"))) | |
157 | 158 | (with-output-chaos-warning () |
158 | 159 | (format t "unknown option for `show term' : ~a" tree?)) |
159 | 160 | (return-from show-term nil)) |
200 | 201 | )) |
201 | 202 | ;; (terpri) |
202 | 203 | (when (equal tree? "tree") |
203 | (print-term-tree target *chaos-verbose*))))) | |
204 | (print-term-tree target *chaos-verbose*)) | |
205 | (when (equal tree? "graph") | |
206 | (print-term-graph target *chaos-verbose*))))) | |
204 | 207 | |
205 | 208 | ;;; ************ |
206 | 209 | ;;; SHOW MOD ... |
1695 | 1695 | |
1696 | 1696 | PACKAGE=cafeobj |
1697 | 1697 | VERSION=1.4 |
1698 | VMINOR=.12Beta4 | |
1698 | VMINOR=.12Beta5 | |
1699 | 1699 | VMEMO=PigNose0.99 |
1700 | 1700 | PATCHLEVEL= |
1701 | 1701 |
5 | 5 | AC_PREREQ(2.4)dnl Required Autoconf version. |
6 | 6 | PACKAGE=cafeobj |
7 | 7 | VERSION=1.4 |
8 | VMINOR=.12Beta4 | |
8 | VMINOR=.12Beta5 | |
9 | 9 | VMEMO=PigNose0.99 |
10 | 10 | PATCHLEVEL= |
11 | 11 | AC_SUBST(PACKAGE) |
12 | 12 | (if (not (equal "" cafeobj-version-memo)) |
13 | 13 | (if (not (equal "" patch-level)) |
14 | 14 | (setq cafeobj-version-minor |
15 | (format nil ".12Beta4(~a,~A)" | |
15 | (format nil ".12Beta5(~a,~A)" | |
16 | 16 | cafeobj-version-memo |
17 | 17 | patch-level)) |
18 | 18 | (setq cafeobj-version-minor |
19 | (format nil ".12Beta4(~a)" cafeobj-version-memo))) | |
20 | (setq cafeobj-version-minor ".12Beta4")) | |
19 | (format nil ".12Beta5(~a)" cafeobj-version-memo))) | |
20 | (setq cafeobj-version-minor ".12Beta5")) | |
21 | 21 | (setq cafeobj-version (concatenate 'string |
22 | 22 | cafeobj-version-major |
23 | 23 | cafeobj-version-minor)) |