Annotation of OpenXM/src/kan96xx/Kan/smacro.sm1, Revision 1.4
1.4 ! takayama 1: %% $OpenXM: OpenXM/src/kan96xx/Kan/smacro.sm1,v 1.3 2004/05/13 05:33:10 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
127: [/v1 /v2] pushVariables
128: /v1 arg1 def /v2 arg2 def
129: [
130: [v1 aload pop v2 aload pop] /arg1 set
131: ] pop
132: popVariables
133: arg1
134: } def
135:
136: /n.map 0 def /i.map 0 def /ar.map 0 def /res.map 0 def %% declare variables
137: /map.old { %% recursive
138: /arg1.map set %% arg1.map = { }
139: /arg2.map set %% arg2.map = [ ]
140: %%%debug: /arg1.map load print arg2.map print
141: [n.map /com.map load i.map ar.map %% local variables. Don't push com!
142: %%It's better to use load for all variables.
143: /com.map /arg1.map load def
144: /ar.map arg2.map def %% set variables
145: /n.map ar.map length 1 sub def
146: [
147: 0 1 n.map {
148: /i.map set
149: << ar.map i.map get >> com.map
150: } for
151: ] /res.map set
152: /ar.map set /i.map set /com.map set /n.map set ] pop %% pop local variables
153: res.map %% push the result
154: } def
155:
156: /message {
157: [$PrintDollar$ [$PrintDollar$] system_variable
158: [$PrintDollar$ 0] system_variable pop
159: 4 -1 roll
160: print newline
161: ] system_variable pop
162: } def
163:
164: /messagen {
165: [$PrintDollar$ [$PrintDollar$] system_variable
166: [$PrintDollar$ 0] system_variable pop
167: 4 -1 roll
168: print
169: ] system_variable pop
170: } def
171:
172: /newline {
173: [$PrintDollar$ [$PrintDollar$] system_variable
174: [$PrintDollar$ 0] system_variable pop
175: 10 $string$ data_conversion print
176: ] system_variable pop
177: %% flush stdout
178: [(flush)] extension pop
179: } def
180:
181: /pushVariables {
182: { dup [ 3 1 roll load ] } map
183: } def
184:
185: /popVariables {
186: % dup print
187: { aload pop def } map pop
188: } def
189:
190:
191:
192: /timer {
193: [(TimerOn)] system_variable 1 eq
194: { [(TimerOn) 0] system_variable pop set_timer } { } ifelse
195: set_timer
196: exec
197: set_timer
198: } def
199:
200: /true 1 def
201:
202:
203:
204:
205: %%% prompter
206: ;
207:
208:
209:
210:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>