From cb610ce477272a51c41316e455e209c9d623719c Mon Sep 17 00:00:00 2001 From: b21223327 <zakaria.bazizi@etu.univ-amu.fr> Date: Thu, 1 Feb 2024 17:59:21 +0100 Subject: [PATCH] bjfzf --- src/l.cfg | 2 +- src/sa/Sc2sa.java | 188 ++++++++++++---------------------------------- 2 files changed, 49 insertions(+), 141 deletions(-) diff --git a/src/l.cfg b/src/l.cfg index e6230c2..43e8d58 100644 --- a/src/l.cfg +++ b/src/l.cfg @@ -89,7 +89,7 @@ ins = |{sisinon} si exp alors [alor]:bloc sinon [sino]:bloc |{return} retourner exp pointvirgule |{write} ecrire gparenthese exp dparenthese pointvirgule - |{appelfnc} id gparenthese le dparenthese pointvirgule ; + |{appelfnc} id gparenthese le dparenthese pointvirgule ; //todo bloc = {instr} accoladeg li accoladed; li = {listeinstr} ins li | {epsilon} epsilon ; diff --git a/src/sa/Sc2sa.java b/src/sa/Sc2sa.java index c1a3c88..11187e7 100644 --- a/src/sa/Sc2sa.java +++ b/src/sa/Sc2sa.java @@ -548,12 +548,10 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseAVarE6(AVarE6 node) { - inAVarE6(node); - if(node.getVar() != null) - { - node.getVar().apply(this); - } - outAVarE6(node); + SaVar op1 = null ; + node.getVar().apply(this); + op1 = (SaVar) this.returnValue ; + returnValue = new SaExpVar(op1) ; } public void inAAppelfncE6(AAppelfncE6 node) @@ -602,24 +600,13 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseAAffectationIns(AAffectationIns node) { - inAAffectationIns(node); - if(node.getVar() != null) - { - node.getVar().apply(this); - } - if(node.getEgale() != null) - { - node.getEgale().apply(this); - } - if(node.getExp() != null) - { - node.getExp().apply(this); - } - if(node.getPointvirgule() != null) - { - node.getPointvirgule().apply(this); - } - outAAffectationIns(node); + SaVar op2 =null ; + SaExp op1 =null ; + node.getExp().apply(this); + op1 = (SaExp) this.returnValue; + node.getVar().apply(this); + op2 = (SaVar) this.returnValue ; + returnValue = new SaInstAffect(op2,op1); } public void inATqIns(ATqIns node) @@ -635,24 +622,13 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseATqIns(ATqIns node) { - inATqIns(node); - if(node.getTantque() != null) - { - node.getTantque().apply(this); - } - if(node.getExp() != null) - { - node.getExp().apply(this); - } - if(node.getFaire() != null) - { - node.getFaire().apply(this); - } - if(node.getBloc() != null) - { - node.getBloc().apply(this); - } - outATqIns(node); + SaExp op1 = null ; + SaInst op2 = null ; + node.getExp().apply(this); + op1 =(SaExp) this.returnValue; + node.getBloc().apply(this); + op2 = (SaInst) this.returnValue ; + this.returnValue = new SaInstTantQue(op1,op2); } public void inASiIns(ASiIns node) @@ -668,24 +644,18 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseASiIns(ASiIns node) { - inASiIns(node); - if(node.getSi() != null) - { - node.getSi().apply(this); - } - if(node.getExp() != null) - { - node.getExp().apply(this); - } - if(node.getAlors() != null) - { - node.getAlors().apply(this); - } - if(node.getBloc() != null) - { - node.getBloc().apply(this); - } - outASiIns(node); + SaExp op1 = null ; + SaInst op2 = null ; + SaInst op3 = null ; + + node.getSi().apply(this); + op1 = (SaExp) this.returnValue ; + node.getAlors().apply(this); + op2 = (SaInst) this.returnValue ; + node.getBloc().apply(this); + op3 = (SaInst) this.returnValue ; + + this.returnValue = new SaInstSi(op1,op2,op3); } public void inASisinonIns(ASisinonIns node) @@ -742,20 +712,10 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseAReturnIns(AReturnIns node) { - inAReturnIns(node); - if(node.getRetourner() != null) - { - node.getRetourner().apply(this); - } - if(node.getExp() != null) - { - node.getExp().apply(this); - } - if(node.getPointvirgule() != null) - { - node.getPointvirgule().apply(this); - } - outAReturnIns(node); + SaExp op1 = null ; + node.getRetourner().apply(this); + op1 = (SaExp) this.returnValue ; + returnValue = new SaInstRetour(op1); } public void inAWriteIns(AWriteIns node) @@ -771,28 +731,10 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseAWriteIns(AWriteIns node) { - inAWriteIns(node); - if(node.getEcrire() != null) - { - node.getEcrire().apply(this); - } - if(node.getGparenthese() != null) - { - node.getGparenthese().apply(this); - } - if(node.getExp() != null) - { - node.getExp().apply(this); - } - if(node.getDparenthese() != null) - { - node.getDparenthese().apply(this); - } - if(node.getPointvirgule() != null) - { - node.getPointvirgule().apply(this); - } - outAWriteIns(node); + SaExp op1 = null ; + node.getEcrire().apply(this); + op1 = (SaExp) this.returnValue ; + returnValue = new SaInstEcriture(op1); } public void inAAppelfncIns(AAppelfncIns node) @@ -808,28 +750,12 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseAAppelfncIns(AAppelfncIns node) { - inAAppelfncIns(node); - if(node.getId() != null) - { - node.getId().apply(this); - } - if(node.getGparenthese() != null) - { - node.getGparenthese().apply(this); - } - if(node.getLe() != null) - { + SaLExp op1 = null ; + if (node.getLe() != null) { node.getLe().apply(this); + op1 = (SaLExp) returnValue; } - if(node.getDparenthese() != null) - { - node.getDparenthese().apply(this); - } - if(node.getPointvirgule() != null) - { - node.getPointvirgule().apply(this); - } - outAAppelfncIns(node); + new SaAppel(node.getId().getText(),op1); } public void inAInstrBloc(AInstrBloc node) @@ -1033,12 +959,10 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseAIdVar(AIdVar node) { - inAIdVar(node); - if(node.getId() != null) - { - node.getId().apply(this); - } - outAIdVar(node); + SaVar op1 = null ; + node.getId().apply(this); + op1 = (SaVar) this.returnValue; + returnValue = new SaExpVar(op1) ; } public void inAIdCrochetVar(AIdCrochetVar node) @@ -1054,24 +978,8 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseAIdCrochetVar(AIdCrochetVar node) { - inAIdCrochetVar(node); - if(node.getId() != null) - { - node.getId().apply(this); - } - if(node.getCrochetg() != null) - { - node.getCrochetg().apply(this); - } - if(node.getExp() != null) - { - node.getExp().apply(this); - } - if(node.getCrochetd() != null) - { - node.getCrochetd().apply(this); - } - outAIdCrochetVar(node); + node.getExp().apply(this); + returnValue = new SaVarIndicee(node.getId().getText(), (SaExp) returnValue); } public void inADeclavariableDecvar(ADeclavariableDecvar node) -- GitLab