===================================================================
RCS file: /home/cvs/OpenXM/src/OpenMath/OM2OXM.java,v
retrieving revision 1.9
retrieving revision 1.16
diff -u -p -r1.9 -r1.16
--- OpenXM/src/OpenMath/OM2OXM.java 1999/11/16 13:16:22 1.9
+++ OpenXM/src/OpenMath/OM2OXM.java 2000/01/20 18:14:32 1.16
@@ -1,5 +1,5 @@
/**
- * $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.15 2000/01/20 13:58:48 tam Exp $
*
* このクラスでは以下の BNF で表される構文解析を実装している
* expr -> stag [expr | immediate]* etag
@@ -39,7 +39,7 @@ final class OM2OXM implements Runnable{
private int token = TT_NULL;
private boolean lexPushbackFlag = false;
private OpenXM asir; // for debug
- private boolean debug = false;
+ protected boolean debug = false; // for debug message
// Token Type for lexical analyzer
final static int TT_NULL = 0;
@@ -88,8 +88,18 @@ final class OM2OXM implements Runnable{
case CMO.CMO_STRING:
return ""+ ((CMO_STRING)cmo).getString() +"";
- // case CMO.CMO_LIST:
+ case CMO.CMO_LIST:
+ ret += "";
+ {
+ CMO ob[] = ((CMO_LIST)cmo).getElements();
+ for(int i=0;i";
+ return ret;
+
case CMO.CMO_MONOMIAL32:
ret += "";
ret += CMO2OM_sub(((CMO_MONOMIAL32)cmo).getCoefficient());
@@ -118,6 +128,9 @@ final class OM2OXM implements Runnable{
ret += "2";
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:
ret += "";
ret += CMO2OM_sub(((CMO_DISTRIBUTED_POLYNOMIAL)cmo).getRing());
@@ -129,6 +142,8 @@ final class OM2OXM implements Runnable{
ret += "";
return ret;
+ //case CMO.CMO_POLYNOMIAL_IN_ONE_VARIABLE:
+
case CMO.CMO_BIGFLOAT:
ret += "";
ret += CMO2OM_sub(((CMO_BIGFLOAT)cmo).getSyosubu());
@@ -141,19 +156,53 @@ final class OM2OXM implements Runnable{
case CMO.CMO_INDETERMINATE:
return "";
- /*
- case CMO.CMO_TREE:
- return "" + "";
- */
+ case CMO.CMO_TREE:
+ ret += "";
+ for(int i=0;i<((CMO_TREE)cmo).getLeaves().getElements().length;i++){
+ ret += CMO2OM_sub(((CMO_TREE)cmo).getLeaves().getElements()[i]);
+ }
+ ret += "";
+ return ret;
default:
//return ""+ cmo.toCMOexpression() +"";
}
- 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.getElements()[poly.getVariable()]);
+
+ for(int i=0;i"+
+ ""+
+ variable +""+ poly.getDegrees()[i] +""+
+ CMO2OM_CoefficientOfRecursivePOLYNOMIAL(poly.getCoefficients()[i],
+ variables)
+ +"";
+ if(i==0){
+ ret = mono;
+ }else{
+ ret = ""+ ret + mono +"";
+ }
+ }
+
+ return ret;
+ }
+
private boolean isSpace(int ch){ // use from lex
return (ch==' ' || ch=='\t' || ch=='\n' || ch=='\r');
}
@@ -314,6 +363,8 @@ final class OM2OXM implements Runnable{
if(name.equals("DMP")){
ret = parse_symb_DMP();
debug("poly: "+ret);
+ }else if(name.equals("list")){
+ ret = parse_objects();
}else{
ret = new CMO_TREE(name,"Basic",parse_objects());
}
@@ -568,6 +619,7 @@ final class OM2OXM implements Runnable{
parse_error("We expect integer.");
}
+ debug("ZZ: "+ str);
return new CMO_ZZ(str);
}
@@ -731,6 +783,8 @@ final class OM2OXM implements Runnable{
asir.send(obj);
asir.sendSM(new SM(SM.SM_popCMO));
}catch(NumberFormatException e){
+ System.err.println(e.getMessage());
+ }catch(MathcapViolation e){
System.err.println(e.getMessage());
}
}