Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
2024_compilation_Bazizi_Zaynoune
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Insights
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
BAZIZI Zakaria
2024_compilation_Bazizi_Zaynoune
Commits
962d6d11
Commit
962d6d11
authored
1 year ago
by
ZaynouneFatimaZahrae
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/main'
# Conflicts: # test/result.txt
parents
642e15ce
42e8b37d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/Compiler.java
+2
-1
2 additions, 1 deletion
src/Compiler.java
src/c3a/Sa2c3a.java
+249
-24
249 additions, 24 deletions
src/c3a/Sa2c3a.java
src/ts/Sa2ts.java
+119
-88
119 additions, 88 deletions
src/ts/Sa2ts.java
test/result.txt
+410
-0
410 additions, 0 deletions
test/result.txt
with
780 additions
and
113 deletions
src/Compiler.java
+
2
−
1
View file @
962d6d11
...
@@ -33,13 +33,13 @@ public class Compiler
...
@@ -33,13 +33,13 @@ public class Compiler
buildSc
();
buildSc
();
System
.
out
.
println
(
"[BUILD SA] "
);
System
.
out
.
println
(
"[BUILD SA] "
);
buildSa
();
buildSa
();
/*
System
.
out
.
println
(
"[BUILD TS] "
);
System
.
out
.
println
(
"[BUILD TS] "
);
buildTs
();
buildTs
();
System
.
out
.
println
(
"[TYPE CHECKING]"
);
System
.
out
.
println
(
"[TYPE CHECKING]"
);
typeCheck
();
typeCheck
();
System
.
out
.
println
(
"[BUILD C3A] "
);
System
.
out
.
println
(
"[BUILD C3A] "
);
buildC3a
();
buildC3a
();
/*
System.out.println("[BUILD PRE NASM] ");
System.out.println("[BUILD PRE NASM] ");
buildPreNasm();
buildPreNasm();
System.out.println("[BUILD FLOW GRAPH] ");
System.out.println("[BUILD FLOW GRAPH] ");
...
@@ -48,6 +48,7 @@ public class Compiler
...
@@ -48,6 +48,7 @@ public class Compiler
solveFg();
solveFg();
System.out.println("[BUILD INTERFERENCE GRAPH] ");
System.out.println("[BUILD INTERFERENCE GRAPH] ");
buildIg();
buildIg();
System.out.println("[ALLOCATE REGISTERS]");
System.out.println("[ALLOCATE REGISTERS]");
interferenceGraph.allocateRegisters();
interferenceGraph.allocateRegisters();
System.out.println("[PRINT NASM]");
System.out.println("[PRINT NASM]");
...
...
This diff is collapsed.
Click to expand it.
src/c3a/Sa2c3a.java
+
249
−
24
View file @
962d6d11
package
c3a
;
package
c3a
;
import
java.util.*
;
import
ts.*
;
import
ts.*
;
import
sa.*
;
import
sa.*
;
public
class
Sa2c3a
extends
SaDepthFirstVisitor
<
C3aOperand
>
{
public
class
Sa2c3a
extends
SaDepthFirstVisitor
<
C3aOperand
>
{
private
C3a
c3a
;
private
C3a
c3a
;
int
indentation
;
int
indentation
;
...
@@ -14,36 +14,261 @@ public class Sa2c3a extends SaDepthFirstVisitor <C3aOperand> {
...
@@ -14,36 +14,261 @@ public class Sa2c3a extends SaDepthFirstVisitor <C3aOperand> {
C3aFunction
fct
=
new
C3aFunction
(
tableGlobale
.
getFct
(
"main"
));
C3aFunction
fct
=
new
C3aFunction
(
tableGlobale
.
getFct
(
"main"
));
c3a
.
ajouteInst
(
new
C3aInstCall
(
fct
,
result
,
""
));
c3a
.
ajouteInst
(
new
C3aInstCall
(
fct
,
result
,
""
));
c3a
.
ajouteInst
(
new
C3aInstStop
(
result
,
""
));
c3a
.
ajouteInst
(
new
C3aInstStop
(
result
,
""
));
indentation
=
0
;
indentation
=
0
;
try
{
root
.
accept
(
this
);
}
catch
(
Exception
e
){}
}
}
public
void
defaultIn
(
SaNode
node
)
/*
public void defaultIn(SaNode node)
{
{
//
for(int i = 0; i < indentation; i++){System.out.print(" ");}
for(int i = 0; i < indentation; i++){System.out.print(" ");}
//
indentation++;
indentation++;
//
System.out.println("<" + node.getClass().getSimpleName() + ">");
System.out.println("<" + node.getClass().getSimpleName() + ">");
}
}
public void defaultOut(SaNode node)
public void defaultOut(SaNode node)
{
{
//
indentation--;
indentation--;
//
for(int i = 0; i < indentation; i++){System.out.print(" ");}
for(int i = 0; i < indentation; i++){System.out.print(" ");}
//
System.out.println("</" + node.getClass().getSimpleName() + ">");
System.out.println("</" + node.getClass().getSimpleName() + ">");
}
}
/*
*/
// EXP -> op2 EXP EXP
public
C3aOperand
visit
(
SaInstTantQue
node
)
throws
Exception
{
C3aOperand
startloop
=
c3a
.
newAutoLabel
();
C3aOperand
endloop
=
c3a
.
newAutoLabel
();
c3a
.
addLabelToNextInst
((
C3aLabel
)
startloop
);
C3aOperand
test
=
c3a
.
newTemp
();
C3aOperand
value
=
node
.
getTest
().
accept
(
this
);
c3a
.
ajouteInst
(
new
C3aInstAffect
(
value
,
test
,
""
));
c3a
.
ajouteInst
(
new
C3aInstJumpIfEqual
(
test
,
c3a
.
False
,
endloop
,
""
));
if
(
node
.
getFaire
()!=
null
)
{
node
.
getFaire
().
accept
(
this
);
}
c3a
.
ajouteInst
(
new
C3aInstJump
(
startloop
,
""
));
c3a
.
addLabelToNextInst
((
C3aLabel
)
endloop
);
return
null
;
}
@Override
public
C3aOperand
visit
(
SaExpAdd
node
)
throws
Exception
public
C3aOperand
visit
(
SaExpAdd
node
)
throws
Exception
{
{
defaultIn
(
node
);
defaultIn
(
node
);
C3aOperand
op1
=
node
.
getOp1
().
accept
(
this
);
C3aOperand
op1
=
node
.
getOp1
().
accept
(
this
);
C3aOperand
op2
=
node
.
getOp2
().
accept
(
this
);
C3aOperand
op2
=
node
.
getOp2
().
accept
(
this
);
C3aOperand
result
=
c3a
.
newTemp
();
C3aOperand
result
=
c3a
.
newTemp
();
c3a
.
ajouteInst
(
new
C3aInstAdd
(
op1
,
op2
,
result
,
""
));
c3a
.
ajouteInst
(
new
C3aInstAdd
(
op1
,
op2
,
result
,
""
));
defaultOut
(
node
);
defaultOut
(
node
);
return
result
;
return
result
;
}
}
@Override
public
C3aOperand
visit
(
SaExpDiv
node
)
throws
Exception
{
defaultIn
(
node
);
C3aOperand
op1
=
node
.
getOp1
().
accept
(
this
);
C3aOperand
op2
=
node
.
getOp2
().
accept
(
this
);
C3aOperand
result
=
c3a
.
newTemp
();
c3a
.
ajouteInst
(
new
C3aInstDiv
(
op1
,
op2
,
result
,
""
));
defaultOut
(
node
);
return
result
;
}
@Override
public
C3aOperand
visit
(
SaExpSub
node
)
throws
Exception
{
defaultIn
(
node
);
C3aOperand
op1
=
node
.
getOp1
().
accept
(
this
);
C3aOperand
op2
=
node
.
getOp2
().
accept
(
this
);
C3aOperand
result
=
c3a
.
newTemp
();
c3a
.
ajouteInst
(
new
C3aInstSub
(
op1
,
op2
,
result
,
""
));
defaultOut
(
node
);
return
result
;
}
@Override
public
C3aOperand
visit
(
SaExpMult
node
)
throws
Exception
{
defaultIn
(
node
);
C3aOperand
op1
=
node
.
getOp1
().
accept
(
this
);
C3aOperand
op2
=
node
.
getOp2
().
accept
(
this
);
C3aOperand
result
=
c3a
.
newTemp
();
c3a
.
ajouteInst
(
new
C3aInstMult
(
op1
,
op2
,
result
,
""
));
defaultOut
(
node
);
return
result
;
}
public
C3aOperand
visit
(
SaExpInt
node
)
{
return
new
C3aConstant
(
node
.
getVal
());
}
public
C3aOperand
visit
(
SaExpAppel
node
)
throws
Exception
{
return
node
.
getVal
().
accept
(
this
);
}
public
C3aOperand
visit
(
SaAppel
node
)
throws
Exception
{
if
(
node
.
getArguments
()!=
null
)
{
SaLExp
arguments
=
node
.
getArguments
();
while
(
arguments
!=
null
)
{
SaExp
arg
=
arguments
.
getTete
();
c3a
.
ajouteInst
(
new
C3aInstParam
(
arg
.
accept
(
this
),
""
));
arguments
=
arguments
.
getQueue
();
}
}
C3aOperand
result
=
c3a
.
newTemp
();
c3a
.
ajouteInst
(
new
C3aInstCall
(
new
C3aFunction
(
node
.
tsItem
),
result
,
""
));
return
result
;
}
public
C3aOperand
visit
(
SaDecFonc
node
)
throws
Exception
{
c3a
.
ajouteInst
(
new
C3aInstFBegin
(
node
.
tsItem
,
""
));
if
(
node
.
getCorps
()!=
null
)
{
node
.
getCorps
().
accept
(
this
);
}
c3a
.
ajouteInst
(
new
C3aInstFEnd
(
""
));
return
null
;
}
public
C3aOperand
visit
(
SaInstAffect
node
)
throws
Exception
{
System
.
out
.
println
(
"here"
);
C3aOperand
var
=
node
.
getLhs
().
accept
(
this
);
C3aOperand
value
=
node
.
getRhs
().
accept
(
this
);
c3a
.
ajouteInst
(
new
C3aInstAffect
(
value
,
var
,
""
));
return
null
;
}
public
C3aOperand
visit
(
SaInstRetour
node
)
throws
Exception
{
C3aOperand
returnval
=
node
.
getVal
().
accept
(
this
);
c3a
.
ajouteInst
(
new
C3aInstReturn
(
returnval
,
""
));
return
returnval
;
}
public
C3aOperand
visit
(
SaExpLire
node
)
{
C3aOperand
temp
=
c3a
.
newTemp
();
c3a
.
ajouteInst
(
new
C3aInstRead
(
temp
,
""
));
return
temp
;
}
public
C3aOperand
visit
(
SaVarSimple
node
)
{
if
(
node
.
tsItem
==
null
)
System
.
out
.
println
(
"null"
);
return
new
C3aVar
(
node
.
tsItem
,
null
);
}
public
C3aOperand
visit
(
SaVarIndicee
node
)
throws
Exception
{
C3aOperand
index
=
node
.
getIndice
().
accept
(
this
);
return
new
C3aVar
(
node
.
getTsItem
(),
index
);
}
public
C3aOperand
visit
(
SaInstEcriture
node
)
throws
Exception
{
C3aOperand
op
=
node
.
getArg
().
accept
(
this
);
c3a
.
ajouteInst
(
new
C3aInstWrite
(
op
,
""
));
return
null
;
}
public
C3aOperand
visit
(
SaExpVar
node
)
throws
Exception
{
return
node
.
getVar
().
accept
(
this
);
}
public
C3aOperand
visit
(
SaExpVrai
node
)
{
return
c3a
.
True
;
}
public
C3aOperand
visit
(
SaExpFaux
node
)
{
return
c3a
.
False
;
}
public
C3aOperand
visit
(
SaExpInf
node
)
throws
Exception
{
C3aOperand
value
=
c3a
.
newTemp
();
C3aOperand
label
=
c3a
.
newAutoLabel
();
c3a
.
ajouteInst
(
new
C3aInstAffect
(
c3a
.
True
,
value
,
""
));
c3a
.
ajouteInst
(
new
C3aInstJumpIfLess
(
node
.
getOp1
().
accept
(
this
),
node
.
getOp2
().
accept
(
this
),
label
,
""
));
c3a
.
ajouteInst
(
new
C3aInstAffect
(
c3a
.
False
,
value
,
""
));
c3a
.
addLabelToNextInst
((
C3aLabel
)
label
);
return
value
;
}
public
C3aOperand
visit
(
SaExpAnd
node
)
throws
Exception
{
C3aOperand
value
=
c3a
.
newTemp
();
C3aOperand
label1
=
c3a
.
newAutoLabel
();
C3aOperand
label2
=
c3a
.
newAutoLabel
();
c3a
.
ajouteInst
(
new
C3aInstJumpIfEqual
(
node
.
getOp1
().
accept
(
this
),
c3a
.
False
,
label1
,
""
));
c3a
.
ajouteInst
(
new
C3aInstJumpIfEqual
(
node
.
getOp2
().
accept
(
this
),
c3a
.
False
,
label1
,
""
));
c3a
.
ajouteInst
(
new
C3aInstAffect
(
c3a
.
True
,
value
,
""
));
c3a
.
ajouteInst
(
new
C3aInstJump
(
label2
,
""
));
c3a
.
addLabelToNextInst
((
C3aLabel
)
label1
);
c3a
.
ajouteInst
(
new
C3aInstAffect
(
c3a
.
False
,
value
,
""
));
c3a
.
addLabelToNextInst
((
C3aLabel
)
label2
);
return
value
;
}
public
C3aOperand
visit
(
SaExpOr
node
)
throws
Exception
{
C3aOperand
value
=
c3a
.
newTemp
();
C3aOperand
label
=
c3a
.
newAutoLabel
();
c3a
.
ajouteInst
(
new
C3aInstAffect
(
c3a
.
True
,
value
,
""
));
c3a
.
ajouteInst
(
new
C3aInstJumpIfEqual
(
node
.
getOp1
().
accept
(
this
),
c3a
.
True
,
label
,
""
));
c3a
.
ajouteInst
(
new
C3aInstJumpIfEqual
(
node
.
getOp2
().
accept
(
this
),
c3a
.
True
,
label
,
""
));
c3a
.
ajouteInst
(
new
C3aInstAffect
(
c3a
.
False
,
value
,
""
));
c3a
.
addLabelToNextInst
((
C3aLabel
)
label
);
return
value
;
}
public
C3aOperand
visit
(
SaExpEqual
node
)
throws
Exception
{
C3aOperand
value
=
c3a
.
newTemp
();
C3aOperand
label
=
c3a
.
newAutoLabel
();
c3a
.
ajouteInst
(
new
C3aInstAffect
(
c3a
.
True
,
value
,
""
));
c3a
.
ajouteInst
(
new
C3aInstJumpIfEqual
(
node
.
getOp1
().
accept
(
this
),
node
.
getOp2
().
accept
(
this
),
label
,
""
));
c3a
.
ajouteInst
(
new
C3aInstAffect
(
c3a
.
False
,
value
,
""
));
c3a
.
addLabelToNextInst
((
C3aLabel
)
label
);
return
value
;
}
public
C3aOperand
visit
(
SaExpNot
node
)
throws
Exception
{
C3aOperand
value
=
c3a
.
newTemp
();
C3aOperand
label1
=
c3a
.
newAutoLabel
();
C3aOperand
label2
=
c3a
.
newAutoLabel
();
c3a
.
ajouteInst
(
new
C3aInstAffect
(
node
.
getOp1
().
accept
(
this
),
value
,
""
));
c3a
.
ajouteInst
(
new
C3aInstJumpIfEqual
(
value
,
c3a
.
False
,
label1
,
""
));
c3a
.
ajouteInst
(
new
C3aInstAffect
(
c3a
.
False
,
value
,
""
));
c3a
.
ajouteInst
(
new
C3aInstJump
(
label2
,
""
));
c3a
.
addLabelToNextInst
((
C3aLabel
)
label1
);
c3a
.
ajouteInst
(
new
C3aInstAffect
(
c3a
.
True
,
value
,
""
));
c3a
.
addLabelToNextInst
((
C3aLabel
)
label2
);
return
value
;
}
public
C3aOperand
visit
(
SaInstSi
node
)
throws
Exception
{
C3aOperand
test
=
c3a
.
newTemp
();
C3aOperand
value
=
node
.
getTest
().
accept
(
this
);
c3a
.
ajouteInst
(
new
C3aInstAffect
(
value
,
test
,
""
));
C3aOperand
alors
=
c3a
.
newAutoLabel
();
C3aOperand
sinon
=
c3a
.
newAutoLabel
();
C3aOperand
endsi
=
c3a
.
newAutoLabel
();
c3a
.
ajouteInst
(
new
C3aInstJumpIfEqual
(
test
,
c3a
.
True
,
alors
,
""
));
if
(
node
.
getSinon
()!=
null
)
c3a
.
ajouteInst
(
new
C3aInstJumpIfEqual
(
test
,
c3a
.
False
,
sinon
,
""
));
else
c3a
.
ajouteInst
(
new
C3aInstJumpIfEqual
(
test
,
c3a
.
False
,
endsi
,
""
));
if
(
node
.
getAlors
()!=
null
)
{
c3a
.
addLabelToNextInst
((
C3aLabel
)
alors
);
node
.
getAlors
().
accept
(
this
);
}
c3a
.
ajouteInst
(
new
C3aInstJump
(
endsi
,
""
));
if
(
node
.
getSinon
()!=
null
)
{
c3a
.
addLabelToNextInst
((
C3aLabel
)
sinon
);
node
.
getSinon
().
accept
(
this
);
}
c3a
.
addLabelToNextInst
((
C3aLabel
)
endsi
);
return
null
;
}
}
}
This diff is collapsed.
Click to expand it.
src/ts/Sa2ts.java
+
119
−
88
View file @
962d6d11
package
ts
;
package
ts
;
import
sa.*
;
import
sa.*
;
import
util.Error
;
import
util.Error
;
import
util.Type
;
public
class
Sa2ts
extends
SaDepthFirstVisitor
<
Void
>
{
public
class
Sa2ts
extends
SaDepthFirstVisitor
<
Void
>
{
enum
Context
{
enum
Context
{
...
@@ -23,89 +24,125 @@ public class Sa2ts extends SaDepthFirstVisitor <Void> {
...
@@ -23,89 +24,125 @@ public class Sa2ts extends SaDepthFirstVisitor <Void> {
context
=
Context
.
GLOBAL
;
context
=
Context
.
GLOBAL
;
}
}
public
Void
visit
(
SaDecVar
node
)
throws
Exception
{
public
Void
visit
(
SaDecFonc
node
)
throws
Exception
{
defaultIn
(
node
);
defaultIn
(
node
);
TsItemVar
ts
=
null
;
if
(
tableGlobale
.
getFct
(
node
.
getNom
())==
null
)
try
{
{
if
(
context
==
Context
.
PARAM
)
{
tableLocaleCourante
=
new
Ts
();
ts
=
tableLocaleCourante
.
addParam
(
node
.
getNom
(),
node
.
getType
());
int
nbrArgs
;
}
else
if
(
context
==
Context
.
LOCAL
)
{
if
(
node
.
getParametres
()!=
null
)
if
(
tableLocaleCourante
.
getVar
(
node
.
getNom
())
!=
null
)
{
throw
new
ErrorException
(
Error
.
TS
,
"Variable locale"
);
context
=
Context
.
PARAM
;
ts
=
tableLocaleCourante
.
addVar
(
node
.
getNom
(),
node
.
getType
());
node
.
getParametres
().
accept
(
this
);
}
else
{
nbrArgs
=
node
.
getParametres
().
length
();
if
(
tableGlobale
.
getVar
(
node
.
getNom
())
!=
null
)
throw
new
ErrorException
(
Error
.
TS
,
"Variable globale"
);
ts
=
tableLocaleCourante
.
addVar
(
node
.
getNom
(),
node
.
getType
());
}
}
}
catch
(
ErrorException
e
){
else
nbrArgs
=
0
;
System
.
err
.
print
(
"Erreur dans la declaration de variable"
);
if
(
node
.
getVariable
()!=
null
)
System
.
err
.
println
(
e
.
getMessage
());
{
System
.
exit
(
e
.
getCode
());
context
=
Context
.
LOCAL
;
node
.
getVariable
().
accept
(
this
);
}
}
node
.
setTsItem
(
ts
);
String
nom
=
node
.
getNom
();
defaultOut
(
node
);
Type
type
=
node
.
getTypeRetour
();
System
.
out
.
println
(
tableGlobale
.
variables
);
node
.
tsItem
=
tableGlobale
.
addFct
(
nom
,
type
,
nbrArgs
,
tableLocaleCourante
,
node
);
return
null
;
context
=
Context
.
GLOBAL
;
if
(
node
.
getCorps
()!=
null
)
{
context
=
Context
.
LOCAL
;
node
.
getCorps
().
accept
(
this
);
}
}
public
Void
visit
(
SaDecTab
node
)
{
}
else
{
defaultIn
(
node
);
throw
new
ErrorException
(
Error
.
TS
,
"La fonction a été déja definie"
);
if
(
tableGlobale
.
getVar
(
node
.
getNom
())
!=
null
)
}
node
.
setTsItem
(
this
.
tableGlobale
.
addTab
(
node
.
getNom
(),
node
.
getType
(),
node
.
getTaille
()));
else
throw
new
RuntimeException
(
"Erreur"
);
defaultOut
(
node
);
defaultOut
(
node
);
return
null
;
return
null
;
}
}
public
Void
visit
(
SaDecVar
node
)
throws
ErrorException
public
Void
visit
(
SaDecFonc
node
)
throws
Exception
{
{
defaultIn
(
node
);
defaultIn
(
node
);
tableLocaleCourante
=
new
Ts
();
if
(
context
==
Context
.
PARAM
)
int
nbArgs
=
0
;
{
this
.
context
=
Context
.
GLOBAL
;
if
(
tableLocaleCourante
.
getVar
(
node
.
getNom
())==
null
)
if
(
tableGlobale
.
getFct
(
node
.
getNom
())
==
null
){
{
tableLocaleCourante
.
addFct
(
node
.
getNom
(),
node
.
getTypeRetour
(),
nbArgs
,
tableLocaleCourante
,
node
);
node
.
setTsItem
(
tableLocaleCourante
.
addParam
(
node
.
getNom
(),
node
.
getType
()));
}
else
{
throw
new
ErrorException
(
Error
.
TS
,
"param déja declarée"
);
}
}
else
{
nbArgs
=
node
.
getParametres
().
length
();
tableLocaleCourante
.
addFct
(
node
.
getNom
(),
node
.
getTypeRetour
(),
nbArgs
,
tableLocaleCourante
,
node
);
}
}
this
.
context
=
Context
.
PARAM
;
if
(
context
==
Context
.
LOCAL
)
if
(
node
.
getParametres
()
==
null
){
{
node
.
getParametres
().
accept
(
this
);
if
(
tableLocaleCourante
.
getVar
(
node
.
getNom
())==
null
)
{
node
.
setTsItem
(
tableLocaleCourante
.
addVar
(
node
.
getNom
(),
node
.
getType
()));
}
else
{
throw
new
ErrorException
(
Error
.
TS
,
"varibale déja declarée"
);
}
}
this
.
context
=
Context
.
LOCAL
;
if
(
node
.
getVariable
()
==
null
){
node
.
getParametres
().
accept
(
this
);
}
}
if
(
node
.
getCorps
()
==
null
){
if
(
context
==
Context
.
GLOBAL
)
node
.
getCorps
().
accept
(
this
);
{
if
(
tableGlobale
.
getVar
(
node
.
getNom
())==
null
)
{
node
.
setTsItem
(
tableGlobale
.
addVar
(
node
.
getNom
(),
node
.
getType
()));
}
else
{
throw
new
ErrorException
(
Error
.
TS
,
"varibale déja declarée"
);
}
}
}
defaultOut
(
node
);
defaultOut
(
node
);
return
null
;
return
null
;
}
}
public
Void
visit
(
SaDecTab
node
)
throws
ErrorException
{
defaultIn
(
node
);
if
(
context
==
Context
.
GLOBAL
)
{
if
(
tableGlobale
.
getVar
(
node
.
getNom
())==
null
)
{
node
.
setTsItem
(
tableGlobale
.
addTab
(
node
.
getNom
(),
node
.
getType
(),
node
.
getTaille
()));
}
else
throw
new
ErrorException
(
Error
.
TS
,
"variable deja declarée"
);
}
if
(
context
==
Context
.
LOCAL
)
{
if
(
tableLocaleCourante
.
getVar
(
node
.
getNom
())==
null
)
{
node
.
setTsItem
(
tableLocaleCourante
.
addTab
(
node
.
getNom
(),
node
.
getType
(),
node
.
getTaille
()));
}
else
throw
new
ErrorException
(
Error
.
TS
,
"variable deja declarée"
);
}
defaultOut
(
node
);
public
Void
visit
(
SaVarSimple
node
)
throws
Exception
{
return
null
;
defaultIn
(
node
);
if
(
tableLocaleCourante
.
getVar
(
node
.
getNom
())
!=
null
){
if
(
tableLocaleCourante
.
getVar
(
node
.
getNom
()).
getTaille
()
!=
1
)
throw
new
ErrorException
(
Error
.
TS
,
"Var not find"
);
node
.
tsItem
=
(
TsItemVarSimple
)
tableLocaleCourante
.
getVar
(
node
.
getNom
());
}
}
else
if
(
tableGlobale
.
getVar
(
node
.
getNom
())
!=
null
){
public
Void
visit
(
SaVarSimple
node
)
throws
ErrorException
if
(
tableGlobale
.
getVar
(
node
.
getNom
()).
getTaille
()
!=
1
)
throw
new
ErrorException
(
Error
.
TS
,
"Var not find"
);
{
defaultIn
(
node
);
if
(
tableGlobale
.
getVar
(
node
.
getNom
())!=
null
)
{
node
.
tsItem
=(
TsItemVarSimple
)
tableGlobale
.
getVar
(
node
.
getNom
());
node
.
tsItem
=(
TsItemVarSimple
)
tableGlobale
.
getVar
(
node
.
getNom
());
}
}
else
{
else
if
(
tableLocaleCourante
.
getVar
(
node
.
getNom
())!=
null
)
throw
new
ErrorException
(
Error
.
TS
,
"Var not find"
);
{
node
.
tsItem
=(
TsItemVarSimple
)
tableLocaleCourante
.
getVar
(
node
.
getNom
());
}
else
{
throw
new
ErrorException
(
Error
.
TS
,
"variable jamais declaré"
);
}
}
defaultOut
(
node
);
defaultOut
(
node
);
return
super
.
visit
(
node
)
;
return
null
;
}
}
public
Void
visit
(
SaVarIndicee
node
)
throws
Exception
public
Void
visit
(
SaVarIndicee
node
)
throws
Exception
{
{
defaultIn
(
node
);
defaultIn
(
node
);
if
(
tableGlobale
.
getVar
(
node
.
getNom
())!=
null
)
if
(
tableGlobale
.
getVar
(
node
.
getNom
())!=
null
)
{
{
...
@@ -125,35 +162,29 @@ public class Sa2ts extends SaDepthFirstVisitor <Void> {
...
@@ -125,35 +162,29 @@ public class Sa2ts extends SaDepthFirstVisitor <Void> {
return
null
;
return
null
;
}
}
public
Void
visit
(
SaAppel
node
)
throws
Exception
{
public
Void
visit
(
SaAppel
node
)
throws
Exception
{
defaultIn
(
node
);
defaultIn
(
node
);
if
(
node
.
getArguments
().
length
()
==
tableGlobale
.
getFct
(
node
.
getNom
()).
getNbArgs
()){
if
(
tableGlobale
.
getFct
(
node
.
getNom
())==
null
)
node
.
getArguments
().
accept
(
this
);
{
node
.
tsItem
=
tableGlobale
.
getFct
(
node
.
getNom
());
throw
new
ErrorException
(
Error
.
TS
,
"fonction non declaré "
);
}
else
if
(
node
.
getArguments
()
==
null
&&
tableGlobale
.
getFct
(
node
.
getNom
()).
getNbArgs
()
==
0
)
{
node
.
tsItem
=
tableGlobale
.
getFct
(
node
.
getNom
());
}
}
else
{
if
(
node
.
getArguments
()!=
null
)
throw
new
ErrorException
(
Error
.
TS
,
""
);
{
node
.
getArguments
().
accept
(
this
);
if
(
node
.
getArguments
().
length
()!=
tableGlobale
.
getFct
(
node
.
getNom
()).
getNbArgs
())
throw
new
ErrorException
(
Error
.
TS
,
" nombre de parametre n'est pas correcte 1"
);
}
else
{
if
(
tableGlobale
.
getFct
(
node
.
getNom
()).
getNbArgs
()>
0
)
throw
new
ErrorException
(
Error
.
TS
,
" nombre de parametre n'est pas correcte 2"
);
}
}
context
=
Context
.
LOCAL
;
node
.
tsItem
=
tableGlobale
.
getFct
(
node
.
getNom
());
node
.
tsItem
=
tableGlobale
.
getFct
(
node
.
getNom
());
context
=
Context
.
GLOBAL
;
defaultOut
(
node
);
defaultOut
(
node
);
return
null
;
return
null
;
}
}
public
void
defaultIn
(
SaNode
node
)
{
System
.
out
.
println
(
"<"
+
node
.
getClass
().
getSimpleName
()
+
">"
);
}
public
void
defaultOut
(
SaNode
node
)
{
System
.
out
.
println
(
"</"
+
node
.
getClass
().
getSimpleName
()
+
">"
);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test/result.txt
+
410
−
0
View file @
962d6d11
Évaluation de 5 :
80/80 correct (100.00%)
add1.l CORRECT
add2.l CORRECT
affect1.l CORRECT
affect2.l CORRECT
affect3.l CORRECT
and1.l CORRECT
and2.l CORRECT
and3.l CORRECT
and4.l CORRECT
and5.l CORRECT
appel-param1.l CORRECT
appel-param2.l CORRECT
appel-param3.l CORRECT
appel-retour1.l CORRECT
appel1.l CORRECT
appel2.l CORRECT
appel3.l CORRECT
div1.l CORRECT
div2.l CORRECT
div3.l CORRECT
div4.l CORRECT
ecrire1.l CORRECT
ecrire2.l CORRECT
egal1.l CORRECT
egal2.l CORRECT
egal3.l CORRECT
fibo.l CORRECT
inf1.l CORRECT
inf2.l CORRECT
inf3.l CORRECT
mult1.l CORRECT
mult2.l CORRECT
mult3.l CORRECT
not1.l CORRECT
not2.l CORRECT
not3.l CORRECT
or1.l CORRECT
or2.l CORRECT
or3.l CORRECT
or4.l CORRECT
or5.l CORRECT
parenth1.l CORRECT
parenth2.l CORRECT
prio34-1.l CORRECT
prio34-2.l CORRECT
prio34-3.l CORRECT
prio34-4.l CORRECT
prio45-1.l CORRECT
prio45-2.l CORRECT
prio45-3.l CORRECT
prio45-4.l CORRECT
prio56-1.l CORRECT
prio56-2.l CORRECT
prio67-1.l CORRECT
prio67-2.l CORRECT
rec1.l CORRECT
si1.l CORRECT
si2.l CORRECT
si3.l CORRECT
si4.l CORRECT
si5.l CORRECT
sub1.l CORRECT
sub2.l CORRECT
sub3.l CORRECT
tab1.l CORRECT
tab2.l CORRECT
tab3.l CORRECT
tab4.l CORRECT
tantque1.l CORRECT
tantque2.l CORRECT
tri.l CORRECT
varglob1.l CORRECT
varglob2.l CORRECT
varglob3.l CORRECT
varglob4.l CORRECT
varloc1.l CORRECT
varloc2.l CORRECT
varloc3.l CORRECT
varloc4.l CORRECT
varloc5.l CORRECT
Évaluation de Diff de sa :
80/80 correct (100.00%)
add1.sa CORRECT
add2.sa CORRECT
affect1.sa CORRECT
affect2.sa CORRECT
affect3.sa CORRECT
and1.sa CORRECT
and2.sa CORRECT
and3.sa CORRECT
and4.sa CORRECT
and5.sa CORRECT
appel-param1.sa CORRECT
appel-param2.sa CORRECT
appel-param3.sa CORRECT
appel-retour1.sa CORRECT
appel1.sa CORRECT
appel2.sa CORRECT
appel3.sa CORRECT
div1.sa CORRECT
div2.sa CORRECT
div3.sa CORRECT
div4.sa CORRECT
ecrire1.sa CORRECT
ecrire2.sa CORRECT
egal1.sa CORRECT
egal2.sa CORRECT
egal3.sa CORRECT
fibo.sa CORRECT
inf1.sa CORRECT
inf2.sa CORRECT
inf3.sa CORRECT
mult1.sa CORRECT
mult2.sa CORRECT
mult3.sa CORRECT
not1.sa CORRECT
not2.sa CORRECT
not3.sa CORRECT
or1.sa CORRECT
or2.sa CORRECT
or3.sa CORRECT
or4.sa CORRECT
or5.sa CORRECT
parenth1.sa CORRECT
parenth2.sa CORRECT
prio34-1.sa CORRECT
prio34-2.sa CORRECT
prio34-3.sa CORRECT
prio34-4.sa CORRECT
prio45-1.sa CORRECT
prio45-2.sa CORRECT
prio45-3.sa CORRECT
prio45-4.sa CORRECT
prio56-1.sa CORRECT
prio56-2.sa CORRECT
prio67-1.sa CORRECT
prio67-2.sa CORRECT
rec1.sa CORRECT
si1.sa CORRECT
si2.sa CORRECT
si3.sa CORRECT
si4.sa CORRECT
si5.sa CORRECT
sub1.sa CORRECT
sub2.sa CORRECT
sub3.sa CORRECT
tab1.sa CORRECT
tab2.sa CORRECT
tab3.sa CORRECT
tab4.sa CORRECT
tantque1.sa CORRECT
tantque2.sa CORRECT
tri.sa CORRECT
varglob1.sa CORRECT
varglob2.sa CORRECT
varglob3.sa CORRECT
varglob4.sa CORRECT
varloc1.sa CORRECT
varloc2.sa CORRECT
varloc3.sa CORRECT
varloc4.sa CORRECT
varloc5.sa CORRECT
Évaluation de Diff de ts :
80/80 correct (100.00%)
add1.ts CORRECT
add2.ts CORRECT
affect1.ts CORRECT
affect2.ts CORRECT
affect3.ts CORRECT
and1.ts CORRECT
and2.ts CORRECT
and3.ts CORRECT
and4.ts CORRECT
and5.ts CORRECT
appel-param1.ts CORRECT
appel-param2.ts CORRECT
appel-param3.ts CORRECT
appel-retour1.ts CORRECT
appel1.ts CORRECT
appel2.ts CORRECT
appel3.ts CORRECT
div1.ts CORRECT
div2.ts CORRECT
div3.ts CORRECT
div4.ts CORRECT
ecrire1.ts CORRECT
ecrire2.ts CORRECT
egal1.ts CORRECT
egal2.ts CORRECT
egal3.ts CORRECT
fibo.ts CORRECT
inf1.ts CORRECT
inf2.ts CORRECT
inf3.ts CORRECT
mult1.ts CORRECT
mult2.ts CORRECT
mult3.ts CORRECT
not1.ts CORRECT
not2.ts CORRECT
not3.ts CORRECT
or1.ts CORRECT
or2.ts CORRECT
or3.ts CORRECT
or4.ts CORRECT
or5.ts CORRECT
parenth1.ts CORRECT
parenth2.ts CORRECT
prio34-1.ts CORRECT
prio34-2.ts CORRECT
prio34-3.ts CORRECT
prio34-4.ts CORRECT
prio45-1.ts CORRECT
prio45-2.ts CORRECT
prio45-3.ts CORRECT
prio45-4.ts CORRECT
prio56-1.ts CORRECT
prio56-2.ts CORRECT
prio67-1.ts CORRECT
prio67-2.ts CORRECT
rec1.ts CORRECT
si1.ts CORRECT
si2.ts CORRECT
si3.ts CORRECT
si4.ts CORRECT
si5.ts CORRECT
sub1.ts CORRECT
sub2.ts CORRECT
sub3.ts CORRECT
tab1.ts CORRECT
tab2.ts CORRECT
tab3.ts CORRECT
tab4.ts CORRECT
tantque1.ts CORRECT
tantque2.ts CORRECT
tri.ts CORRECT
varglob1.ts CORRECT
varglob2.ts CORRECT
varglob3.ts CORRECT
varglob4.ts CORRECT
varloc1.ts CORRECT
varloc2.ts CORRECT
varloc3.ts CORRECT
varloc4.ts CORRECT
varloc5.ts CORRECT
Évaluation de Execution de sa :
79/80 correct ( 98.75%)
add1.saout CORRECT
add2.saout CORRECT
affect1.saout CORRECT
affect2.saout CORRECT
affect3.saout CORRECT
and1.saout CORRECT
and2.saout CORRECT
and3.saout CORRECT
and4.saout CORRECT
and5.saout CORRECT
appel-param1.saout CORRECT
appel-param2.saout CORRECT
appel-param3.saout CORRECT
appel-retour1.saout CORRECT
appel1.saout CORRECT
appel2.saout CORRECT
appel3.saout CORRECT
div1.saout CORRECT
div2.saout CORRECT
div3.saout CORRECT
div4.saout CORRECT
ecrire1.saout CORRECT
ecrire2.saout CORRECT
egal1.saout CORRECT
egal2.saout CORRECT
egal3.saout CORRECT
fibo.saout CORRECT
inf1.saout CORRECT
inf2.saout CORRECT
inf3.saout CORRECT
mult1.saout CORRECT
mult2.saout CORRECT
mult3.saout CORRECT
not1.saout CORRECT
not2.saout CORRECT
not3.saout CORRECT
or1.saout CORRECT
or2.saout CORRECT
or3.saout CORRECT
or4.saout CORRECT
or5.saout CORRECT
parenth1.saout CORRECT
parenth2.saout CORRECT
prio34-1.saout CORRECT
prio34-2.saout CORRECT
prio34-3.saout CORRECT
prio34-4.saout CORRECT
prio45-1.saout CORRECT
prio45-2.saout CORRECT
prio45-3.saout CORRECT
prio45-4.saout CORRECT
prio56-1.saout CORRECT
prio56-2.saout CORRECT
prio67-1.saout CORRECT
prio67-2.saout CORRECT
rec1.saout CORRECT
si1.saout CORRECT
si2.saout CORRECT
si3.saout CORRECT
si4.saout CORRECT
si5.saout CORRECT
sub1.saout CORRECT
sub2.saout CORRECT
sub3.saout CORRECT
tab1.saout CORRECT
tab2.saout CORRECT
tab3.saout CORRECT
tab4.saout CORRECT
tantque1.saout CORRECT
tantque2.saout CORRECT
tri.saout CORRECT
varglob1.saout CORRECT
varglob2.saout CORRECT
varglob3.saout CORRECT
varglob4.saout CORRECT
varloc1.saout CORRECT
varloc2.saout CORRECT
varloc3.saout CORRECT
varloc4.saout CORRECT
varloc5.saout INCORRECT
Évaluation de Diff de c3a :
0/80 correct ( 0.00%)
add1.c3a INCORRECT
add2.c3a INCORRECT
affect1.c3a INCORRECT
affect2.c3a INCORRECT
affect3.c3a INCORRECT
and1.c3a INCORRECT
and2.c3a INCORRECT
and3.c3a INCORRECT
and4.c3a INCORRECT
and5.c3a INCORRECT
appel-param1.c3a INCORRECT
appel-param2.c3a INCORRECT
appel-param3.c3a INCORRECT
appel-retour1.c3a INCORRECT
appel1.c3a INCORRECT
appel2.c3a INCORRECT
appel3.c3a INCORRECT
div1.c3a INCORRECT
div2.c3a INCORRECT
div3.c3a INCORRECT
div4.c3a INCORRECT
ecrire1.c3a INCORRECT
ecrire2.c3a INCORRECT
egal1.c3a INCORRECT
egal2.c3a INCORRECT
egal3.c3a INCORRECT
fibo.c3a INCORRECT
inf1.c3a INCORRECT
inf2.c3a INCORRECT
inf3.c3a INCORRECT
mult1.c3a INCORRECT
mult2.c3a INCORRECT
mult3.c3a INCORRECT
not1.c3a INCORRECT
not2.c3a INCORRECT
not3.c3a INCORRECT
or1.c3a INCORRECT
or2.c3a INCORRECT
or3.c3a INCORRECT
or4.c3a INCORRECT
or5.c3a INCORRECT
parenth1.c3a INCORRECT
parenth2.c3a INCORRECT
prio34-1.c3a INCORRECT
prio34-2.c3a INCORRECT
prio34-3.c3a INCORRECT
prio34-4.c3a INCORRECT
prio45-1.c3a INCORRECT
prio45-2.c3a INCORRECT
prio45-3.c3a INCORRECT
prio45-4.c3a INCORRECT
prio56-1.c3a INCORRECT
prio56-2.c3a INCORRECT
prio67-1.c3a INCORRECT
prio67-2.c3a INCORRECT
rec1.c3a INCORRECT
si1.c3a INCORRECT
si2.c3a INCORRECT
si3.c3a INCORRECT
si4.c3a INCORRECT
si5.c3a INCORRECT
sub1.c3a INCORRECT
sub2.c3a INCORRECT
sub3.c3a INCORRECT
tab1.c3a INCORRECT
tab2.c3a INCORRECT
tab3.c3a INCORRECT
tab4.c3a INCORRECT
tantque1.c3a INCORRECT
tantque2.c3a INCORRECT
tri.c3a INCORRECT
varglob1.c3a INCORRECT
varglob2.c3a INCORRECT
varglob3.c3a INCORRECT
varglob4.c3a INCORRECT
varloc1.c3a INCORRECT
varloc2.c3a INCORRECT
varloc3.c3a INCORRECT
varloc4.c3a INCORRECT
varloc5.c3a INCORRECT
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