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
fa51f89e
Commit
fa51f89e
authored
1 year ago
by
BAUQUIN Niels
Browse files
Options
Downloads
Patches
Plain Diff
BAHAHHAHAHAHAHAHAHHAHAHAHHAHAHAHHAHAHAHAHHAHAHAH
parent
02784007
No related branches found
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
-1
2 additions, 1 deletion
src/Compiler.java
src/c3a/Sa2c3a.java
+191
-6
191 additions, 6 deletions
src/c3a/Sa2c3a.java
with
193 additions
and
7 deletions
src/Compiler.java
+
2
−
1
View file @
fa51f89e
...
...
@@ -38,9 +38,10 @@ public class Compiler
System
.
out
.
println
(
"[TYPE CHECKING]"
);
typeCheck
();
/*
System
.
out
.
println
(
"[BUILD C3A] "
);
buildC3a
();
/*
System.out.println("[BUILD PRE NASM] ");
buildPreNasm();
System.out.println("[BUILD FLOW GRAPH] ");
...
...
This diff is collapsed.
Click to expand it.
src/c3a/Sa2c3a.java
+
191
−
6
View file @
fa51f89e
...
...
@@ -19,16 +19,16 @@ public class Sa2c3a extends SaDepthFirstVisitor <C3aOperand> {
public
void
defaultIn
(
SaNode
node
)
{
//
for(int i = 0; i < indentation; i++){System.out.print(" ");}
//
indentation++;
//
System.out.println("<" + node.getClass().getSimpleName() + ">");
for
(
int
i
=
0
;
i
<
indentation
;
i
++){
System
.
out
.
print
(
" "
);}
indentation
++;
System
.
out
.
println
(
"<"
+
node
.
getClass
().
getSimpleName
()
+
">"
);
}
public
void
defaultOut
(
SaNode
node
)
{
//
indentation--;
//
for(int i = 0; i < indentation; i++){System.out.print(" ");}
//
System.out.println("</" + node.getClass().getSimpleName() + ">");
indentation
--;
for
(
int
i
=
0
;
i
<
indentation
;
i
++){
System
.
out
.
print
(
" "
);}
System
.
out
.
println
(
"</"
+
node
.
getClass
().
getSimpleName
()
+
">"
);
}
...
...
@@ -45,5 +45,190 @@ public class Sa2c3a extends SaDepthFirstVisitor <C3aOperand> {
return
result
;
}
@Override
public
C3aOperand
visit
(
SaProg
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaDecTab
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaExp
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaExpInt
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaExpVrai
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaExpFaux
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaExpVar
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaInstEcriture
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaInstTantQue
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaLInst
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaDecFonc
node
)
throws
Exception
{
defaultIn
(
node
);
C3aOperand
result
=
c3a
.
newAutoLabel
();
c3a
.
ajouteInst
(
new
C3aInstFBegin
(
node
.
tsItem
,
"begin"
));
node
.
getCorps
().
accept
(
this
);
c3a
.
ajouteInst
(
new
C3aInstFEnd
(
"end"
));
defaultOut
(
node
);
return
result
;
}
@Override
public
C3aOperand
visit
(
SaDecVar
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaInstAffect
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaLDecVar
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaLDecFonc
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaVarSimple
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaAppel
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaExpAppel
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@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
;
}
@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
(
SaExpInf
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaExpEqual
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaExpAnd
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaExpOr
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaExpNot
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaExpLire
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaInstBloc
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaInstSi
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaInstRetour
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaLExp
node
)
throws
Exception
{
return
super
.
visit
(
node
);
}
@Override
public
C3aOperand
visit
(
SaVarIndicee
node
)
throws
Exception
{
return
super
.
visit
(
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