===================================================================
RCS file: /home/cvs/OpenXM/src/OpenMath/OM2OXM.java,v
retrieving revision 1.12
retrieving revision 1.19
diff -u -p -r1.12 -r1.19
--- OpenXM/src/OpenMath/OM2OXM.java 1999/11/18 15:13:01 1.12
+++ OpenXM/src/OpenMath/OM2OXM.java 2000/03/14 04:44:16 1.19
@@ -1,5 +1,5 @@
/**
- * $OpenXM: OpenXM/src/OpenMath/OM2OXM.java,v 1.11 1999/11/17 08:37:29 tam Exp $
+ * $OpenXM: OpenXM/src/OpenMath/OM2OXM.java,v 1.18 2000/02/28 14:10:28 takayama 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;
@@ -77,10 +77,10 @@ final class OM2OXM implements Runnable{
String ret = "";
switch(cmo.getDISCRIMINATOR()){
- case CMO.CMO_NULL:
+ case CMO.NULL:
return "0";
- case CMO.CMO_INT32:
+ case CMO.INT32:
return ""+ ((CMO_INT32)cmo).intValue() +"";
// case CMO.CMO_DATUM:
@@ -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());
@@ -132,7 +142,7 @@ final class OM2OXM implements Runnable{
ret += "";
return ret;
- //case CMO.CMO_POLYNOMIAL_IN_ONE_VARIABLE:
+ //case CMO.POLYNOMIAL_IN_ONE_VARIABLE:
case CMO.CMO_BIGFLOAT:
ret += "";
@@ -149,8 +159,8 @@ final class OM2OXM implements Runnable{
case CMO.CMO_TREE:
ret += "";
- for(int i=0;i<((CMO_TREE)cmo).getLeaves().getElement().length;i++){
- ret += CMO2OM_sub(((CMO_TREE)cmo).getLeaves().getElement()[i]);
+ for(int i=0;i<((CMO_TREE)cmo).getLeaves().getElements().length;i++){
+ ret += CMO2OM_sub(((CMO_TREE)cmo).getLeaves().getElements()[i]);
}
ret += "";
return ret;
@@ -172,7 +182,7 @@ final class OM2OXM implements Runnable{
}
poly = (CMO_POLYNOMIAL_IN_ONE_VARIABLE)cmo;
- variable = CMO2OM_sub(variables.getElement()[poly.getVariable()]);
+ variable = CMO2OM_sub(variables.getElements()[poly.getVariable()]);
for(int i=0;i'.");
}
}else{
- parse_error("???");
+ parse_error("We expect ' or '' or ''.");
ret = null;
}
@@ -447,6 +467,7 @@ final class OM2OXM implements Runnable{
private CMO_MONOMIAL32 parse_symb_Monom() throws IOException{
Vector degree = new Vector();
+ CMO coefficient;
int[] array;
exceptTokenTypeInParse(TT_StartTag);
@@ -458,6 +479,14 @@ final class OM2OXM implements Runnable{
parse_error("We expect ''");
}
+ coefficient = parse_object();
+ if(!(coefficient instanceof CMO_ZZ
+ || coefficient instanceof CMO_QQ
+ || coefficient instanceof CMO_INT32
+ || coefficient instanceof CMO_ZERO)){
+ parse_error("the coefficient of Monomials must be integer or rational.");
+ }
+
while(readNextToken() != TT_EndTag){
pushbackLex();
degree.addElement(parse_OMI());
@@ -467,17 +496,16 @@ final class OM2OXM implements Runnable{
parse_error("We expect ''.");
}
- array = new int[degree.size()-1];
+ array = new int[degree.size()];
for(int i=0;i