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