===================================================================
RCS file: /home/cvs/OpenXM/src/OpenMath/OM2OXM.java,v
retrieving revision 1.16
retrieving revision 1.21
diff -u -p -r1.16 -r1.21
--- OpenXM/src/OpenMath/OM2OXM.java 2000/01/20 18:14:32 1.16
+++ OpenXM/src/OpenMath/OM2OXM.java 2000/03/14 05:10:37 1.21
@@ -1,5 +1,5 @@
/**
- * $OpenXM: OpenXM/src/OpenMath/OM2OXM.java,v 1.15 2000/01/20 13:58:48 tam Exp $
+ * $OpenXM: OpenXM/src/OpenMath/OM2OXM.java,v 1.20 2000/03/14 05:02:34 tam Exp $
*
* このクラスでは以下の BNF で表される構文解析を実装している
* expr -> stag [expr | immediate]* etag
@@ -77,18 +77,18 @@ 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:
- case CMO.CMO_STRING:
+ case CMO.STRING:
return ""+ ((CMO_STRING)cmo).getString() +"";
- case CMO.CMO_LIST:
+ case CMO.LIST:
ret += "";
{
CMO ob[] = ((CMO_LIST)cmo).getElements();
@@ -142,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 += "";
@@ -363,10 +363,18 @@ 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());
+ CMO[] leaves = parse_objects();
+
+ if(name.equals("list")){
+ ret = new CMO_LIST(leaves);
+ }else if(name.equals("over") && leaves.length==2
+ && leaves[0] instanceof CMO_ZZ
+ && leaves[1] instanceof CMO_ZZ){
+ ret = new CMO_QQ((CMO_ZZ)leaves[0],(CMO_ZZ)leaves[1]);
+ }else{
+ ret = new CMO_TREE(name,"basic",new CMO_LIST(leaves));
+ }
}
exceptTokenTypeInParse(TT_EndTag);
@@ -374,7 +382,7 @@ final class OM2OXM implements Runnable{
parse_error("We expect ''.");
}
}else{
- parse_error("???");
+ parse_error("We expect ' or '' or ''.");
ret = null;
}
@@ -459,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);
@@ -470,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());
@@ -479,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