Skip to content
Snippets Groups Projects
Commit 259e17dc authored by lucien.noel's avatar lucien.noel
Browse files

analyse de la division, soustraction et multiplication terminée

parent 38534785
Branches
No related tags found
No related merge requests found
......@@ -87,6 +87,19 @@ public class SemanticAnalyzer implements ASTVisitor {
public Object visit(Division node) {
node.getGauche().accept(this);
node.getDroite().accept(this);
//test si la partie de gauche est un nombre ou un Idf qui pointe vers un entier
if (!(node.getGauche() instanceof Nombre ||
(node.getGauche() instanceof Idf && TDS.getInstance().identifier(new Entree(((Idf)node.getGauche()).getNom())).getType() instanceof Entier))
) {
throw new RuntimeException("Impossible d'effectuer la divions car la valeur de gauche n'est pas un nombre !");
}
//test si la partie de droite est un nombre ou un Idf qui pointe vers un entier
if (!(node.getDroite() instanceof Nombre ||
(node.getDroite() instanceof Idf && TDS.getInstance().identifier(new Entree(((Idf)node.getDroite()).getNom())).getType() instanceof Entier))
) {
throw new RuntimeException("Impossible d'effectuer la division car la valeur de droite n'est pas un nombre !");
}
return null;
}
......@@ -169,6 +182,19 @@ public class SemanticAnalyzer implements ASTVisitor {
public Object visit(Produit node) {
node.getGauche().accept(this);
node.getDroite().accept(this);
//test si la partie de gauche est un nombre ou un Idf qui pointe vers un entier
if (!(node.getGauche() instanceof Nombre ||
(node.getGauche() instanceof Idf && TDS.getInstance().identifier(new Entree(((Idf)node.getGauche()).getNom())).getType() instanceof Entier))
) {
throw new RuntimeException("Impossible d'effectuer la multiplication car la valeur de gauche n'est pas un nombre !");
}
//test si la partie de droite est un nombre ou un Idf qui pointe vers un entier
if (!(node.getDroite() instanceof Nombre ||
(node.getDroite() instanceof Idf && TDS.getInstance().identifier(new Entree(((Idf)node.getDroite()).getNom())).getType() instanceof Entier))
) {
throw new RuntimeException("Impossible d'effectuer la multiplication car la valeur de droite n'est pas un nombre !");
}
return null;
}
......@@ -179,6 +205,19 @@ public class SemanticAnalyzer implements ASTVisitor {
public Object visit(Soustraction node) {
node.getGauche().accept(this);
node.getDroite().accept(this);
//test si la partie de gauche est un nombre ou un Idf qui pointe vers un entier
if (!(node.getGauche() instanceof Nombre ||
(node.getGauche() instanceof Idf && TDS.getInstance().identifier(new Entree(((Idf)node.getGauche()).getNom())).getType() instanceof Entier))
) {
throw new RuntimeException("Impossible d'effectuer la soustraction car la valeur de gauche n'est pas un nombre !");
}
//test si la partie de droite est un nombre ou un Idf qui pointe vers un entier
if (!(node.getDroite() instanceof Nombre ||
(node.getDroite() instanceof Idf && TDS.getInstance().identifier(new Entree(((Idf)node.getDroite()).getNom())).getType() instanceof Entier))
) {
throw new RuntimeException("Impossible d'effectuer la soustraction car la valeur de droite n'est pas un nombre !");
}
return null;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment