Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
2024_compilation_bauquin
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
BAUQUIN Niels
2024_compilation_bauquin
Commits
78a444d9
Commit
78a444d9
authored
1 year ago
by
BAUQUIN Niels
Browse files
Options
Downloads
Patches
Plain Diff
geg
parent
766fe5db
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Compiler.java
+2
-2
2 additions, 2 deletions
src/Compiler.java
src/sa/Sc2sa.java
+133
-12
133 additions, 12 deletions
src/sa/Sc2sa.java
with
135 additions
and
14 deletions
src/Compiler.java
+
2
−
2
View file @
78a444d9
...
@@ -31,8 +31,8 @@ public class Compiler
...
@@ -31,8 +31,8 @@ public class Compiler
processCommandLine
(
args
);
processCommandLine
(
args
);
System
.
out
.
println
(
"[BUILD SC] "
);
System
.
out
.
println
(
"[BUILD SC] "
);
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]");
...
...
This diff is collapsed.
Click to expand it.
src/sa/Sc2sa.java
+
133
−
12
View file @
78a444d9
...
@@ -31,7 +31,8 @@ public class Sc2sa extends DepthFirstAdapter
...
@@ -31,7 +31,8 @@ public class Sc2sa extends DepthFirstAdapter
@Override
@Override
public
void
caseStart
(
Start
node
)
{
public
void
caseStart
(
Start
node
)
{
super
.
caseStart
(
node
);
inStart
(
node
);
outStart
(
node
);
}
}
@Override
@Override
...
@@ -206,18 +207,8 @@ public class Sc2sa extends DepthFirstAdapter
...
@@ -206,18 +207,8 @@ public class Sc2sa extends DepthFirstAdapter
@Override
@Override
public
void
caseAParenthesisExp6
(
AParenthesisExp6
node
)
{
public
void
caseAParenthesisExp6
(
AParenthesisExp6
node
)
{
SaExp
op1
=
null
;
SaExp
op2
=
null
;
SaExp
op3
=
null
;
inAParenthesisExp6
(
node
);
inAParenthesisExp6
(
node
);
node
.
getGpar
().
apply
(
this
);
op1
=
(
SaExp
)
this
.
returnValue
;
node
.
getExp
().
apply
(
this
);
node
.
getExp
().
apply
(
this
);
op2
=
(
SaExp
)
this
.
returnValue
;
node
.
getDpar
().
apply
(
this
);
op3
=
(
SaExp
)
this
.
returnValue
;
this
.
returnValue
=
new
SaExp
(
op1
,
op2
,
op3
);
outAParenthesisExp6
(
node
);
outAParenthesisExp6
(
node
);
}
}
...
@@ -233,126 +224,220 @@ public class Sc2sa extends DepthFirstAdapter
...
@@ -233,126 +224,220 @@ public class Sc2sa extends DepthFirstAdapter
@Override
@Override
public
void
caseAVraiExp6
(
AVraiExp6
node
)
{
public
void
caseAVraiExp6
(
AVraiExp6
node
)
{
inAVraiExp6
(
node
);
inAVraiExp6
(
node
);
this
.
returnValue
=
new
SaExpVrai
();
outAVraiExp6
(
node
);
outAVraiExp6
(
node
);
}
}
@Override
@Override
public
void
caseAFauxExp6
(
AFauxExp6
node
)
{
public
void
caseAFauxExp6
(
AFauxExp6
node
)
{
inAFauxExp6
(
node
);
inAFauxExp6
(
node
);
this
.
returnValue
=
new
SaExpFaux
();
outAFauxExp6
(
node
);
outAFauxExp6
(
node
);
}
}
@Override
@Override
public
void
caseAAfExp6
(
AAfExp6
node
)
{
public
void
caseAAfExp6
(
AAfExp6
node
)
{
inAAfExp6
(
node
);
inAAfExp6
(
node
);
SaAppel
appel
=
null
;
node
.
getAf
().
apply
(
this
);
appel
=
(
SaAppel
)
this
.
returnValue
;
this
.
returnValue
=
new
SaExpAppel
(
appel
);
outAAfExp6
(
node
);
outAAfExp6
(
node
);
}
}
@Override
@Override
public
void
caseAVarExp6
(
AVarExp6
node
)
{
public
void
caseAVarExp6
(
AVarExp6
node
)
{
inAVarExp6
(
node
);
inAVarExp6
(
node
);
SaVar
saVar
=
null
;
node
.
getVar
().
apply
(
this
);
saVar
=
(
SaVar
)
this
.
returnValue
;
this
.
returnValue
=
new
SaExpVar
(
saVar
);
outAVarExp6
(
node
);
outAVarExp6
(
node
);
}
}
@Override
@Override
public
void
caseALireExp6
(
ALireExp6
node
)
{
public
void
caseALireExp6
(
ALireExp6
node
)
{
inALireExp6
(
node
);
inALireExp6
(
node
);
node
.
getLire
().
apply
(
this
);
this
.
returnValue
=
new
SaExpLire
();
outALireExp6
(
node
);
outALireExp6
(
node
);
}
}
@Override
@Override
public
void
caseAAffectationIns
(
AAffectationIns
node
)
{
public
void
caseAAffectationIns
(
AAffectationIns
node
)
{
inAAffectationIns
(
node
);
inAAffectationIns
(
node
);
SaVar
lhs
=
null
;
SaExp
rhs
=
null
;
node
.
getVar
().
apply
(
this
);
lhs
=
(
SaVar
)
this
.
returnValue
;
node
.
getExp
().
apply
(
this
);
rhs
=
(
SaExp
)
this
.
returnValue
;
this
.
returnValue
=
new
SaInstAffect
(
lhs
,
rhs
);
outAAffectationIns
(
node
);
outAAffectationIns
(
node
);
}
}
@Override
@Override
public
void
caseAFairetantqueIns
(
AFairetantqueIns
node
)
{
public
void
caseAFairetantqueIns
(
AFairetantqueIns
node
)
{
inAFairetantqueIns
(
node
);
inAFairetantqueIns
(
node
);
SaExp
test
=
null
;
SaInst
faire
=
null
;
node
.
getTantque
().
apply
(
this
);
test
=
(
SaExp
)
this
.
returnValue
;
node
.
getBloc
().
apply
(
this
);
faire
=
(
SaInst
)
this
.
returnValue
;
this
.
returnValue
=
new
SaInstTantQue
(
test
,
faire
);
outAFairetantqueIns
(
node
);
outAFairetantqueIns
(
node
);
}
}
@Override
@Override
public
void
caseAFonctionIns
(
AFonctionIns
node
)
{
public
void
caseAFonctionIns
(
AFonctionIns
node
)
{
inAFonctionIns
(
node
);
inAFonctionIns
(
node
);
node
.
getId
().
apply
(
this
);
node
.
getGpar
().
apply
(
this
);
outAFonctionIns
(
node
);
outAFonctionIns
(
node
);
}
}
@Override
@Override
public
void
caseASialorsIns
(
ASialorsIns
node
)
{
public
void
caseASialorsIns
(
ASialorsIns
node
)
{
inASialorsIns
(
node
);
inASialorsIns
(
node
);
SaExp
test
=
null
;
SaInst
alors
=
null
;
SaInst
sinon
=
null
;
node
.
getExp
().
apply
(
this
);
test
=
(
SaExp
)
this
.
returnValue
;
node
.
getBloc
().
apply
(
this
);
alors
=
(
SaInst
)
this
.
returnValue
;
this
.
returnValue
=
new
SaInstSi
(
test
,
alors
,
sinon
);
outASialorsIns
(
node
);
outASialorsIns
(
node
);
}
}
@Override
@Override
public
void
caseASisinonIns
(
ASisinonIns
node
)
{
public
void
caseASisinonIns
(
ASisinonIns
node
)
{
inASisinonIns
(
node
);
inASisinonIns
(
node
);
SaExp
test
=
null
;
SaInst
alors
=
null
;
SaInst
sinon
=
null
;
node
.
getExp
().
apply
(
this
);
test
=
(
SaExp
)
this
.
returnValue
;
node
.
getAlors1
().
apply
(
this
);
alors
=
(
SaInst
)
this
.
returnValue
;
node
.
getSinon1
().
apply
(
this
);
sinon
=
(
SaInst
)
this
.
returnValue
;
this
.
returnValue
=
new
SaInstSi
(
test
,
alors
,
sinon
);
outASisinonIns
(
node
);
outASisinonIns
(
node
);
}
}
@Override
@Override
public
void
caseARetourIns
(
ARetourIns
node
)
{
public
void
caseARetourIns
(
ARetourIns
node
)
{
inARetourIns
(
node
);
inARetourIns
(
node
);
SaExp
val
=
null
;
node
.
getExp
().
apply
(
this
);
val
=
(
SaExp
)
this
.
returnValue
;
this
.
returnValue
=
new
SaInstRetour
(
val
);
outARetourIns
(
node
);
outARetourIns
(
node
);
}
}
@Override
@Override
public
void
caseAEcrireIns
(
AEcrireIns
node
)
{
public
void
caseAEcrireIns
(
AEcrireIns
node
)
{
inAEcrireIns
(
node
);
inAEcrireIns
(
node
);
SaExp
arg
=
null
;
node
.
getExp
().
apply
(
this
);
arg
=
(
SaExp
)
this
.
returnValue
;
this
.
returnValue
=
new
SaInstEcriture
(
arg
);
outAEcrireIns
(
node
);
outAEcrireIns
(
node
);
}
}
@Override
@Override
public
void
caseABlocIns
(
ABlocIns
node
)
{
public
void
caseABlocIns
(
ABlocIns
node
)
{
inABlocIns
(
node
);
inABlocIns
(
node
);
SaLInst
linst
=
null
;
node
.
getBloc
().
apply
(
this
);
linst
=
(
SaLInst
)
this
.
returnValue
;
this
.
returnValue
=
new
SaInstBloc
(
linst
);
outABlocIns
(
node
);
outABlocIns
(
node
);
}
}
@Override
@Override
public
void
caseAAccoladesBloc
(
AAccoladesBloc
node
)
{
public
void
caseAAccoladesBloc
(
AAccoladesBloc
node
)
{
inAAccoladesBloc
(
node
);
inAAccoladesBloc
(
node
);
SaLInst
linst
=
null
;
node
.
getLins
().
apply
(
this
);
linst
=
(
SaLInst
)
this
.
returnValue
;
this
.
returnValue
=
new
SaInstBloc
(
linst
);
outAAccoladesBloc
(
node
);
outAAccoladesBloc
(
node
);
}
}
@Override
@Override
public
void
caseALinsLins
(
ALinsLins
node
)
{
public
void
caseALinsLins
(
ALinsLins
node
)
{
inALinsLins
(
node
);
inALinsLins
(
node
);
SaInst
tete
=
null
;
SaLInst
queue
=
null
;
node
.
getIns
().
apply
(
this
);
tete
=
(
SaInst
)
this
.
returnValue
;
node
.
getLins
().
apply
(
this
);
queue
=
(
SaLInst
)
this
.
returnValue
;
this
.
returnValue
=
new
SaLInst
(
tete
,
queue
);
outALinsLins
(
node
);
outALinsLins
(
node
);
}
}
@Override
@Override
public
void
caseAEpsilonLins
(
AEpsilonLins
node
)
{
public
void
caseAEpsilonLins
(
AEpsilonLins
node
)
{
inAEpsilonLins
(
node
);
inAEpsilonLins
(
node
);
this
.
returnValue
=
null
;
outAEpsilonLins
(
node
);
outAEpsilonLins
(
node
);
}
}
@Override
@Override
public
void
caseALexp2Lexp
(
ALexp2Lexp
node
)
{
public
void
caseALexp2Lexp
(
ALexp2Lexp
node
)
{
inALexp2Lexp
(
node
);
inALexp2Lexp
(
node
);
SaExp
tete
=
null
;
SaLExp
queue
=
null
;
node
.
getExp
().
apply
(
this
);
tete
=
(
SaExp
)
this
.
returnValue
;
node
.
getLexp2
().
apply
(
this
);
queue
=
(
SaLExp
)
this
.
returnValue
;
this
.
returnValue
=
new
SaLExp
(
tete
,
queue
);
outALexp2Lexp
(
node
);
outALexp2Lexp
(
node
);
}
}
@Override
@Override
public
void
caseAEpsilonLexp
(
AEpsilonLexp
node
)
{
public
void
caseAEpsilonLexp
(
AEpsilonLexp
node
)
{
inAEpsilonLexp
(
node
);
inAEpsilonLexp
(
node
);
this
.
returnValue
=
null
;
outAEpsilonLexp
(
node
);
outAEpsilonLexp
(
node
);
}
}
@Override
@Override
public
void
caseAVirguleLexp2
(
AVirguleLexp2
node
)
{
public
void
caseAVirguleLexp2
(
AVirguleLexp2
node
)
{
inAVirguleLexp2
(
node
);
inAVirguleLexp2
(
node
);
SaExp
tete
=
null
;
SaLExp
queue
=
null
;
node
.
getExp
().
apply
(
this
);
tete
=
(
SaExp
)
this
.
returnValue
;
node
.
getLexp2
().
apply
(
this
);
queue
=
(
SaLExp
)
this
.
returnValue
;
this
.
returnValue
=
new
SaLExp
(
tete
,
queue
);
outAVirguleLexp2
(
node
);
outAVirguleLexp2
(
node
);
}
}
@Override
@Override
public
void
caseAEpsilonLexp2
(
AEpsilonLexp2
node
)
{
public
void
caseAEpsilonLexp2
(
AEpsilonLexp2
node
)
{
inAEpsilonLexp2
(
node
);
inAEpsilonLexp2
(
node
);
this
.
returnValue
=
null
;
outAEpsilonLexp2
(
node
);
outAEpsilonLexp2
(
node
);
}
}
@Override
@Override
public
void
caseAAfAf
(
AAfAf
node
)
{
public
void
caseAAfAf
(
AAfAf
node
)
{
inAAfAf
(
node
);
inAAfAf
(
node
);
String
id
=
null
;
SaLExp
lexp
=
null
;
id
=
node
.
getId
().
getText
();
node
.
getGpar
().
apply
(
this
);
node
.
getLexp
().
apply
(
this
);
lexp
=
(
SaLExp
)
this
.
returnValue
;
node
.
getDpar
().
apply
(
this
);
this
.
returnValue
=
new
SaAppel
(
id
,
lexp
);
outAAfAf
(
node
);
outAAfAf
(
node
);
}
}
...
@@ -361,13 +446,20 @@ public class Sc2sa extends DepthFirstAdapter
...
@@ -361,13 +446,20 @@ public class Sc2sa extends DepthFirstAdapter
String
id
=
""
;
String
id
=
""
;
inAIdVar
(
node
);
inAIdVar
(
node
);
id
=
node
.
getId
().
getText
();
id
=
node
.
getId
().
getText
();
this
.
returnValue
=
new
Sa
Id
this
.
returnValue
=
new
Sa
VarSimple
(
id
);
outAIdVar
(
node
);
outAIdVar
(
node
);
}
}
@Override
@Override
public
void
caseACrochetsVar
(
ACrochetsVar
node
)
{
public
void
caseACrochetsVar
(
ACrochetsVar
node
)
{
inACrochetsVar
(
node
);
inACrochetsVar
(
node
);
String
id
=
node
.
getId
().
getText
();
SaExp
exp
=
null
;
node
.
getGcro
().
apply
(
this
);
node
.
getExp
().
apply
(
this
);
exp
=
(
SaExp
)
this
.
returnValue
;
node
.
getDcro
().
apply
(
this
);
this
.
returnValue
=
new
SaVarIndicee
(
id
,
exp
);
outACrochetsVar
(
node
);
outACrochetsVar
(
node
);
}
}
...
@@ -388,12 +480,17 @@ public class Sc2sa extends DepthFirstAdapter
...
@@ -388,12 +480,17 @@ public class Sc2sa extends DepthFirstAdapter
@Override
@Override
public
void
caseATypeTypeopt
(
ATypeTypeopt
node
)
{
public
void
caseATypeTypeopt
(
ATypeTypeopt
node
)
{
inATypeTypeopt
(
node
);
inATypeTypeopt
(
node
);
Type
type
=
null
;
node
.
getType
().
apply
(
this
);
type
=
this
.
returnType
;
this
.
returnType
=
Type
.
fromString
(
type
.
nom
());
outATypeTypeopt
(
node
);
outATypeTypeopt
(
node
);
}
}
@Override
@Override
public
void
caseAEpsilonTypeopt
(
AEpsilonTypeopt
node
)
{
public
void
caseAEpsilonTypeopt
(
AEpsilonTypeopt
node
)
{
inAEpsilonTypeopt
(
node
);
inAEpsilonTypeopt
(
node
);
this
.
returnValue
=
null
;
outAEpsilonTypeopt
(
node
);
outAEpsilonTypeopt
(
node
);
}
}
...
@@ -413,12 +510,32 @@ public class Sc2sa extends DepthFirstAdapter
...
@@ -413,12 +510,32 @@ public class Sc2sa extends DepthFirstAdapter
@Override
@Override
public
void
caseATableauDecvar
(
ATableauDecvar
node
)
{
public
void
caseATableauDecvar
(
ATableauDecvar
node
)
{
inATableauDecvar
(
node
);
inATableauDecvar
(
node
);
String
nom
=
node
.
getId
().
getText
();
Type
type
;
node
.
getType
().
apply
(
this
);
type
=
this
.
returnType
;
int
taille
=
Integer
.
parseInt
(
node
.
getNombre
().
getText
());
this
.
returnValue
=
new
SaDecTab
(
nom
,
type
,
taille
);
outATableauDecvar
(
node
);
outATableauDecvar
(
node
);
}
}
@Override
@Override
public
void
caseAFonctionDecfonc
(
AFonctionDecfonc
node
)
{
public
void
caseAFonctionDecfonc
(
AFonctionDecfonc
node
)
{
inAFonctionDecfonc
(
node
);
inAFonctionDecfonc
(
node
);
String
nom
=
node
.
getId
().
getText
();
Type
typeretour
;
node
.
getTypeopt
().
apply
(
this
);
typeretour
=
this
.
returnType
;
SaLDecVar
parametres
=
null
;
SaLDecVar
variables
=
null
;
SaInst
corps
=
null
;
node
.
getParams
().
apply
(
this
);
parametres
=
(
SaLDecVar
)
this
.
returnValue
;
node
.
getLocals
().
apply
(
this
);
variables
=
(
SaLDecVar
)
this
.
returnValue
;
node
.
getBloc
().
apply
(
this
);
corps
=
(
SaInst
)
this
.
returnValue
;
this
.
returnValue
=
new
SaDecFonc
(
nom
,
typeretour
,
parametres
,
variables
,
corps
);
outAFonctionDecfonc
(
node
);
outAFonctionDecfonc
(
node
);
}
}
...
@@ -431,6 +548,7 @@ public class Sc2sa extends DepthFirstAdapter
...
@@ -431,6 +548,7 @@ public class Sc2sa extends DepthFirstAdapter
@Override
@Override
public
void
caseAEpsilonLdecvar
(
AEpsilonLdecvar
node
)
{
public
void
caseAEpsilonLdecvar
(
AEpsilonLdecvar
node
)
{
inAEpsilonLdecvar
(
node
);
inAEpsilonLdecvar
(
node
);
this
.
returnValue
=
null
;
outAEpsilonLdecvar
(
node
);
outAEpsilonLdecvar
(
node
);
}
}
...
@@ -443,6 +561,7 @@ public class Sc2sa extends DepthFirstAdapter
...
@@ -443,6 +561,7 @@ public class Sc2sa extends DepthFirstAdapter
@Override
@Override
public
void
caseAEpsilonLdecvar2
(
AEpsilonLdecvar2
node
)
{
public
void
caseAEpsilonLdecvar2
(
AEpsilonLdecvar2
node
)
{
inAEpsilonLdecvar2
(
node
);
inAEpsilonLdecvar2
(
node
);
this
.
returnValue
=
null
;
outAEpsilonLdecvar2
(
node
);
outAEpsilonLdecvar2
(
node
);
}
}
...
@@ -455,12 +574,14 @@ public class Sc2sa extends DepthFirstAdapter
...
@@ -455,12 +574,14 @@ public class Sc2sa extends DepthFirstAdapter
@Override
@Override
public
void
caseAEpsilonLdecfonc
(
AEpsilonLdecfonc
node
)
{
public
void
caseAEpsilonLdecfonc
(
AEpsilonLdecfonc
node
)
{
inAEpsilonLdecfonc
(
node
);
inAEpsilonLdecfonc
(
node
);
this
.
returnValue
=
null
;
outAEpsilonLdecfonc
(
node
);
outAEpsilonLdecfonc
(
node
);
}
}
@Override
@Override
public
void
caseAEpsilon
(
AEpsilon
node
)
{
public
void
caseAEpsilon
(
AEpsilon
node
)
{
inAEpsilon
(
node
);
inAEpsilon
(
node
);
this
.
returnValue
=
null
;
outAEpsilon
(
node
);
outAEpsilon
(
node
);
}
}
}
}
...
...
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