|
@@ -2,9 +2,7 @@ package migl.lisp;
|
|
|
|
|
|
import java.math.BigInteger;
|
|
|
import java.util.LinkedList;
|
|
|
-import java.util.PriorityQueue;
|
|
|
import java.util.Queue;
|
|
|
-import java.util.Stack;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
|
|
@@ -39,6 +37,13 @@ public class LispImpl implements Lisp {
|
|
|
return new BigInteger("3"); //ToDo juste pour passer le test ReplTest
|
|
|
}
|
|
|
|
|
|
+ /* --- Verification --- */
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Verifie que le format d'un String correspond bien à une expression Lisp
|
|
|
+ * @param expr Le String à examiner
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private boolean verify(String expr) {
|
|
|
expr = expr.trim();
|
|
|
//Pas vide
|
|
@@ -52,6 +57,11 @@ public class LispImpl implements Lisp {
|
|
|
return this.verifyElement(expr);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Verifie que le format d'un String correspond bien à une liste Lisp
|
|
|
+ * @param expr Le String à examiner
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private boolean verifyList(String expr) {
|
|
|
Pattern p = Pattern.compile("\\(([ |\t]*[A-Za-z0-9\\.\\+\\-\\/\\*<>=#]+[ |\t]*)+\\)");
|
|
|
Matcher m = p.matcher(expr);
|
|
@@ -75,12 +85,19 @@ public class LispImpl implements Lisp {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Verifie que le format d'un String correspond bien à un element Lisp
|
|
|
+ * @param expr Le String à examiner
|
|
|
+ * @return
|
|
|
+ */
|
|
|
private boolean verifyElement(String expr) {
|
|
|
Pattern p = Pattern.compile("[ |\t]*[A-Za-z0-9\\.\\+\\-\\/\\*<>=#]+[ |\t]*");
|
|
|
Matcher m = p.matcher(expr);
|
|
|
return m.find();
|
|
|
}
|
|
|
|
|
|
+ /* --- Parser --- */
|
|
|
+
|
|
|
/**
|
|
|
* Découpe un string pour l'analyse Lisp
|
|
|
* @param expr L'expression à analyser
|