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

soustraction

parent 3d5b26de
No related branches found
No related tags found
No related merge requests found
/*
* Represent an addition expression node inside the AST.
*/
public class Soustraction extends Arithmetique {
/**
* Constructor
*/
public Soustraction(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);
}
}
This diff is collapsed.
......@@ -2,5 +2,5 @@ programme Program
debutprg
b = 3;
c = c + 2;
c = c - 2;
finprg
......@@ -35,7 +35,7 @@ public interface ASTVisitor {
// Object visit(Parentheses node);
// Object visit(Pour node);
// Object visit(Produit node);
// Object visit(Soustraction node);
Object visit(Soustraction node);
// Object visit(SupEgal node);
// Object visit(Superieur node);
// Object visit(Tantque node);
......
......@@ -60,7 +60,7 @@ public class ByteCodeGenerator implements ASTVisitor{
// public Object visit(Relation node) { return null; }
// public Object visit(Soustraction node) { return null; }
public Object visit(Soustraction node) { return null; }
// public Object visit(SupEgal node) { return null; }
......
......@@ -62,7 +62,7 @@ public class SemanticAnalyzer implements ASTVisitor {
// public Object visit(Relation node) { return null; }
// public Object visit(Soustraction node) { return null; }
public Object visit(Soustraction node) { return null; }
// public Object visit(SupEgal node) { return null; }
......
......@@ -237,12 +237,12 @@ public class SourceCodeGenerator implements ASTVisitor{
// return null;
// }
//
// public Object visit(Soustraction node){
// node.getGauche().accept(this);
// code += " - ";
// node.getDroite().accept(this);
// return null;
// }
public Object visit(Soustraction node){
node.getGauche().accept(this);
code += " - ";
node.getDroite().accept(this);
return null;
}
//
// public Object visit(SupEgal node){
// node.getGauche().accept(this);
......
......@@ -11,7 +11,6 @@ terminal CLOSEPARENT, COMMA, EQUAL, DOUBLEPOINTS, OPENBRACK, CLOSEBRACK;
terminal READ, WRITE, IF, THEN, ELSE, ENDIF, WHILE, DO, ENDWHILE;
terminal FOR, FROM, TO, ENDFOR, TRUE, FALSE, PLUS, MINUS, TIMES, DIVIDE;
terminal EQUALS, DIFF, INF, INFEQUAL, SUP, SUPEQUAL, AND, OR, NOT, UMINUS;
terminal String IDENT, STRINGCONST, TINTEGER, TBOOLEAN;
terminal int INTEGERCONST;
......@@ -77,7 +76,7 @@ type ::= TINTEGER {: :}
declar_const ::= CONSTANT type IDENT EQUAL expr SEMICOLON {: :};
op_bin ::= expr:a PLUS expr:b {: RESULT = new Addition(a, b, "", aleft, aright); :}
| expr MINUS expr {: :}
| expr:a MINUS expr:b {: RESULT = new Soustraction(a, b, "", aleft, aright); :}
| expr TIMES expr {: :}
| expr DIVIDE expr {: :}
| expr AND expr {: :}
......
This diff is collapsed.
sym.java 0 → 100644
//----------------------------------------------------
// The following code was generated by CUP v0.11a beta 20060608
// Wed Nov 23 18:32:15 CET 2022
//----------------------------------------------------
/** CUP generated class containing symbol constants. */
public class sym {
/* terminals */
public static final int DIVIDE = 32;
public static final int TBOOLEAN = 46;
public static final int EQUALS = 33;
public static final int UMINUS = 42;
public static final int CLOSEPARENT = 8;
public static final int PRG = 2;
public static final int FOR = 23;
public static final int MINUS = 30;
public static final int WRITE = 15;
public static final int STRINGCONST = 44;
public static final int NOT = 41;
public static final int AND = 39;
public static final int SEMICOLON = 6;
public static final int DOUBLEPOINTS = 11;
public static final int OR = 40;
public static final int INF = 35;
public static final int INTEGERCONST = 47;
public static final int COMMA = 9;
public static final int ENDPRG = 4;
public static final int ENDFOR = 26;
public static final int PLUS = 29;
public static final int IF = 16;
public static final int ENDWHILE = 22;
public static final int EOF = 0;
public static final int SUPEQUAL = 38;
public static final int STARTPRG = 3;
public static final int EQUAL = 10;
public static final int TRUE = 27;
public static final int error = 1;
public static final int INFEQUAL = 36;
public static final int IDENT = 43;
public static final int CONSTANT = 5;
public static final int FROM = 24;
public static final int TIMES = 31;
public static final int ENDIF = 19;
public static final int CLOSEBRACK = 13;
public static final int ELSE = 18;
public static final int TINTEGER = 45;
public static final int READ = 14;
public static final int TO = 25;
public static final int WHILE = 20;
public static final int OPENBRACK = 12;
public static final int SUP = 37;
public static final int THEN = 17;
public static final int DIFF = 34;
public static final int OPENPARENT = 7;
public static final int FALSE = 28;
public static final int DO = 21;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment