Skip to content
Snippets Groups Projects
Commit 76934276 authored by christia.agodomou's avatar christia.agodomou
Browse files

ecrire fait

parent 8363ac04
No related branches found
No related tags found
No related merge requests found
/*
* Represent an equal comparaison expression node inside the AST.
*/
public class Ecrire extends Instruction {
private Expression source;
/**
* Constructor
*/
public Ecrire(Expression source, String fl, int line, int col) {
super(fl, line, col);
this.source = source;
}
/**
* Get the binary operator
*/
public Expression getSource() {
return this.source;
}
/**
* Accepts a AST visitor
*/
Object accept(ASTVisitor visitor){
return visitor.visit(this);
}
}
...@@ -4,4 +4,6 @@ debutprg ...@@ -4,4 +4,6 @@ debutprg
c = c * 2; c = c * 2;
b = 3; b = 3;
d = c <> b; d = c <> b;
ecrire "oui";
finprg finprg
...@@ -26,7 +26,7 @@ public interface ASTVisitor { ...@@ -26,7 +26,7 @@ public interface ASTVisitor {
Object visit(Diff node); Object visit(Diff node);
Object visit(Division node); Object visit(Division node);
// Object visit(Ecrire node); Object visit(Ecrire node);
Object visit(Egal node); Object visit(Egal node);
Object visit(Et node); Object visit(Et node);
......
...@@ -40,7 +40,7 @@ public class ByteCodeGenerator implements ASTVisitor { ...@@ -40,7 +40,7 @@ public class ByteCodeGenerator implements ASTVisitor {
return null; return null;
} }
// public Object visit(Ecrire node) { return null; } public Object visit(Ecrire node) { return null; }
public Object visit(Egal node) { public Object visit(Egal node) {
return null; return null;
......
...@@ -42,7 +42,7 @@ public class SemanticAnalyzer implements ASTVisitor { ...@@ -42,7 +42,7 @@ public class SemanticAnalyzer implements ASTVisitor {
return null; return null;
} }
// public Object visit(Ecrire node) { return null; } public Object visit(Ecrire node) { return null; }
public Object visit(Egal node) { public Object visit(Egal node) {
return null; return null;
......
...@@ -15,7 +15,7 @@ public class SourceCodeGenerator implements ASTVisitor { ...@@ -15,7 +15,7 @@ public class SourceCodeGenerator implements ASTVisitor {
/** /**
* Depth level (tabulations) * Depth level (tabulations)
*/ */
private int level = 0; private int level = 1;
/** /**
* If we are currently declaring function parameters * If we are currently declaring function parameters
*/ */
...@@ -131,13 +131,13 @@ public class SourceCodeGenerator implements ASTVisitor { ...@@ -131,13 +131,13 @@ public class SourceCodeGenerator implements ASTVisitor {
node.getDroite().accept(this); node.getDroite().accept(this);
return null; return null;
} }
//
// public Object visit(Ecrire node){ public Object visit(Ecrire node){
// code += "ecrire "; code += "ecrire ";
// node.getSource().accept(this); node.getSource().accept(this);
// code += ";"; code += ";";
// return null; return null;
// } }
public Object visit(Egal node) { public Object visit(Egal node) {
node.getGauche().accept(this); node.getGauche().accept(this);
......
...@@ -24,7 +24,7 @@ non terminal Expression expr, access, operand; ...@@ -24,7 +24,7 @@ non terminal Expression expr, access, operand;
non terminal for_instr; non terminal for_instr;
non terminal while_instr; non terminal while_instr;
non terminal cond_instr; non terminal cond_instr;
non terminal write_instr; non terminal Ecrire write_instr;
non terminal read_instr; non terminal read_instr;
non terminal Instruction instr; non terminal Instruction instr;
non terminal Affectation assign; non terminal Affectation assign;
...@@ -117,7 +117,7 @@ instr_lst ::= {: RESULT = new ArrayList(); :} ...@@ -117,7 +117,7 @@ instr_lst ::= {: RESULT = new ArrayList(); :}
:}; :};
instr ::= assign:inst {: RESULT = inst; :} instr ::= assign:inst {: RESULT = inst; :}
| write_instr {: :} | write_instr:e {: RESULT = e; :}
| read_instr {: :} | read_instr {: :}
| cond_instr {: :} | cond_instr {: :}
| while_instr {: :} | while_instr {: :}
...@@ -125,8 +125,8 @@ instr ::= assign:inst {: RESULT = inst; :} ...@@ -125,8 +125,8 @@ instr ::= assign:inst {: RESULT = inst; :}
assign ::= access:dest EQUAL:e expr:src SEMICOLON {: RESULT = new Affectation(dest, src, "", eleft, eright); :}; assign ::= access:dest EQUAL:e expr:src SEMICOLON {: RESULT = new Affectation(dest, src, "", eleft, eright); :};
write_instr ::= WRITE expr SEMICOLON {: :} write_instr ::= WRITE expr:a SEMICOLON {: RESULT = new Ecrire(a, "", aleft, aright); :}
| WRITE STRINGCONST SEMICOLON {: :}; | WRITE STRINGCONST:b SEMICOLON {: RESULT = new Ecrire(new Chaine(b, "",bleft, bright), "", bleft, bright); :};
read_instr ::= READ IDENT SEMICOLON {: :}; read_instr ::= READ IDENT SEMICOLON {: :};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment