mirror of
https://github.com/LucasVbr/interpreteur-lir.git
synced 2026-07-09 06:58:05 +00:00
Mise en commun pour même base
This commit is contained in:
@@ -1,128 +0,0 @@
|
|||||||
/*
|
|
||||||
* Identificateur.java , 08/05/2021
|
|
||||||
* IUT Rodez 2020-2021, info1
|
|
||||||
* pas de copyright, aucun droits
|
|
||||||
*/
|
|
||||||
|
|
||||||
package donnees;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Nicolas Caminade
|
|
||||||
* @author Sylvan Courtiol
|
|
||||||
* @author Pierre Debas
|
|
||||||
* @author Heia Dexter
|
|
||||||
* @author Lucas Vabre
|
|
||||||
*/
|
|
||||||
public class Identificateur /* extends Variable */
|
|
||||||
implements Comparable<Identificateur> {
|
|
||||||
|
|
||||||
/** Longueur maximale d'un identificateur (ne prend pas en compte le $) */
|
|
||||||
public static final int LONGUEUR_MAX = 24;
|
|
||||||
|
|
||||||
/** Nom identificateur */
|
|
||||||
private String nom;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiation de l'identificateur
|
|
||||||
* @param identificateur
|
|
||||||
*/
|
|
||||||
public Identificateur(String identificateur) {
|
|
||||||
super();
|
|
||||||
if(!isIdentificateur(identificateur)) {
|
|
||||||
throw new IllegalArgumentException(identificateur
|
|
||||||
+ " n'est pas un identificateur");
|
|
||||||
}
|
|
||||||
|
|
||||||
nom = identificateur;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prédicat qui vérifie si une chaîne correspond à un identificateur
|
|
||||||
* <ul>
|
|
||||||
* <li>Longueur comprise entre 1 et 24 caractères</li>
|
|
||||||
* <li>N'est pas une chaîne vide</li>
|
|
||||||
* <li>N'est pas null</li>
|
|
||||||
* </ul>
|
|
||||||
* @param aComparer
|
|
||||||
* @return true si le prédicat est vérifié
|
|
||||||
* false sinon
|
|
||||||
*/
|
|
||||||
public static boolean isIdentificateur(String aComparer) {
|
|
||||||
return aComparer != null
|
|
||||||
&& aComparer.length() > 0
|
|
||||||
&& !removeDollar(aComparer).isBlank()
|
|
||||||
&& removeDollar(aComparer).length() <= LONGUEUR_MAX
|
|
||||||
&& isAlphanumerique(removeDollar(aComparer));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Supprime le caractère $ si il est présent en premier dans la chaîne
|
|
||||||
* @param chaine a modifier
|
|
||||||
* @return la chaîne modifiée
|
|
||||||
*/
|
|
||||||
public static String removeDollar(String chaine) {
|
|
||||||
if(chaine.charAt(0) == '$') return chaine.substring(1);
|
|
||||||
return chaine;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prédicat testant si une chaîne est composée de chiffre ou de lettres
|
|
||||||
* @param aTester chaîne a tester
|
|
||||||
* @return true si le prédicat est vérifié
|
|
||||||
* false sinon
|
|
||||||
*/
|
|
||||||
public static boolean isAlphanumerique(String aTester) {
|
|
||||||
int index;
|
|
||||||
|
|
||||||
for (index = 0 ;
|
|
||||||
index < aTester.length()
|
|
||||||
&& (isLettre(aTester.charAt(index))
|
|
||||||
|| isChiffre(aTester.charAt(index)));
|
|
||||||
index++)
|
|
||||||
; // Corps vide
|
|
||||||
|
|
||||||
return index >= aTester.length();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prédicat attestant si un caractère est une lettre
|
|
||||||
* @param aTester caractère a tester
|
|
||||||
* @return true si le prédicat est vérifié
|
|
||||||
* false sinon
|
|
||||||
*/
|
|
||||||
public static boolean isLettre(char aTester) {
|
|
||||||
return 'a' <= aTester && aTester <= 'z'
|
|
||||||
|| 'A' <= aTester && aTester <= 'Z';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prédicat attestant si un caractère est un chiffre
|
|
||||||
* @param aTester caractère a tester
|
|
||||||
* @return true si le prédicat est vérifié
|
|
||||||
* false sinon
|
|
||||||
*/
|
|
||||||
public static boolean isChiffre(char aTester) {
|
|
||||||
return '0' <= aTester && aTester <= '9';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return la valeur de nom
|
|
||||||
*/
|
|
||||||
public String getNom() {
|
|
||||||
return nom;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* non javadoc - @see java.lang.Object#toString() */
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "Identificateur [nom=" + nom + "]";
|
|
||||||
}
|
|
||||||
|
|
||||||
/* non javadoc - @see java.lang.String#Comparable() */
|
|
||||||
@Override
|
|
||||||
public int compareTo(Identificateur aComparer) {
|
|
||||||
return nom.compareTo(aComparer.getNom());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* IdentificateurChaine.java, 08/05/2021
|
|
||||||
* IUT Rodez 2020-2021, info1
|
|
||||||
* pas de copyright, aucun droits
|
|
||||||
*/
|
|
||||||
|
|
||||||
package donnees;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Identificateur de chaîne
|
|
||||||
* @author Nicolas Caminade
|
|
||||||
* @author Sylvan Courtiol
|
|
||||||
* @author Pierre Debas
|
|
||||||
* @author Heia Dexter
|
|
||||||
* @author Lucas Vabre
|
|
||||||
*/
|
|
||||||
public class IdentificateurChaine extends Identificateur {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiation d'identificateur de chaîne
|
|
||||||
* @param identificateur a instancier
|
|
||||||
* @throws IllegalAccessException si l'identificateur est invalide
|
|
||||||
*/
|
|
||||||
public IdentificateurChaine(String identificateur) {
|
|
||||||
super(identificateur);
|
|
||||||
|
|
||||||
if(!isIdentificateurChaine(identificateur)) {
|
|
||||||
throw new IllegalArgumentException(identificateur
|
|
||||||
+ " n'est pas un identificateur"
|
|
||||||
+ " de chaine");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prédicat attestant la validité de l'identificateur
|
|
||||||
* @param identificateur à tester
|
|
||||||
* @return true si l'identificateur est bien un identificateur d'entier
|
|
||||||
* false sinon
|
|
||||||
*/
|
|
||||||
private static boolean isIdentificateurChaine(String identificateur) {
|
|
||||||
|
|
||||||
return identificateur.length() >= 2
|
|
||||||
&& identificateur.charAt(0) == '$'
|
|
||||||
&& isLettre(identificateur.charAt(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* IdentificateurEntier.java , 08/05/2021
|
|
||||||
* IUT Rodez 2020-2021, info1
|
|
||||||
* pas de copyright, aucun droits
|
|
||||||
*/
|
|
||||||
|
|
||||||
package donnees;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Identificateur d'entier
|
|
||||||
* @author Nicolas Caminade
|
|
||||||
* @author Sylvan Courtiol
|
|
||||||
* @author Pierre Debas
|
|
||||||
* @author Heia Dexter
|
|
||||||
* @author Lucas Vabre
|
|
||||||
*/
|
|
||||||
public class IdentificateurEntier extends Identificateur {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiation d'identificateur d'entier
|
|
||||||
* @param identificateur a instancier
|
|
||||||
* @throws IllegalAccessException si l'identificateur est invalide
|
|
||||||
*/
|
|
||||||
public IdentificateurEntier(String identificateur) {
|
|
||||||
super(identificateur);
|
|
||||||
|
|
||||||
if(!isIdentificateurEntier(identificateur)) {
|
|
||||||
throw new IllegalArgumentException(identificateur
|
|
||||||
+ " n'est pas un identificateur"
|
|
||||||
+ " d'entier");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prédicat attestant la validité de l'identificateur
|
|
||||||
*
|
|
||||||
* Un identificateur d'entier est valide si
|
|
||||||
* - Il contient au maximum 24 caractères
|
|
||||||
* - Commence obligatoirement par une lettre (majuscule ou minuscule)
|
|
||||||
* - suivie uniquement de lettres (majuscule ou minuscule) ou de chiffres
|
|
||||||
*
|
|
||||||
* @param identificateur à tester
|
|
||||||
* @return true si l'identificateur est bien un identificateur d'entier
|
|
||||||
* false sinon
|
|
||||||
*/
|
|
||||||
private static boolean isIdentificateurEntier(String identificateur) {
|
|
||||||
|
|
||||||
return isLettre(identificateur.charAt(0))
|
|
||||||
&& isAlphanumerique(identificateur.substring(1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
/**
|
|
||||||
* Chaine.java 7 mai 2021
|
|
||||||
* IUT info1 2020-2021, pas de copyright, aucun droit
|
|
||||||
*/
|
|
||||||
package interpreteurlir.donnees.litteraux;
|
|
||||||
|
|
||||||
import interpreteurlir.InterpreteurException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constante littérale de type chaîne de caractères.
|
|
||||||
* @author Nicolas Caminade
|
|
||||||
* @author Sylvan Courtiol
|
|
||||||
* @author Pierre Debas
|
|
||||||
* @author Heïa Dexter
|
|
||||||
* @author Lucas Vabre
|
|
||||||
*/
|
|
||||||
public class Chaine extends Litteral {
|
|
||||||
|
|
||||||
/** Longueur maximale d'une chaîne */
|
|
||||||
public static final int LG_MAX_CHAINE = 70;
|
|
||||||
|
|
||||||
/** Erreur chaîne trop longue */
|
|
||||||
private static final String ERREUR_LG_MAX = "Longueur maximale dépassée";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* initialise cette chaîne avec une valeur par défaut.
|
|
||||||
*/
|
|
||||||
public Chaine() {
|
|
||||||
valeur = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialise une chaîne avec la séquence de caractères passée en argument.
|
|
||||||
* @param uneValeur
|
|
||||||
*/
|
|
||||||
public Chaine(String uneValeur) {
|
|
||||||
|
|
||||||
if (uneValeur.length() > LG_MAX_CHAINE)
|
|
||||||
throw new InterpreteurException(ERREUR_LG_MAX);
|
|
||||||
|
|
||||||
valeur = uneValeur;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Concatène deux chaînes ensemble. Opération non commutative:
|
|
||||||
* a + b != b + a
|
|
||||||
* @param a une Chaîne
|
|
||||||
* @param b une autre Chaîne
|
|
||||||
* @return une nouvelle Chaîne.
|
|
||||||
*/
|
|
||||||
public static Chaine concatener(Chaine a, Chaine b) {
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* non javadoc
|
|
||||||
* @see interpreteurlir.donnees.litteraux.Litteral#compareTo(interpreteurlir.donnees.litteraux.Litteral)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int compareTo(Litteral autre) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return this.valeur.toString().compareTo(autre.valeur.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
/* non javadoc
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return '\"' + valeur.toString() + '\"';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/**
|
|
||||||
* Litteral.java 7 mai 2021
|
|
||||||
* IUT info1 2020-2021, pas de copyright, aucun droit
|
|
||||||
*/
|
|
||||||
package interpreteurlir.donnees.litteraux;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Valeur littérale utilisée dans une expression.
|
|
||||||
* Chaque littérale est reconnue par sont type.
|
|
||||||
* @author Nicolas Caminade
|
|
||||||
* @author Sylvan Courtiol
|
|
||||||
* @author Pierre Debas
|
|
||||||
* @author Heïa Dexter
|
|
||||||
* @author Lucas Vabre
|
|
||||||
*/
|
|
||||||
public class Litteral implements Comparable<Litteral> {
|
|
||||||
|
|
||||||
/** valeur de ce littéral */
|
|
||||||
protected Object valeur;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialise ce littéral par défaut.
|
|
||||||
*/
|
|
||||||
protected Litteral() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialise cette valeur avec un objet argument.
|
|
||||||
* @param valeur
|
|
||||||
*/
|
|
||||||
public Litteral(Object valeur) { // TODO public >>> protected
|
|
||||||
super();
|
|
||||||
this.valeur = valeur;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return la valeur de valeur
|
|
||||||
*/
|
|
||||||
public Object getValeur() {
|
|
||||||
return valeur;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* non javadoc
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return valeur.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* non javadoc
|
|
||||||
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public int compareTo(Litteral autre) {
|
|
||||||
|
|
||||||
if (autre.valeur.getClass() == this.valeur.getClass())
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return this.valeur.hashCode() - autre.valeur.hashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -82,7 +82,7 @@ public class Contexte {
|
|||||||
public Litteral lireValeurVariable(Identificateur id) {
|
public Litteral lireValeurVariable(Identificateur id) {
|
||||||
Litteral valeur;
|
Litteral valeur;
|
||||||
int indexVar = indexVariable(id);
|
int indexVar = indexVariable(id);
|
||||||
if (variables.size() < indexVar
|
if (variables.size() > indexVar
|
||||||
&& variables.get(indexVar).getIdentificateur().compareTo(id)
|
&& variables.get(indexVar).getIdentificateur().compareTo(id)
|
||||||
== 0) {
|
== 0) {
|
||||||
/* La variables est présente */
|
/* La variables est présente */
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
/*
|
||||||
|
* Identificateur.java , 08/05/2021
|
||||||
|
* IUT Rodez 2020-2021, info1
|
||||||
|
* pas de copyright, aucun droits
|
||||||
|
*/
|
||||||
|
|
||||||
|
package interpreteurlir.donnees;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Nicolas Caminade
|
||||||
|
* @author Sylvan Courtiol
|
||||||
|
* @author Pierre Debas
|
||||||
|
* @author Heia Dexter
|
||||||
|
* @author Lucas Vabre
|
||||||
|
*/
|
||||||
|
public class Identificateur /* extends Variable */
|
||||||
|
implements Comparable<Identificateur> {
|
||||||
|
|
||||||
|
/** Longueur maximale d'un identificateur (ne prend pas en compte le $) */
|
||||||
|
public static final int LONGUEUR_MAX = 24;
|
||||||
|
|
||||||
|
/** Nom identificateur */
|
||||||
|
private String nom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiation de l'identificateur
|
||||||
|
* @param identificateur
|
||||||
|
*/
|
||||||
|
public Identificateur(String identificateur) {
|
||||||
|
super();
|
||||||
|
if(!isIdentificateur(identificateur)) {
|
||||||
|
throw new IllegalArgumentException(identificateur
|
||||||
|
+ " n'est pas un identificateur");
|
||||||
|
}
|
||||||
|
|
||||||
|
nom = identificateur;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prédicat qui vérifie si une chaîne correspond à un identificateur
|
||||||
|
* <ul>
|
||||||
|
* <li>Longueur comprise entre 1 et 24 caractères</li>
|
||||||
|
* <li>N'est pas une chaîne vide</li>
|
||||||
|
* <li>N'est pas null</li>
|
||||||
|
* </ul>
|
||||||
|
* @param aComparer
|
||||||
|
* @return true si le prédicat est vérifié
|
||||||
|
* false sinon
|
||||||
|
*/
|
||||||
|
public static boolean isIdentificateur(String aComparer) {
|
||||||
|
return aComparer != null
|
||||||
|
&& aComparer.length() > 0
|
||||||
|
&& !removeDollar(aComparer).isBlank()
|
||||||
|
&& removeDollar(aComparer).length() <= LONGUEUR_MAX
|
||||||
|
&& isAlphanumerique(removeDollar(aComparer));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Supprime le caractère $ si il est présent en premier dans la chaîne
|
||||||
|
* @param chaine a modifier
|
||||||
|
* @return la chaîne modifiée
|
||||||
|
*/
|
||||||
|
public static String removeDollar(String chaine) {
|
||||||
|
if(chaine.charAt(0) == '$') return chaine.substring(1);
|
||||||
|
return chaine;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prédicat testant si une chaîne est composée de chiffre ou de lettres
|
||||||
|
* @param aTester chaîne a tester
|
||||||
|
* @return true si le prédicat est vérifié
|
||||||
|
* false sinon
|
||||||
|
*/
|
||||||
|
public static boolean isAlphanumerique(String aTester) {
|
||||||
|
int index;
|
||||||
|
|
||||||
|
for (index = 0 ;
|
||||||
|
index < aTester.length()
|
||||||
|
&& (isLettre(aTester.charAt(index))
|
||||||
|
|| isChiffre(aTester.charAt(index)));
|
||||||
|
index++)
|
||||||
|
; // Corps vide
|
||||||
|
|
||||||
|
return index >= aTester.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prédicat attestant si un caractère est une lettre
|
||||||
|
* @param aTester caractère a tester
|
||||||
|
* @return true si le prédicat est vérifié
|
||||||
|
* false sinon
|
||||||
|
*/
|
||||||
|
public static boolean isLettre(char aTester) {
|
||||||
|
return 'a' <= aTester && aTester <= 'z'
|
||||||
|
|| 'A' <= aTester && aTester <= 'Z';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prédicat attestant si un caractère est un chiffre
|
||||||
|
* @param aTester caractère a tester
|
||||||
|
* @return true si le prédicat est vérifié
|
||||||
|
* false sinon
|
||||||
|
*/
|
||||||
|
public static boolean isChiffre(char aTester) {
|
||||||
|
return '0' <= aTester && aTester <= '9';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return la valeur de nom
|
||||||
|
*/
|
||||||
|
public String getNom() {
|
||||||
|
return nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* non javadoc - @see java.lang.Object#toString() */
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return nom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* non javadoc - @see java.lang.String#Comparable() */
|
||||||
|
@Override
|
||||||
|
public int compareTo(Identificateur aComparer) {
|
||||||
|
return nom.compareTo(aComparer.nom);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* IdentificateurChaine.java, 08/05/2021
|
||||||
|
* IUT Rodez 2020-2021, info1
|
||||||
|
* pas de copyright, aucun droits
|
||||||
|
*/
|
||||||
|
|
||||||
|
package interpreteurlir.donnees;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identificateur de chaîne
|
||||||
|
* @author Nicolas Caminade
|
||||||
|
* @author Sylvan Courtiol
|
||||||
|
* @author Pierre Debas
|
||||||
|
* @author Heia Dexter
|
||||||
|
* @author Lucas Vabre
|
||||||
|
*/
|
||||||
|
public class IdentificateurChaine extends Identificateur {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiation d'identificateur de chaîne
|
||||||
|
* @param identificateur a instancier
|
||||||
|
* @throws IllegalAccessException si l'identificateur est invalide
|
||||||
|
*/
|
||||||
|
public IdentificateurChaine(String identificateur) {
|
||||||
|
super(identificateur);
|
||||||
|
|
||||||
|
if(!isIdentificateurChaine(identificateur)) {
|
||||||
|
throw new IllegalArgumentException(identificateur
|
||||||
|
+ " n'est pas un identificateur"
|
||||||
|
+ " de chaine");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prédicat attestant la validité de l'identificateur
|
||||||
|
* @param identificateur à tester
|
||||||
|
* @return true si l'identificateur est bien un identificateur d'entier
|
||||||
|
* false sinon
|
||||||
|
*/
|
||||||
|
private static boolean isIdentificateurChaine(String identificateur) {
|
||||||
|
|
||||||
|
return identificateur.length() >= 2
|
||||||
|
&& identificateur.charAt(0) == '$'
|
||||||
|
&& isLettre(identificateur.charAt(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
/*
|
||||||
|
* IdentificateurEntier.java , 08/05/2021
|
||||||
|
* IUT Rodez 2020-2021, info1
|
||||||
|
* pas de copyright, aucun droits
|
||||||
|
*/
|
||||||
|
|
||||||
|
package interpreteurlir.donnees;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Identificateur d'entier
|
||||||
|
* @author Nicolas Caminade
|
||||||
|
* @author Sylvan Courtiol
|
||||||
|
* @author Pierre Debas
|
||||||
|
* @author Heia Dexter
|
||||||
|
* @author Lucas Vabre
|
||||||
|
*/
|
||||||
|
public class IdentificateurEntier extends Identificateur {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiation d'identificateur d'entier
|
||||||
|
* @param identificateur a instancier
|
||||||
|
* @throws IllegalAccessException si l'identificateur est invalide
|
||||||
|
*/
|
||||||
|
public IdentificateurEntier(String identificateur) {
|
||||||
|
super(identificateur);
|
||||||
|
|
||||||
|
if(!isIdentificateurEntier(identificateur)) {
|
||||||
|
throw new IllegalArgumentException(identificateur
|
||||||
|
+ " n'est pas un identificateur"
|
||||||
|
+ " d'entier");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prédicat attestant la validité de l'identificateur
|
||||||
|
*
|
||||||
|
* Un identificateur d'entier est valide si
|
||||||
|
* - Il contient au maximum 24 caractères
|
||||||
|
* - Commence obligatoirement par une lettre (majuscule ou minuscule)
|
||||||
|
* - suivie uniquement de lettres (majuscule ou minuscule) ou de chiffres
|
||||||
|
*
|
||||||
|
* @param identificateur à tester
|
||||||
|
* @return true si l'identificateur est bien un identificateur d'entier
|
||||||
|
* false sinon
|
||||||
|
*/
|
||||||
|
private static boolean isIdentificateurEntier(String identificateur) {
|
||||||
|
|
||||||
|
return isLettre(identificateur.charAt(0))
|
||||||
|
&& isAlphanumerique(identificateur.substring(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
/**
|
||||||
|
* Chaine.java 7 mai 2021
|
||||||
|
* IUT info1 2020-2021, pas de copyright, aucun droit
|
||||||
|
*/
|
||||||
|
package interpreteurlir.donnees.litteraux;
|
||||||
|
|
||||||
|
import interpreteurlir.InterpreteurException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constante littérale de type chaîne de caractères.
|
||||||
|
* @author Nicolas Caminade
|
||||||
|
* @author Sylvan Courtiol
|
||||||
|
* @author Pierre Debas
|
||||||
|
* @author Heïa Dexter
|
||||||
|
* @author Lucas Vabre
|
||||||
|
*/
|
||||||
|
public class Chaine extends Litteral {
|
||||||
|
|
||||||
|
/** Longueur maximale d'une chaîne */
|
||||||
|
public static final int LG_MAX_CHAINE = 70;
|
||||||
|
|
||||||
|
/** Erreur chaîne trop longue */
|
||||||
|
private static final String ERREUR_LG_MAX = "Longueur maximale dépassée";
|
||||||
|
|
||||||
|
/** Erreur constante littéral chaîne invalide */
|
||||||
|
private static final String ERREUR_INVALIDE =
|
||||||
|
"syntaxe incorrecte pour une constante de type chaîne : ";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* initialise cette chaîne avec une valeur par défaut.
|
||||||
|
*/
|
||||||
|
public Chaine() {
|
||||||
|
valeur = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise une chaîne avec la séquence de caractères passée en argument.
|
||||||
|
* @param uneValeur
|
||||||
|
*/
|
||||||
|
public Chaine(String uneValeur) {
|
||||||
|
|
||||||
|
if (!uneValeur.startsWith("\"") || !uneValeur.endsWith("\"")) {
|
||||||
|
throw new InterpreteurException(ERREUR_INVALIDE
|
||||||
|
+ uneValeur);
|
||||||
|
}
|
||||||
|
|
||||||
|
uneValeur = uneValeur.substring(1, uneValeur.length() - 1);
|
||||||
|
|
||||||
|
if (uneValeur.length() > LG_MAX_CHAINE)
|
||||||
|
throw new InterpreteurException(ERREUR_LG_MAX);
|
||||||
|
|
||||||
|
valeur = uneValeur;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Concatène deux chaînes ensemble. Opération non commutative:
|
||||||
|
* a + b != b + a
|
||||||
|
* @param a une Chaîne
|
||||||
|
* @param b une autre Chaîne
|
||||||
|
* @return une nouvelle Chaîne.
|
||||||
|
*/
|
||||||
|
public static Chaine concatener(Chaine a, Chaine b) {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* non javadoc
|
||||||
|
* @see interpreteurlir.donnees.litteraux.Litteral#compareTo(interpreteurlir.donnees.litteraux.Litteral)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int compareTo(Litteral autre) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return this.valeur.toString().compareTo(autre.valeur.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* non javadoc
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return '\"' + valeur.toString() + '\"';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* Entier.java 8 mai 2021
|
||||||
|
* IUT Rodez info1 2020-2021, pas de copyright, aucun droit
|
||||||
|
*/
|
||||||
|
package interpreteurlir.donnees.litteraux;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BOUCHON
|
||||||
|
* @author
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class Entier extends Litteral {
|
||||||
|
|
||||||
|
|
||||||
|
/** TODO commenter l'état initial
|
||||||
|
* @param i
|
||||||
|
*/
|
||||||
|
public Entier(int i) {
|
||||||
|
super(Integer.valueOf(i));
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
valeur = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* non javadoc
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return valeur.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/**
|
||||||
|
* Litteral.java 7 mai 2021
|
||||||
|
* IUT info1 2020-2021, pas de copyright, aucun droit
|
||||||
|
*/
|
||||||
|
package interpreteurlir.donnees.litteraux;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Valeur littérale utilisée dans une expression.
|
||||||
|
* Chaque littérale est reconnue par sont type.
|
||||||
|
* @author Nicolas Caminade
|
||||||
|
* @author Sylvan Courtiol
|
||||||
|
* @author Pierre Debas
|
||||||
|
* @author Heïa Dexter
|
||||||
|
* @author Lucas Vabre
|
||||||
|
*/
|
||||||
|
public class Litteral implements Comparable<Litteral> {
|
||||||
|
|
||||||
|
/** valeur de ce littéral */
|
||||||
|
protected Object valeur;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise ce littéral par défaut.
|
||||||
|
*/
|
||||||
|
protected Litteral() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialise cette valeur avec un objet argument.
|
||||||
|
* @param valeur
|
||||||
|
*/
|
||||||
|
public Litteral(Object valeur) { // TODO public >>> protected
|
||||||
|
super();
|
||||||
|
this.valeur = valeur;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return la valeur de valeur
|
||||||
|
*/
|
||||||
|
public Object getValeur() {
|
||||||
|
return valeur;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* non javadoc
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return valeur.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* non javadoc
|
||||||
|
* @see java.lang.Comparable#compareTo(java.lang.Object)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int compareTo(Litteral autre) {
|
||||||
|
|
||||||
|
if (autre.valeur.getClass() == this.valeur.getClass())
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return this.valeur.hashCode() - autre.valeur.hashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
+17
-14
@@ -2,7 +2,7 @@
|
|||||||
* TestChaine.java 8 mai 2021
|
* TestChaine.java 8 mai 2021
|
||||||
* IUT info1 2020-2021, pas de copyright, aucun droit
|
* IUT info1 2020-2021, pas de copyright, aucun droit
|
||||||
*/
|
*/
|
||||||
package interpreteurlir.donnees.litteraux.test;
|
package interpreteurlir.donnees.litteraux.tests;
|
||||||
|
|
||||||
import interpreteurlir.InterpreteurException;
|
import interpreteurlir.InterpreteurException;
|
||||||
import interpreteurlir.donnees.litteraux.Chaine;
|
import interpreteurlir.donnees.litteraux.Chaine;
|
||||||
@@ -22,9 +22,10 @@ public class TestChaine {
|
|||||||
public static void testChaine() {
|
public static void testChaine() {
|
||||||
|
|
||||||
final String[] VALIDE = {
|
final String[] VALIDE = {
|
||||||
"arztyehjklmpoijhghnbghjklmpoiuytrf" +
|
"\"arztyehjklmpoijhghnbghjklmpoiuytrf" +
|
||||||
"ghjnklmpoiuytrezaqsdfghnjklmpjbfrtyu", "","coucou ",
|
"ghjnklmpoiuytrezaqsdfghnjklmpjbfrtyu\"",
|
||||||
Integer.toString(42)
|
"\"\"","\"coucou \"",
|
||||||
|
"\"" + 42 + "\""
|
||||||
};
|
};
|
||||||
|
|
||||||
final String INVALIDE =
|
final String INVALIDE =
|
||||||
@@ -47,17 +48,17 @@ public class TestChaine {
|
|||||||
/** test de compareTo */
|
/** test de compareTo */
|
||||||
public static void testCompareTo() {
|
public static void testCompareTo() {
|
||||||
final Chaine[][] EGALITES = {
|
final Chaine[][] EGALITES = {
|
||||||
{new Chaine("coucou"), new Chaine("coucou")},
|
{new Chaine("\"coucou\""), new Chaine("\"coucou\"")},
|
||||||
{new Chaine(" "), new Chaine(" ")},
|
{new Chaine("\" \""), new Chaine("\" \"")},
|
||||||
{new Chaine(""), new Chaine()}
|
{new Chaine("\"\""), new Chaine()}
|
||||||
};
|
};
|
||||||
|
|
||||||
final Chaine[][] DIFFERENCES = {
|
final Chaine[][] DIFFERENCES = {
|
||||||
{new Chaine("coucou"), new Chaine("camomille")},
|
{new Chaine("\"coucou\""), new Chaine("\"camomille\"")},
|
||||||
{new Chaine("tarentule"), new Chaine("coucou")},
|
{new Chaine("\"tarentule\""), new Chaine("\"coucou\"")},
|
||||||
{new Chaine("coucou"), new Chaine(" ")},
|
{new Chaine("\"coucou\""), new Chaine("\" \"")},
|
||||||
{new Chaine("coucou"), new Chaine()},
|
{new Chaine("\"coucou\""), new Chaine()},
|
||||||
{new Chaine(" "), new Chaine()}
|
{new Chaine("\" \""), new Chaine()}
|
||||||
};
|
};
|
||||||
|
|
||||||
System.out.println("test de compareTo(Chaine)\nAvec égalités");
|
System.out.println("test de compareTo(Chaine)\nAvec égalités");
|
||||||
@@ -87,8 +88,10 @@ public class TestChaine {
|
|||||||
/** test de toString */
|
/** test de toString */
|
||||||
public static void testToString() {
|
public static void testToString() {
|
||||||
final Chaine[] A_AFFICHER = {
|
final Chaine[] A_AFFICHER = {
|
||||||
new Chaine(), new Chaine(" "), new Chaine("coucou"),
|
new Chaine(), new Chaine("\" \""),
|
||||||
new Chaine(" coucou "), new Chaine("coucou monsieur")
|
new Chaine("\"coucou\""),
|
||||||
|
new Chaine("\" coucou \""),
|
||||||
|
new Chaine("\"coucou monsieur\"")
|
||||||
};
|
};
|
||||||
|
|
||||||
final String[] AFFICHAGE_GUILLEMETS = {
|
final String[] AFFICHAGE_GUILLEMETS = {
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
* TestLitteraux.java 7 mai 2021
|
* TestLitteraux.java 7 mai 2021
|
||||||
* IUT info1 2020-2021, pas de copyright, aucun droit
|
* IUT info1 2020-2021, pas de copyright, aucun droit
|
||||||
*/
|
*/
|
||||||
package interpreteurlir.donnees.litteraux.test;
|
package interpreteurlir.donnees.litteraux.tests;
|
||||||
|
|
||||||
import interpreteurlir.donnees.litteraux.Litteral;
|
import interpreteurlir.donnees.litteraux.Litteral;
|
||||||
|
|
||||||
+17
-17
@@ -2,11 +2,11 @@
|
|||||||
* TestIdentificateur.java 8 mai 2021
|
* TestIdentificateur.java 8 mai 2021
|
||||||
* IUT-Rodez info1 2020-2021, pas de droits, pas de copyrights
|
* IUT-Rodez info1 2020-2021, pas de droits, pas de copyrights
|
||||||
*/
|
*/
|
||||||
package donnees.tests;
|
package interpreteurlir.donnees.tests;
|
||||||
|
|
||||||
import static outils.glg.Assertions.*;
|
import static info1.outils.glg.Assertions.*;
|
||||||
|
|
||||||
import donnees.Identificateur;
|
import interpreteurlir.donnees.Identificateur;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test de la classe donnees.Identificateur
|
* Test de la classe donnees.Identificateur
|
||||||
@@ -79,7 +79,7 @@ public class TestIdentificateur {
|
|||||||
public static void testCompareTo() {
|
public static void testCompareTo() {
|
||||||
final Identificateur REF_MIN = new Identificateur("$AAAAAAAAAAAAAAAAAAAAAAAA");
|
final Identificateur REF_MIN = new Identificateur("$AAAAAAAAAAAAAAAAAAAAAAAA");
|
||||||
final Identificateur REF_MAX = new Identificateur("zzzzzzzzzzzzzzzzzzzzzzzz");
|
final Identificateur REF_MAX = new Identificateur("zzzzzzzzzzzzzzzzzzzzzzzz");
|
||||||
|
|
||||||
for(int noJeu = 0; noJeu < FIXTURE.length; noJeu++) {
|
for(int noJeu = 0; noJeu < FIXTURE.length; noJeu++) {
|
||||||
assertTrue(FIXTURE[noJeu].compareTo(REF_MIN) >= 0);
|
assertTrue(FIXTURE[noJeu].compareTo(REF_MIN) >= 0);
|
||||||
assertTrue(FIXTURE[noJeu].compareTo(REF_MAX) <= 0);
|
assertTrue(FIXTURE[noJeu].compareTo(REF_MAX) <= 0);
|
||||||
@@ -92,22 +92,22 @@ public class TestIdentificateur {
|
|||||||
*/
|
*/
|
||||||
public static void testToString() {
|
public static void testToString() {
|
||||||
final String[] CHAINES_VALIDES = {
|
final String[] CHAINES_VALIDES = {
|
||||||
"Identificateur [nom=b]",
|
"b",
|
||||||
"Identificateur [nom=A]",
|
"A",
|
||||||
"Identificateur [nom=zalpha]",
|
"zalpha",
|
||||||
"Identificateur [nom=Alpha]",
|
"Alpha",
|
||||||
"Identificateur [nom=Alpha5]",
|
"Alpha5",
|
||||||
"Identificateur [nom=jeSuisUnTresLongIdentifi]",
|
"jeSuisUnTresLongIdentifi",
|
||||||
"Identificateur [nom=$b]",
|
"$b",
|
||||||
"Identificateur [nom=z]",
|
"z",
|
||||||
"Identificateur [nom=$zalpha]",
|
"$zalpha",
|
||||||
"Identificateur [nom=$Alpha]",
|
"$Alpha",
|
||||||
"Identificateur [nom=$Alpha5]",
|
"$Alpha5",
|
||||||
"Identificateur [nom=$jeSuisUnTresLongIdentifi]"
|
"$jeSuisUnTresLongIdentifi"
|
||||||
};
|
};
|
||||||
|
|
||||||
for (int noJeu = 0 ; noJeu < CHAINES_VALIDES.length ; noJeu++) {
|
for (int noJeu = 0 ; noJeu < CHAINES_VALIDES.length ; noJeu++) {
|
||||||
assertEquivalent(CHAINES_VALIDES[noJeu],
|
assertEquivalence(CHAINES_VALIDES[noJeu],
|
||||||
FIXTURE[noJeu].toString());
|
FIXTURE[noJeu].toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-5
@@ -4,12 +4,11 @@
|
|||||||
* pas de copyright, aucun droits
|
* pas de copyright, aucun droits
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package donnees.tests;
|
package interpreteurlir.donnees.tests;
|
||||||
|
|
||||||
import static outils.glg.Assertions.assertEquivalent;
|
import static info1.outils.glg.Assertions.*;
|
||||||
import static outils.glg.Assertions.echec;
|
|
||||||
|
|
||||||
import donnees.IdentificateurChaine;
|
import interpreteurlir.donnees.IdentificateurChaine;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests unitaires de la classe donnees.IdentificateurEntier
|
* Tests unitaires de la classe donnees.IdentificateurEntier
|
||||||
@@ -87,7 +86,7 @@ public class TestIdentificateurChaine {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (int noJeu = 0 ; noJeu < NOM_VALIDES.length ; noJeu++) {
|
for (int noJeu = 0 ; noJeu < NOM_VALIDES.length ; noJeu++) {
|
||||||
assertEquivalent(NOM_VALIDES[noJeu], FIXTURE[noJeu].getNom());
|
assertEquivalence(NOM_VALIDES[noJeu], FIXTURE[noJeu].getNom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-4
@@ -4,11 +4,11 @@
|
|||||||
* pas de copyright, aucun droits
|
* pas de copyright, aucun droits
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package donnees.tests;
|
package interpreteurlir.donnees.tests;
|
||||||
|
|
||||||
import static outils.glg.Assertions.*;
|
import static info1.outils.glg.Assertions.*;
|
||||||
|
|
||||||
import donnees.IdentificateurEntier;
|
import interpreteurlir.donnees.IdentificateurEntier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests unitaires de la classe donnees.IdentificateurEntier
|
* Tests unitaires de la classe donnees.IdentificateurEntier
|
||||||
@@ -77,7 +77,7 @@ public class TestIdentificateurEntier {
|
|||||||
};
|
};
|
||||||
|
|
||||||
for (int noJeu = 0 ; noJeu < NOM_VALIDES.length ; noJeu++) {
|
for (int noJeu = 0 ; noJeu < NOM_VALIDES.length ; noJeu++) {
|
||||||
assertEquivalent(NOM_VALIDES[noJeu], FIXTURE[noJeu].getNom());
|
assertEquivalence(NOM_VALIDES[noJeu], FIXTURE[noJeu].getNom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* ExpressionEntier.java 7 mai 2021
|
* TestExpressionEntier.java 7 mai 2021
|
||||||
* IUT Rodez info1 2020-2021, pas de copyright, aucun droit
|
* IUT Rodez info1 2020-2021, pas de copyright, aucun droit
|
||||||
*/
|
*/
|
||||||
package interpreteurlir.expressions.tests;
|
package interpreteurlir.expressions.tests;
|
||||||
@@ -14,6 +14,6 @@ import interpreteurlir.expressions.Expression;
|
|||||||
* @author Heïa Dexter
|
* @author Heïa Dexter
|
||||||
* @author Lucas Vabre
|
* @author Lucas Vabre
|
||||||
*/
|
*/
|
||||||
public class ExpressionEntier {
|
public class TestExpressionEntier {
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,12 +7,8 @@ package interpreteurlir.tests;
|
|||||||
import static info1.outils.glg.Assertions.*;
|
import static info1.outils.glg.Assertions.*;
|
||||||
|
|
||||||
import interpreteurlir.Contexte;
|
import interpreteurlir.Contexte;
|
||||||
import interpreteurlir.donnees.Identificateur;
|
import interpreteurlir.donnees.*;
|
||||||
import interpreteurlir.donnees.IdentificateurChaine;
|
import interpreteurlir.donnees.litteraux.*;
|
||||||
import interpreteurlir.donnees.IdentificateurEntier;
|
|
||||||
import interpreteurlir.donnees.litteraux.Chaine;
|
|
||||||
import interpreteurlir.donnees.litteraux.Entier;
|
|
||||||
import interpreteurlir.donnees.litteraux.Litteral;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests unitaires de {@link Contexte}
|
* Tests unitaires de {@link Contexte}
|
||||||
@@ -54,6 +50,8 @@ public class TestContexte {
|
|||||||
new IdentificateurChaine("$chaine"), // ajout dans liste vide
|
new IdentificateurChaine("$chaine"), // ajout dans liste vide
|
||||||
new IdentificateurEntier("entier"), // ajout fin
|
new IdentificateurEntier("entier"), // ajout fin
|
||||||
new IdentificateurChaine("$zoro"), // ajout milieu
|
new IdentificateurChaine("$zoro"), // ajout milieu
|
||||||
|
|
||||||
|
new IdentificateurChaine("$abcd"), // ajout debut
|
||||||
};
|
};
|
||||||
|
|
||||||
Litteral[] valeur = {
|
Litteral[] valeur = {
|
||||||
@@ -64,6 +62,8 @@ public class TestContexte {
|
|||||||
new Chaine("\"viveLa Vie\""),
|
new Chaine("\"viveLa Vie\""),
|
||||||
new Entier(-1),
|
new Entier(-1),
|
||||||
new Chaine("\" ah ah ! \""),
|
new Chaine("\" ah ah ! \""),
|
||||||
|
|
||||||
|
new Chaine("\"lol\""),
|
||||||
};
|
};
|
||||||
|
|
||||||
System.out.println("\tExécution du test de "
|
System.out.println("\tExécution du test de "
|
||||||
@@ -134,7 +134,7 @@ public class TestContexte {
|
|||||||
|
|
||||||
// lire valeur défaut contexte vid
|
// lire valeur défaut contexte vid
|
||||||
assertEquivalence(fixture[0].lireValeurVariable(
|
assertEquivalence(fixture[0].lireValeurVariable(
|
||||||
new IdentificateurChaine("$chaine")).getValeur(), "\"\"");
|
new IdentificateurChaine("$chaine")).getValeur(), "");
|
||||||
assertEquivalence(fixture[0].lireValeurVariable(
|
assertEquivalence(fixture[0].lireValeurVariable(
|
||||||
new IdentificateurEntier("entier")).getValeur(), Integer.valueOf(0));
|
new IdentificateurEntier("entier")).getValeur(), Integer.valueOf(0));
|
||||||
|
|
||||||
@@ -143,7 +143,7 @@ public class TestContexte {
|
|||||||
new Chaine("\"Zoro le héro\""));
|
new Chaine("\"Zoro le héro\""));
|
||||||
|
|
||||||
assertEquivalence(fixture[1].lireValeurVariable(
|
assertEquivalence(fixture[1].lireValeurVariable(
|
||||||
new IdentificateurChaine("$chaine")).getValeur(), "\"\"");
|
new IdentificateurChaine("$chaine")).getValeur(), "");
|
||||||
assertEquivalence(fixture[1].lireValeurVariable(
|
assertEquivalence(fixture[1].lireValeurVariable(
|
||||||
new IdentificateurEntier("entier")).getValeur(), 0);
|
new IdentificateurEntier("entier")).getValeur(), 0);
|
||||||
|
|
||||||
@@ -152,14 +152,18 @@ public class TestContexte {
|
|||||||
new Chaine("\"blabla\""));
|
new Chaine("\"blabla\""));
|
||||||
fixture[1].ajouterVariable(new IdentificateurEntier("entier"),
|
fixture[1].ajouterVariable(new IdentificateurEntier("entier"),
|
||||||
new Entier(25));
|
new Entier(25));
|
||||||
//
|
|
||||||
// assertEquivalence(fixture[1].lireValeurVariable(
|
System.out.println(fixture[1].lireValeurVariable(
|
||||||
// new IdentificateurChaine("$chaine")).getValeur(), "\"blabla\"");
|
new IdentificateurChaine("$zoro")).getValeur());
|
||||||
// assertEquivalence(fixture[1].lireValeurVariable(
|
|
||||||
// new IdentificateurEntier("entier")).getValeur(), 25);
|
|
||||||
// assertEquivalence(fixture[1].lireValeurVariable(
|
assertEquivalence(fixture[1].lireValeurVariable(
|
||||||
// new IdentificateurChaine("$zoro")).getValeur(),
|
new IdentificateurChaine("$chaine")).getValeur(), "blabla");
|
||||||
// "\"Zoro le héro\"");
|
assertEquivalence(fixture[1].lireValeurVariable(
|
||||||
|
new IdentificateurEntier("entier")).getValeur(), 25);
|
||||||
|
assertEquivalence(fixture[1].lireValeurVariable(
|
||||||
|
new IdentificateurChaine("$zoro")).getValeur(),
|
||||||
|
"Zoro le héro");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user