Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Technique de compilation - TP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lucien.noel
Technique de compilation - TP
Commits
259e17dc
Commit
259e17dc
authored
2 years ago
by
lucien.noel
Browse files
Options
Downloads
Patches
Plain Diff
analyse de la division, soustraction et multiplication terminée
parent
38534785
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Visitors/SemanticAnalyzer.java
+39
-0
39 additions, 0 deletions
Visitors/SemanticAnalyzer.java
with
39 additions
and
0 deletions
Visitors/SemanticAnalyzer.java
+
39
−
0
View file @
259e17dc
...
...
@@ -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
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment