Browse Source

Gestion d'erreur évaluation element seul

Arthur Brandao 6 years ago
parent
commit
fc630f2987
1 changed files with 10 additions and 4 deletions
  1. 10 4
      src/migl/lisp/LispImpl.java

+ 10 - 4
src/migl/lisp/LispImpl.java

@@ -168,11 +168,17 @@ public class LispImpl implements Lisp {
 
 	@Override
 	@SuppressWarnings("unchecked")
-	public Object evaluate(Object ex) throws LispError {
-		if(ex instanceof ConsList) {
-			return eval((ConsList<Object>) ex);
+	public Object evaluate(Object lisp) throws LispError {
+		if(lisp instanceof ConsList) {
+			return eval((ConsList<Object>) lisp);
 		}
-		return LispElement.generate(ex);
+		//Si element seul on évalue directement sa valeur
+		try {
+			return LispElement.generate(lisp);
+		} catch (IllegalArgumentException ex) {
+			throw new LispError(ex.getMessage(), ex);
+		}
+		
 	}
 	
 	/* --- Verification --- */