Annotation of OpenXM/src/kan96xx/Kan/smacro.sm1, Revision 1.1.1.1
1.1 maekawa 1:
2: %%%%%% global control variables
3: %% /@@@.quiet 0 def It is defined in scanner().
4: /@@@.Dsymbol (D) def
5: /@@@.diffEsymbol (E) def
6: /@@@.Qsymbol (Q) def
7: /@@@.hsymbol (h) def
8: /@@@.esymbol (e_) def
9: /@@@.Esymbol (E) def
10:
11: %%% pointer to the StandardContext.
12: /StandardContextp [(CurrentContextp)] system_variable def
13: /null 0 (null) data_conversion def
14:
15: %%%%%%%%%%%%%%%%%%%%%% usages %%%%%%%%%%%%%%%%%%%%
16: /@.usages [[( ) [(gate keeper)]] ] def
17: /putUsages {
18: /arg1 set
19: /@.usages @.usages [ arg1 ] join def
20: } def
21:
22: /showKeywords {
23: @.usages { 0 get } map shell @@@.printSVector
24: ( ) message
25: } def
26:
27: /usage {
28: /arg1 set
29: [/name /flag /n /k /slist /m /i] pushVariables
30: [
31: /name arg1 def
32: /flag true def
33: @.usages length /n set
34: 0 1 << n 1 sub >>
35: {
36: /k set
37: name << @.usages k get 0 get >> eq
38: {
39: /slist @.usages k get 1 get def
40: /m slist length def
41: 0 1 << m 1 sub >> {
42: /i set
43: slist i get message
44: } for
45: /flag false def
46: }
47: { }
48: ifelse
49: } for
50:
51: flag
52: {name Usage}
53: { }
54: ifelse
55: ] pop
56: popVariables
57: } def
58:
59:
60: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61:
62: /; %%% prompt of the sm1
63: { [ $PrintDollar$ [$PrintDollar$] system_variable %% save value
64: [$PrintDollar$ 0] system_variable pop
65: @@@.quiet 0 eq
66: {$sm1>$ print} { } ifelse
67: ] system_variable pop
68: } def
69:
70: /?
71: {
72: show_systemdictionary
73: (-- ?? : to see macro dictionary --)
74: message
75: $-- (keyWord) usage to see the usages. Data type of (xxxyyy) is string.--$
76: message
77: $Main data types: 1:integer(machine integer), 2:literal, 5:string, 6:array,$
78: message
79: $ 7:poly, 13:file, 14:ring, 15:number(bignum,universalNumber), 16:rational, 17:class. $ message
80:
81: } def
82:
83: /??
84: { (------------ Macros ------------------------------------------------)
85: message
86: showKeywords
87: $------------ Use (keyWord) usage to see the usages. ---------------$
88: message
89: } def
90:
91: /::
92: {
93: print newline ;
94: } def
95:
96: /. {expand} def
97:
98: /, { } def
99:
100: /false 0 def
101:
102: %% You cannot use the variable arg1 in expand.
103: /expand {
104: /@@@expand.arg1 set
105: [/in-expand /f-expand /f-ans] pushVariables
106: [
107: /f-expand @@@expand.arg1 def
108: f-expand isArray {
109: f-expand { expand } map /f-ans set
110: }{
111: f-expand $poly$ data_conversion /f-ans set
112: } ifelse
113: /@@@expand.arg1 f-ans def
114: ] pop
115: popVariables
116: @@@expand.arg1
117: } def
118:
119: /<< { } def
120: />> { } def
121:
122: % v1 v2 join
123: /join {
124: /arg2 set /arg1 set
125: [/v1 /v2] pushVariables
126: /v1 arg1 def /v2 arg2 def
127: [
128: [v1 aload pop v2 aload pop] /arg1 set
129: ] pop
130: popVariables
131: arg1
132: } def
133:
134: /n.map 0 def /i.map 0 def /ar.map 0 def /res.map 0 def %% declare variables
135: /map.old { %% recursive
136: /arg1.map set %% arg1.map = { }
137: /arg2.map set %% arg2.map = [ ]
138: %%%debug: /arg1.map load print arg2.map print
139: [n.map /com.map load i.map ar.map %% local variables. Don't push com!
140: %%It's better to use load for all variables.
141: /com.map /arg1.map load def
142: /ar.map arg2.map def %% set variables
143: /n.map ar.map length 1 sub def
144: [
145: 0 1 n.map {
146: /i.map set
147: << ar.map i.map get >> com.map
148: } for
149: ] /res.map set
150: /ar.map set /i.map set /com.map set /n.map set ] pop %% pop local variables
151: res.map %% push the result
152: } def
153:
154: /message {
155: [$PrintDollar$ [$PrintDollar$] system_variable
156: [$PrintDollar$ 0] system_variable pop
157: 4 -1 roll
158: print newline
159: ] system_variable pop
160: } def
161:
162: /messagen {
163: [$PrintDollar$ [$PrintDollar$] system_variable
164: [$PrintDollar$ 0] system_variable pop
165: 4 -1 roll
166: print
167: ] system_variable pop
168: } def
169:
170: /newline {
171: [$PrintDollar$ [$PrintDollar$] system_variable
172: [$PrintDollar$ 0] system_variable pop
173: 10 $string$ data_conversion print
174: ] system_variable pop
175: %% flush stdout
176: [(flush)] extension pop
177: } def
178:
179: /pushVariables {
180: { dup [ 3 1 roll load ] } map
181: } def
182:
183: /popVariables {
184: % dup print
185: { aload pop def } map pop
186: } def
187:
188:
189:
190: /timer {
191: [(TimerOn)] system_variable 1 eq
192: { [(TimerOn) 0] system_variable pop set_timer } { } ifelse
193: set_timer
194: exec
195: set_timer
196: } def
197:
198: /true 1 def
199:
200:
201:
202:
203: %%% prompter
204: ;
205:
206:
207:
208:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>