version 1.16, 2000/01/20 18:14:32 |
version 1.19, 2000/03/14 04:44:16 |
|
|
/** |
/** |
* $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.18 2000/02/28 14:10:28 takayama 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 77 final class OM2OXM implements Runnable{ |
|
Line 77 final class OM2OXM implements Runnable{ |
|
String ret = ""; |
String ret = ""; |
|
|
switch(cmo.getDISCRIMINATOR()){ |
switch(cmo.getDISCRIMINATOR()){ |
case CMO.CMO_NULL: |
case CMO.NULL: |
return "<OMI>0</OMI>"; |
return "<OMI>0</OMI>"; |
|
|
case CMO.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.CMO_DATUM: |
Line 142 final class OM2OXM implements Runnable{ |
|
Line 142 final class OM2OXM implements Runnable{ |
|
ret += "</OMA></OMA>"; |
ret += "</OMA></OMA>"; |
return ret; |
return ret; |
|
|
//case CMO.CMO_POLYNOMIAL_IN_ONE_VARIABLE: |
//case 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\"/>"; |
Line 363 final class OM2OXM implements Runnable{ |
|
Line 363 final class OM2OXM implements Runnable{ |
|
if(name.equals("DMP")){ |
if(name.equals("DMP")){ |
ret = parse_symb_DMP(); |
ret = parse_symb_DMP(); |
debug("poly: "+ret); |
debug("poly: "+ret); |
}else if(name.equals("list")){ |
|
ret = parse_objects(); |
|
}else{ |
}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); |
exceptTokenTypeInParse(TT_EndTag); |
Line 374 final class OM2OXM implements Runnable{ |
|
Line 382 final class OM2OXM implements Runnable{ |
|
parse_error("We expect '</OMA>'."); |
parse_error("We expect '</OMA>'."); |
} |
} |
}else{ |
}else{ |
parse_error("???"); |
parse_error("We expect '<OMI> or '<OMA>' or '<OMV>'."); |
ret = null; |
ret = null; |
} |
} |
|
|
Line 459 final class OM2OXM implements Runnable{ |
|
Line 467 final class OM2OXM implements Runnable{ |
|
|
|
private CMO_MONOMIAL32 parse_symb_Monom() throws IOException{ |
private CMO_MONOMIAL32 parse_symb_Monom() throws IOException{ |
Vector degree = new Vector(); |
Vector degree = new Vector(); |
|
CMO coefficient; |
int[] array; |
int[] array; |
|
|
exceptTokenTypeInParse(TT_StartTag); |
exceptTokenTypeInParse(TT_StartTag); |
Line 470 final class OM2OXM implements Runnable{ |
|
Line 479 final class OM2OXM implements Runnable{ |
|
parse_error("We expect '<Monom>'"); |
parse_error("We expect '<Monom>'"); |
} |
} |
|
|
|
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){ |
while(readNextToken() != TT_EndTag){ |
pushbackLex(); |
pushbackLex(); |
degree.addElement(parse_OMI()); |
degree.addElement(parse_OMI()); |
Line 479 final class OM2OXM implements Runnable{ |
|
Line 496 final class OM2OXM implements Runnable{ |
|
parse_error("We expect '<OMA>'."); |
parse_error("We expect '<OMA>'."); |
} |
} |
|
|
array = new int[degree.size()-1]; |
array = new int[degree.size()]; |
for(int i=0;i<array.length;i++){ |
for(int i=0;i<array.length;i++){ |
array[i] = ((CMO_ZZ)degree.elementAt(i+1)).intValue(); |
array[i] = ((CMO_ZZ)degree.elementAt(i)).intValue(); |
} |
} |
|
|
//debug("monom: "+ new CMO_MONOMIAL32(array,(CMO_ZZ)degree.elementAt(0))); |
//debug("monom: "+ new CMO_MONOMIAL32(array,coefficient)); |
return new CMO_MONOMIAL32(array,(CMO_ZZ)degree.elementAt(0)); |
return new CMO_MONOMIAL32(array,coefficient); |
} |
} |
|
|
private CMO_LIST parse_objects() throws IOException{ |
private CMO[] parse_objects() throws IOException{ |
// $B2r@O$5$l$?(B object $B$r(B LIST $B$GJV$9(B |
|
Vector objects = new Vector(); |
Vector objects = new Vector(); |
CMO[] array; |
CMO[] array; |
|
|
Line 504 final class OM2OXM implements Runnable{ |
|
Line 520 final class OM2OXM implements Runnable{ |
|
objects.copyInto((Object[])array); |
objects.copyInto((Object[])array); |
|
|
debug("debug :"+ new CMO_LIST(array)); |
debug("debug :"+ new CMO_LIST(array)); |
return new CMO_LIST(array); |
return array; |
} |
} |
|
|
private String parse_symbol() throws IOException{ |
private String parse_symbol() throws IOException{ |
Line 716 final class OM2OXM implements Runnable{ |
|
Line 732 final class OM2OXM implements Runnable{ |
|
String ret; |
String ret; |
|
|
ret = mesg +"\n"; |
ret = mesg +"\n"; |
ret += "error occuered near :"; |
ret += "error occuered before that :"; |
try{ |
try{ |
for(int i=0;i<10;i++){ |
for(int i=0;i<40;i++){ |
ret += (char)is.read(); |
ret += (char)is.read(); |
} |
} |
}catch(IOException e){} |
}catch(IOException e){} |