LispImpl.java 800 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package migl.lisp;
  2. public class LispImpl implements Lisp {
  3. private final LispParser parser = new LispParser();
  4. private final LispEval eval = new LispEval(this);
  5. @Override
  6. public Object parse(String expr) throws LispError {
  7. this.parser.setExpr(expr);
  8. if(!this.parser.verify()) {
  9. throw new LispError("Invalid Format");
  10. }
  11. return this.parser.parse();
  12. }
  13. @Override
  14. public Object evaluate(Object lisp) throws LispError {
  15. this.eval.setLisp(lisp);
  16. return this.eval.evaluate();
  17. }
  18. /**
  19. * Retourne l'instance utilisée pour analyser les epxressions lisp
  20. * @return
  21. */
  22. public LispParser getParser() {
  23. return this.parser;
  24. }
  25. /**
  26. * Retourne l'instance utilisée pour évaluer les epxressions lisp
  27. * @return
  28. */
  29. public LispEval getEval() {
  30. return this.eval;
  31. }
  32. }