From fcd2f19dd738f0fcf10026ac2c7ce6435fd5a570 Mon Sep 17 00:00:00 2001 From: ZaynouneFatimaZahrae <131474298+ZaynouneFatimaZahrae@users.noreply.github.com> Date: Fri, 23 Feb 2024 16:58:45 +0100 Subject: [PATCH] sa2ts --- src/ts/Sa2ts.java | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/ts/Sa2ts.java b/src/ts/Sa2ts.java index 238982d..0620ea1 100644 --- a/src/ts/Sa2ts.java +++ b/src/ts/Sa2ts.java @@ -88,25 +88,23 @@ public class Sa2ts extends SaDepthFirstVisitor <Void> { } - public Void visit(SaDecVarSimple node) { - boolean isGlobal = false; - if (tableLocaleCourante.getVar(node.getNom()) != null) { - if (tableGlobale.getVar(node.getNom()) != null) { - throw new RuntimeException("Erreur"); - } else { - isGlobal = true; + public Void visit(SaVarSimple node) throws Exception { + defaultIn(node); + if (tableLocaleCourante.getVar(node.getNom()) != null){ + if (tableLocaleCourante.getVar(node.getNom()).getTaille() != 1) throw new ErrorException(Error.TS,"Var not find"); + node.tsItem = (TsItemVarSimple) tableLocaleCourante.getVar(node.getNom()); + } + else if (tableGlobale.getVar(node.getNom()) != null){ + if (tableGlobale.getVar(node.getNom()).getTaille() != 1) throw new ErrorException(Error.TS,"Var not find"); + node.tsItem = (TsItemVarSimple) tableGlobale.getVar(node.getNom()); + } + else { + throw new ErrorException(Error.TS,"Var not find"); } + defaultOut(node); + return super.visit(node); } - TsItemVar tsItemVar; - if(isGlobal){ - tsItemVar = tableGlobale.getVar(node.getNom()); - }else{ - tsItemVar = tableLocaleCourante.getVar(node.getNom()); - } - node.tsItem = tsItemVar; - return null; - } public Void visit(SaVarIndicee node) throws Exception { defaultIn(node); if(tableGlobale.getVar(node.getNom()) != null){ -- GitLab