version 1.20, 2000/03/14 05:02:34 |
version 1.26, 2000/10/11 08:32:13 |
|
|
|
/* |
|
* $OpenXM: OpenXM/src/OpenMath/OM2OXM.java,v 1.25 2000/09/13 06:44:55 tam Exp $ |
|
*/ |
|
|
/** |
/** |
* $OpenXM: OpenXM/src/OpenMath/OM2OXM.java,v 1.19 2000/03/14 04:44:16 tam Exp $ |
|
* |
|
* $B$3$N%/%i%9$G$O0J2<$N(B BNF $B$GI=$5$l$k9=J82r@O$r<BAu$7$F$$$k(B |
* $B$3$N%/%i%9$G$O0J2<$N(B BNF $B$GI=$5$l$k9=J82r@O$r<BAu$7$F$$$k(B |
* expr -> stag [expr | immediate]* etag |
* expr -> stag [expr | immediate]* etag |
* immediate -> INTEGER |
* immediate -> INTEGER |
|
|
import java.io.*; |
import java.io.*; |
import java.net.*; |
import java.net.*; |
import java.util.Vector; |
import java.util.Vector; |
import JP.ac.kobe_u.math.tam.OpenXM.*; |
import ORG.openxm.tam.*; |
|
|
final class OM2OXM implements Runnable{ |
final class OM2OXM implements Runnable{ |
private PushbackInputStream is; |
private PushbackInputStream is; |
Line 52 final class OM2OXM implements Runnable{ |
|
Line 54 final class OM2OXM implements Runnable{ |
|
//$B%5!<%PB&$+$iAw?.$5$l$?J8;zNs$r<u?.$7$^$9!#(B |
//$B%5!<%PB&$+$iAw?.$5$l$?J8;zNs$r<u?.$7$^$9!#(B |
try{ |
try{ |
while(true){ |
while(true){ |
CMO tmp; |
OXmessage message = asir.receive(); |
|
|
switch(asir.receiveOXtag()){ |
if(message.getTag() == OXmessage.OX_DATA){ |
case OpenXM.OX_COMMAND: |
System.err.println("=> "+ CMO2OM((CMO)message.getBody())); |
asir.receiveSM(); |
|
break; |
break; |
|
|
case OpenXM.OX_DATA: |
|
tmp = asir.receiveCMO(); |
|
System.out.println("=> "+ CMO2OM(tmp)); |
|
break; |
|
} |
} |
|
|
} |
} |
}catch(IOException e){} |
}catch(IOException e){} |
} |
} |
Line 83 final class OM2OXM implements Runnable{ |
|
Line 78 final class OM2OXM implements Runnable{ |
|
case CMO.INT32: |
case CMO.INT32: |
return "<OMI>"+ ((CMO_INT32)cmo).intValue() +"</OMI>"; |
return "<OMI>"+ ((CMO_INT32)cmo).intValue() +"</OMI>"; |
|
|
// case CMO.CMO_DATUM: |
// case CMO.DATUM: |
|
|
case CMO.STRING: |
case CMO.STRING: |
return "<OMSTR>"+ ((CMO_STRING)cmo).getString() +"</OMSTR>"; |
return "<OMSTR>"+ ((CMO_STRING)cmo).getString() +"</OMSTR>"; |
|
|
case CMO.CMO_LIST: |
case CMO.LIST: |
ret += "<OMA><OMS name=\"list\" cd=\"basic\"/>"; |
ret += "<OMA><OMS name=\"list\" cd=\"basic\"/>"; |
{ |
{ |
CMO ob[] = ((CMO_LIST)cmo).getElements(); |
CMO ob[] = ((CMO_LIST)cmo).getElements(); |
Line 100 final class OM2OXM implements Runnable{ |
|
Line 95 final class OM2OXM implements Runnable{ |
|
ret += "</OMA>"; |
ret += "</OMA>"; |
return ret; |
return ret; |
|
|
case CMO.CMO_MONOMIAL32: |
case CMO.MONOMIAL32: |
ret += "<OMA><OMS name=\"Monom\" cd=\"poly\"/>"; |
ret += "<OMA><OMS name=\"Monom\" cd=\"poly\"/>"; |
ret += CMO2OM_sub(((CMO_MONOMIAL32)cmo).getCoefficient()); |
ret += CMO2OM_sub(((CMO_MONOMIAL32)cmo).getCoefficient()); |
for(int i=0;i<((CMO_MONOMIAL32)cmo).getDegree().length;i++){ |
for(int i=0;i<((CMO_MONOMIAL32)cmo).getDegree().length;i++){ |
Line 109 final class OM2OXM implements Runnable{ |
|
Line 104 final class OM2OXM implements Runnable{ |
|
ret += "</OMA>"; |
ret += "</OMA>"; |
return ret; |
return ret; |
|
|
case CMO.CMO_ZZ: |
case CMO.ZZ: |
return "<OMI>"+ ((CMO_ZZ)cmo).BigIntValue() +"</OMI>"; |
return "<OMI>"+ ((CMO_ZZ)cmo).BigIntValue() +"</OMI>"; |
|
|
case CMO.CMO_QQ: |
case CMO.QQ: |
return "<OMA><OMS name=\"over\" cd=\"basic\"/>"+ |
return "<OMA><OMS name=\"over\" cd=\"basic\"/>"+ |
CMO2OM_sub(((CMO_QQ)cmo).getBunshi())+ |
CMO2OM_sub(((CMO_QQ)cmo).getBunshi())+ |
CMO2OM_sub(((CMO_QQ)cmo).getBunbo())+ |
CMO2OM_sub(((CMO_QQ)cmo).getBunbo())+ |
"</OMA>"; |
"</OMA>"; |
|
|
case CMO.CMO_ZERO: |
case CMO.ZERO: |
return "<OMI> 0 </OMI>"; |
return "<OMI> 0 </OMI>"; |
|
|
// case CMO.CMO_DMS: |
// case CMO.DMS: |
|
|
case CMO.CMO_DMS_GENERIC: |
case CMO.DMS_GENERIC: |
ret += "<OMA><OMS name=\"PolyRing\" cd=\"poly\"/>"; |
ret += "<OMA><OMS name=\"PolyRing\" cd=\"poly\"/>"; |
ret += "<OMI>2</OMI></OMA>"; |
ret += "<OMI>2</OMI></OMA>"; |
return ret; |
return ret; |
|
|
case CMO.CMO_RECURSIVE_POLYNOMIAL: |
case CMO.RECURSIVE_POLYNOMIAL: |
return CMO2OM_CoefficientOfRecursivePOLYNOMIAL(((CMO_RECURSIVE_POLYNOMIAL)cmo).getPolynomial(),((CMO_RECURSIVE_POLYNOMIAL)cmo).getVariables()); |
return CMO2OM_CoefficientOfRecursivePOLYNOMIAL(((CMO_RECURSIVE_POLYNOMIAL)cmo).getPolynomial(),((CMO_RECURSIVE_POLYNOMIAL)cmo).getVariables()); |
|
|
case CMO.CMO_DISTRIBUTED_POLYNOMIAL: |
case CMO.DISTRIBUTED_POLYNOMIAL: |
ret += "<OMA><OMS name=\"DMP\" cd=\"poly\"/>"; |
ret += "<OMA><OMS name=\"DMP\" cd=\"poly\"/>"; |
ret += CMO2OM_sub(((CMO_DISTRIBUTED_POLYNOMIAL)cmo).getRing()); |
ret += CMO2OM_sub(((CMO_DISTRIBUTED_POLYNOMIAL)cmo).getRing()); |
ret += "<OMA><OMS name=\"SDMP\" cd=\"poly\"/>"; |
ret += "<OMA><OMS name=\"SDMP\" cd=\"poly\"/>"; |
Line 144 final class OM2OXM implements Runnable{ |
|
Line 139 final class OM2OXM implements Runnable{ |
|
|
|
//case CMO.POLYNOMIAL_IN_ONE_VARIABLE: |
//case CMO.POLYNOMIAL_IN_ONE_VARIABLE: |
|
|
case CMO.CMO_BIGFLOAT: |
case CMO.BIGFLOAT: |
ret += "<OMA><OMS name=\"times\" cd=\"basic\"/>"; |
ret += "<OMA><OMS name=\"times\" cd=\"basic\"/>"; |
ret += CMO2OM_sub(((CMO_BIGFLOAT)cmo).getSyosubu()); |
ret += CMO2OM_sub(((CMO_BIGFLOAT)cmo).getSyosubu()); |
ret += "<OMA><OMS name=\"power\" cd=\"basic\"/>"; |
ret += "<OMA><OMS name=\"power\" cd=\"basic\"/>"; |
Line 153 final class OM2OXM implements Runnable{ |
|
Line 148 final class OM2OXM implements Runnable{ |
|
ret += "</OMA></OMA>"; |
ret += "</OMA></OMA>"; |
return ret; |
return ret; |
|
|
case CMO.CMO_INDETERMINATE: |
case CMO.INDETERMINATE: |
return "<OMV name=\""+ ((CMO_INDETERMINATE)cmo).getString() +"\"/>"; |
return "<OMV name=\""+ ((CMO_INDETERMINATE)cmo).getString() +"\"/>"; |
|
|
case CMO.CMO_TREE: |
case CMO.TREE: |
ret += "<OMA><OMS name=\""+ ((CMO_TREE)cmo).getName() +"\" cd=\""+ |
ret += "<OMA><OMS name=\""+ ((CMO_TREE)cmo).getName() +"\" cd=\""+ |
((CMO_TREE)cmo).getCDName() +"\"/>"; |
((CMO_TREE)cmo).getCDName() +"\"/>"; |
for(int i=0;i<((CMO_TREE)cmo).getLeaves().getElements().length;i++){ |
for(int i=0;i<((CMO_TREE)cmo).getLeaves().getElements().length;i++){ |
Line 757 final class OM2OXM implements Runnable{ |
|
Line 752 final class OM2OXM implements Runnable{ |
|
|
|
for(int i=0;i<argv.length;i++){ |
for(int i=0;i<argv.length;i++){ |
if(argv[i].equals("-h")){ |
if(argv[i].equals("-h")){ |
System.out.println(""); |
System.err.println(""); |
System.exit(0); |
System.exit(0); |
}else if(argv[i].equals("-host")){ |
}else if(argv[i].equals("-host")){ |
host = argv[++i]; |
host = argv[++i]; |
Line 773 final class OM2OXM implements Runnable{ |
|
Line 768 final class OM2OXM implements Runnable{ |
|
|
|
try{ |
try{ |
asir = new OpenXM(host,CtrlPort,StreamPort); |
asir = new OpenXM(host,CtrlPort,StreamPort); |
asir.sendSM(new SM(SM.SM_mathcap)); |
asir.send(new SM(SM.SM_mathcap)); |
}catch(UnknownHostException e){ |
}catch(UnknownHostException e){ |
System.err.println("host unknown."); |
System.err.println("host unknown."); |
System.err.println(e.getMessage()); |
System.err.println(e.getMessage()); |
Line 783 final class OM2OXM implements Runnable{ |
|
Line 778 final class OM2OXM implements Runnable{ |
|
System.err.println("IOException occuer !!"); |
System.err.println("IOException occuer !!"); |
System.err.println(e.getMessage()); |
System.err.println(e.getMessage()); |
return; |
return; |
|
}catch(MathcapViolation e){ |
|
System.err.println("MathcapViolation !!"); |
|
System.err.println(e.getMessage()); |
|
return; |
} |
} |
|
|
P.asir = asir; |
P.asir = asir; |
new Thread(P).start(); |
new Thread(P).start(); |
System.out.println("start"); |
System.err.println("start"); |
|
|
try{ |
try{ |
//P.value = new Attribute(System.in); |
//P.value = new Attribute(System.in); |
Line 797 final class OM2OXM implements Runnable{ |
|
Line 796 final class OM2OXM implements Runnable{ |
|
try{ |
try{ |
CMO obj = P.parse(System.in); |
CMO obj = P.parse(System.in); |
asir.send(obj); |
asir.send(obj); |
asir.sendSM(new SM(SM.SM_popCMO)); |
asir.send(new SM(SM.SM_popCMO)); |
}catch(NumberFormatException e){ |
}catch(NumberFormatException e){ |
System.err.println(e.getMessage()); |
System.err.println(e.getMessage()); |
}catch(MathcapViolation e){ |
}catch(MathcapViolation e){ |
Line 808 final class OM2OXM implements Runnable{ |
|
Line 807 final class OM2OXM implements Runnable{ |
|
}catch(IOException e){ |
}catch(IOException e){ |
e.printStackTrace(); |
e.printStackTrace(); |
}finally{ |
}finally{ |
System.out.println("breaking..."); |
System.err.println("breaking..."); |
} |
} |
} |
} |
} |
} |