version 1.9, 1999/11/16 13:16:22 |
version 1.12, 1999/11/18 15:13:01 |
|
|
/** |
/** |
* $OpenXM: OpenXM/src/OpenMath/OM2OXM.java,v 1.8 1999/11/15 23:13:21 tam Exp $ |
* $OpenXM: OpenXM/src/OpenMath/OM2OXM.java,v 1.11 1999/11/17 08:37:29 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 |
Line 118 final class OM2OXM implements Runnable{ |
|
Line 118 final class OM2OXM implements Runnable{ |
|
ret += "<OMI>2</OMI></OMA>"; |
ret += "<OMI>2</OMI></OMA>"; |
return ret; |
return ret; |
|
|
|
case CMO.CMO_RECURSIVE_POLYNOMIAL: |
|
return CMO2OM_CoefficientOfRecursivePOLYNOMIAL(((CMO_RECURSIVE_POLYNOMIAL)cmo).getPolynomial(),((CMO_RECURSIVE_POLYNOMIAL)cmo).getVariables()); |
|
|
case CMO.CMO_DISTRIBUTED_POLYNOMIAL: |
case CMO.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()); |
Line 129 final class OM2OXM implements Runnable{ |
|
Line 132 final class OM2OXM implements Runnable{ |
|
ret += "</OMA></OMA>"; |
ret += "</OMA></OMA>"; |
return ret; |
return ret; |
|
|
|
//case CMO.CMO_POLYNOMIAL_IN_ONE_VARIABLE: |
|
|
case CMO.CMO_BIGFLOAT: |
case CMO.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()); |
Line 141 final class OM2OXM implements Runnable{ |
|
Line 146 final class OM2OXM implements Runnable{ |
|
case CMO.CMO_INDETERMINATE: |
case CMO.CMO_INDETERMINATE: |
return "<OMV name=\""+ ((CMO_INDETERMINATE)cmo).getString() +"\"/>"; |
return "<OMV name=\""+ ((CMO_INDETERMINATE)cmo).getString() +"\"/>"; |
|
|
/* |
case CMO.CMO_TREE: |
case CMO.CMO_TREE: |
ret += "<OMA><OMS name=\""+ ((CMO_TREE)cmo).getName() +"\" cd=\""+ |
return "<OMA><OMS name=\""+ ((CMO_TREE)cmo).getName() +"\" cdname=\""+ |
((CMO_TREE)cmo).getCDName() +"\"/>"; |
((CMO_TREE)cmo).getCDName() +"\"/>" + "</OMA>"; |
for(int i=0;i<((CMO_TREE)cmo).getLeaves().getElement().length;i++){ |
*/ |
ret += CMO2OM_sub(((CMO_TREE)cmo).getLeaves().getElement()[i]); |
|
} |
|
ret += "</OMA>"; |
|
return ret; |
|
|
default: |
default: |
//return "<OMSTR>"+ cmo.toCMOexpression() +"</OMSTR>"; |
//return "<OMSTR>"+ cmo.toCMOexpression() +"</OMSTR>"; |
} |
} |
|
|
throw new NumberFormatException(""+ cmo.toCMOexpression()); |
throw new NumberFormatException("unknown convert way:"+ |
|
cmo.toCMOexpression()); |
|
} |
|
|
|
private static String CMO2OM_CoefficientOfRecursivePOLYNOMIAL(CMO cmo,CMO_LIST variables){ |
|
CMO_POLYNOMIAL_IN_ONE_VARIABLE poly; |
|
String ret = "",variable; |
|
|
|
if(!(cmo instanceof CMO_POLYNOMIAL_IN_ONE_VARIABLE)){ |
|
return CMO2OM_sub(cmo); |
|
} |
|
|
|
poly = (CMO_POLYNOMIAL_IN_ONE_VARIABLE)cmo; |
|
variable = CMO2OM_sub(variables.getElement()[poly.getVariable()]); |
|
|
|
for(int i=0;i<poly.getDegrees().length;i++){ |
|
String mono; |
|
|
|
mono = "<OMA><OMS name=\"times\" cd=\"basic\"/>"+ |
|
"<OMA><OMS name=\"power\" cd=\"basic\"/>"+ |
|
variable +"<OMI>"+ poly.getDegrees()[i] +"</OMI></OMA>"+ |
|
CMO2OM_CoefficientOfRecursivePOLYNOMIAL(poly.getCoefficients()[i], |
|
variables) |
|
+"</OMA>"; |
|
if(i==0){ |
|
ret = mono; |
|
}else{ |
|
ret = "<OMA><OMS name=\"plus\" cd=\"basic\"/>"+ ret + mono +"</OMA>"; |
|
} |
|
} |
|
|
|
return ret; |
} |
} |
|
|
private boolean isSpace(int ch){ // use from lex |
private boolean isSpace(int ch){ // use from lex |