Codebase list cafeobj / b2788c6
* 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
7 changed file(s) with 29 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
11221122 (with-output-chaos-warning ()
11231123 (princ "no current term to display."))))
11241124 ("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")))
11261127 (second dat)
11271128 nil))
11281129 (tree? (if target
12291230 (princ " show [all] rules [<Modexp>] .") (terpri)
12301231 ;; (princ " show abbrev [<Modexp>] .") (terpri)
12311232 (princ " show tree") (terpri)
1232 (princ " show term [let-variable] [tree]") (terpri)
1233 (princ " show term [let-variable] [tree | graph]") (terpri)
12331234 (princ " show subterm [tree]") (terpri)
12341235 (princ " show let") (terpri)
12351236 (princ " show selection") (terpri)
558558 (defun print-term-graph (tree &optional (show-sort nil) (stream *standard-output*))
559559 (!print-term-tree tree show-sort stream t))
560560
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))
562562 (let* ((*show-sort* show-sort)
563563 (leaf?
564564 #'(lambda (tree) (or (term-is-variable? tree)
222222 (setq res (list (info-for-special-builtins token))))
223223 ;; normal token
224224 (t (setq res (dictionary-get-token-info (dictionary-table dictionary)
225 token))
225 token))
226226 ;; blocked let variable?
227227 ;; *TODO*
228228
235235 (push (simple-copy-term-sharing-variables
236236 val dictionary)
237237 res)))))
238 ;;----
239 ;; (when res (return-from collect nil))
240 ;;----
241
242238 ;; try other possiblities.
243239 ;; variable ?
244240 (let ((res2 (assoc (intern token) *parse-variables*)))
252248 (t
253249 ;; check sort qualified variable reference
254250 ;; = on-the-fly (dynamic) variable declaration.
255 ;;
256251 (let ((q-pos (position #\: (the simple-string token)
257252 :from-end t)))
258253 (declare (type (or null fixnum) q-pos))
293288 (princ ".")
294289 (terpri))))
295290 ;;
291 #||
296292 (let ((gv (dictionary-get-token-info
297293 (dictionary-table dictionary)
298294 var-name)))
302298 'variable)
303299 (with-output-chaos-error ('already-used-name)
304300 (format t "~&on the fly variable name ~A is already used for static variable declaration..." var-name))))))
305 ;; OK
301 ||#
306302 (setq var-name (intern var-name))
303
307304 ;; success parsing it as a variable declaration.
308305 ;; checks if there alredy a variable with the same
309306 ;; name.
315312 (unless (sort= (variable-sort (cdr old-var))
316313 sort)
317314 (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.~%"
319316 (string var-name)
320317 (string (sort-id
321318 (variable-sort (cdr
346343 *current-module*)))
347344 ||#
348345 )
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
350353 (push var res)
351354 #||
352355 (when (err-sort-p (variable-sort var))
443446 (when *on-parse-debug*
444447 (format t "~& : sort constraint = ")
445448 (print-chaos-object sort-constraint)
446 (format t "~& : result info = ")
449 (format t "~& : result info = ~s" res)
447450 (print-chaos-object res))
448451 ;; (values (delete-duplicates res :test #'equal) (car mod-token))
449452 (values res (car mod-token))
11751178 ;; Note: a variable is referenced by *ONE* token--always !
11761179 ((variable builtin lisp-form normal-term)
11771180 ;; 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*))
11781183 (list (cons (cons op-var parser-min-precedence) token-list)))
11791184
11801185 ;; 2. Antefix
153153 (defun show-term (target tree?)
154154 (when (and tree?
155155 (not (equal tree? "."))
156 (not (equal tree? "tree")))
156 (not (equal tree? "tree"))
157 (not (equal tree? "graph")))
157158 (with-output-chaos-warning ()
158159 (format t "unknown option for `show term' : ~a" tree?))
159160 (return-from show-term nil))
200201 ))
201202 ;; (terpri)
202203 (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*)))))
204207
205208 ;;; ************
206209 ;;; SHOW MOD ...
16951695
16961696 PACKAGE=cafeobj
16971697 VERSION=1.4
1698 VMINOR=.12Beta4
1698 VMINOR=.12Beta5
16991699 VMEMO=PigNose0.99
17001700 PATCHLEVEL=
17011701
55 AC_PREREQ(2.4)dnl Required Autoconf version.
66 PACKAGE=cafeobj
77 VERSION=1.4
8 VMINOR=.12Beta4
8 VMINOR=.12Beta5
99 VMEMO=PigNose0.99
1010 PATCHLEVEL=
1111 AC_SUBST(PACKAGE)
1212 (if (not (equal "" cafeobj-version-memo))
1313 (if (not (equal "" patch-level))
1414 (setq cafeobj-version-minor
15 (format nil ".12Beta4(~a,~A)"
15 (format nil ".12Beta5(~a,~A)"
1616 cafeobj-version-memo
1717 patch-level))
1818 (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"))
2121 (setq cafeobj-version (concatenate 'string
2222 cafeobj-version-major
2323 cafeobj-version-minor))