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

analyse de la declaration de contstante terminée

parent ece5ab1e
No related branches found
No related tags found
No related merge requests found
...@@ -88,6 +88,13 @@ public class SemanticAnalyzer implements ASTVisitor { ...@@ -88,6 +88,13 @@ public class SemanticAnalyzer implements ASTVisitor {
public Object visit(DeclarationConstant node) { public Object visit(DeclarationConstant node) {
node.getIdentifier().accept(this); node.getIdentifier().accept(this);
node.getConstantExpression().accept(this); node.getConstantExpression().accept(this);
String idfNom = node.getIdentifier().getNom();
if(isExpressionBooleen(node.getIdentifier()) && !isExpressionBooleen(node.getConstantExpression())){
throw new RuntimeException("Impossible d'affecter un non-booleen à la variable '"+idfNom+"' !");
}
if(isExpressionNumber(node.getIdentifier()) && !isExpressionNumber(node.getConstantExpression())){
throw new RuntimeException("Impossible d'affecter un non-nombre à la variable '"+idfNom+"' !");
}
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