Return to xml.sm1 CVS log | Up to [local] / OpenXM / src / kan96xx / Doc |
File: [local] / OpenXM / src / kan96xx / Doc / xml.sm1 (download)
Revision 1.4, Sat Nov 20 05:17:31 1999 UTC (24 years, 10 months ago) by takayama
cmoTreeToPostfix and cmoTreeToPrefix are added. These functions translate Open Math tree expressions or CMO tree expressions to postfix forms (for sm1) or prefix forms (for asir and Mathematica). For example, $<OMOBJ> <OMA> <OMS name="plus" cd="basic"/> <OMI> 2 </OMI> <OMI> 3 </OMI> </OMA> </OMOBJ>$ xml_to_cmo cmoTreeToPrefix returns $plus_Basic(2,3)$ |
%% $OpenXM: OpenXM/src/kan96xx/Doc/xml.sm1,v 1.4 1999/11/20 05:17:31 takayama Exp $ %% xml.sm1 XML support for sm1. %% This package requires ox.sm1 [(parse) (ox.sm1) pushfile] extension (xml.sm1 : 1999, 11/20 Sat) message %%%%% These should be under /usr/local/OpenXM or OpenXM_HOME /oxpath.java-support (lib/java-support) def [(getenv) (OpenXM_HOME)] extension tag 0 eq { /oxpath.java-support [(/usr/local/OpenXM/) oxpath.java-support] cat def } { /oxpath.java-support [ [(getenv) (OpenXM_HOME)] extension (/) oxpath.java-support] cat def } ifelse /xmlconnect { [/in-xmlconnect /data /control /com] pushVariables [ /data [(oxGenPass)] extension def /control [(oxGenPass)] extension def [data control] message [(tdiv_qr) data .. (2000)..] mpzext 1 get (integer) dc 1025 add /data set [(tdiv_qr) control .. (2000)..] mpzext 1 get (integer) dc 1025 add /control set [$($ ( cd ) oxpath.java-support ( ; ) %% (/bin/csh -c ") ( java OMproxy ) ( -data ) data ( -control ) control %% ( >& /dev/null ) %% Syntax error: Bad fd ( > /dev/null ) %% (") $)$ ( & ) ] cat /com set (Executing the command ) messagen com message com system (sleep 5) system [(oxCreateClient) (localhost) data control] extension /@@@.xml set (The server is binded to the variable @@@.xml) message @@@.xml /arg1 set ] pop popVariables arg1 } def /xml { /arg1 set [/in-cmo2xml /ob] pushVariables [ /ob arg1 def @@@.xml ob oxpushcmo @@@.xml (CMO2OMXML) oxexec @@@.xml oxpopcmo /arg1 set ] pop popVariables arg1 } def [(xml) [(object xml xml-string) (Example: ) ( xmlconnect ) $ (12345).. xml :: $ $ ( (x-1)^2 ). xml :: $ ]] putUsages /xml_to_cmo { /arg1 set [/in-xml_to_cmo /ob] pushVariables [ /ob arg1 def @@@.xml ob oxpushcmo @@@.xml (OMXML2CMO) oxexec @@@.xml oxpopcmo /arg1 set ] pop popVariables arg1 } def [(xml_to_cmo) [(xml-string xml_to_cmo cmo) (Example: ) ( xmlconnect ) $ (<OMOBJ><OMI>5</OMI></OMOBJ>) xml_to_cmo :: $ $ ( (x-1)^2 ). xml /aa set $ $ aa xml_to_cmo :: $ ]] putUsages /t_aux { /arg1 set [/in-t_aux /ob /r /r2] pushVariables [ /ob arg1 def (_______________________________________) message (tag = ) messagen ob tag messagen (, ) messagen (Sending object :) messagen ob message ob xml /r set (XML expression is:) messagen r message r xml_to_cmo /r2 set (XML to CMO :) messagen r2 message (~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~) message ] pop popVariables } def %% Just type in OMproxy-testsuits1 /OMproxy-testsuits1 { xmlconnect @@@.xml oxmathcap (Mathcap is ) messagen @@@.xml message null t_aux 123 t_aux (Hello World) t_aux %% was error in XML to CMO. % [1 2 3] t_aux %% not supported. (123123).. t_aux % (-12).. (12345).. div t_aux %% not supported in sm1. (x^2-1). t_aux %% was not supported. CMO_DMS_GENERIC?? (End) message } def /cmoTreeToPostfix { /arg1 set [/in-cmoTreeToPostfix /in /ans /dic] pushVariables [ /in arg1 def in etag 263 eq not { /ans in toStringForParse def } { in (array) dc /in set /dic in 1 get def %% concatenate the dictionary name to the function name. /ans in 2 get { cmoTreeToPostfix } map toString def [ ans ( ) in 0 get (_) dic] cat /ans set } ifelse /arg1 ans def ] pop popVariables arg1 } def [(cmoTreeToPostfix) [(tree-obj cmoTreeToPostfix postfix-str) $Example 1: [(plus) (Basic) [(123).. (345)..]] [(class) (tree)] dc /ff set$ $ ff cmoTreeToPostfix /gg set $ $ [(parse) gg] extension pop :: $ $Example 2: ( (x-T-2)^5). /p set $ $ p [(class) (recursivePolynomial)] dc xml /ff set $ $ ff xml_to_cmo cmoTreeToPostfix /gg set $ $ [(parse) gg] extension pop p sub :: $ ]] putUsages /toStringForParse { /arg1 set [/in-toStringForParse /f /ans] pushVariables [ /f arg1 def f isUniversalNumber { /ans [ $ ($ f toString $).. $] cat def /@@@.LLL goto } { } ifelse f isPolynomial { /ans [ $ ($ f toString $). $] cat def /@@@.LLL goto } { } ifelse f etag 262 eq { %% indeterminate /ans [ $ ($ f (string) dc toString $). $] cat def /@@@.LLL goto } { } ifelse f toString /ans set /@@@.LLL /arg1 ans def ] pop popVariables arg1 } def /plus_Basic { /arg1 set [/in-plus_Basic /s /a /n /i] pushVariables [ /a arg1 def /s a 0 get def /n a length 1 sub def 1 1 n { /i set s a i get add /s set } for s /arg1 set ] pop popVariables arg1 } def /times_Basic { /arg1 set [/in-times_Basic /s /a /n /i] pushVariables [ /a arg1 def /s a 0 get def /n a length 1 sub def 1 1 n { /i set s a i get mul /s set } for s /arg1 set ] pop popVariables arg1 } def /power_Basic { /arg1 set [/in-power_Basic /a ] pushVariables [ /a arg1 def a 0 get a 1 get power /arg1 set ] pop popVariables arg1 } def /cmoTreeToPrefix { /arg1 set [/in-cmoTreeToPostfix /in /ans /dic] pushVariables [ /in arg1 def in etag 263 eq not { /ans in toStringForParse2 def } { in (array) dc /in set /dic in 1 get def %% concatenate the dictionary name to the function name. /ans in 2 get { cmoTreeToPrefix } map bracketForm def [in 0 get (_) dic ans ] cat /ans set } ifelse /arg1 ans def ] pop popVariables arg1 } def [(cmoTreeToPrefix) [(tree-obj cmoTreeToPrefix prefix-str) $Example 1: [(plus) (Basic) [(123).. (345)..]] [(class) (tree)] dc /ff set$ $ ff cmoTreeToPrefix /gg set $ $Example 2: ( (x-T-2)^5). /p set $ $ p [(class) (recursivePolynomial)] dc xml /ff set $ $ ff xml_to_cmo cmoTreeToPrefix /gg set $ ]] putUsages /bracketForm { /arg1 set [/in-bracketForm /ans /f /i /n] pushVariables [ /f arg1 def /n f length 1 sub def [ $($ 0 1 n 1 sub { /i set f i get toStringForParse2 (,) } for f n get toStringForParse2 $)$ ] cat /arg1 set ] pop popVariables arg1 } def /toStringForParse2 { /arg1 set [/in-toStringForParse2 /f /ans] pushVariables [ /f arg1 def f etag 262 eq { %% indeterminate /ans f (string) dc def /@@@.LLL goto } { } ifelse f toString /ans set /@@@.LLL /arg1 ans def ] pop popVariables arg1 } def