Skip to content
Snippets Groups Projects
Commit 8363ac04 authored by lucien.noel's avatar lucien.noel
Browse files

git cest de la merde

parent 21a1c816
Branches
No related tags found
No related merge requests found
/*
* Represent an equal comparaison expression node inside the AST.
*/
public class Diff extends Relation {
/**
* Constructor
*/
public Diff(Expression operandeGauche, Expression operandeDroite, String fl, int line, int col) {
super(operandeGauche, operandeDroite, fl, line, col);
}
/**
* Get the binary operator
*/
public String operateur() {
return "<>";
}
/**
* Accepts a AST visitor
*/
Object accept(ASTVisitor visitor){
return visitor.visit(this);
}
}
/*
* Represent an equal comparaison expression node inside the AST.
*/
public class InfEgal extends Relation {
/**
* Constructor
*/
public InfEgal(Expression operandeGauche, Expression operandeDroite, String fl, int line, int col) {
super(operandeGauche, operandeDroite, fl, line, col);
}
/**
* Get the binary operator
*/
public String operateur() {
return "<=";
}
/**
* Accepts a AST visitor
*/
Object accept(ASTVisitor visitor){
return visitor.visit(this);
}
}
/*
* Represent an equal comparaison expression node inside the AST.
*/
public class Inferieur extends Relation {
/**
* Constructor
*/
public Inferieur(Expression operandeGauche, Expression operandeDroite, String fl, int line, int col) {
super(operandeGauche, operandeDroite, fl, line, col);
}
/**
* Get the binary operator
*/
public String operateur() {
return "<";
}
/**
* Accepts a AST visitor
*/
Object accept(ASTVisitor visitor){
return visitor.visit(this);
}
}
/*
* Represent an equal comparaison expression node inside the AST.
*/
public class SupEgal extends Relation {
/**
* Constructor
*/
public SupEgal(Expression operandeGauche, Expression operandeDroite, String fl, int line, int col) {
super(operandeGauche, operandeDroite, fl, line, col);
}
/**
* Get the binary operator
*/
public String operateur() {
return "=<";
}
/**
* Accepts a AST visitor
*/
Object accept(ASTVisitor visitor){
return visitor.visit(this);
}
}
/*
* Represent an equal comparaison expression node inside the AST.
*/
public class Superieur extends Relation {
/**
* Constructor
*/
public Superieur(Expression operandeGauche, Expression operandeDroite, String fl, int line, int col) {
super(operandeGauche, operandeDroite, fl, line, col);
}
/**
* Get the binary operator
*/
public String operateur() {
return ">";
}
/**
* Accepts a AST visitor
*/
Object accept(ASTVisitor visitor){
return visitor.visit(this);
}
}
......@@ -2,5 +2,6 @@ programme Program
debutprg
c = c * 2;
b = faux et vrai;
b = 3;
d = c <> b;
finprg
......@@ -23,7 +23,7 @@ public interface ASTVisitor {
Object visit(DeclarationProgramme node);
// Object visit(DeclarationVariable node);
// Object visit(Diff node);
Object visit(Diff node);
Object visit(Division node);
// Object visit(Ecrire node);
......@@ -34,8 +34,8 @@ public interface ASTVisitor {
Object visit(Faux node);
Object visit(Idf node);
// Object visit(InfEgal node);
// Object visit(Inferieur node);
Object visit(InfEgal node);
Object visit(Inferieur node);
// Object visit(Lire node);
// Object visit(Moins node);
Object visit(Nombre node);
......@@ -47,8 +47,8 @@ public interface ASTVisitor {
Object visit(Produit node);
Object visit(Soustraction node);
// Object visit(SupEgal node);
// Object visit(Superieur node);
Object visit(SupEgal node);
Object visit(Superieur node);
// Object visit(Tantque node);
Object visit(Vrai node);
}
......@@ -34,7 +34,7 @@ public class ByteCodeGenerator implements ASTVisitor {
// public Object visit(DeclarationVariable node) { return null; }
// public Object visit(Diff node) { return null; }
public Object visit(Diff node) { return null; }
public Object visit(Division node) {
return null;
......@@ -56,9 +56,9 @@ public class ByteCodeGenerator implements ASTVisitor {
return null;
}
// public Object visit(InfEgal node) { return null; }
public Object visit(InfEgal node) { return null; }
// public Object visit(Inferieur node) { return null; }
public Object visit(Inferieur node) { return null; }
// public Object visit(Lire node) { return null; }
......@@ -86,9 +86,9 @@ public class ByteCodeGenerator implements ASTVisitor {
return null;
}
// public Object visit(SupEgal node) { return null; }
public Object visit(SupEgal node) { return null; }
// public Object visit(Superieur node) { return null; }
public Object visit(Superieur node) { return null; }
// public Object visit(Tantque node) { return null; }
......
......@@ -36,7 +36,7 @@ public class SemanticAnalyzer implements ASTVisitor {
// public Object visit(DeclarationVariable node) { return null; }
// public Object visit(Diff node) { return null; }
public Object visit(Diff node) { return null; }
public Object visit(Division node) {
return null;
......@@ -58,9 +58,9 @@ public class SemanticAnalyzer implements ASTVisitor {
return null;
}
// public Object visit(InfEgal node) { return null; }
public Object visit(InfEgal node) { return null; }
// public Object visit(Inferieur node) { return null; }
public Object visit(Inferieur node) { return null; }
// public Object visit(Lire node) { return null; }
......@@ -88,9 +88,9 @@ public class SemanticAnalyzer implements ASTVisitor {
return null;
}
// public Object visit(SupEgal node) { return null; }
public Object visit(SupEgal node) { return null; }
// public Object visit(Superieur node) { return null; }
public Object visit(Superieur node) { return null; }
// public Object visit(Tantque node) { return null; }
......
......@@ -117,14 +117,14 @@ public class SourceCodeGenerator implements ASTVisitor {
// code += ";";
// return null;
// }
//
// public Object visit(Diff node){
// node.getGauche().accept(this);
// code += " <> ";
// node.getDroite().accept(this);
// return null;
// }
//
public Object visit(Diff node){
node.getGauche().accept(this);
code += " <> ";
node.getDroite().accept(this);
return null;
}
public Object visit(Division node) {
node.getGauche().accept(this);
code += " / ";
......@@ -163,20 +163,20 @@ public class SourceCodeGenerator implements ASTVisitor {
return null;
}
// public Object visit(InfEgal node){
// node.getGauche().accept(this);
// code += " <= ";
// node.getDroite().accept(this);
// return null;
// }
//
// public Object visit(Inferieur node){
// node.getGauche().accept(this);
// code += " < ";
// node.getDroite().accept(this);
// return null;
// }
//
public Object visit(InfEgal node){
node.getGauche().accept(this);
code += " <= ";
node.getDroite().accept(this);
return null;
}
public Object visit(Inferieur node){
node.getGauche().accept(this);
code += " < ";
node.getDroite().accept(this);
return null;
}
// public Object visit(Lire node){
// code += "lire ";
// node.getDestination().accept(this);
......@@ -245,21 +245,21 @@ public class SourceCodeGenerator implements ASTVisitor {
node.getDroite().accept(this);
return null;
}
//
// public Object visit(SupEgal node){
// node.getGauche().accept(this);
// code += " >= ";
// node.getDroite().accept(this);
// return null;
// }
//
// public Object visit(Superieur node){
// node.getGauche().accept(this);
// code += " > ";
// node.getDroite().accept(this);
// return null;
// }
//
public Object visit(SupEgal node){
node.getGauche().accept(this);
code += " >= ";
node.getDroite().accept(this);
return null;
}
public Object visit(Superieur node){
node.getGauche().accept(this);
code += " > ";
node.getDroite().accept(this);
return null;
}
// public Object visit(Tantque node){
// code += "tantque ";
// node.getCondition().accept(this);
......
......@@ -83,11 +83,11 @@ op_bin ::= expr:a PLUS expr:b {: RESULT = new Addition(a, b, "", a
| expr:a OR expr:b {: RESULT = new Ou(a, b, "", aleft, aright);:};
relation ::= expr:a EQUALS expr:b {: RESULT = new Egal(a, b, "", aleft, aright); :}
| expr DIFF expr {: :}
| expr INF expr {: :}
| expr SUP expr {: :}
| expr INFEQUAL expr {: :}
| expr SUPEQUAL expr {: :};
|expr:a DIFF expr:b {: RESULT = new Diff(a, b, "", aleft, aright); :}
| expr:a INF expr:b {: RESULT = new Inferieur(a, b, "", aleft, aright); :}
| expr:a SUP expr:b {: RESULT = new Superieur(a, b, "", aleft, aright); :}
| expr:a INFEQUAL expr:b {: RESULT = new InfEgal(a, b, "", aleft, aright); :}
| expr:a SUPEQUAL expr:b {: RESULT = new SupEgal(a, b, "", aleft, aright); :};
op_una ::= NOT expr {: :}
| MINUS expr {: :}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment