Annotation of OpenXM/src/kan96xx/Kan/smacro.sm1, Revision 1.6
1.6 ! takayama 1: %% $OpenXM: OpenXM/src/kan96xx/Kan/smacro.sm1,v 1.5 2004/09/09 03:14:46 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:
101: /false 0 def
102:
103: %% You cannot use the variable arg1 in expand.
104: /expand {
105: /@@@expand.arg1 set
106: [/in-expand /f-expand /f-ans] pushVariables
107: [
108: /f-expand @@@expand.arg1 def
109: f-expand isArray {
110: f-expand { expand } map /f-ans set
111: }{
112: f-expand $poly$ data_conversion /f-ans set
113: } ifelse
114: /@@@expand.arg1 f-ans def
115: ] pop
116: popVariables
117: @@@expand.arg1
118: } def
119:
120: /<< { } def
121: />> { } def
122:
123: % v1 v2 join
124: /join {
125: /arg2 set /arg1 set
1.5 takayama 126: [(Kjoin) arg1 arg2] extension
1.1 maekawa 127: } def
128:
129: /n.map 0 def /i.map 0 def /ar.map 0 def /res.map 0 def %% declare variables
130: /map.old { %% recursive
131: /arg1.map set %% arg1.map = { }
132: /arg2.map set %% arg2.map = [ ]
133: %%%debug: /arg1.map load print arg2.map print
134: [n.map /com.map load i.map ar.map %% local variables. Don't push com!
135: %%It's better to use load for all variables.
136: /com.map /arg1.map load def
137: /ar.map arg2.map def %% set variables
138: /n.map ar.map length 1 sub def
139: [
140: 0 1 n.map {
141: /i.map set
142: << ar.map i.map get >> com.map
143: } for
144: ] /res.map set
145: /ar.map set /i.map set /com.map set /n.map set ] pop %% pop local variables
146: res.map %% push the result
147: } def
148:
149: /message {
150: [$PrintDollar$ [$PrintDollar$] system_variable
151: [$PrintDollar$ 0] system_variable pop
152: 4 -1 roll
153: print newline
154: ] system_variable pop
155: } def
156:
157: /messagen {
158: [$PrintDollar$ [$PrintDollar$] system_variable
159: [$PrintDollar$ 0] system_variable pop
160: 4 -1 roll
161: print
162: ] system_variable pop
163: } def
164:
165: /newline {
166: [$PrintDollar$ [$PrintDollar$] system_variable
167: [$PrintDollar$ 0] system_variable pop
168: 10 $string$ data_conversion print
169: ] system_variable pop
170: %% flush stdout
171: [(flush)] extension pop
172: } def
173:
174: /pushVariables {
175: { dup [ 3 1 roll load ] } map
176: } def
177:
178: /popVariables {
179: % dup print
180: { aload pop def } map pop
181: } def
182:
183:
184:
185: /timer {
186: [(TimerOn)] system_variable 1 eq
187: { [(TimerOn) 0] system_variable pop set_timer } { } ifelse
188: set_timer
189: exec
190: set_timer
191: } def
192:
193: /true 1 def
194:
195:
196:
197:
198: %%% prompter
199: ;
200:
201:
202:
203:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>