If Done
This commit is contained in:
parent
18f64a1653
commit
358e98d6d6
2 changed files with 12 additions and 10 deletions
|
@ -49,6 +49,7 @@ void addLine(char* s) {
|
|||
/*inserts the address in case of jumps*/
|
||||
void setJumpLine(int index, int addr) {
|
||||
asmTable[index].jumpLine = addr;
|
||||
printf("\n%d aaaaa %d\n",index,addr);
|
||||
displayASMTable();
|
||||
}
|
||||
|
||||
|
|
21
yacc.y
21
yacc.y
|
@ -48,6 +48,7 @@ void yyerror (const char *);
|
|||
%type <addr> Declaration
|
||||
%type <addr> NbOrVariable
|
||||
%token <nbInt> tIF
|
||||
%type <nbInt> IfStatement1
|
||||
|
||||
%start Program
|
||||
%%
|
||||
|
@ -100,17 +101,17 @@ NumericalOperator : tLE | tGE | tEQ | tNE | tLT | tGT;
|
|||
Operation: tADD | tMUL | tSUB | tDIV;
|
||||
*/
|
||||
|
||||
IfStatement : tIF Condition {
|
||||
int ligne =getCurrentLineNumber(); addLine("JMPF"); $1 = ligne ;
|
||||
} InnerBlock {
|
||||
int current = getCurrentLineNumber(); printf("current Line %d", current); addLine("JMP"); $1 = current + 1; setJumpLine($1, current+1);
|
||||
} tELSE InnerBlock {
|
||||
int current = getCurrentLineNumber() ; setJumpLine($1, current);
|
||||
IfStatement1 : %empty {
|
||||
int ligne =getCurrentLineNumber(); addLine("JMPF"); $<nbInt>$ = ligne ;
|
||||
};
|
||||
|
||||
IfStatement : tIF Condition IfStatement1 InnerBlock tELSE {
|
||||
int current = getCurrentLineNumber(); printf("current Line %d", current); addLine("JMP"); $1 = current; setJumpLine($3, current+1);
|
||||
} InnerBlock {
|
||||
int current = getCurrentLineNumber() ; printf("%d, %d",$1, current);setJumpLine($1, current);
|
||||
}
|
||||
| tIF Condition {
|
||||
int ligne =getCurrentLineNumber(); addLine("JMPF"); $1 = ligne ;
|
||||
} InnerBlock {
|
||||
int current = getCurrentLineNumber(); printf("current Line %d", current); setJumpLine($1, current);
|
||||
| tIF Condition IfStatement1 InnerBlock {
|
||||
int current = getCurrentLineNumber(); printf("current Line %d", current); setJumpLine($3, current);
|
||||
};
|
||||
|
||||
// todo it does either one of the two but not the two
|
||||
|
|
Loading…
Reference in a new issue