Ajout STOP avec arg
This commit is contained in:
parent
1ec1d418b7
commit
f4356f9d58
7 changed files with 945 additions and 932 deletions
|
@ -1,19 +1,10 @@
|
|||
int g(int y[]){
|
||||
int u;
|
||||
y[1] = 2;
|
||||
return 15;
|
||||
}
|
||||
|
||||
|
||||
int fonction(int p[]){
|
||||
g(p);
|
||||
return 1;
|
||||
int fonction(int p){
|
||||
int y = p*3;
|
||||
return y;
|
||||
}
|
||||
|
||||
int main(){
|
||||
int b[2];
|
||||
int c = fonction(b);
|
||||
c = get();
|
||||
b[0] = 25;
|
||||
printf(b[0]);
|
||||
int a;
|
||||
int c = fonction(3);
|
||||
stop(3);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ yyerror (char const *s)
|
|||
"[" { return tOCROCH;}
|
||||
"]" { return tCCROCH;}
|
||||
"get" { return tGET;}
|
||||
"stop" { return tSTOP;}
|
||||
|
||||
|
||||
[0-9]+ { yylval.nombre = atoi(yytext); return tNB; }
|
||||
|
|
1846
Lex_Yacc/as.dot
1846
Lex_Yacc/as.dot
File diff suppressed because it is too large
Load diff
|
@ -30,7 +30,7 @@ int nbs_instructions_to_patch[10];
|
|||
%token tMUL tDIV tADD tSUB tEQ
|
||||
%token<nombre> tNB tNBEXP
|
||||
%token<id> tID
|
||||
%token tPRINTF tGET
|
||||
%token tPRINTF tGET tSTOP
|
||||
%token tERROR
|
||||
%token<nombre> tIF tWHILE tELSE
|
||||
%token tRETURN
|
||||
|
@ -69,6 +69,8 @@ Fonction : Main {print_fonctions();};
|
|||
|
||||
Get : tGET tOBRACE tCBRACE {int addr = push("0_TEMPORARY", 0, integer); add_operation(GET,addr,0,0); $$ = addr;};
|
||||
|
||||
Stop : tSTOP tOBRACE tNB tCBRACE {add_operation(STOP,$3,0,0);};
|
||||
|
||||
Return : tRETURN E tPV {add_operation(COP,0,$2,0); pop(); };
|
||||
|
||||
Args : Arg ArgSuite {$$ = $1 + $2; printf("Les arguments de la fonctions vont avoir une taille dans la pile de : %d\n",$$);};
|
||||
|
@ -90,6 +92,7 @@ Instruction : Invocation tPV{pop();};
|
|||
Instruction : If {};
|
||||
Instruction : While {};
|
||||
Instruction : Return {};
|
||||
Instruction : Stop tPV {};
|
||||
|
||||
|
||||
Invocation : tID tOBRACE {struct fonction_t fonc = get_fonction($1);}
|
||||
|
|
2
Makefile
2
Makefile
|
@ -21,7 +21,7 @@ clean_Lex_Yacc:
|
|||
@rm -f Lex_Yacc/as.output Lex_Yacc/as.tab.* Lex_Yacc/lex.yy.*
|
||||
|
||||
build : clean build_Symboles build_Instructions build_Lex_Yacc build_Fonctions
|
||||
gcc Lex_Yacc/as.tab.o Lex_Yacc/lex.yy.o Tables/Instructions/tab_instruc.o Tables/Symboles/table_symboles.o Tables/Fonctions/tab_fonctions.o -ly -o rondoudou_gcc
|
||||
gcc Lex_Yacc/as.tab.o Lex_Yacc/lex.yy.o Tables/Instructions/tab_instruc.o Tables/Symboles/table_symboles.o Tables/Fonctions/tab_fonctions.o -ll -o rondoudou_gcc
|
||||
|
||||
build_Symboles: clean_Symboles
|
||||
gcc -c Tables/Symboles/table_symboles.c -o Tables/Symboles/table_symboles.o
|
||||
|
|
Binary file not shown.
|
@ -77,7 +77,7 @@ char * get_asm_line_from_op(struct operation_t op){
|
|||
sprintf(buffer,"GET %d\n",op.arg1);
|
||||
break;
|
||||
case (STOP):
|
||||
sprintf(buffer,"STOP\n");
|
||||
sprintf(buffer,"STOP %d\n", op.arg1);
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
|
|
Loading…
Reference in a new issue