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

class Moins créée

parent a7feff19
Branches
Tags
No related merge requests found
public class Moins extends Unaire{
public Moins(Expression operande, String fl, int line, int col) {
super(operande, fl, line, col);
}
/**
* Get the binary operator
*/
public String operateur() {
return "-";
}
/**
* Accepts a AST visitor
*/
Object accept(ASTVisitor visitor){
return visitor.visit(this);
}
}
programme Program
debutprg
c = c * 2;
b = 3;
d = c <> b;
lire "oui";
c = -2;
finprg
......@@ -37,7 +37,7 @@ public interface ASTVisitor {
Object visit(InfEgal node);
Object visit(Inferieur node);
Object visit(Lire node);
// Object visit(Moins node);
Object visit(Moins node);
Object visit(Nombre node);
Object visit(Non node);
......
......@@ -62,7 +62,7 @@ public class ByteCodeGenerator implements ASTVisitor {
public Object visit(Lire node) { return null; }
// public Object visit(Moins node) { return null; }
public Object visit(Moins node) { return null; }
public Object visit(Nombre node) {
return null;
......
......@@ -64,7 +64,7 @@ public class SemanticAnalyzer implements ASTVisitor {
public Object visit(Lire node) { return null; }
// public Object visit(Moins node) { return null; }
public Object visit(Moins node) { return null; }
public Object visit(Nombre node) {
return null;
......
......@@ -184,11 +184,11 @@ public class SourceCodeGenerator implements ASTVisitor {
return null;
}
// public Object visit(Moins node){
// code += "-";
// node.getOperand().accept(this);
// return null;
// }
public Object visit(Moins node){
code += node.operateur();
node.getOperand().accept(this);
return null;
}
public Object visit(Nombre node) {
code += Integer.toString(node.getValeur());
......
......@@ -90,7 +90,7 @@ relation ::= expr:a EQUALS expr:b {: RESULT = new Egal(a, b, "", aleft
| expr:a SUPEQUAL expr:b {: RESULT = new SupEgal(a, b, "", aleft, aright); :};
op_una ::= NOT expr:a {: RESULT = new Non(a, "", aleft, aright); :}
| MINUS expr {: :}
| MINUS expr:a {: RESULT = new Moins(a, "", aleft, aright);:}
%prec UMINUS;
operand ::= access:access {: RESULT = access; :}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment