Skip to content
Snippets Groups Projects
Commit ff8e31dc authored by Alexis Nasr's avatar Alexis Nasr
Browse files

ajout des packages sa et ts

parent 39156af7
No related branches found
No related tags found
No related merge requests found
Showing
with 1302 additions and 3 deletions
......@@ -2,7 +2,7 @@ import java.io.*;
import sc.parser.*;
import sc.lexer.*;
import sc.node.*;
//import sa.*;
import sa.*;
//import ts.*;
//import c3a.*;
//import nasm.*;
......@@ -51,7 +51,7 @@ public class Compiler
tree.apply(new Sc2Xml(baseName));
}
/* System.out.println("[BUILD SA] ");
System.out.println("[BUILD SA] ");
Sc2sa sc2sa = new Sc2sa();
tree.apply(sc2sa);
SaNode saRoot = sc2sa.getRoot();
......@@ -59,7 +59,7 @@ public class Compiler
if(verboseLevel > 1){
System.out.println("[PRINT SA]");
new Sa2Xml(saRoot, baseName);
}*/
}
/* System.out.println("[BUILD TS] ");
Ts tableGlobale = new Sa2ts(saRoot).getTableGlobale();
......
import sc.analysis.*;
import sc.node.*;
import sa.*;
import util.Type;
public class Sc2sa extends DepthFirstAdapter
{
private SaNode returnValue;
private Type returnType;
public void defaultIn(@SuppressWarnings("unused") Node node)
{
//System.out.println("<" + node.getClass().getSimpleName() + ">");
}
public void defaultOut(@SuppressWarnings("unused") Node node)
{
//System.out.println("</" + node.getClass().getSimpleName() + ">");
}
public SaNode getRoot()
{
return this.returnValue;
}
// un exemple de méthode associé à la règle
// exp3 = {plus} exp3 plus exp4
@Override
public void caseAPlusExp3(APlusExp3 node)
{
SaExp op1 = null;
SaExp op2 = null;
inAPlusExp3(node);
node.getExp3().apply(this);
op1 = (SaExp) this.returnValue;
node.getExp4().apply(this);
op2 = (SaExp) this.returnValue;
this.returnValue = new SaExpAdd(op1, op2);
outAPlusExp3(node);
}
}
package sa;
import util.Error;
public class ErrorException extends Exception{
private Error error;
private String message;
public ErrorException(Error error, String message){
this.error = error;
this.message = message;
}
public String getMessage(){
return message;
}
public int getCode(){
return error.code();
}
}
package sa;
import java.io.*;
public class Sa2Xml extends SaDepthFirstVisitor < Void > {
private int indentation = 0;
private String baseFileName;
private String fileName;
private PrintStream out;
private String childName;
public Sa2Xml(SaNode root, String baseFileName)
{
if (baseFileName == null){
this.out = System.out;
}
else{
try {
this.baseFileName = baseFileName;
this.fileName = baseFileName + ".sa";
this.out = new PrintStream(this.fileName);
}
catch (IOException e) {
System.err.println("Error: " + e.getMessage());
}
}
childName = "programme";
try{
root.accept(this);
}
catch(Exception e){}
}
public void printOpenTag(String TagName){
printOpenTag(TagName, null, null);
}
public void printOpenTag(String TagName, SaNode node){
printOpenTag(TagName, node, null);
}
public void printOpenTag(String TagName, String attrValList){
printOpenTag(TagName, null, attrValList);
}
public void printOpenTag(String TagName, SaNode node, String attrValList){
for(int i = 0; i < indentation; i++){this.out.print(" ");}
indentation++;
if(node != null)
this.out.print("<" + TagName + " type=" + "\"" + node.getClass().getSimpleName() + "\"");
else
this.out.print("<" + TagName);
if(attrValList != null)
this.out.print(attrValList);
this.out.println(">");
}
public void printCloseTag(String TagName)
{
indentation--;
for(int i = 0; i < indentation; i++){this.out.print(" ");}
this.out.println("</" + TagName + ">");
}
public void printOpenCloseTag(String TagName){
printOpenTag(TagName, null, null);
}
public void printOpenCloseTag(String TagName, SaNode node){
printOpenCloseTag(TagName, node, null);
}
public void printOpenCloseTag(String TagName, String attrValList){
printOpenCloseTag(TagName, null, attrValList);
}
public void printOpenCloseTag(String TagName, SaNode node, String attrValList){
for(int i = 0; i < indentation; i++){this.out.print(" ");}
// indentation++;
if(node != null)
this.out.print("<" + TagName + " type=" + "\"" + node.getClass().getSimpleName() + "\"");
else
this.out.print("<" + TagName);
if(attrValList != null)
this.out.print(attrValList);
this.out.println("/>");
}
// P -> LDEC LDEC
public Void visit(SaProg node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
if(node.getVariables() != null){
this.childName = "variables";
node.getVariables().accept(this);
}
if(node.getFonctions() != null){
this.childName = "fonctions";
node.getFonctions().accept(this);
}
printCloseTag(nodeName);
return null;
}
// DEC -> var id taille
public Void visit(SaDecTab node) throws Exception{
String nodeName = this.childName;
String attrValList = " nom=\"" + node.getNom() + "\"" + " taille=\"" + node.getTaille() + "\"" + " typeVariable=\"" + node.getType().nom() + "\"";
printOpenTag(nodeName, node, attrValList);
printCloseTag(nodeName);
return null;
}
// EXP -> entier
public Void visit(SaExpInt node) throws Exception
{
String nodeName = this.childName;
String attrValList = " val=\"" + node.getVal() + "\"";
printOpenCloseTag(nodeName, node, attrValList);
// printCloseTag(nodeName);
// printOpenCloseTag(nodeName, node, attrValList);
return null;
}
// EXP -> vrai
public Void visit(SaExpVrai node) throws Exception
{
String nodeName = this.childName;
// String attrValList = " val=\"" + node.getVal() + "\"";
String attrValList = null;
printOpenCloseTag(nodeName, node, attrValList);
return null;
}
// EXP -> faux
public Void visit(SaExpFaux node) throws Exception
{
String nodeName = this.childName;
// String attrValList = " val=\"" + node.getVal() + "\"";
String attrValList = null;
printOpenCloseTag(nodeName, node, attrValList);
return null;
}
public Void visit(SaExpVar node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "var";
node.getVar().accept(this);
printCloseTag(nodeName);
return null;
}
public Void visit(SaInstEcriture node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "arg";
node.getArg().accept(this);
printCloseTag(nodeName);
return null;
}
public Void visit(SaInstTantQue node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "test";
node.getTest().accept(this);
if (node.getFaire() != null){
childName = "faire";
node.getFaire().accept(this);
}
printCloseTag(nodeName);
return null;
}
public Void visit(SaLInst node) throws Exception
{
if(node == null) return null;
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "tete";
node.getTete().accept(this);
if(node.getQueue() != null){
childName = "queue";
node.getQueue().accept(this);
}
printCloseTag(nodeName);
return null;
}
// DEC -> fct id LDEC LDEC LINST
public Void visit(SaDecFonc node) throws Exception
{
String nodeName = this.childName;
String attrValList = " nom=\"" + node.getNom() + "\"" + " typeRetour=\"" + node.getTypeRetour().nom() + "\"";
printOpenTag(nodeName, node, attrValList);
if(node.getParametres() != null){
childName = "parametres";
node.getParametres().accept(this);
}
if(node.getVariable() != null){
childName = "variables";
node.getVariable().accept(this);
}
if (node.getCorps() != null){
childName = "corps";
node.getCorps().accept(this);
}
printCloseTag(nodeName);
return null;
}
// DEC -> var id
public Void visit(SaDecVar node) throws Exception
{
String nodeName = this.childName;
String attrValList = " nom=\"" + node.getNom() + "\"" + " typeVariable=\"" + node.getType().nom() + "\"";
printOpenCloseTag(nodeName, node, attrValList);
return null;
}
public Void visit(SaInstAffect node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
this.childName = "lhs";
node.getLhs().accept(this);
this.childName = "rhs";
node.getRhs().accept(this);
printCloseTag(nodeName);
return null;
}
// LDEC -> DEC LDEC
// LDEC -> null
/* public Void visit(SaLDec node)
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName="tete";
node.getTete().accept(this);
if(node.getQueue() != null){
childName="queue";
node.getQueue().accept(this);
}
printCloseTag(nodeName);
return null;
}*/
public Void visit(SaLDecVar node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName="tete";
node.getTete().accept(this);
if(node.getQueue() != null){
childName="queue";
node.getQueue().accept(this);
}
printCloseTag(nodeName);
return null;
}
public Void visit(SaLDecFonc node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName="tete";
node.getTete().accept(this);
if(node.getQueue() != null){
childName="queue";
node.getQueue().accept(this);
}
printCloseTag(nodeName);
return null;
}
public Void visit(SaVarSimple node) throws Exception
{
String nodeName = this.childName;
String attrValList = " nom=\"" + node.getNom() + "\"";
printOpenCloseTag(nodeName, node, attrValList);
return null;
}
public Void visit(SaAppel node) throws Exception
{
String nodeName = this.childName;
String attrValList = " nom=\"" + node.getNom() + "\"";
printOpenTag(nodeName, node, attrValList);
if(node.getArguments() != null){
childName = "arguments";
node.getArguments().accept(this);
}
printCloseTag(nodeName);
return null;
}
public Void visit(SaExpAppel node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "val";
node.getVal().accept(this);
printCloseTag(nodeName);
return null;
}
// EXP -> add EXP EXP
public Void visit(SaExpAdd node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "op1";
node.getOp1().accept(this);
childName = "op2";
node.getOp2().accept(this);
printCloseTag(nodeName);
return null;
}
// EXP -> sub EXP EXP
public Void visit(SaExpSub node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "op1";
node.getOp1().accept(this);
childName = "op2";
node.getOp2().accept(this);
printCloseTag(nodeName);
return null;
}
// EXP -> mult EXP EXP
public Void visit(SaExpMult node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "op1";
node.getOp1().accept(this);
childName = "op2";
node.getOp2().accept(this);
printCloseTag(nodeName);
return null;
}
// EXP -> div EXP EXP
public Void visit(SaExpDiv node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "op1";
node.getOp1().accept(this);
childName = "op2";
node.getOp2().accept(this);
printCloseTag(nodeName);
return null;
}
// EXP -> inf EXP EXP
public Void visit(SaExpInf node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "op1";
node.getOp1().accept(this);
childName = "op2";
node.getOp2().accept(this);
printCloseTag(nodeName);
return null;
}
// EXP -> eq EXP EXP
public Void visit(SaExpEqual node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "op1";
node.getOp1().accept(this);
childName = "op2";
node.getOp2().accept(this);
printCloseTag(nodeName);
return null;
}
// EXP -> and EXP EXP
public Void visit(SaExpAnd node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "op1";
node.getOp1().accept(this);
childName = "op2";
node.getOp2().accept(this);
printCloseTag(nodeName);
return null;
}
// EXP -> or EXP EXP
public Void visit(SaExpOr node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "op1";
node.getOp1().accept(this);
childName = "op2";
node.getOp2().accept(this);
printCloseTag(nodeName);
return null;
}
// EXP -> not EXP
public Void visit(SaExpNot node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "op1";
node.getOp1().accept(this);
printCloseTag(nodeName);
return null;
}
public Void visit(SaExpLire node) throws Exception
{
String nodeName = this.childName;
printOpenCloseTag(nodeName, node);
return null;
}
public Void visit(SaInstBloc node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "val";
node.getVal().accept(this);
printCloseTag(nodeName);
return null;
}
public Void visit(SaInstSi node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "test";
node.getTest().accept(this);
if (node.getAlors() != null){
childName = "alors";
node.getAlors().accept(this);
}
if(node.getSinon() != null){
childName = "sinon";
node.getSinon().accept(this);
}
printCloseTag(nodeName);
return null;
}
// INST -> ret EXP
public Void visit(SaInstRetour node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "val";
node.getVal().accept(this);
printCloseTag(nodeName);
return null;
}
public Void visit(SaLExp node) throws Exception
{
String nodeName = this.childName;
printOpenTag(nodeName, node);
childName = "tete";
node.getTete().accept(this);
if(node.getQueue() != null){
childName = "queue";
node.getQueue().accept(this);
}
printCloseTag(nodeName);
return null;
}
public Void visit(SaVarIndicee node) throws Exception
{
String nodeName = this.childName;
String attrValList = " nom=\"" + node.getNom() + "\"";
printOpenTag(nodeName, node, attrValList);
childName = "indice";
node.getIndice().accept(this);
printCloseTag(nodeName);
return null;
}
}
package sa;
import ts.*;
import util.Type;
public class SaAppel implements SaExp, SaInst{
private String nom;
private SaLExp arguments;
public TsItemFct tsItem;
public SaAppel(String nom, SaLExp arguments){
this.nom = nom;
this.arguments = arguments;
this.tsItem = null;
}
public String getNom(){return this.nom;}
public SaLExp getArguments(){return this.arguments;}
public Type getType(){
return tsItem.typeRetour;
}
public <T> T accept(SaVisitor <T> visitor) throws Exception{
return visitor.visit(this);
}
}
package sa;
public interface SaDec extends SaNode {
public String getNom();
}
package sa;
import ts.*;
import util.Type;
public class SaDecFonc implements SaDec{
private String nom;
private SaLDecVar parametres;
private SaLDecVar variables;
private SaInst corps;
private Type typeRetour;
public TsItemFct tsItem;
public SaDecFonc(String nom, Type typeRetour, SaLDecVar parametres, SaLDecVar variables, SaInst corps){
this.nom = nom;
this.typeRetour = typeRetour;
this.parametres = parametres;
this.variables = variables;
this.corps = corps;
this.tsItem = null;
}
public String getNom(){return this.nom;}
public Type getTypeRetour(){return this.typeRetour;}
public SaLDecVar getParametres(){return this.parametres;}
public SaLDecVar getVariable(){return this.variables;}
public SaInst getCorps(){return this.corps;}
public <T> T accept(SaVisitor <T> visitor) throws Exception{
return visitor.visit(this);
}
}
package sa;
import ts.*;
import util.Type;
public class SaDecTab implements SaDecVar{
private String nom;
private int taille;
private Type type;
public TsItemVar tsItem;
public SaDecTab(String nom, Type type, int taille){
this.nom = nom;
this.type = type;
this.taille = taille;
this.tsItem = null;
}
public String getNom(){return this.nom;}
public int getTaille(){return this.taille;}
public Type getType(){return this.type;}
public TsItemVar getTsItem(){return this.tsItem;}
public void setTsItem(TsItemVar tsItem){this.tsItem = tsItem;}
public <T> T accept(SaVisitor <T> visitor) throws Exception{
return visitor.visit(this);
}
}
package sa;
import util.Type;
import ts.*;
public interface SaDecVar extends SaNode {
public String getNom();
public Type getType();
public TsItemVar getTsItem();
public void setTsItem(TsItemVar tsItem);
}
package sa;
import ts.*;
import util.Type;
public class SaDecVarSimple implements SaDecVar{
private String nom;
private Type type;
public TsItemVar tsItem;
public SaDecVarSimple(String nom, Type type){
this.nom = nom;
this.type = type;
this.tsItem = null;
}
public String getNom(){return this.nom;}
public Type getType(){return this.type;}
public TsItemVar getTsItem(){return this.tsItem;}
public void setTsItem(TsItemVar tsItem){this.tsItem = tsItem;}
public <T> T accept(SaVisitor <T> visitor) throws Exception{
return visitor.visit(this);
}
}
package sa;
// P -> LDEC LDEC
// DEC -> var id taille
// DEC -> fct id LDEC LDEC LINST
// DEC -> var id
// LDEC -> DEC LDEC
// LDEC -> null
// VAR ->simple id
// VAR ->indicee id EXP
// LINST -> INST LINST
// LINST -> null
// INST -> aff VAR EXP
// INST -> si EXP LINST LINST
// INST -> tq EXP LINST
// INST -> app APP
// INST -> ret EXP
// INST -> ecr EXP
// APP -> id LEXP
// LEXP -> EXP LEXP
// LEXP -> null
// EXP -> op2 EXP EXP
// EXP -> op1 EXP
// EXP -> VAR
// EXP -> entier
// EXP -> APP
// EXP -> lire
//**********
// VAR ->simple id
// VAR ->indicee id EXP
// LINST -> INST LINST
// LINST -> null
// INST -> aff VAR EXP
// INST -> si EXP LINST LINST
// INST -> tq EXP LINST
// INST -> app APP
// INST -> ecr EXP
// APP -> id LEXP
// LEXP -> EXP LEXP
// LEXP -> null
// EXP -> op1 EXP
// EXP -> VAR
// EXP -> lire
public class SaDepthFirstVisitor <T> implements SaVisitor <T>{
// private NouvelleClasse x;
public void defaultIn(SaNode node)
{
}
public void defaultOut(SaNode node)
{
}
// P -> LDEC LDEC
public T visit(SaProg node) throws Exception
{
defaultIn(node);
if(node.getVariables() != null)
node.getVariables().accept(this);
if(node.getFonctions() != null)
node.getFonctions().accept(this);
defaultOut(node);
return null;
}
// DEC -> var id taille
public T visit(SaDecTab node) throws Exception{
defaultIn(node);
defaultOut(node);
return null;
}
public T visit(SaExp node) throws Exception
{
defaultIn(node);
defaultOut(node);
return null;
}
// EXP -> entier
public T visit(SaExpInt node) throws Exception
{
defaultIn(node);
defaultOut(node);
return null;
}
// EXP -> vrai
public T visit(SaExpVrai node) throws Exception
{
defaultIn(node);
defaultOut(node);
return null;
}
// EXP -> faux
public T visit(SaExpFaux node) throws Exception
{
defaultIn(node);
defaultOut(node);
return null;
}
public T visit(SaExpVar node) throws Exception
{
defaultIn(node);
node.getVar().accept(this);
defaultOut(node);
return null;
}
public T visit(SaInstEcriture node) throws Exception
{
defaultIn(node);
node.getArg().accept(this);
defaultOut(node);
return null;
}
public T visit(SaInstTantQue node) throws Exception
{
defaultIn(node);
node.getTest().accept(this);
if (node.getFaire() != null)
node.getFaire().accept(this);
defaultOut(node);
return null;
}
public T visit(SaLInst node) throws Exception
{
defaultIn(node);
if(node != null){
if(node.getTete() != null)node.getTete().accept(this);
if(node.getQueue() != null) node.getQueue().accept(this);
}
defaultOut(node);
return null;
}
// DEC -> fct id LDEC LDEC LINST
public T visit(SaDecFonc node) throws Exception
{
defaultIn(node);
if(node.getParametres() != null) node.getParametres().accept(this);
if(node.getVariable() != null) node.getVariable().accept(this);
if(node.getCorps() != null) node.getCorps().accept(this);
defaultOut(node);
return null;
}
// DEC -> var id
public T visit(SaDecVar node) throws Exception
{
defaultIn(node);
defaultOut(node);
return null;
}
public T visit(SaInstAffect node) throws Exception
{
defaultIn(node);
node.getLhs().accept(this);
node.getRhs().accept(this);
defaultOut(node);
return null;
}
// LDEC -> DEC LDEC
// LDEC -> null
/* public T visit(SaLDec node) throws Exception
{
defaultIn(node);
node.getTete().accept(this);
if(node.getQueue() != null) node.getQueue().accept(this);
defaultOut(node);
return null;
}*/
public T visit(SaLDecVar node) throws Exception
{
defaultIn(node);
node.getTete().accept(this);
if(node.getQueue() != null) node.getQueue().accept(this);
defaultOut(node);
return null;
}
public T visit(SaLDecFonc node) throws Exception
{
defaultIn(node);
node.getTete().accept(this);
if(node.getQueue() != null) node.getQueue().accept(this);
defaultOut(node);
return null;
}
public T visit(SaVarSimple node) throws Exception
{
defaultIn(node);
defaultOut(node);
return null;
}
public T visit(SaAppel node) throws Exception
{
defaultIn(node);
if(node.getArguments() != null) node.getArguments().accept(this);
defaultOut(node);
return null;
}
public T visit(SaExpAppel node) throws Exception
{
defaultIn(node);
node.getVal().accept(this);
defaultOut(node);
return null;
}
// EXP -> add EXP EXP
public T visit(SaExpAdd node) throws Exception
{
defaultIn(node);
node.getOp1().accept(this);
node.getOp2().accept(this);
defaultOut(node);
return null;
}
// EXP -> sub EXP EXP
public T visit(SaExpSub node) throws Exception
{
defaultIn(node);
node.getOp1().accept(this);
node.getOp2().accept(this);
defaultOut(node);
return null;
}
// EXP -> mult EXP EXP
public T visit(SaExpMult node) throws Exception
{
defaultIn(node);
node.getOp1().accept(this);
node.getOp2().accept(this);
defaultOut(node);
return null;
}
// EXP -> div EXP EXP
public T visit(SaExpDiv node) throws Exception
{
defaultIn(node);
node.getOp1().accept(this);
node.getOp2().accept(this);
defaultOut(node);
return null;
}
// EXP -> inf EXP EXP
public T visit(SaExpInf node) throws Exception
{
defaultIn(node);
node.getOp1().accept(this);
node.getOp2().accept(this);
defaultOut(node);
return null;
}
// EXP -> eq EXP EXP
public T visit(SaExpEqual node) throws Exception
{
defaultIn(node);
node.getOp1().accept(this);
node.getOp2().accept(this);
defaultOut(node);
return null;
}
// EXP -> and EXP EXP
public T visit(SaExpAnd node) throws Exception
{
defaultIn(node);
node.getOp1().accept(this);
node.getOp2().accept(this);
defaultOut(node);
return null;
}
// EXP -> or EXP EXP
public T visit(SaExpOr node) throws Exception
{
defaultIn(node);
node.getOp1().accept(this);
node.getOp2().accept(this);
defaultOut(node);
return null;
}
// EXP -> not EXP
public T visit(SaExpNot node) throws Exception
{
defaultIn(node);
node.getOp1().accept(this);
defaultOut(node);
return null;
}
public T visit(SaExpLire node) throws Exception
{
defaultIn(node);
defaultOut(node);
return null;
}
public T visit(SaInstBloc node) throws Exception
{
defaultIn(node);
node.getVal().accept(this);
defaultOut(node);
return null;
}
public T visit(SaInstSi node) throws Exception
{
defaultIn(node);
node.getTest().accept(this);
if (node.getAlors() != null)
node.getAlors().accept(this);
if(node.getSinon() != null) node.getSinon().accept(this);
defaultOut(node);
return null;
}
// INST -> ret EXP
public T visit(SaInstRetour node) throws Exception
{
defaultIn(node);
node.getVal().accept(this);
defaultOut(node);
return null;
}
public T visit(SaLExp node) throws Exception
{
defaultIn(node);
node.getTete().accept(this);
if(node.getQueue() != null)
node.getQueue().accept(this);
defaultOut(node);
return null;
}
public T visit(SaVarIndicee node) throws Exception
{
defaultIn(node);
node.getIndice().accept(this);
defaultOut(node);
return null;
}
}
package sa;
import java.util.*;
import ts.*;
import util.Memory;
public class SaEnvironment {
public Memory vars;
public Memory args;
public TypeVal returnValue;
public SaEnvironment (TsItemFct fct)
{
SaLExp lArgs = null;
Ts localTable = fct.getTable();
int i = 0;
args = new Memory(localTable.getAdrArgCourante(), 0);
vars = new Memory(localTable.getAdrVarCourante(), 0);
// args = new Memory(200, 0);
// vars = new Memory(200, 0);
returnValue = null;
// System.out.println("allocation d'un nouvel environnement, fonction " + fct.getIdentif());
// System.out.println("dim var = " + localTable.getAdrVarCourante());
// System.out.println("dim arg = " + localTable.getAdrArgCourante());
}
public TypeVal getReturnValue(){return returnValue;}
public void setReturnValue(TypeVal typeVal){returnValue = typeVal;}
}
package sa;
import util.Type;
public interface SaExp extends SaNode {
public Type getType();
}
package sa;
import util.Type;
public class SaExpAdd implements SaExp{
private SaExp op1;
private SaExp op2;
public SaExpAdd(SaExp op1, SaExp op2){
this.op1 = op1;
this.op2 = op2;
}
public SaExp getOp1(){return this.op1;}
public SaExp getOp2(){return this.op2;}
public Type getType(){
return Type.ENTIER;
}
public <T> T accept(SaVisitor <T> visitor) throws Exception{
return visitor.visit(this);
}
}
package sa;
import util.Type;
public class SaExpAnd implements SaExp{
private SaExp op1;
private SaExp op2;
public SaExpAnd(SaExp op1, SaExp op2){
this.op1 = op1;
this.op2 = op2;
}
public SaExp getOp1(){return this.op1;}
public SaExp getOp2(){return this.op2;}
public Type getType(){
return Type.BOOL;
}
public <T> T accept(SaVisitor <T> visitor) throws Exception{
return visitor.visit(this);
}
}
package sa;
import util.Type;
public class SaExpAppel implements SaExp{
private SaAppel val;
public SaExpAppel(SaAppel val){
this.val = val;
}
public SaAppel getVal(){return this.val;}
public Type getType(){
return val.getType();
}
public <T> T accept(SaVisitor <T> visitor) throws Exception{
return visitor.visit(this);
}
}
package sa;
import util.Type;
public class SaExpDiv implements SaExp{
private SaExp op1;
private SaExp op2;
public SaExpDiv(SaExp op1, SaExp op2){
this.op1 = op1;
this.op2 = op2;
}
public SaExp getOp1(){return this.op1;}
public SaExp getOp2(){return this.op2;}
public Type getType(){
return Type.ENTIER;
}
public <T> T accept(SaVisitor <T> visitor) throws Exception{
return visitor.visit(this);
}
}
package sa;
import util.Type;
public class SaExpEqual implements SaExp{
private SaExp op1;
private SaExp op2;
public SaExpEqual(SaExp op1, SaExp op2){
this.op1 = op1;
this.op2 = op2;
}
public SaExp getOp1(){return this.op1;}
public SaExp getOp2(){return this.op2;}
public Type getType(){
return Type.BOOL;
}
public <T> T accept(SaVisitor <T> visitor) throws Exception{
return visitor.visit(this);
}
}
package sa;
import util.Type;
public class SaExpFaux implements SaExp{
private final boolean val;
public SaExpFaux(){
this.val = false;
}
public boolean getVal(){
return this.val;
}
public Type getType(){
return Type.BOOL;
}
public <T> T accept(SaVisitor <T> visitor) throws Exception{
return visitor.visit(this);
}
}
package sa;
import util.Type;
public class SaExpInf implements SaExp{
private SaExp op1;
private SaExp op2;
public SaExpInf(SaExp op1, SaExp op2){
this.op1 = op1;
this.op2 = op2;
}
public SaExp getOp1(){return this.op1;}
public SaExp getOp2(){return this.op2;}
public Type getType(){
return Type.BOOL;
}
public <T> T accept(SaVisitor <T> visitor) throws Exception {
return visitor.visit(this);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment