Codes sources prototype 1

This commit is contained in:
SylvanCourtiol
2021-05-09 17:42:30 +02:00
parent 14d39af284
commit a1161d0399
16 changed files with 1144 additions and 73 deletions
@@ -0,0 +1,58 @@
/**
* InstructionVar.java 9 mai 2021
* IUT info1 2020-2021, pas de copyright, aucun droit
*/
package interpreteurlir.motscles.instructions;
import interpreteurlir.Contexte;
import interpreteurlir.InterpreteurException;
import interpreteurlir.expressions.Expression;
import interpreteurlir.expressions.ExpressionChaine;
/**
* Instruction de déclaration et d'affectation de variables. La syntaxe de
* cette expression est de la forme var identificateur = expression. Si
* expression non renseignée, l'interpréteur affichera un message d'erreur ;
* l'instruction doit effectuer systématiquement une affectation.
* @author Nicolas Caminade
* @author Sylvan Courtiol
* @author Pierre Debas
* @author Heïa Dexter
* @author Lucas Vabre
*/
public class InstructionVar extends Instruction {
/**
* TODO comment initial state of the object
* @param arguments expression à exécuter
* @param contexte global de l'interpréteur
*/
public InstructionVar(String arguments, Contexte contexte) {
super(arguments, contexte);
if (arguments == null || arguments.isBlank()
|| ExpressionChaine.indexOperateur(arguments, '=') <= 0)
throw new InterpreteurException("erreur de syntaxe");
aExecuter = Expression.determinerTypeExpression(arguments.trim());
}
/*
* Non - javadoc
* @see interpreteurlir.motscles.instructions.Instruction#executer()
*/
@Override
public boolean executer() {
aExecuter.calculer();
return false;
}
/*
* Non - javadoc
* @see interpreteurlir.motscles.instructions.Instruction#toString()
*/
@Override
public String toString() {
return "var " + aExecuter;
}
}