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

analyse du == terminée

parent 259e17dc
No related branches found
No related tags found
No related merge requests found
...@@ -2,6 +2,4 @@ public class Booleen extends Ttype{ ...@@ -2,6 +2,4 @@ public class Booleen extends Ttype{
public Booleen() { public Booleen() {
super("booleen"); super("booleen");
} }
} }
...@@ -13,6 +13,10 @@ public class Symbole{ ...@@ -13,6 +13,10 @@ public class Symbole{
} }
public Ttype getType(){
return this.type;
}
@Override @Override
public String toString() { public String toString() {
// TODO Auto-generated method stub // TODO Auto-generated method stub
......
...@@ -111,6 +111,19 @@ public class SemanticAnalyzer implements ASTVisitor { ...@@ -111,6 +111,19 @@ public class SemanticAnalyzer implements ASTVisitor {
public Object visit(Egal node) { public Object visit(Egal node) {
node.getGauche().accept(this); node.getGauche().accept(this);
node.getDroite().accept(this); node.getDroite().accept(this);
//test si la valeur à gauche et à droite du == sont du même type
if(node.getGauche() instanceof Vrai || node.getGauche() instanceof Faux || (node.getGauche() instanceof Idf && TDS.getInstance().identifier(new Entree(((Idf)node.getGauche()).getNom())).getType() instanceof Booleen)){
if(!(node.getDroite() instanceof Vrai || node.getDroite() instanceof Faux || (node.getDroite() instanceof Idf && TDS.getInstance().identifier(new Entree(((Idf)node.getDroite()).getNom())).getType() instanceof Booleen))){
throw new RuntimeException("Impossible d'effectuer une comparaison entre 2 valeur qui ne sont pas du même type !");
}
}else if(node.getGauche() instanceof Nombre || (node.getGauche() instanceof Idf && TDS.getInstance().identifier(new Entree(((Idf)node.getGauche()).getNom())).getType() instanceof 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 une comparaison entre 2 valeur qui ne sont pas du même type !");
}
}else{
throw new RuntimeException("Normalement cette exception ne devrait jamais apparaitre mais on ne sait jamais");
}
return null; return null;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment