瀏覽代碼

Ajout documentation

Arthur Brandao 6 年之前
父節點
當前提交
6562bf20bf
共有 2 個文件被更改,包括 41 次插入0 次删除
  1. 6 0
      src/migl/lisp/LispFactory.java
  2. 35 0
      src/migl/lisp/operator/DefineOperator.java

+ 6 - 0
src/migl/lisp/LispFactory.java

@@ -18,6 +18,7 @@ public class LispFactory {
 
     /**
      * Create a new instance of the interpreter.
+     * Reset LispElement cache and define variable
      * 
      * @return a new lisp interpreter.
      */
@@ -30,6 +31,11 @@ public class LispFactory {
         return interpreter;
     }
     
+    /**
+     * Create a new instance of the interpreter.
+     * 
+     * @return a new lisp interpreter.
+     */
     public static Lisp getInterpreter() {
     	if(interpreter == null) {
     		interpreter = new LispImpl();

+ 35 - 0
src/migl/lisp/operator/DefineOperator.java

@@ -22,6 +22,11 @@ public class DefineOperator implements LispOperator {
 		define.clear();
 	}
 	
+	/**
+	 * Indique si un Objet est la representation d'une expression lambda
+	 * @param elt L'objet à evaluer
+	 * @return
+	 */
 	@SuppressWarnings("unchecked")
 	public static boolean isLambda(Object elt) {
 		if(!(elt instanceof String)) {
@@ -43,6 +48,12 @@ public class DefineOperator implements LispOperator {
 		}
 	}
 	
+	/**
+	 * Evalue un objet
+	 * @param elt
+	 * @return
+	 * @throws LispError
+	 */
 	@SuppressWarnings("unchecked")
 	public static LispElement eval(Object elt) throws LispError {
 		if(elt instanceof ConsList) {
@@ -66,6 +77,11 @@ public class DefineOperator implements LispOperator {
 		return LispElement.generate(cl.car());
 	}
 	
+	/**
+	 * Evalue une liste
+	 * @param lisp
+	 * @return
+	 */
 	public static LispElement eval(ConsList<Object> lisp) {
 		if(lisp.car() instanceof ConsList) {
 			String res = lisp.car().toString();
@@ -86,6 +102,12 @@ public class DefineOperator implements LispOperator {
 		}
 	}
 	
+	/**
+	 * Operateur lisp define
+	 * @param lisp
+	 * @return
+	 * @throws LispError
+	 */
 	private LispElement define(ConsList<Object> lisp) throws LispError {
 		if(lisp.size() != 2) {
 			throw new LispError(LispError.ERR_NUM_ARG);
@@ -106,6 +128,12 @@ public class DefineOperator implements LispOperator {
 		return eval(lisp.cdr());
 	}
 
+	/**
+	 * Operateur lisp set!
+	 * @param lisp
+	 * @return
+	 * @throws LispError
+	 */
 	private LispElement set(ConsList<Object> lisp) throws LispError {
 		if(lisp.size() != 2) {
 			throw new LispError(LispError.ERR_NUM_ARG);
@@ -129,6 +157,13 @@ public class DefineOperator implements LispOperator {
 		return eval(lisp.cdr());
 	}
 	
+	/**
+	 * Evalue une expression lambda
+	 * @param operator Le nom de l'expression
+	 * @param lisp Les parametres de l'expression
+	 * @return La valeur de l'expression
+	 * @throws LispError
+	 */
 	@SuppressWarnings("unchecked")
 	private LispElement lambda(String operator, ConsList<Object> lisp) throws LispError {
 		if(!isLambda(operator)) {