diff --git a/src/sa/Sc2sa.java b/src/sa/Sc2sa.java index 79dfcb89d37e8463ae47016d3fbcf1943e22081b..100f4fc62d3bc65dcf9c334beb052fd700d1feac 100644 --- a/src/sa/Sc2sa.java +++ b/src/sa/Sc2sa.java @@ -979,16 +979,14 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseADeclavariableDecvar(ADeclavariableDecvar node) { - inADeclavariableDecvar(node); - if(node.getType() != null) - { - node.getType().apply(this); - } - if(node.getId() != null) - { - node.getId().apply(this); - } - outADeclavariableDecvar(node); + //decvar = {declavariable} type id |type id crochetg nombre crochetd ; + + Type type = null; + node.getType().apply(this); + type = this.returnType; + + returnValue = new SaDecVarSimple(node.getId().getText(),type); + } public void inADecvar(ADecvar node) @@ -1004,28 +1002,12 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseADecvar(ADecvar node) { - inADecvar(node); - if(node.getType() != null) - { - node.getType().apply(this); - } - if(node.getId() != null) - { - node.getId().apply(this); - } - if(node.getCrochetg() != null) - { - node.getCrochetg().apply(this); - } - if(node.getNombre() != null) - { - node.getNombre().apply(this); - } - if(node.getCrochetd() != null) - { - node.getCrochetd().apply(this); - } - outADecvar(node); + //decvar = {declavariable} type id |type id crochetg nombre crochetd ; + + Type type = null; + node.getType().apply(this); + type = this.returnType; + returnValue = new SaDecTab(node.getId().getText(),type,Integer.parseInt(node.getNombre().getText())); } public void inATypeType(ATypeType node) @@ -1081,36 +1063,7 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseADeclafoncDecfonc(ADeclafoncDecfonc node) { - inADeclafoncDecfonc(node); - if(node.getTypeopt() != null) - { - node.getTypeopt().apply(this); - } - if(node.getId() != null) - { - node.getId().apply(this); - } - if(node.getGparenthese() != null) - { - node.getGparenthese().apply(this); - } - if(node.getFirstldec() != null) - { - node.getFirstldec().apply(this); - } - if(node.getDparenthese() != null) - { - node.getDparenthese().apply(this); - } - if(node.getSecondldec() != null) - { - node.getSecondldec().apply(this); - } - if(node.getBloc() != null) - { - node.getBloc().apply(this); - } - outADeclafoncDecfonc(node); + new SaDecFonc() } public void inATypeoptTypeopt(ATypeoptTypeopt node) @@ -1127,10 +1080,7 @@ public class Sc2sa extends DepthFirstAdapter public void caseATypeoptTypeopt(ATypeoptTypeopt node) { inATypeoptTypeopt(node); - if(node.getType() != null) - { - node.getType().apply(this); - } + node.getType().apply(this); outATypeoptTypeopt(node); } @@ -1168,16 +1118,16 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseALstdeclacvarLdec(ALstdeclacvarLdec node) { - inALstdeclacvarLdec(node); - if(node.getDecvar() != null) - { - node.getDecvar().apply(this); - } - if(node.getSuitedec() != null) - { - node.getSuitedec().apply(this); - } - outALstdeclacvarLdec(node); + //ldec = {lstdeclacvar} decvar suitedec | epsilon ; + SaDecVar op1 = null; + SaLDecVar op2 = null; + + node.getDecvar().apply(this); + op1 = (SaDecVar) this.returnValue; + node.getSuitedec().apply(this); + op2 = (SaLDecVar) this.returnValue; + returnValue = new SaLDecVar(op1,op2); + } public void inALdec(ALdec node) @@ -1214,20 +1164,17 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseASuitedeclvarSuitedec(ASuitedeclvarSuitedec node) { - inASuitedeclvarSuitedec(node); - if(node.getVirgule() != null) - { - node.getVirgule().apply(this); - } - if(node.getDecvar() != null) - { - node.getDecvar().apply(this); - } - if(node.getSuitedec() != null) - { - node.getSuitedec().apply(this); - } - outASuitedeclvarSuitedec(node); + //suitedec = {suitedeclvar} virgule decvar suitedec |epsilon ; + //ldec = {lstdeclacvar} decvar suitedec | epsilon ; + SaDecVar op1 = null; + SaLDecVar op2 = null; + + //node.getVirgule().apply(this); + node.getDecvar().apply(this); + op1 = (SaDecVar) this.returnValue; + node.getSuitedec().apply(this); + op2 = (SaLDecVar) this.returnValue; + returnValue = new SaLDecVar(op1,op2); } public void inASuitedec(ASuitedec node) @@ -1263,17 +1210,16 @@ public class Sc2sa extends DepthFirstAdapter @Override public void caseALstdecfncLdf(ALstdecfncLdf node) - { - inALstdecfncLdf(node); - if(node.getDecfonc() != null) - { - node.getDecfonc().apply(this); - } - if(node.getLdf() != null) - { - node.getLdf().apply(this); - } - outALstdecfncLdf(node); + {; + //ldf = {lstdecfnc} decfonc ldf | epsilon + SaDecFonc op1 = null; + SaLDecFonc op2 = null; + + node.getDecfonc().apply(this); + op1 = (SaDecFonc) this.returnValue; + node.getLdf().apply(this); + op2 = (SaLDecFonc) this.returnValue; + returnValue = new SaLDecFonc(op1,op2); } public void inALdf(ALdf node)