Summary
###########################################################################
File: image.icn
Subject: Procedures to produce images of Icon values
Authors: Michael Glass, Ralph E. Griswold, and David Yost
Date: May 2, 2001
###########################################################################
This file is in the public domain.
###########################################################################
The procedure Image(x,style) produces a string image of the value x.
The value produced is a generalization of the value produced by
the Icon function image(x), providing detailed information about
structures. The value of style determines the formatting and
order of processing:
1 indented, with ] and ) at end of last item (default)
2 indented, with ] and ) on new line
3 puts the whole image on one line
4 as 3, but with structures expanded breadth-first instead of
depth-first as for other styles.
###########################################################################
Tags are used to uniquely identify structures. A tag consists
of a letter identifying the type followed by an integer. The tag
letters are L for lists, R for records, S for sets, and T for
tables. The first time a structure is encountered, it is imaged
as the tag followed by a colon, followed by a representation of
the structure. If the same structure is encountered again, only
the tag is given.
An example is
a := ["x"]
push(a,a)
t := table()
push(a,t)
t[a] := t
t["x"] := []
t[t] := a
write(Image(t))
which produces
T1:[
"x"->L1:[],
L2:[
T1,
L2,
"x"]->T1,
T1->L2]
On the other hand, Image(t,3) produces
T1:["x"->L1:[],L2:[T1,L2,"x"]->T1,T1->L2]
Note that a table is represented as a list of entry and assigned
values separated by ->.
###########################################################################
Problem:
The procedure here really is a combination of an earlier version and
two modifications to it. It should be re-organized to combine the
presentation style and order of expansion.
Bug:
Since the table of structures used in a call to Image is local to
that call, but the numbers used to generate unique tags are static to
the procedures that generate tags, the same structure gets different
tags in different calls of Image.
###########################################################################
Procedures:
Image, Imageb, Limage, Rimage, Simage, Timage, defer_image, do_image, endof, limageb, rimageb, simageb, tagit, timageb
This file is part of the (main) package.
Source code.
Image(x, style, done, depth, nonewline)
Imageb(x, done, tags)
Limage(a, done, depth, style)
list image
Rimage(x, done, depth, style)
record image
Simage(S, done, depth, style)
set image
Timage(t, done, depth, style)
table image
defer_image(a, done, tags)
Every component sub-structure of the current structure gets tagged
and added to a pseudo-done set.
do_image(a, done, tags)
Create the image of every component of the current structure.
Sub-structures get deleted from the local pseudo-done set before
we actually create their image.
endof(s, depth, style)
limageb(a, done, tags)
list image
rimageb(x, done, tags)
record image
simageb(S, done, tags)
set image
tagit(x, tags)
Create and return a tag for a structure, and save it in tags[x].
Otherwise, if x is not a structure, return image(x).
timageb(t, done, tags)
table image
This page produced by UniDoc on 2021/04/15 @ 23:59:54.