1. 30 Jun, 2020 1 commit
  2. 14 Jun, 2020 4 commits
    • Jiawen Lyu's avatar
      add function key word · 50d7c590
      Jiawen Lyu authored
      50d7c590
    • Jiawen Lyu's avatar
      ca58f49a
    • Jiawen Lyu's avatar
      more params for procedure · 3d3f24ff
      Jiawen Lyu authored
      3d3f24ff
    • Jiawen Lyu's avatar
      procedure without params · 887c128c
      Jiawen Lyu authored
      diff --git a/logo-fx/bin/logoparsing/LogoTreeVisitor.class b/logo-fx/bin/logoparsing/LogoTreeVisitor.class
      index 35b97e8..bd7627d 100644
      Binary files a/logo-fx/bin/logoparsing/LogoTreeVisitor.class and b/logo-fx/bin/logoparsing/LogoTreeVisitor.class differ
      diff --git a/logo-fx/src/logoparsing/LogoTreeVisitor.java b/logo-fx/src/logoparsing/LogoTreeVisitor.java
      index e96ea23..deb8946 100644
      --- a/logo-fx/src/logoparsing/LogoTreeVisitor.java
      +++ b/logo-fx/src/logoparsing/LogoTreeVisitor.java
      @@ -217,14 +217,20 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
           @Override
           public Integer visitProcedure(LogoParser.ProcedureContext ctx) {
               String nomProcedure = ctx.VAR().getText();
      -        Integer createListeParamsSuccess;
               //创建一个作用域,然后推入执行栈中,方便参数列表把记住所有的参数名
               TableSymboles currentTableSymboles = new TableSymboles();
               pileExecution.push(currentTableSymboles);
      
               Liste_instructionsContext listeInstructions = ctx.liste_instructions();
               //通过执行栈存储参数列表
      -        createListeParamsSuccess = visit(ctx.liste_parametres());
      +        Integer createListeParamsSuccess;
      +        if(ctx.liste_parametres() != null) {
      +            //如果有参数传进来
      +            createListeParamsSuccess = visit(ctx.liste_parametres());
      +        }else {
      +            //如果没有参数
      +            createListeParamsSuccess = 0;
      +        }
      
               //获取到参数名之后,创建相应的procedure实例
               currentTableSymboles = pileExecution.pop();
      @@ -477,7 +483,6 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
               if (!pileExecution.empty()) {
                   currentTableSymboles = pileExecution.pop();
               } else {
      -            System.out.println("执行栈为空");
                   return -1;
               }
      
      @@ -500,7 +505,6 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
               if (!pileExecution.empty()) {
                   currentTableSymboles = pileExecution.pop();
               } else {
      -            System.out.println("执行栈为空");
                   return -1;
               }
               setExprValue(ctx, currentTableSymboles.getValeur(varText));
      887c128c
  3. 11 Jun, 2020 2 commits
  4. 05 Jun, 2020 3 commits
  5. 04 Jun, 2020 1 commit
  6. 01 Jun, 2020 1 commit
  7. 22 May, 2020 8 commits
    • Jiawen Lyu's avatar
      add tantque · dd5a208a
      Jiawen Lyu authored
      dd5a208a
    • Jiawen Lyu's avatar
      add si instruction · 3884b602
      Jiawen Lyu authored
      3884b602
    • Jiawen Lyu's avatar
      add appelle · 4da0a130
      Jiawen Lyu authored
      4da0a130
    • Jiawen Lyu's avatar
      create tablesymboles table · 9308417f
      Jiawen Lyu authored
      9308417f
    • Jiawen Lyu's avatar
      finish affectation · a3847cd1
      Jiawen Lyu authored
      a3847cd1
    • Jiawen Lyu's avatar
      add fixecap · 53e3b935
      Jiawen Lyu authored
      diff --git a/logo-fx/bin/logoparsing/LogoTreeVisitor.class b/logo-fx/bin/logoparsing/LogoTreeVisitor.class
      index 27d0a8c..16be9ad 100644
      Binary files a/logo-fx/bin/logoparsing/LogoTreeVisitor.class and b/logo-fx/bin/logoparsing/LogoTreeVisitor.class differ
      diff --git a/logo-fx/bin/logoparsing/Traceur.class b/logo-fx/bin/logoparsing/Traceur.class
      index c530069..85924fe 100644
      Binary files a/logo-fx/bin/logoparsing/Traceur.class and b/logo-fx/bin/logoparsing/Traceur.class differ
      diff --git a/logo-fx/src/logoparsing/LogoTreeVisitor.java b/logo-fx/src/logoparsing/LogoTreeVisitor.java
      index 7fe07d7..0b7ca78 100644
      --- a/logo-fx/src/logoparsing/LogoTreeVisitor.java
      +++ b/logo-fx/src/logoparsing/LogoTreeVisitor.java
      @@ -65,24 +65,24 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       		// 开始访问bloc子树
       		res._1 = visit(bloc);
       		// 在这里不用存值
      -		res._2 = res._1 == 0 ? getExprValue(bloc): -1;
      +		res._2 = res._1 == 0 ? getExprValue(bloc) : -1;
       		return res;
       	}
      -
      +
       	private Binome evaluateLoop(ParseTree loop) {
       		Binome res = new Binome();
       		// 开始访问bloc子树
       		ParseTree parentBloc = loop.getParent();
      -		while(!(parentBloc instanceof BlocContext)) {
      +		while (!(parentBloc instanceof BlocContext)) {
       			parentBloc = parentBloc.getParent();
       		}
      -
      -		if(parentBloc instanceof RepeteContext) {
      -			res._1 = -2;
      +
      +		if (parentBloc instanceof RepeteContext) {
      +			res._1 = -2;
       		} else {
       			res._1 = 0;
       		}
      -		res._2 = res._1 == 0 ? getExprValue(parentBloc): -1;
      +		res._2 = res._1 == 0 ? getExprValue(parentBloc) : -1;
       		return res;
       	}
      
      @@ -196,7 +196,13 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
      
       	@Override
       	public Integer visitFixeCap(FixeCapContext ctx) {
      -		return 0;
      +		Binome bilan = evaluateExpr(ctx.expr());
      +		if (bilan._1 == 0) {
      +			traceur.fixeCap(bilan._2);
      +			log.setValue("Fixer l'angle:  " + bilan._2);
      +			log.setValue("\n");
      +		}
      +		return bilan._1;
       	}
      
       	@Override
      @@ -374,18 +380,21 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
      
       	@Override
       	public Integer visitMove(MoveContext ctx) {
      -		traceur.movePosition();
      -		log.setValue(
      -				"Déplacer à la position ( " + traceur.getPosx() + ", " + traceur.getPosy() + traceur.getAngle() + " )");
      -		log.setValue("\n");
      -		return 0;
      +		int res = traceur.movePosition();
      +		if (res == 0) {
      +			log.setValue("Déplacer à la position ( " + traceur.getPosx() + ", " + traceur.getPosy() + traceur.getAngle()
      +					+ " )");
      +			log.setValue("\n");
      +		}
      +		return res;
      +
       	}
      
      -	 @Override
      -	 public Integer visitLoop(LoopContext ctx) {
      -		 Binome bilan = evaluateLoop(ctx);
      -		 setExprValue(ctx, bilan._2);
      -		 return 0;
      -	 }
      +	@Override
      +	public Integer visitLoop(LoopContext ctx) {
      +		Binome bilan = evaluateLoop(ctx);
      +		setExprValue(ctx, bilan._2);
      +		return 0;
      +	}
      
       }
      diff --git a/logo-fx/src/logoparsing/Traceur.java b/logo-fx/src/logoparsing/Traceur.java
      index fa3add9..6548d6c 100644
      --- a/logo-fx/src/logoparsing/Traceur.java
      +++ b/logo-fx/src/logoparsing/Traceur.java
      @@ -90,13 +90,13 @@ public class Traceur {
       		this.moveable = canMove;
       	}
      
      -	public void movePosition() {
      +	public Integer movePosition() {
       		if (!positionStack.empty()) {
       			Double[] destnation = positionStack.pop();
       			setPosition(destnation);
      -
      +			return 0;
       		} else {
      -			return;
      +			return -3;
       		}
      
       	}
      @@ -123,5 +123,10 @@ public class Traceur {
       	public double getAngle() {
       		return angle;
       	}
      +
      +	public void fixeCap(double angle) {
      +		this.angle = angle;
      +		setTeta();
      +	}
      
       }
      53e3b935
    • Jiawen Lyu's avatar
      add loop · b90eaa58
      Jiawen Lyu authored
      diff --git a/logo-fx/bin/logoparsing/LogoTreeVisitor$Binome.class b/logo-fx/bin/logoparsing/LogoTreeVisitor$Binome.class
      index c0204b5..61b12c2 100644
      Binary files a/logo-fx/bin/logoparsing/LogoTreeVisitor$Binome.class and b/logo-fx/bin/logoparsing/LogoTreeVisitor$Binome.class differ
      diff --git a/logo-fx/bin/logoparsing/LogoTreeVisitor.class b/logo-fx/bin/logoparsing/LogoTreeVisitor.class
      index 1b06d67..27d0a8c 100644
      Binary files a/logo-fx/bin/logoparsing/LogoTreeVisitor.class and b/logo-fx/bin/logoparsing/LogoTreeVisitor.class differ
      diff --git a/logo-fx/bin/logoparsing/Traceur.class b/logo-fx/bin/logoparsing/Traceur.class
      index ee499a3..c530069 100644
      Binary files a/logo-fx/bin/logoparsing/Traceur.class and b/logo-fx/bin/logoparsing/Traceur.class differ
      diff --git a/logo-fx/src/logoparsing/LogoTreeVisitor.java b/logo-fx/src/logoparsing/LogoTreeVisitor.java
      index 0b46d31..7fe07d7 100644
      --- a/logo-fx/src/logoparsing/LogoTreeVisitor.java
      +++ b/logo-fx/src/logoparsing/LogoTreeVisitor.java
      @@ -7,9 +7,9 @@ import org.antlr.v4.runtime.tree.ParseTreeProperty;
      
       import javafx.beans.property.SimpleStringProperty;
       import javafx.beans.property.StringProperty;
      -import logogui.Color;
       import logoparsing.LogoParser.AvContext;
       import logoparsing.LogoParser.BaisseCrayonContext;
      +import logoparsing.LogoParser.BlocContext;
       import logoparsing.LogoParser.CosContext;
       import logoparsing.LogoParser.CouleurContext;
       import logoparsing.LogoParser.CrochetContext;
      @@ -65,7 +65,24 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       		// 开始访问bloc子树
       		res._1 = visit(bloc);
       		// 在这里不用存值
      -		// res._2 = res._1 == 0 ? ;
      +		res._2 = res._1 == 0 ? getExprValue(bloc): -1;
      +		return res;
      +	}
      +
      +	private Binome evaluateLoop(ParseTree loop) {
      +		Binome res = new Binome();
      +		// 开始访问bloc子树
      +		ParseTree parentBloc = loop.getParent();
      +		while(!(parentBloc instanceof BlocContext)) {
      +			parentBloc = parentBloc.getParent();
      +		}
      +
      +		if(parentBloc instanceof RepeteContext) {
      +			res._1 = -2;
      +		} else {
      +			res._1 = 0;
      +		}
      +		res._2 = res._1 == 0 ? getExprValue(parentBloc): -1;
       		return res;
       	}
      
      @@ -82,10 +99,6 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
      
       		// stocker le résultat du calcul
       		public Double _2;
      -
      -		public boolean isValid() {
      -			return _1 == 0;
      -		}
       	}
      
       	/*
      @@ -316,9 +329,9 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       		try {
       			if (expr._1 == 0) {
       				compteur = (int) Math.round(expr._2);
      -				for (int i = 0; i < compteur; i++) {
      +				for (int i = 1; i < compteur + 1; i++) {
      +					setExprValue(ctx.bloc(), i);
       					bloc = evaluateBloc(ctx.bloc());
      -					System.out.println("LogoTreeVisitor.visitRepete()" + bloc._2);
       				}
       			} else {
       				return expr._1 == 0 ? bloc._1 : expr._1;
      @@ -368,9 +381,11 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       		return 0;
       	}
      
      -	// @Override
      -	// public Integer visitLoop(LoopContext ctx) {
      -	//
      -	// }
      +	 @Override
      +	 public Integer visitLoop(LoopContext ctx) {
      +		 Binome bilan = evaluateLoop(ctx);
      +		 setExprValue(ctx, bilan._2);
      +		 return 0;
      +	 }
      
       }
      diff --git a/logo-fx/src/logoparsing/Traceur.java b/logo-fx/src/logoparsing/Traceur.java
      index 6df15d8..fa3add9 100644
      --- a/logo-fx/src/logoparsing/Traceur.java
      +++ b/logo-fx/src/logoparsing/Traceur.java
      @@ -16,7 +16,7 @@ import logogui.GraphParameter;
      
       public class Traceur {
       	private Color couleur;
      -	private double initx = 350, inity = 350; // position initiale
      +	private double initx = 450, inity = 150; // position initiale
       	private double posx = initx, posy = inity; // position courante
       	private double angle = 90;
       	private double teta;
      b90eaa58
    • Jiawen Lyu's avatar
      add store and move function · e1f1a0bf
      Jiawen Lyu authored
      e1f1a0bf
  8. 21 May, 2020 4 commits
    • Jiawen Lyu's avatar
      add lc and bc · b642594a
      Jiawen Lyu authored
      diff --git a/logo-fx/bin/logoparsing/Logo.interp b/logo-fx/bin/logoparsing/Logo.interp
      index 20cf0bd..a34b375 100644
      --- a/logo-fx/bin/logoparsing/Logo.interp
      +++ b/logo-fx/bin/logoparsing/Logo.interp
      @@ -12,6 +12,7 @@ null
       'lc'
       'bc'
       'fpos'
      +','
       '*'
       '/'
       '+'
      @@ -51,6 +52,7 @@ null
       null
       null
       null
      +null
       FLOAT
       WS
       COMMENT1
      @@ -65,4 +67,4 @@ expr
      
       atn:
      -[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 28, 77, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 3, 2, 3, 2, 3, 3, 6, 3, 16, 10, 3, 13, 3, 14, 3, 17, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 5, 5, 43, 10, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 64, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 7, 6, 72, 10, 6, 12, 6, 14, 6, 75, 11, 6, 3, 6, 2, 3, 10, 7, 2, 4, 6, 8, 10, 2, 4, 3, 2, 15, 16, 3, 2, 17, 18, 2, 88, 2, 12, 3, 2, 2, 2, 4, 15, 3, 2, 2, 2, 6, 19, 3, 2, 2, 2, 8, 42, 3, 2, 2, 2, 10, 63, 3, 2, 2, 2, 12, 13, 5, 4, 3, 2, 13, 3, 3, 2, 2, 2, 14, 16, 5, 8, 5, 2, 15, 14, 3, 2, 2, 2, 16, 17, 3, 2, 2, 2, 17, 15, 3, 2, 2, 2, 17, 18, 3, 2, 2, 2, 18, 5, 3, 2, 2, 2, 19, 20, 7, 3, 2, 2, 20, 21, 5, 4, 3, 2, 21, 22, 7, 4, 2, 2, 22, 7, 3, 2, 2, 2, 23, 24, 7, 5, 2, 2, 24, 25, 5, 10, 6, 2, 25, 26, 5, 6, 4, 2, 26, 43, 3, 2, 2, 2, 27, 28, 7, 6, 2, 2, 28, 43, 5, 10, 6, 2, 29, 30, 7, 7, 2, 2, 30, 43, 5, 10, 6, 2, 31, 32, 7, 8, 2, 2, 32, 43, 5, 10, 6, 2, 33, 34, 7, 9, 2, 2, 34, 43, 5, 10, 6, 2, 35, 36, 7, 10, 2, 2, 36, 43, 5, 10, 6, 2, 37, 38, 7, 11, 2, 2, 38, 43, 5, 10, 6, 2, 39, 43, 7, 12, 2, 2, 40, 43, 7, 13, 2, 2, 41, 43, 7, 14, 2, 2, 42, 23, 3, 2, 2, 2, 42, 27, 3, 2, 2, 2, 42, 29, 3, 2, 2, 2, 42, 31, 3, 2, 2, 2, 42, 33, 3, 2, 2, 2, 42, 35, 3, 2, 2, 2, 42, 37, 3, 2, 2, 2, 42, 39, 3, 2, 2, 2, 42, 40, 3, 2, 2, 2, 42, 41, 3, 2, 2, 2, 43, 9, 3, 2, 2, 2, 44, 45, 8, 6, 1, 2, 45, 46, 7, 19, 2, 2, 46, 64, 5, 10, 6, 2, 47, 48, 7, 20, 2, 2, 48, 49, 7, 21, 2, 2, 49, 50, 5, 10, 6, 2, 50, 51, 7, 22, 2, 2, 51, 64, 3, 2, 2, 2, 52, 53, 7, 23, 2, 2, 53, 54, 7, 21, 2, 2, 54, 55, 5, 10, 6, 2, 55, 56, 7, 22, 2, 2, 56, 64, 3, 2, 2, 2, 57, 64, 7, 25, 2, 2, 58, 64, 7, 24, 2, 2, 59, 60, 7, 21, 2, 2, 60, 61, 5, 10, 6, 2, 61, 62, 7, 22, 2, 2, 62, 64, 3, 2, 2, 2, 63, 44, 3, 2, 2, 2, 63, 47, 3, 2, 2, 2, 63, 52, 3, 2, 2, 2, 63, 57, 3, 2, 2, 2, 63, 58, 3, 2, 2, 2, 63, 59, 3, 2, 2, 2, 64, 73, 3, 2, 2, 2, 65, 66, 12, 10, 2, 2, 66, 67, 9, 2, 2, 2, 67, 72, 5, 10, 6, 11, 68, 69, 12, 9, 2, 2, 69, 70, 9, 3, 2, 2, 70, 72, 5, 10, 6, 10, 71, 65, 3, 2, 2, 2, 71, 68, 3, 2, 2, 2, 72, 75, 3, 2, 2, 2, 73, 71, 3, 2, 2, 2, 73, 74, 3, 2, 2, 2, 74, 11, 3, 2, 2, 2, 75, 73, 3, 2, 2, 2, 7, 17, 42, 63, 71, 73]
      \ No newline at end of file
      +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 3, 29, 83, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 3, 2, 3, 2, 3, 3, 6, 3, 16, 10, 3, 13, 3, 14, 3, 17, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 3, 5, 5, 5, 49, 10, 5, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 5, 6, 70, 10, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 7, 6, 78, 10, 6, 12, 6, 14, 6, 81, 11, 6, 3, 6, 2, 3, 10, 7, 2, 4, 6, 8, 10, 2, 4, 3, 2, 16, 17, 3, 2, 18, 19, 2, 94, 2, 12, 3, 2, 2, 2, 4, 15, 3, 2, 2, 2, 6, 19, 3, 2, 2, 2, 8, 48, 3, 2, 2, 2, 10, 69, 3, 2, 2, 2, 12, 13, 5, 4, 3, 2, 13, 3, 3, 2, 2, 2, 14, 16, 5, 8, 5, 2, 15, 14, 3, 2, 2, 2, 16, 17, 3, 2, 2, 2, 17, 15, 3, 2, 2, 2, 17, 18, 3, 2, 2, 2, 18, 5, 3, 2, 2, 2, 19, 20, 7, 3, 2, 2, 20, 21, 5, 4, 3, 2, 21, 22, 7, 4, 2, 2, 22, 7, 3, 2, 2, 2, 23, 24, 7, 5, 2, 2, 24, 25, 5, 10, 6, 2, 25, 26, 5, 6, 4, 2, 26, 49, 3, 2, 2, 2, 27, 28, 7, 6, 2, 2, 28, 49, 5, 10, 6, 2, 29, 30, 7, 7, 2, 2, 30, 49, 5, 10, 6, 2, 31, 32, 7, 8, 2, 2, 32, 49, 5, 10, 6, 2, 33, 34, 7, 9, 2, 2, 34, 49, 5, 10, 6, 2, 35, 36, 7, 10, 2, 2, 36, 49, 5, 10, 6, 2, 37, 38, 7, 11, 2, 2, 38, 49, 5, 10, 6, 2, 39, 49, 7, 12, 2, 2, 40, 49, 7, 13, 2, 2, 41, 42, 7, 14, 2, 2, 42, 43, 7, 3, 2, 2, 43, 44, 5, 10, 6, 2, 44, 45, 7, 15, 2, 2, 45, 46, 5, 10, 6, 2, 46, 47, 7, 4, 2, 2, 47, 49, 3, 2, 2, 2, 48, 23, 3, 2, 2, 2, 48, 27, 3, 2, 2, 2, 48, 29, 3, 2, 2, 2, 48, 31, 3, 2, 2, 2, 48, 33, 3, 2, 2, 2, 48, 35, 3, 2, 2, 2, 48, 37, 3, 2, 2, 2, 48, 39, 3, 2, 2, 2, 48, 40, 3, 2, 2, 2, 48, 41, 3, 2, 2, 2, 49, 9, 3, 2, 2, 2, 50, 51, 8, 6, 1, 2, 51, 52, 7, 20, 2, 2, 52, 70, 5, 10, 6, 2, 53, 54, 7, 21, 2, 2, 54, 55, 7, 22, 2, 2, 55, 56, 5, 10, 6, 2, 56, 57, 7, 23, 2, 2, 57, 70, 3, 2, 2, 2, 58, 59, 7, 24, 2, 2, 59, 60, 7, 22, 2, 2, 60, 61, 5, 10, 6, 2, 61, 62, 7, 23, 2, 2, 62, 70, 3, 2, 2, 2, 63, 70, 7, 26, 2, 2, 64, 70, 7, 25, 2, 2, 65, 66, 7, 22, 2, 2, 66, 67, 5, 10, 6, 2, 67, 68, 7, 23, 2, 2, 68, 70, 3, 2, 2, 2, 69, 50, 3, 2, 2, 2, 69, 53, 3, 2, 2, 2, 69, 58, 3, 2, 2, 2, 69, 63, 3, 2, 2, 2, 69, 64, 3, 2, 2, 2, 69, 65, 3, 2, 2, 2, 70, 79, 3, 2, 2, 2, 71, 72, 12, 10, 2, 2, 72, 73, 9, 2, 2, 2, 73, 78, 5, 10, 6, 11, 74, 75, 12, 9, 2, 2, 75, 76, 9, 3, 2, 2, 76, 78, 5, 10, 6, 10, 77, 71, 3, 2, 2, 2, 77, 74, 3, 2, 2, 2, 78, 81, 3, 2, 2, 2, 79, 77, 3, 2, 2, 2, 79, 80, 3, 2, 2, 2, 80, 11, 3, 2, 2, 2, 81, 79, 3, 2, 2, 2, 7, 17, 48, 69, 77, 79]
      \ No newline at end of file
      diff --git a/logo-fx/bin/logoparsing/Logo.tokens b/logo-fx/bin/logoparsing/Logo.tokens
      index e55e07a..7999d72 100644
      --- a/logo-fx/bin/logoparsing/Logo.tokens
      +++ b/logo-fx/bin/logoparsing/Logo.tokens
      @@ -20,10 +20,11 @@ T__18=19
       T__19=20
       T__20=21
       T__21=22
      -FLOAT=23
      -WS=24
      -COMMENT1=25
      -COMMENT2=26
      +T__22=23
      +FLOAT=24
      +WS=25
      +COMMENT1=26
      +COMMENT2=27
       '['=1
       ']'=2
       'repete'=3
      @@ -36,13 +37,14 @@ COMMENT2=26
       'lc'=10
       'bc'=11
       'fpos'=12
      -'*'=13
      -'/'=14
      -'+'=15
      -'-'=16
      -'hasard'=17
      -'cos'=18
      -'('=19
      -')'=20
      -'sin'=21
      -'loop'=22
      +','=13
      +'*'=14
      +'/'=15
      +'+'=16
      +'-'=17
      +'hasard'=18
      +'cos'=19
      +'('=20
      +')'=21
      +'sin'=22
      +'loop'=23
      diff --git a/logo-fx/bin/logoparsing/LogoLexer.interp b/logo-fx/bin/logoparsing/LogoLexer.interp
      index 588f81d..cbbd639 100644
      --- a/logo-fx/bin/logoparsing/LogoLexer.interp
      +++ b/logo-fx/bin/logoparsing/LogoLexer.interp
      @@ -12,6 +12,7 @@ null
       'lc'
       'bc'
       'fpos'
      +','
       '*'
       '/'
       '+'
      @@ -51,6 +52,7 @@ null
       null
       null
       null
      +null
       FLOAT
       WS
       COMMENT1
      @@ -79,6 +81,7 @@ T__18
       T__19
       T__20
       T__21
      +T__22
       FLOAT
       WS
       COMMENT1
      @@ -92,4 +95,4 @@ mode names:
       DEFAULT_MODE
      
       atn:
      -[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 28, 182, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 7, 24, 133, 10, 24, 12, 24, 14, 24, 136, 11, 24, 3, 24, 3, 24, 6, 24, 140, 10, 24, 13, 24, 14, 24, 141, 5, 24, 144, 10, 24, 3, 25, 6, 25, 147, 10, 25, 13, 25, 14, 25, 148, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 26, 7, 26, 157, 10, 26, 12, 26, 14, 26, 160, 11, 26, 3, 26, 6, 26, 163, 10, 26, 13, 26, 14, 26, 164, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 7, 27, 173, 10, 27, 12, 27, 14, 27, 176, 11, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 4, 158, 174, 2, 28, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 3, 2, 5, 3, 2, 50, 59, 5, 2, 11, 12, 15, 15, 34, 34, 4, 2, 12, 12, 15, 15, 2, 188, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 3, 55, 3, 2, 2, 2, 5, 57, 3, 2, 2, 2, 7, 59, 3, 2, 2, 2, 9, 66, 3, 2, 2, 2, 11, 69, 3, 2, 2, 2, 13, 72, 3, 2, 2, 2, 15, 75, 3, 2, 2, 2, 17, 78, 3, 2, 2, 2, 19, 82, 3, 2, 2, 2, 21, 87, 3, 2, 2, 2, 23, 90, 3, 2, 2, 2, 25, 93, 3, 2, 2, 2, 27, 98, 3, 2, 2, 2, 29, 100, 3, 2, 2, 2, 31, 102, 3, 2, 2, 2, 33, 104, 3, 2, 2, 2, 35, 106, 3, 2, 2, 2, 37, 113, 3, 2, 2, 2, 39, 117, 3, 2, 2, 2, 41, 119, 3, 2, 2, 2, 43, 121, 3, 2, 2, 2, 45, 125, 3, 2, 2, 2, 47, 130, 3, 2, 2, 2, 49, 146, 3, 2, 2, 2, 51, 152, 3, 2, 2, 2, 53, 168, 3, 2, 2, 2, 55, 56, 7, 93, 2, 2, 56, 4, 3, 2, 2, 2, 57, 58, 7, 95, 2, 2, 58, 6, 3, 2, 2, 2, 59, 60, 7, 116, 2, 2, 60, 61, 7, 103, 2, 2, 61, 62, 7, 114, 2, 2, 62, 63, 7, 103, 2, 2, 63, 64, 7, 118, 2, 2, 64, 65, 7, 103, 2, 2, 65, 8, 3, 2, 2, 2, 66, 67, 7, 99, 2, 2, 67, 68, 7, 120, 2, 2, 68, 10, 3, 2, 2, 2, 69, 70, 7, 116, 2, 2, 70, 71, 7, 103, 2, 2, 71, 12, 3, 2, 2, 2, 72, 73, 7, 118, 2, 2, 73, 74, 7, 102, 2, 2, 74, 14, 3, 2, 2, 2, 75, 76, 7, 118, 2, 2, 76, 77, 7, 105, 2, 2, 77, 16, 3, 2, 2, 2, 78, 79, 7, 104, 2, 2, 79, 80, 7, 101, 2, 2, 80, 81, 7, 101, 2, 2, 81, 18, 3, 2, 2, 2, 82, 83, 7, 104, 2, 2, 83, 84, 7, 101, 2, 2, 84, 85, 7, 99, 2, 2, 85, 86, 7, 114, 2, 2, 86, 20, 3, 2, 2, 2, 87, 88, 7, 110, 2, 2, 88, 89, 7, 101, 2, 2, 89, 22, 3, 2, 2, 2, 90, 91, 7, 100, 2, 2, 91, 92, 7, 101, 2, 2, 92, 24, 3, 2, 2, 2, 93, 94, 7, 104, 2, 2, 94, 95, 7, 114, 2, 2, 95, 96, 7, 113, 2, 2, 96, 97, 7, 117, 2, 2, 97, 26, 3, 2, 2, 2, 98, 99, 7, 44, 2, 2, 99, 28, 3, 2, 2, 2, 100, 101, 7, 49, 2, 2, 101, 30, 3, 2, 2, 2, 102, 103, 7, 45, 2, 2, 103, 32, 3, 2, 2, 2, 104, 105, 7, 47, 2, 2, 105, 34, 3, 2, 2, 2, 106, 107, 7, 106, 2, 2, 107, 108, 7, 99, 2, 2, 108, 109, 7, 117, 2, 2, 109, 110, 7, 99, 2, 2, 110, 111, 7, 116, 2, 2, 111, 112, 7, 102, 2, 2, 112, 36, 3, 2, 2, 2, 113, 114, 7, 101, 2, 2, 114, 115, 7, 113, 2, 2, 115, 116, 7, 117, 2, 2, 116, 38, 3, 2, 2, 2, 117, 118, 7, 42, 2, 2, 118, 40, 3, 2, 2, 2, 119, 120, 7, 43, 2, 2, 120, 42, 3, 2, 2, 2, 121, 122, 7, 117, 2, 2, 122, 123, 7, 107, 2, 2, 123, 124, 7, 112, 2, 2, 124, 44, 3, 2, 2, 2, 125, 126, 7, 110, 2, 2, 126, 127, 7, 113, 2, 2, 127, 128, 7, 113, 2, 2, 128, 129, 7, 114, 2, 2, 129, 46, 3, 2, 2, 2, 130, 134, 9, 2, 2, 2, 131, 133, 9, 2, 2, 2, 132, 131, 3, 2, 2, 2, 133, 136, 3, 2, 2, 2, 134, 132, 3, 2, 2, 2, 134, 135, 3, 2, 2, 2, 135, 143, 3, 2, 2, 2, 136, 134, 3, 2, 2, 2, 137, 139, 7, 48, 2, 2, 138, 140, 9, 2, 2, 2, 139, 138, 3, 2, 2, 2, 140, 141, 3, 2, 2, 2, 141, 139, 3, 2, 2, 2, 141, 142, 3, 2, 2, 2, 142, 144, 3, 2, 2, 2, 143, 137, 3, 2, 2, 2, 143, 144, 3, 2, 2, 2, 144, 48, 3, 2, 2, 2, 145, 147, 9, 3, 2, 2, 146, 145, 3, 2, 2, 2, 147, 148, 3, 2, 2, 2, 148, 146, 3, 2, 2, 2, 148, 149, 3, 2, 2, 2, 149, 150, 3, 2, 2, 2, 150, 151, 8, 25, 2, 2, 151, 50, 3, 2, 2, 2, 152, 153, 7, 49, 2, 2, 153, 154, 7, 49, 2, 2, 154, 158, 3, 2, 2, 2, 155, 157, 11, 2, 2, 2, 156, 155, 3, 2, 2, 2, 157, 160, 3, 2, 2, 2, 158, 159, 3, 2, 2, 2, 158, 156, 3, 2, 2, 2, 159, 162, 3, 2, 2, 2, 160, 158, 3, 2, 2, 2, 161, 163, 9, 4, 2, 2, 162, 161, 3, 2, 2, 2, 163, 164, 3, 2, 2, 2, 164, 162, 3, 2, 2, 2, 164, 165, 3, 2, 2, 2, 165, 166, 3, 2, 2, 2, 166, 167, 8, 26, 2, 2, 167, 52, 3, 2, 2, 2, 168, 169, 7, 49, 2, 2, 169, 170, 7, 44, 2, 2, 170, 174, 3, 2, 2, 2, 171, 173, 11, 2, 2, 2, 172, 171, 3, 2, 2, 2, 173, 176, 3, 2, 2, 2, 174, 175, 3, 2, 2, 2, 174, 172, 3, 2, 2, 2, 175, 177, 3, 2, 2, 2, 176, 174, 3, 2, 2, 2, 177, 178, 7, 44, 2, 2, 178, 179, 7, 49, 2, 2, 179, 180, 3, 2, 2, 2, 180, 181, 8, 27, 2, 2, 181, 54, 3, 2, 2, 2, 10, 2, 134, 141, 143, 148, 158, 164, 174, 3, 8, 2, 2]
      \ No newline at end of file
      +[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 29, 186, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 3, 2, 3, 2, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 15, 3, 15, 3, 16, 3, 16, 3, 17, 3, 17, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 7, 25, 137, 10, 25, 12, 25, 14, 25, 140, 11, 25, 3, 25, 3, 25, 6, 25, 144, 10, 25, 13, 25, 14, 25, 145, 5, 25, 148, 10, 25, 3, 26, 6, 26, 151, 10, 26, 13, 26, 14, 26, 152, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 7, 27, 161, 10, 27, 12, 27, 14, 27, 164, 11, 27, 3, 27, 6, 27, 167, 10, 27, 13, 27, 14, 27, 168, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 7, 28, 177, 10, 28, 12, 28, 14, 28, 180, 11, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 4, 162, 178, 2, 29, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 3, 2, 5, 3, 2, 50, 59, 5, 2, 11, 12, 15, 15, 34, 34, 4, 2, 12, 12, 15, 15, 2, 192, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 3, 57, 3, 2, 2, 2, 5, 59, 3, 2, 2, 2, 7, 61, 3, 2, 2, 2, 9, 68, 3, 2, 2, 2, 11, 71, 3, 2, 2, 2, 13, 74, 3, 2, 2, 2, 15, 77, 3, 2, 2, 2, 17, 80, 3, 2, 2, 2, 19, 84, 3, 2, 2, 2, 21, 89, 3, 2, 2, 2, 23, 92, 3, 2, 2, 2, 25, 95, 3, 2, 2, 2, 27, 100, 3, 2, 2, 2, 29, 102, 3, 2, 2, 2, 31, 104, 3, 2, 2, 2, 33, 106, 3, 2, 2, 2, 35, 108, 3, 2, 2, 2, 37, 110, 3, 2, 2, 2, 39, 117, 3, 2, 2, 2, 41, 121, 3, 2, 2, 2, 43, 123, 3, 2, 2, 2, 45, 125, 3, 2, 2, 2, 47, 129, 3, 2, 2, 2, 49, 134, 3, 2, 2, 2, 51, 150, 3, 2, 2, 2, 53, 156, 3, 2, 2, 2, 55, 172, 3, 2, 2, 2, 57, 58, 7, 93, 2, 2, 58, 4, 3, 2, 2, 2, 59, 60, 7, 95, 2, 2, 60, 6, 3, 2, 2, 2, 61, 62, 7, 116, 2, 2, 62, 63, 7, 103, 2, 2, 63, 64, 7, 114, 2, 2, 64, 65, 7, 103, 2, 2, 65, 66, 7, 118, 2, 2, 66, 67, 7, 103, 2, 2, 67, 8, 3, 2, 2, 2, 68, 69, 7, 99, 2, 2, 69, 70, 7, 120, 2, 2, 70, 10, 3, 2, 2, 2, 71, 72, 7, 116, 2, 2, 72, 73, 7, 103, 2, 2, 73, 12, 3, 2, 2, 2, 74, 75, 7, 118, 2, 2, 75, 76, 7, 102, 2, 2, 76, 14, 3, 2, 2, 2, 77, 78, 7, 118, 2, 2, 78, 79, 7, 105, 2, 2, 79, 16, 3, 2, 2, 2, 80, 81, 7, 104, 2, 2, 81, 82, 7, 101, 2, 2, 82, 83, 7, 101, 2, 2, 83, 18, 3, 2, 2, 2, 84, 85, 7, 104, 2, 2, 85, 86, 7, 101, 2, 2, 86, 87, 7, 99, 2, 2, 87, 88, 7, 114, 2, 2, 88, 20, 3, 2, 2, 2, 89, 90, 7, 110, 2, 2, 90, 91, 7, 101, 2, 2, 91, 22, 3, 2, 2, 2, 92, 93, 7, 100, 2, 2, 93, 94, 7, 101, 2, 2, 94, 24, 3, 2, 2, 2, 95, 96, 7, 104, 2, 2, 96, 97, 7, 114, 2, 2, 97, 98, 7, 113, 2, 2, 98, 99, 7, 117, 2, 2, 99, 26, 3, 2, 2, 2, 100, 101, 7, 46, 2, 2, 101, 28, 3, 2, 2, 2, 102, 103, 7, 44, 2, 2, 103, 30, 3, 2, 2, 2, 104, 105, 7, 49, 2, 2, 105, 32, 3, 2, 2, 2, 106, 107, 7, 45, 2, 2, 107, 34, 3, 2, 2, 2, 108, 109, 7, 47, 2, 2, 109, 36, 3, 2, 2, 2, 110, 111, 7, 106, 2, 2, 111, 112, 7, 99, 2, 2, 112, 113, 7, 117, 2, 2, 113, 114, 7, 99, 2, 2, 114, 115, 7, 116, 2, 2, 115, 116, 7, 102, 2, 2, 116, 38, 3, 2, 2, 2, 117, 118, 7, 101, 2, 2, 118, 119, 7, 113, 2, 2, 119, 120, 7, 117, 2, 2, 120, 40, 3, 2, 2, 2, 121, 122, 7, 42, 2, 2, 122, 42, 3, 2, 2, 2, 123, 124, 7, 43, 2, 2, 124, 44, 3, 2, 2, 2, 125, 126, 7, 117, 2, 2, 126, 127, 7, 107, 2, 2, 127, 128, 7, 112, 2, 2, 128, 46, 3, 2, 2, 2, 129, 130, 7, 110, 2, 2, 130, 131, 7, 113, 2, 2, 131, 132, 7, 113, 2, 2, 132, 133, 7, 114, 2, 2, 133, 48, 3, 2, 2, 2, 134, 138, 9, 2, 2, 2, 135, 137, 9, 2, 2, 2, 136, 135, 3, 2, 2, 2, 137, 140, 3, 2, 2, 2, 138, 136, 3, 2, 2, 2, 138, 139, 3, 2, 2, 2, 139, 147, 3, 2, 2, 2, 140, 138, 3, 2, 2, 2, 141, 143, 7, 48, 2, 2, 142, 144, 9, 2, 2, 2, 143, 142, 3, 2, 2, 2, 144, 145, 3, 2, 2, 2, 145, 143, 3, 2, 2, 2, 145, 146, 3, 2, 2, 2, 146, 148, 3, 2, 2, 2, 147, 141, 3, 2, 2, 2, 147, 148, 3, 2, 2, 2, 148, 50, 3, 2, 2, 2, 149, 151, 9, 3, 2, 2, 150, 149, 3, 2, 2, 2, 151, 152, 3, 2, 2, 2, 152, 150, 3, 2, 2, 2, 152, 153, 3, 2, 2, 2, 153, 154, 3, 2, 2, 2, 154, 155, 8, 26, 2, 2, 155, 52, 3, 2, 2, 2, 156, 157, 7, 49, 2, 2, 157, 158, 7, 49, 2, 2, 158, 162, 3, 2, 2, 2, 159, 161, 11, 2, 2, 2, 160, 159, 3, 2, 2, 2, 161, 164, 3, 2, 2, 2, 162, 163, 3, 2, 2, 2, 162, 160, 3, 2, 2, 2, 163, 166, 3, 2, 2, 2, 164, 162, 3, 2, 2, 2, 165, 167, 9, 4, 2, 2, 166, 165, 3, 2, 2, 2, 167, 168, 3, 2, 2, 2, 168, 166, 3, 2, 2, 2, 168, 169, 3, 2, 2, 2, 169, 170, 3, 2, 2, 2, 170, 171, 8, 27, 2, 2, 171, 54, 3, 2, 2, 2, 172, 173, 7, 49, 2, 2, 173, 174, 7, 44, 2, 2, 174, 178, 3, 2, 2, 2, 175, 177, 11, 2, 2, 2, 176, 175, 3, 2, 2, 2, 177, 180, 3, 2, 2, 2, 178, 179, 3, 2, 2, 2, 178, 176, 3, 2, 2, 2, 179, 181, 3, 2, 2, 2, 180, 178, 3, 2, 2, 2, 181, 182, 7, 44, 2, 2, 182, 183, 7, 49, 2, 2, 183, 184, 3, 2, 2, 2, 184, 185, 8, 28, 2, 2, 185, 56, 3, 2, 2, 2, 10, 2, 138, 145, 147, 152, 162, 168, 178, 3, 8, 2, 2]
      \ No newline at end of file
      diff --git a/logo-fx/bin/logoparsing/LogoLexer.tokens b/logo-fx/bin/logoparsing/LogoLexer.tokens
      index e55e07a..7999d72 100644
      --- a/logo-fx/bin/logoparsing/LogoLexer.tokens
      +++ b/logo-fx/bin/logoparsing/LogoLexer.tokens
      @@ -20,10 +20,11 @@ T__18=19
       T__19=20
       T__20=21
       T__21=22
      -FLOAT=23
      -WS=24
      -COMMENT1=25
      -COMMENT2=26
      +T__22=23
      +FLOAT=24
      +WS=25
      +COMMENT1=26
      +COMMENT2=27
       '['=1
       ']'=2
       'repete'=3
      @@ -36,13 +37,14 @@ COMMENT2=26
       'lc'=10
       'bc'=11
       'fpos'=12
      -'*'=13
      -'/'=14
      -'+'=15
      -'-'=16
      -'hasard'=17
      -'cos'=18
      -'('=19
      -')'=20
      -'sin'=21
      -'loop'=22
      +','=13
      +'*'=14
      +'/'=15
      +'+'=16
      +'-'=17
      +'hasard'=18
      +'cos'=19
      +'('=20
      +')'=21
      +'sin'=22
      +'loop'=23
      diff --git a/logo-fx/bin/logoparsing/LogoTreeVisitor$Binome.class b/logo-fx/bin/logoparsing/LogoTreeVisitor$Binome.class
      index 381b387..38e0d05 100644
      Binary files a/logo-fx/bin/logoparsing/LogoTreeVisitor$Binome.class and b/logo-fx/bin/logoparsing/LogoTreeVisitor$Binome.class differ
      diff --git a/logo-fx/bin/logoparsing/LogoTreeVisitor.class b/logo-fx/bin/logoparsing/LogoTreeVisitor.class
      index eea03b0..adce355 100644
      Binary files a/logo-fx/bin/logoparsing/LogoTreeVisitor.class and b/logo-fx/bin/logoparsing/LogoTreeVisitor.class differ
      diff --git a/logo-fx/bin/logoparsing/Traceur.class b/logo-fx/bin/logoparsing/Traceur.class
      index 8106f56..17cc64f 100644
      Binary files a/logo-fx/bin/logoparsing/Traceur.class and b/logo-fx/bin/logoparsing/Traceur.class differ
      diff --git a/logo-fx/src/logoparsing/LogoTreeVisitor.java b/logo-fx/src/logoparsing/LogoTreeVisitor.java
      index 7ef3349..25a94db 100644
      --- a/logo-fx/src/logoparsing/LogoTreeVisitor.java
      +++ b/logo-fx/src/logoparsing/LogoTreeVisitor.java
      @@ -31,10 +31,10 @@ import logoparsing.LogoParser.TgContext;
       public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       	Traceur traceur;
       	StringProperty log = new SimpleStringProperty();
      -
      -	//用来保留两位小数
      +
      +	// 用来保留两位小数
       	DecimalFormat df = new DecimalFormat("#.00");
      -
      +
       	public LogoTreeVisitor() {
       		traceur = new Traceur();
       	}
      @@ -46,40 +46,39 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       	public Traceur getTraceur() {
       		return traceur;
       	}
      -
      -	//得到解析代表表达式的子树的结果
      +
      +	// 得到解析代表表达式的子树的结果
       	private Binome evaluateExpr(ParseTree expr) {
       		Binome res = new Binome();
      -
      -		//访问该节点下面的所有expr结点
      +
      +		// 访问该节点下面的所有expr结点
       		res._1 = visit(expr);
      -		res._2 = res._1 == 0 ?
      -		getExprValue(expr) : Double.POSITIVE_INFINITY;
      +		res._2 = res._1 == 0 ? getExprValue(expr) : Double.POSITIVE_INFINITY;
       		return res;
       	}
      -
      -	//得到解析代表循环的子树的结果
      +
      +	// 得到解析代表循环的子树的结果
       	private Binome evaluateBloc(ParseTree bloc) {
       		Binome res = new Binome();
      -		//开始访问bloc子树
      +		// 开始访问bloc子树
       		res._1 = visit(bloc);
      -		//在这里不用存值
      -//		res._2 = res._1 == 0 ? ;
      +		// 在这里不用存值
      +		// res._2 = res._1 == 0 ? ;
       		return res;
       	}
      
       	private class Binome {
       		public Binome() {
       			this._1 = null;
      -			this._2 = (double)0;
      +			this._2 = (double) 0;
       		}
      -
      -		//返回这一步操作是否成功
      -		//L'information qui indique si l'éxecution réussit
      -
      +
      +		// 返回这一步操作是否成功
      +		// L'information qui indique si l'éxecution réussit
      +
       		public Integer _1;
      -
      -		//stocker le résultat du calcul
      +
      +		// stocker le résultat du calcul
       		public Double _2;
      
       		public boolean isValid() {
      @@ -91,10 +90,10 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       	 * Map des attributs associés à chaque noeud de l'arbre key = node, value =
       	 * valeur de l'expression du node
       	 */
      -	//C'est un map pour stocker des values de calcul courant
      -	//存储这一步计算结果的map
      +	// C'est un map pour stocker des values de calcul courant
      +	// 存储这一步计算结果的map
       	ParseTreeProperty<Double> atts = new ParseTreeProperty<Double>();
      -
      +
       	public void setExprValue(ParseTree node, double value) {
       		atts.put(node, value);
       	}
      @@ -107,7 +106,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       		return value;
       	}
      
      -// Instructions de base
      +	// Instructions de base
      
       	@Override
       	public Integer visitTd(TdContext ctx) {
      @@ -133,56 +132,71 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
      
       	@Override
       	public Integer visitRe(ReContext ctx) {
      -		Binome bilan = evaluateExpr(ctx.expr());
      -		if (bilan._1 == 0) {
      -			traceur.recule(bilan._2);
      -			log.setValue("Recule de  " + bilan._2);
      +		if (traceur.isMoveable()) {
      +			Binome bilan = evaluateExpr(ctx.expr());
      +			if (bilan._1 == 0) {
      +				traceur.recule(bilan._2);
      +				log.setValue("Recule de  " + bilan._2);
      +				log.setValue("\n");
      +			}
      +			return bilan._1;
      +
      +		} else {
      +			log.setValue("I can't move");
       			log.setValue("\n");
      +			return -1;
       		}
      -		return bilan._1;
       	}
      
       	@Override
       	public Integer visitTg(TgContext ctx) {
      -		Binome bilan = evaluateExpr(ctx.expr());
      -		if (bilan._1 == 0) {
      -			traceur.tg(bilan._2);
      -			log.setValue("Trouner à gauche de  " + bilan._2);
      -			log.setValue("\n");
      -		}
      -		return bilan._1;
      +		if (traceur.isMoveable()) {
      +			Binome bilan = evaluateExpr(ctx.expr());
      +			if (bilan._1 == 0) {
      +				traceur.tg(bilan._2);
      +				log.setValue("Trouner à gauche de  " + bilan._2);
      +				log.setValue("\n");
      +			}
      +			return bilan._1;
      +		} else
      +			return -1;
      +
       	}
      
       	@Override
       	public Integer visitCouleur(CouleurContext ctx) {
      -		Binome bilan = evaluateExpr(ctx.expr());
      -		if (bilan._1 == 0) {
      -			traceur.changeColeur(bilan._2);
      -			log.setValue("Change couleur  " + logogui.Color.values()[bilan._2.intValue()].toString());
      -			log.setValue("\n");
      +		if (!traceur.isMoveable()) {
      +			Binome bilan = evaluateExpr(ctx.expr());
      +			if (bilan._1 == 0) {
      +				traceur.changeColeur(bilan._2);
      +				log.setValue("Change couleur  " + logogui.Color.values()[bilan._2.intValue()].toString());
      +				log.setValue("\n");
      +			}
      +			return bilan._1;
      +		} else {
      +			return -1;
       		}
      -		return bilan._1;
      +
       	}
      
       	@Override
       	public Integer visitFixeCap(FixeCapContext ctx) {
      -		// TODO Auto-generated method stub
      -		return super.visitFixeCap(ctx);
      +		return 0;
       	}
      
       	@Override
       	public Integer visitLeveCrayon(LeveCrayonContext ctx) {
      -		// TODO Auto-generated method stub
      -		return super.visitLeveCrayon(ctx);
      +		traceur.setMoveable(false);
      +		return 0;
       	}
      
       	@Override
       	public Integer visitBaisseCrayon(BaisseCrayonContext ctx) {
      -		// TODO Auto-generated method stub
      -		return super.visitBaisseCrayon(ctx);
      +		traceur.setMoveable(true);
      +		return 0;
       	}
      
      -// Expressions
      +	// Expressions
      
       	@Override
       	public Integer visitParenthese(ParentheseContext ctx) {
      @@ -200,9 +214,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       		return 0;
       	}
      
      -
      -
      -	//Fonctions de TD3
      +	// Fonctions de TD3
      
       	@Override
       	public Integer visitSum(SumContext ctx) {
      @@ -229,7 +241,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       			left = evaluateExpr(ctx.expr(0));
       			right = evaluateExpr(ctx.expr(1));
       			if (left._1 == 0 && right._1 == 0) {
      -				if(ctx.getChild(1).getText().equals("/") || right._2 < 0.000001) {
      +				if (ctx.getChild(1).getText().equals("/") || right._2 < 0.000001) {
       					return right._1 = -1;
       				}
       				Double r = ctx.getChild(1).getText().equals("*") ? left._2 * right._2 : left._2 / right._2;
      @@ -248,9 +260,9 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       		Binome bilan = evaluateExpr(ctx.expr());
       		try {
       			if (bilan._1 == 0) {
      -				Double r = Math.ceil((1+Math.random()*(bilan._2 - 1 + 1)));
      +				Double r = Math.ceil((1 + Math.random() * (bilan._2 - 1 + 1)));
       				setExprValue(ctx, r);
      -
      +
       			} else {
       				return bilan._1;
       			}
      @@ -267,7 +279,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       			if (bilan._1 == 0) {
       				Double r = Double.parseDouble(df.format(Math.cos(Math.toRadians(bilan._2))));
       				setExprValue(ctx, r);
      -
      +
       			} else {
       				return bilan._1;
       			}
      @@ -284,7 +296,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       			if (bilan._1 == 0) {
       				Double r = Double.parseDouble(df.format(Math.sin(Math.toRadians(bilan._2))));
       				setExprValue(ctx, r);
      -
      +
       			} else {
       				return bilan._1;
       			}
      @@ -298,19 +310,18 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       	public Integer visitRepete(RepeteContext ctx) {
       		int compteur = 0;
       		Binome expr = evaluateExpr(ctx.expr());
      -		Binome bloc = new Binome() ;
      +		Binome bloc = new Binome();
       		try {
       			if (expr._1 == 0) {
      -				compteur = (int) Math.round(expr._2) ;
      -				for(int i = 0; i < compteur; i++) {
      +				compteur = (int) Math.round(expr._2);
      +				for (int i = 0; i < compteur; i++) {
       					bloc = evaluateBloc(ctx.bloc());
       					System.out.println("LogoTreeVisitor.visitRepete()" + bloc._2);
       				}
       			} else {
       				return expr._1 == 0 ? bloc._1 : expr._1;
       			}
      -
      -
      +
       		} catch (NullPointerException ex) {
       			ex.printStackTrace();
       		}
      @@ -320,7 +331,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       	@Override
       	public Integer visitCrochet(CrochetContext ctx) {
       		Binome bilan = new Binome();
      -		//访问代表循环的子树
      +		// 访问代表循环的子树
       		bilan._1 = visit(ctx.liste_instructions());
       		return bilan._1;
       	}
      @@ -337,9 +348,9 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       		return 0;
       	}
      
      -//	@Override
      -//	public Integer visitLoop(LoopContext ctx) {
      -//
      -//	}
      +	// @Override
      +	// public Integer visitLoop(LoopContext ctx) {
      +	//
      +	// }
      
       }
      diff --git a/logo-fx/src/logoparsing/Traceur.java b/logo-fx/src/logoparsing/Traceur.java
      index b0ee50a..e393109 100644
      --- a/logo-fx/src/logoparsing/Traceur.java
      +++ b/logo-fx/src/logoparsing/Traceur.java
      @@ -18,13 +18,13 @@ public class Traceur {
       	private double posx = initx, posy = inity; // position courante
       	private double angle = 90;
       	private double teta;
      -	HashMap<Integer, int[]> couleurList = new HashMap<Integer, int[]>();
      +	private boolean moveable;
       	ObjectProperty<GraphParameter> line;
      
       	public Traceur() {
       		setTeta();
       		line = new SimpleObjectProperty<GraphParameter>();
      -		this.couleurList.put(0, new int[] {0,0,0});
      +		this.moveable = false;
       	}
      
       	ObjectProperty<GraphParameter> lineProperty() {
      @@ -78,4 +78,12 @@ public class Traceur {
       		posy = y;
       	}
      
      +	public boolean isMoveable() {
      +		return moveable;
      +	}
      +
      +	public void setMoveable(boolean canMove) {
      +		this.moveable = canMove;
      +	}
      +
       }
      b642594a
    • Jiawen Lyu's avatar
      show color name in console · 87d0130a
      Jiawen Lyu authored
      87d0130a
    • Jiawen Lyu's avatar
      add color enum · 77ec72b1
      Jiawen Lyu authored
      77ec72b1
    • Jiawen Lyu's avatar
      finish fpos · 0d1ca05b
      Jiawen Lyu authored
      0d1ca05b
  9. 20 May, 2020 3 commits
    • Jiawen Lyu's avatar
      repete complete · c32a8683
      Jiawen Lyu authored
      diff --git a/logo-fx/bin/logoparsing/LogoTreeVisitor$Binome.class b/logo-fx/bin/logoparsing/LogoTreeVisitor$Binome.class
      index 2d4d41d..3a85d7c 100644
      Binary files a/logo-fx/bin/logoparsing/LogoTreeVisitor$Binome.class and b/logo-fx/bin/logoparsing/LogoTreeVisitor$Binome.class differ
      diff --git a/logo-fx/bin/logoparsing/LogoTreeVisitor.class b/logo-fx/bin/logoparsing/LogoTreeVisitor.class
      index ec62c13..8e9884f 100644
      Binary files a/logo-fx/bin/logoparsing/LogoTreeVisitor.class and b/logo-fx/bin/logoparsing/LogoTreeVisitor.class differ
      diff --git a/logo-fx/src/logoparsing/LogoTreeVisitor.java b/logo-fx/src/logoparsing/LogoTreeVisitor.java
      index d5e3866..b1fe55b 100644
      --- a/logo-fx/src/logoparsing/LogoTreeVisitor.java
      +++ b/logo-fx/src/logoparsing/LogoTreeVisitor.java
      @@ -11,6 +11,7 @@ import logoparsing.LogoParser.AvContext;
       import logoparsing.LogoParser.BaisseCrayonContext;
       import logoparsing.LogoParser.CosContext;
       import logoparsing.LogoParser.CouleurContext;
      +import logoparsing.LogoParser.CrochetContext;
       import logoparsing.LogoParser.FixeCapContext;
       import logoparsing.LogoParser.FloatContext;
       import logoparsing.LogoParser.HasardContext;
      @@ -18,6 +19,7 @@ import logoparsing.LogoParser.LeveCrayonContext;
       import logoparsing.LogoParser.MultContext;
       import logoparsing.LogoParser.ParentheseContext;
       import logoparsing.LogoParser.ReContext;
      +import logoparsing.LogoParser.RepeteContext;
       import logoparsing.LogoParser.SinContext;
       import logoparsing.LogoParser.SumContext;
       import logoparsing.LogoParser.TdContext;
      @@ -26,6 +28,8 @@ import logoparsing.LogoParser.TgContext;
       public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       	Traceur traceur;
       	StringProperty log = new SimpleStringProperty();
      +
      +	//用来保留两位小数
       	DecimalFormat df = new DecimalFormat("#.00");
      
       	public LogoTreeVisitor() {
      @@ -39,29 +43,51 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       	public Traceur getTraceur() {
       		return traceur;
       	}
      +
      +	private Binome evaluateExpr(ParseTree expr) {
      +		Binome res = new Binome();
      +
      +		//访问该节点下面的所有expr结点
      +		res._1 = visit(expr);
      +		res._2 = res._1 == 0 ?
      +		getExprValue(expr) : Double.POSITIVE_INFINITY;
      +		return res;
      +	}
      +
      +	private Binome evaluateBloc(ParseTree bloc) {
      +		Binome res = new Binome();
      +		//开始访问bloc子树
      +		res._1 = visit(bloc);
      +		//在这里不用存值
      +		res._2 = (double) res._1;
      +		return res;
      +	}
      +
      +	private class Binome {
      +		//返回这一步操作是否成功
      +		//L'information qui indique si l'éxecution réussit
      +		public Integer _1;
      +
      +		//stocker le résultat du calcul
      +		public Double _2;
      +
      +		public boolean isValid() {
      +			return _1 == 0;
      +		}
      +	}
      
       	/*
       	 * Map des attributs associés à chaque noeud de l'arbre key = node, value =
       	 * valeur de l'expression du node
       	 */
      +	//C'est un map pour stocker des values de calcul courant
      +	//存储这一步计算结果的map
       	ParseTreeProperty<Double> atts = new ParseTreeProperty<Double>();
      -
      -	public void setValue(ParseTree node, double value) {
      -		atts.put(node, value);
      -	}
      
       	public void setExprValue(ParseTree node, double value) {
       		atts.put(node, value);
       	}
      
      -	public double getValue(ParseTree node) {
      -		Double value = atts.get(node);
      -		if (value == null) {
      -			throw new NullPointerException();
      -		}
      -		return value;
      -	}
      -
       	public Double getExprValue(ParseTree node) {
       		Double value = atts.get(node);
       		if (value == null) {
      @@ -74,7 +100,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
      
       	@Override
       	public Integer visitTd(TdContext ctx) {
      -		Binome bilan = evaluate(ctx.expr());
      +		Binome bilan = evaluateExpr(ctx.expr());
       		if (bilan._1 == 0) {
       			traceur.td(bilan._2);
       			log.setValue("Tourner à droite de  " + bilan._2);
      @@ -85,7 +111,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
      
       	@Override
       	public Integer visitAv(AvContext ctx) {
      -		Binome bilan = evaluate(ctx.expr());
      +		Binome bilan = evaluateExpr(ctx.expr());
       		if (bilan._1 == 0) {
       			traceur.avance(bilan._2);
       			log.setValue("Avance de  " + bilan._2);
      @@ -96,7 +122,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
      
       	@Override
       	public Integer visitRe(ReContext ctx) {
      -		Binome bilan = evaluate(ctx.expr());
      +		Binome bilan = evaluateExpr(ctx.expr());
       		if (bilan._1 == 0) {
       			traceur.recule(bilan._2);
       			log.setValue("Recule de  " + bilan._2);
      @@ -107,7 +133,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
      
       	@Override
       	public Integer visitTg(TgContext ctx) {
      -		Binome bilan = evaluate(ctx.expr());
      +		Binome bilan = evaluateExpr(ctx.expr());
       		if (bilan._1 == 0) {
       			traceur.tg(bilan._2);
       			log.setValue("Trouner à gauche de  " + bilan._2);
      @@ -118,7 +144,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
      
       	@Override
       	public Integer visitCouleur(CouleurContext ctx) {
      -		Binome bilan = evaluate(ctx.expr());
      +		Binome bilan = evaluateExpr(ctx.expr());
       		if (bilan._1 == 0) {
       			traceur.changeColeur(bilan._2);
       			log.setValue("Change couleur  " + bilan._2);
      @@ -149,7 +175,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
      
       	@Override
       	public Integer visitParenthese(ParentheseContext ctx) {
      -		Binome bilan = evaluate(ctx.expr());
      +		Binome bilan = evaluateExpr(ctx.expr());
       		if (bilan._1 == 0) {
       			setExprValue(ctx, bilan._2);
       		}
      @@ -163,21 +189,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       		return 0;
       	}
      
      -	private Binome evaluate(ParseTree expr) {
      -		Binome res = new Binome();
      -		res._1 = visit(expr);
      -		res._2 = res._1 == 0 ?
      -		getExprValue(expr) : Double.POSITIVE_INFINITY; return res;
      -	}
      -
      -	private class Binome {
      -		public Integer _1;
      -		public Double _2;
      
      -		public boolean isValid() {
      -			return _1 == 0;
      -		}
      -	}
      
       	//Fonctions de TD3
      
      @@ -185,8 +197,8 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       	public Integer visitSum(SumContext ctx) {
       		Binome left, right;
       		try {
      -			left = evaluate(ctx.expr(0));
      -			right = evaluate(ctx.expr(1));
      +			left = evaluateExpr(ctx.expr(0));
      +			right = evaluateExpr(ctx.expr(1));
       			if (left._1 == 0 && right._1 == 0) {
       				Double r = ctx.getChild(1).getText().equals("+") ? left._2 + right._2 : left._2 - right._2;
       				setExprValue(ctx, r);
      @@ -203,8 +215,8 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       	public Integer visitMult(MultContext ctx) {
       		Binome left, right;
       		try {
      -			left = evaluate(ctx.expr(0));
      -			right = evaluate(ctx.expr(1));
      +			left = evaluateExpr(ctx.expr(0));
      +			right = evaluateExpr(ctx.expr(1));
       			if (left._1 == 0 && right._1 == 0) {
       				if(ctx.getChild(1).getText().equals("/") || right._2 < 0.000001) {
       					return right._1 = -1;
      @@ -222,7 +234,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       	@Override
       	// retourner une double entre 1 et un resultat de l'expression
       	public Integer visitHasard(HasardContext ctx) {
      -		Binome bilan = evaluate(ctx.expr());
      +		Binome bilan = evaluateExpr(ctx.expr());
       		try {
       			if (bilan._1 == 0) {
       				Double r = Math.ceil((1+Math.random()*(bilan._2 - 1 + 1)));
      @@ -239,7 +251,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
      
       	@Override
       	public Integer visitCos(CosContext ctx) {
      -		Binome bilan = evaluate(ctx.expr());
      +		Binome bilan = evaluateExpr(ctx.expr());
       		try {
       			if (bilan._1 == 0) {
       				Double r = Double.parseDouble(df.format(Math.cos(Math.toRadians(bilan._2))));
      @@ -256,7 +268,7 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
      
       	@Override
       	public Integer visitSin(SinContext ctx) {
      -		Binome bilan = evaluate(ctx.expr());
      +		Binome bilan = evaluateExpr(ctx.expr());
       		try {
       			if (bilan._1 == 0) {
       				Double r = Double.parseDouble(df.format(Math.sin(Math.toRadians(bilan._2))));
      @@ -271,4 +283,34 @@ public class LogoTreeVisitor extends LogoBaseVisitor<Integer> {
       		return 0;
       	}
      
      +	@Override
      +	public Integer visitRepete(RepeteContext ctx) {
      +		int compteur = 0;
      +		Binome expr = evaluateExpr(ctx.expr());
      +		Binome bloc = new Binome() ;
      +		try {
      +			if (expr._1 == 0) {
      +				compteur = (int) Math.round(expr._2) ;
      +				for(int i = 0; i < compteur; i++) {
      +					bloc = evaluateBloc(ctx.bloc());
      +				}
      +			} else {
      +				return expr._1 == 0 ? bloc._1 : expr._1;
      +			}
      +
      +
      +		} catch (NullPointerException ex) {
      +			ex.printStackTrace();
      +		}
      +		return 0;
      +	}
      +
      +	@Override
      +	public Integer visitCrochet(CrochetContext ctx) {
      +		Binome bilan = new Binome();
      +		bilan._1 = visit(ctx.liste_instructions());
      +		System.out.println("here");
      +		return bilan._1;
      +	}
      +
       }
      c32a8683
    • Jiawen Lyu's avatar
      avoid 0 multipe · cae0ca1c
      Jiawen Lyu authored
      cae0ca1c
    • Jiawen Lyu's avatar
      finish cos instruction · fc1ec8ec
      Jiawen Lyu authored
      fc1ec8ec
  10. 19 May, 2020 3 commits
  11. 12 May, 2020 2 commits