|
@@ -13,7 +13,7 @@ public class LispImpl implements Lisp {
|
|
|
Stack<String> explode = this.explode(expr);
|
|
|
//Analyse le type d'expression
|
|
|
String val = explode.remove(0);
|
|
|
- if(val.equals("(")){
|
|
|
+ if("(".equals(val)){
|
|
|
return this.parseList(explode);
|
|
|
} else {
|
|
|
//Element seul
|
|
@@ -74,20 +74,17 @@ public class LispImpl implements Lisp {
|
|
|
*/
|
|
|
private Object parseElement(String val) {
|
|
|
try {
|
|
|
- BigInteger bi = new BigInteger(val);
|
|
|
- return bi;
|
|
|
+ return new BigInteger(val);
|
|
|
} catch(NumberFormatException ex) {
|
|
|
//Rien
|
|
|
}
|
|
|
try {
|
|
|
- Double d = Double.valueOf(val);
|
|
|
- return d;
|
|
|
+ return Double.valueOf(val);
|
|
|
} catch(NumberFormatException ex) {
|
|
|
//Rien
|
|
|
}
|
|
|
try {
|
|
|
- LispBoolean lbool = LispBoolean.valueOf(val);
|
|
|
- return lbool;
|
|
|
+ return LispBoolean.valueOf(val);
|
|
|
} catch(IllegalArgumentException ex) {
|
|
|
//Rien
|
|
|
}
|
|
@@ -103,8 +100,8 @@ public class LispImpl implements Lisp {
|
|
|
private Object parseList(Stack<String> pile) throws LispError {
|
|
|
ConsList<Object> list = ConsListFactory.nil();
|
|
|
String val = pile.remove(0);
|
|
|
- while(pile.size() > 0 && !val.equals(")")) {
|
|
|
- if(val.equals("(")) {
|
|
|
+ while(pile.size() > 0 && !")".equals(val)) {
|
|
|
+ if("(".equals(val)) {
|
|
|
//list = list.append(this.parse("(" + val));
|
|
|
list = list.append(this.parseList(pile));
|
|
|
} else {
|
|
@@ -113,7 +110,7 @@ public class LispImpl implements Lisp {
|
|
|
val = pile.remove(0);
|
|
|
}
|
|
|
//Si arret cause pile vide erreur
|
|
|
- if(!val.equals(")")) {
|
|
|
+ if(!")".equals(val)) {
|
|
|
throw new LispError("Invalid Format");
|
|
|
}
|
|
|
return list;
|