Annotation of OpenXM/src/kan96xx/Doc/xml.sm1, Revision 1.9
1.9 ! takayama 1: %% $OpenXM: OpenXM/src/kan96xx/Doc/xml.sm1,v 1.8 2000/02/28 14:10:29 takayama Exp $
1.1 takayama 2: %% xml.sm1 XML support for sm1.
3: %% This package requires ox.sm1
1.9 ! takayama 4: [(ostype)] extension 0 get (windows) eq {
! 5: [(parse) (ox-win.sm1) pushfile] extension
! 6: }{
! 7: [(parse) (ox.sm1) pushfile] extension
! 8: } ifelse
1.4 takayama 9: (xml.sm1 : 1999, 11/20 Sat) message
1.1 takayama 10: %%%%% These should be under /usr/local/OpenXM or OpenXM_HOME
11: /oxpath.java-support (lib/java-support) def
1.6 takayama 12: /@@@.xml null def
1.1 takayama 13:
14: [(getenv) (OpenXM_HOME)] extension
15: tag 0 eq {
16: /oxpath.java-support [(/usr/local/OpenXM/) oxpath.java-support] cat def
17: } {
18: /oxpath.java-support [ [(getenv) (OpenXM_HOME)] extension (/) oxpath.java-support] cat def
19: } ifelse
20:
21: /xmlconnect {
22: [/in-xmlconnect /data /control /com] pushVariables
23: [
24: /data [(oxGenPass)] extension def
25: /control [(oxGenPass)] extension def
26: [data control] message
27: [(tdiv_qr) data .. (2000)..] mpzext 1 get (integer) dc 1025 add /data set
28: [(tdiv_qr) control .. (2000)..] mpzext 1 get (integer) dc 1025 add /control set
29:
30: [$($ ( cd ) oxpath.java-support ( ; )
1.3 takayama 31: %% (/bin/csh -c ")
1.1 takayama 32: ( java OMproxy )
33: ( -data ) data ( -control ) control
1.3 takayama 34: %% ( >& /dev/null ) %% Syntax error: Bad fd
35: ( > /dev/null )
36: %% (")
1.1 takayama 37: $)$
38: ( & )
39: ] cat /com set
40: (Executing the command ) messagen com message
41: com system
42: (sleep 5) system
43: [(oxCreateClient) (localhost) data control] extension
44: /@@@.xml set
45: (The server is binded to the variable @@@.xml) message
46: @@@.xml /arg1 set
47: ] pop
48: popVariables
49: arg1
50: } def
51:
52: /xml {
53: /arg1 set
54: [/in-cmo2xml /ob] pushVariables
55: [
56: /ob arg1 def
1.6 takayama 57: @@@.xml tag 0 eq {
58: xmlconnect
59: }{ } ifelse
1.1 takayama 60: @@@.xml ob oxpushcmo
1.7 takayama 61: @@@.xml 1 oxpushcmo
1.1 takayama 62: @@@.xml (CMO2OMXML) oxexec
63: @@@.xml oxpopcmo /arg1 set
64: ] pop
65: popVariables
66: arg1
67: } def
68: [(xml)
69: [(object xml xml-string)
70: (Example: )
71: ( xmlconnect )
72: $ (12345).. xml :: $
73: $ ( (x-1)^2 ). xml :: $
1.2 takayama 74: ]] putUsages
75:
76: /xml_to_cmo {
77: /arg1 set
78: [/in-xml_to_cmo /ob] pushVariables
79: [
80: /ob arg1 def
1.6 takayama 81: @@@.xml tag 0 eq {
82: xmlconnect
83: }{ } ifelse
1.2 takayama 84: @@@.xml ob oxpushcmo
1.7 takayama 85: @@@.xml 1 oxpushcmo
1.2 takayama 86: @@@.xml (OMXML2CMO) oxexec
87: @@@.xml oxpopcmo /arg1 set
88: ] pop
89: popVariables
90: arg1
91: } def
92: [(xml_to_cmo)
93: [(xml-string xml_to_cmo cmo)
94: (Example: )
95: ( xmlconnect )
96: $ (<OMOBJ><OMI>5</OMI></OMOBJ>) xml_to_cmo :: $
97: $ ( (x-1)^2 ). xml /aa set $
98: $ aa xml_to_cmo :: $
1.1 takayama 99: ]] putUsages
100:
1.3 takayama 101:
102: /t_aux {
103: /arg1 set
104: [/in-t_aux /ob /r /r2] pushVariables
105: [
106: /ob arg1 def
107: (_______________________________________) message
108: (tag = ) messagen ob tag messagen (, ) messagen
109: (Sending object :) messagen ob message
110: ob xml /r set
111: (XML expression is:) messagen r message
112: r xml_to_cmo /r2 set
113: (XML to CMO :) messagen r2 message
114: (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) message
115: ] pop
116: popVariables
117: } def
118:
119: %% Just type in OMproxy-testsuits1
120: /OMproxy-testsuits1 {
121: xmlconnect
122:
123: @@@.xml oxmathcap
124: (Mathcap is ) messagen @@@.xml message
125:
126: null t_aux
127: 123 t_aux
1.4 takayama 128: (Hello World) t_aux %% was error in XML to CMO.
1.3 takayama 129: % [1 2 3] t_aux %% not supported.
130: (123123).. t_aux
131: % (-12).. (12345).. div t_aux %% not supported in sm1.
1.4 takayama 132: (x^2-1). t_aux %% was not supported. CMO_DMS_GENERIC??
1.3 takayama 133:
134: (End) message
135: } def
1.1 takayama 136:
1.4 takayama 137: /cmoTreeToPostfix {
138: /arg1 set
139: [/in-cmoTreeToPostfix /in /ans /dic] pushVariables
140: [
141: /in arg1 def
142: in etag 263 eq not
143: { /ans in toStringForParse def }
144: {
145: in (array) dc /in set
146: /dic in 1 get def
147: %% concatenate the dictionary name to the function name.
148: /ans in 2 get { cmoTreeToPostfix } map toString def
149: [ ans ( ) in 0 get (_) dic] cat /ans set
150: } ifelse
151: /arg1 ans def
152: ] pop
153: popVariables
154: arg1
155: } def
156:
157: [(cmoTreeToPostfix)
158: [(tree-obj cmoTreeToPostfix postfix-str)
1.8 takayama 159: $Example 1: [(plus) (basic) [(123).. (345)..]] [(class) (tree)] dc /ff set$
1.4 takayama 160: $ ff cmoTreeToPostfix /gg set $
161: $ [(parse) gg] extension pop :: $
162: $Example 2: ( (x-T-2)^5). /p set $
163: $ p [(class) (recursivePolynomial)] dc xml /ff set $
164: $ ff xml_to_cmo cmoTreeToPostfix /gg set $
165: $ [(parse) gg] extension pop p sub :: $
166: ]] putUsages
167:
168: /toStringForParse {
169: /arg1 set
170: [/in-toStringForParse /f /ans] pushVariables
171: [
172: /f arg1 def
173: f isUniversalNumber {
174: /ans [ $ ($ f toString $).. $] cat def
175: /@@@.LLL goto
176: } { } ifelse
177: f isPolynomial {
178: /ans [ $ ($ f toString $). $] cat def
179: /@@@.LLL goto
180: } { } ifelse
181: f etag 262 eq { %% indeterminate
182: /ans [ $ ($ f (string) dc toString $). $] cat def
183: /@@@.LLL goto
184: } { } ifelse
185: f toString /ans set
186: /@@@.LLL
187: /arg1 ans def
188: ] pop
189: popVariables
190: arg1
191: } def
192:
1.8 takayama 193: /basic_plus {
1.4 takayama 194: /arg1 set
1.8 takayama 195: [/in-basic_plus /s /a /n /i] pushVariables
1.4 takayama 196: [
197: /a arg1 def
198: /s a 0 get def
199: /n a length 1 sub def
200: 1 1 n {
201: /i set
202: s a i get add /s set
203: } for
204: s /arg1 set
205: ] pop
206: popVariables
207: arg1
208: } def
1.8 takayama 209: /basic_times {
1.4 takayama 210: /arg1 set
1.8 takayama 211: [/in-basic_times /s /a /n /i] pushVariables
1.4 takayama 212: [
213: /a arg1 def
214: /s a 0 get def
215: /n a length 1 sub def
216: 1 1 n {
217: /i set
218: s a i get mul /s set
219: } for
220: s /arg1 set
221: ] pop
222: popVariables
223: arg1
224: } def
1.8 takayama 225: /basic_power {
1.4 takayama 226: /arg1 set
1.8 takayama 227: [/in-basic_power /a ] pushVariables
1.4 takayama 228: [
229: /a arg1 def
230: a 0 get a 1 get power /arg1 set
231: ] pop
232: popVariables
233: arg1
234: } def
235:
236:
237: /cmoTreeToPrefix {
238: /arg1 set
239: [/in-cmoTreeToPostfix /in /ans /dic] pushVariables
240: [
241: /in arg1 def
242: in etag 263 eq not
243: { /ans in toStringForParse2 def }
244: {
245: in (array) dc /in set
246: /dic in 1 get def
1.8 takayama 247: /dic dic tolower def
1.4 takayama 248: %% concatenate the dictionary name to the function name.
249: /ans in 2 get { cmoTreeToPrefix } map bracketForm def
1.8 takayama 250: [dic (_) in 0 get ans ] cat /ans set
1.4 takayama 251: } ifelse
252: /arg1 ans def
253: ] pop
254: popVariables
255: arg1
256: } def
257:
258: [(cmoTreeToPrefix)
259: [(tree-obj cmoTreeToPrefix prefix-str)
1.8 takayama 260: (Dictionary names are translated to lower characters.)
261: $Example 1: [(plus) (basic) [(123).. (345)..]] [(class) (tree)] dc /ff set$
1.4 takayama 262: $ ff cmoTreeToPrefix /gg set $
263: $Example 2: ( (x-T-2)^5). /p set $
264: $ p [(class) (recursivePolynomial)] dc xml /ff set $
265: $ ff xml_to_cmo cmoTreeToPrefix /gg set $
266: ]] putUsages
267:
268:
269: /bracketForm {
270: /arg1 set
271: [/in-bracketForm /ans /f /i /n] pushVariables
272: [
273: /f arg1 def
274: /n f length 1 sub def
275: [ $($
276: 0 1 n 1 sub {
277: /i set
278: f i get toStringForParse2
279: (,)
280: } for
281: f n get toStringForParse2
282: $)$
283: ] cat /arg1 set
284: ] pop
285: popVariables
286: arg1
287: } def
288:
289: /toStringForParse2 {
290: /arg1 set
291: [/in-toStringForParse2 /f /ans] pushVariables
292: [
293: /f arg1 def
294: f etag 262 eq { %% indeterminate
295: /ans f (string) dc def
296: /@@@.LLL goto
297: } { } ifelse
298: f toString /ans set
299: /@@@.LLL
300: /arg1 ans def
301: ] pop
302: popVariables
303: arg1
304: } def
1.5 takayama 305:
1.6 takayama 306: /xml_tree_to_prefix_string {
307: /arg1 set
308: [/in-xml_tree_to_prefix_string /sss] pushVariables
309: [
310: /sss arg1 def
311: sss isString {
312: }{
313: (string xml_tree_to_prefix_string) error
314: }ifelse
315: sss xml_to_cmo cmoTreeToPrefix /ans set
316: /arg1 ans def
317: ] pop
318: arg1
319: } def
320:
321:
1.5 takayama 322: /OMproxy-testsuits2 {
323: xmlconnect
324: 1 1 30 {
325: /i set
326: [( (x-T-2)^) i toString] cat . /p set
327: p [(class) (recursivePolynomial)] dc xml /ff set
328: ff xml_to_cmo cmoTreeToPostfix /gg set
329: [(parse) gg] extension pop p sub /result set
330: result (0). eq
331: {
332: }
333: {
334: (p = ) messagen p message
335: (i=) messagen i message (Error in OMproxy-testsuits2 ) error
336: } ifelse
337: } for
338: (Done.) message
339: } def
1.6 takayama 340:
341:
342:
1.5 takayama 343:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>