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

l'analyse pour l'addition est terminée

parent 335d7408
No related branches found
No related tags found
No related merge requests found
import javax.management.RuntimeErrorException;
/* /*
* Semantic analyser that walks the AST. * Semantic analyser that walks the AST.
* Check for scope and type compatibility. * Check for scope and type compatibility.
...@@ -14,10 +16,16 @@ public class SemanticAnalyzer implements ASTVisitor { ...@@ -14,10 +16,16 @@ public class SemanticAnalyzer implements ASTVisitor {
node.getGauche().accept(this); node.getGauche().accept(this);
node.getDroite().accept(this); node.getDroite().accept(this);
if (!(node.getGauche() instanceof Nombre)) { //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 l'addition car la valeur de gauche n'est pas un nombre !"); throw new RuntimeException("Impossible d'effectuer l'addition car la valeur de gauche n'est pas un nombre !");
} }
if (!(node.getDroite() instanceof 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 l'addition car la valeur de droite n'est pas un nombre !"); throw new RuntimeException("Impossible d'effectuer l'addition car la valeur de droite n'est pas un nombre !");
} }
return null; return null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment