Nettoyage de la classe JArithmeticInterpreter

This commit is contained in:
Marc Baloup 2014-12-26 16:56:39 +01:00
parent 9ec2dfb95b
commit 6f05cf681f

View File

@ -449,16 +449,19 @@ public class JArithmeticInterpreter {
//.................................................................................... Write_Tree
public String writeTree() {
StringBuffer sb = new StringBuffer();
writeTree(sb);
return sb.toString();
}
private void writeTree(StringBuffer string) {
boolean parenthese=false;
switch(mOperator) {
case -2:
string.append('y');
break;
case -1:
string.append('x');
break;
case 0:
string.append(mValue);
break;
@ -550,7 +553,7 @@ public class JArithmeticInterpreter {
string.append(')');
break;
case 9:
string.append("<EFBFBD>(");
string.append("sqrt(");
fg.writeTree(string);
string.append(')');
break;
@ -605,7 +608,7 @@ public class JArithmeticInterpreter {
signe=-1;
i++;
}
if (chaine.charAt(i)=='<27>') return signe*Math.PI;
if (chaine.charAt(i)=='<27>') return signe*Math.PI; // TODO changer le caractère non reconnu
while (i<longueur && chaine.charAt(i)>47 && chaine.charAt(i)<58) {
temp=temp*10+(chaine.charAt(i)-48);
@ -626,102 +629,102 @@ public class JArithmeticInterpreter {
//.................................................................................... FindOperator
private static void FindOperator(VariableInt oper,VariableInt esp,StringBuffer chaine,int pos) {
switch(chaine.charAt(pos)) {
case 'a':
switch(chaine.charAt(pos+1)) {
case 'b':
esp.mValue=3;
oper.mValue=10;
break;
case 'c':
esp.mValue=4;
oper.mValue=15;
break;
case 's':
esp.mValue=4;
oper.mValue=14;
break;
case 't':
esp.mValue=4;
oper.mValue=16;
break;
}
break;
case 'c':
if (chaine.charAt(pos+1)=='h') {
esp.mValue=2;
oper.mValue=18;
}
else if ((chaine.charAt(pos+1)=='o') && (chaine.charAt(pos+2)=='s')) {
if (chaine.charAt(pos+3)=='h') {
esp.mValue=4;
switch(chaine.charAt(pos)) {
case 'a':
switch(chaine.charAt(pos+1)) {
case 'b':
esp.mValue=3;
oper.mValue=10;
break;
case 'c':
esp.mValue=4;
oper.mValue=15;
break;
case 's':
esp.mValue=4;
oper.mValue=14;
break;
case 't':
esp.mValue=4;
oper.mValue=16;
break;
}
break;
case 'c':
if (chaine.charAt(pos+1)=='h') {
esp.mValue=2;
oper.mValue=18;
}
else {
esp.mValue=3;
oper.mValue=12;
else if ((chaine.charAt(pos+1)=='o') && (chaine.charAt(pos+2)=='s')) {
if (chaine.charAt(pos+3)=='h') {
esp.mValue=4;
oper.mValue=18;
}
else {
esp.mValue=3;
oper.mValue=12;
}
}
}
break;
case 'e':
if ((chaine.charAt(pos+1)=='x') && (chaine.charAt(pos+2)=='p')) {
esp.mValue=3;
oper.mValue=6;
}
else oper.mValue=-10;
break;
case 'l':
if (chaine.charAt(pos+1)=='n') {
esp.mValue=2;
oper.mValue=7;
}
else if ((chaine.charAt(pos+1)=='o') && (chaine.charAt(pos+2)=='g')){
esp.mValue=3;
oper.mValue=8;
}
else oper.mValue=-10;
break;
case 's':
if (chaine.charAt(pos+1)=='h') {
esp.mValue=2;
oper.mValue=17;
}
else if (chaine.charAt(pos+1)=='q') {
esp.mValue=4;
oper.mValue=9;
}
else {
if (chaine.charAt(pos+3)=='h') {
esp.mValue=4;
break;
case 'e':
if ((chaine.charAt(pos+1)=='x') && (chaine.charAt(pos+2)=='p')) {
esp.mValue=3;
oper.mValue=6;
}
else oper.mValue=-10;
break;
case 'l':
if (chaine.charAt(pos+1)=='n') {
esp.mValue=2;
oper.mValue=7;
}
else if ((chaine.charAt(pos+1)=='o') && (chaine.charAt(pos+2)=='g')){
esp.mValue=3;
oper.mValue=8;
}
else oper.mValue=-10;
break;
case 's':
if (chaine.charAt(pos+1)=='h') {
esp.mValue=2;
oper.mValue=17;
}
else {
esp.mValue=3;
oper.mValue=11;
}
}
break;
case 't':
if (chaine.charAt(pos+1)=='h') {
esp.mValue=2;
oper.mValue=19;
}
else if ((chaine.charAt(pos+1)=='a') && (chaine.charAt(pos+2)=='n')) {
if (chaine.charAt(pos+3)=='h') {
else if (chaine.charAt(pos+1)=='q') {
esp.mValue=4;
oper.mValue=9;
}
else {
if (chaine.charAt(pos+3)=='h') {
esp.mValue=4;
oper.mValue=17;
}
else {
esp.mValue=3;
oper.mValue=11;
}
}
break;
case 't':
if (chaine.charAt(pos+1)=='h') {
esp.mValue=2;
oper.mValue=19;
}
else {
esp.mValue=3;
oper.mValue=13;
else if ((chaine.charAt(pos+1)=='a') && (chaine.charAt(pos+2)=='n')) {
if (chaine.charAt(pos+3)=='h') {
esp.mValue=4;
oper.mValue=19;
}
else {
esp.mValue=3;
oper.mValue=13;
}
}
else oper.mValue=-10;
break;
default:
oper.mValue=-10;
break;
}
else oper.mValue=-10;
break;
default:
oper.mValue=-10;
break;
}
}
//.................................................................................... CopyPartialString