Skip to content
Snippets Groups Projects
Commit 78a444d9 authored by BAUQUIN Niels's avatar BAUQUIN Niels
Browse files

geg

parent 766fe5db
No related branches found
No related tags found
No related merge requests found
......@@ -31,8 +31,8 @@ public class Compiler
processCommandLine(args);
System.out.println("[BUILD SC] ");
buildSc();
/* System.out.println("[BUILD SA] ");
buildSa();
System.out.println("[BUILD SA] ");
buildSa();/*
System.out.println("[BUILD TS] ");
buildTs();
System.out.println("[TYPE CHECKING]");
......
......@@ -31,7 +31,8 @@ public class Sc2sa extends DepthFirstAdapter
@Override
public void caseStart(Start node) {
super.caseStart(node);
inStart(node);
outStart(node);
}
@Override
......@@ -206,18 +207,8 @@ public class Sc2sa extends DepthFirstAdapter
@Override
public void caseAParenthesisExp6(AParenthesisExp6 node) {
SaExp op1 = null;
SaExp op2 = null;
SaExp op3 = null;
inAParenthesisExp6(node);
node.getGpar().apply(this);
op1 = (SaExp) this.returnValue;
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);
}
......@@ -233,126 +224,220 @@ public class Sc2sa extends DepthFirstAdapter
@Override
public void caseAVraiExp6(AVraiExp6 node) {
inAVraiExp6(node);
this.returnValue = new SaExpVrai();
outAVraiExp6(node);
}
@Override
public void caseAFauxExp6(AFauxExp6 node) {
inAFauxExp6(node);
this.returnValue = new SaExpFaux();
outAFauxExp6(node);
}
@Override
public void caseAAfExp6(AAfExp6 node) {
inAAfExp6(node);
SaAppel appel = null;
node.getAf().apply(this);
appel = (SaAppel) this.returnValue;
this.returnValue = new SaExpAppel(appel);
outAAfExp6(node);
}
@Override
public void caseAVarExp6(AVarExp6 node) {
inAVarExp6(node);
SaVar saVar = null;
node.getVar().apply(this);
saVar = (SaVar) this.returnValue;
this.returnValue = new SaExpVar(saVar);
outAVarExp6(node);
}
@Override
public void caseALireExp6(ALireExp6 node) {
inALireExp6(node);
node.getLire().apply(this);
this.returnValue = new SaExpLire();
outALireExp6(node);
}
@Override
public void caseAAffectationIns(AAffectationIns 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);
}
@Override
public void caseAFairetantqueIns(AFairetantqueIns 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);
}
@Override
public void caseAFonctionIns(AFonctionIns node) {
inAFonctionIns(node);
node.getId().apply(this);
node.getGpar().apply(this);
outAFonctionIns(node);
}
@Override
public void caseASialorsIns(ASialorsIns 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);
}
@Override
public void caseASisinonIns(ASisinonIns 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);
}
@Override
public void caseARetourIns(ARetourIns node) {
inARetourIns(node);
SaExp val = null;
node.getExp().apply(this);
val = (SaExp) this.returnValue;
this.returnValue = new SaInstRetour(val);
outARetourIns(node);
}
@Override
public void caseAEcrireIns(AEcrireIns node) {
inAEcrireIns(node);
SaExp arg = null;
node.getExp().apply(this);
arg = (SaExp) this.returnValue;
this.returnValue = new SaInstEcriture(arg);
outAEcrireIns(node);
}
@Override
public void caseABlocIns(ABlocIns node) {
inABlocIns(node);
SaLInst linst = null;
node.getBloc().apply(this);
linst = (SaLInst) this.returnValue;
this.returnValue = new SaInstBloc(linst);
outABlocIns(node);
}
@Override
public void caseAAccoladesBloc(AAccoladesBloc node) {
inAAccoladesBloc(node);
SaLInst linst = null;
node.getLins().apply(this);
linst = (SaLInst) this.returnValue;
this.returnValue = new SaInstBloc(linst);
outAAccoladesBloc(node);
}
@Override
public void caseALinsLins(ALinsLins 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);
}
@Override
public void caseAEpsilonLins(AEpsilonLins node) {
inAEpsilonLins(node);
this.returnValue = null;
outAEpsilonLins(node);
}
@Override
public void caseALexp2Lexp(ALexp2Lexp 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);
}
@Override
public void caseAEpsilonLexp(AEpsilonLexp node) {
inAEpsilonLexp(node);
this.returnValue = null;
outAEpsilonLexp(node);
}
@Override
public void caseAVirguleLexp2(AVirguleLexp2 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);
}
@Override
public void caseAEpsilonLexp2(AEpsilonLexp2 node) {
inAEpsilonLexp2(node);
this.returnValue = null;
outAEpsilonLexp2(node);
}
@Override
public void caseAAfAf(AAfAf 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);
}
......@@ -361,13 +446,20 @@ public class Sc2sa extends DepthFirstAdapter
String id = "";
inAIdVar(node);
id = node.getId().getText();
this.returnValue = new SaId
this.returnValue = new SaVarSimple(id);
outAIdVar(node);
}
@Override
public void caseACrochetsVar(ACrochetsVar 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);
}
......@@ -388,12 +480,17 @@ public class Sc2sa extends DepthFirstAdapter
@Override
public void caseATypeTypeopt(ATypeTypeopt node) {
inATypeTypeopt(node);
Type type = null;
node.getType().apply(this);
type = this.returnType;
this.returnType = Type.fromString(type.nom());
outATypeTypeopt(node);
}
@Override
public void caseAEpsilonTypeopt(AEpsilonTypeopt node) {
inAEpsilonTypeopt(node);
this.returnValue = null;
outAEpsilonTypeopt(node);
}
......@@ -413,12 +510,32 @@ public class Sc2sa extends DepthFirstAdapter
@Override
public void caseATableauDecvar(ATableauDecvar 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);
}
@Override
public void caseAFonctionDecfonc(AFonctionDecfonc 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);
}
......@@ -431,6 +548,7 @@ public class Sc2sa extends DepthFirstAdapter
@Override
public void caseAEpsilonLdecvar(AEpsilonLdecvar node) {
inAEpsilonLdecvar(node);
this.returnValue = null;
outAEpsilonLdecvar(node);
}
......@@ -443,6 +561,7 @@ public class Sc2sa extends DepthFirstAdapter
@Override
public void caseAEpsilonLdecvar2(AEpsilonLdecvar2 node) {
inAEpsilonLdecvar2(node);
this.returnValue = null;
outAEpsilonLdecvar2(node);
}
......@@ -455,12 +574,14 @@ public class Sc2sa extends DepthFirstAdapter
@Override
public void caseAEpsilonLdecfonc(AEpsilonLdecfonc node) {
inAEpsilonLdecfonc(node);
this.returnValue = null;
outAEpsilonLdecfonc(node);
}
@Override
public void caseAEpsilon(AEpsilon node) {
inAEpsilon(node);
this.returnValue = null;
outAEpsilon(node);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment