|
@@ -10,27 +10,18 @@ public class LispImpl implements Lisp {
|
|
|
|
|
|
@Override
|
|
|
public Object parse(String expr) throws LispError {
|
|
|
- /*
|
|
|
- * Implementer Grammaire
|
|
|
- * X = E | F
|
|
|
- * E = bool | entier | decimal | string
|
|
|
- * F = '('X*')'
|
|
|
- */
|
|
|
Stack<String> explode = this.explode(expr);
|
|
|
- while(explode.size() > 0) {
|
|
|
- String val = explode.remove(0);
|
|
|
- //Analyse le type d'expression
|
|
|
- if(val.equals("(")){
|
|
|
- return this.parseList(explode);
|
|
|
- } else {
|
|
|
- //Element seul
|
|
|
- if(explode.size() > 1) {
|
|
|
- throw new LispError("Invalid format");
|
|
|
- }
|
|
|
- return this.parseElement(val);
|
|
|
+ //Analyse le type d'expression
|
|
|
+ String val = explode.remove(0);
|
|
|
+ if(val.equals("(")){
|
|
|
+ return this.parseList(explode);
|
|
|
+ } else {
|
|
|
+ //Element seul
|
|
|
+ if(explode.size() > 1) {
|
|
|
+ throw new LispError("Invalid format");
|
|
|
}
|
|
|
+ return this.parseElement(val);
|
|
|
}
|
|
|
- return null;
|
|
|
}
|
|
|
|
|
|
@Override
|