mirror of
https://github.com/LucasVbr/interpreteur-lir.git
synced 2026-12-05 18:40:49 +00:00
Mise en commun pour même base
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user