Interpreteur non sécurisé terminé
This commit is contained in:
parent
9c38352e61
commit
95409eb5bf
2 changed files with 10 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
|||
|
||||
%{
|
||||
#include "../Tables/tables.h"
|
||||
#include <stdlib.h>
|
||||
%}
|
||||
|
||||
%token tMUL tDIV tADD tSUB tINF tSUP tEQU
|
||||
|
@ -65,7 +66,13 @@ Instruction : tSTOP tNB {add_instruction(STOP, $2, 0, 0);};
|
|||
|
||||
%%
|
||||
|
||||
int main(void) {
|
||||
int main(int argc, char * argv[]) {
|
||||
if (argc != 2) {
|
||||
printf("Specifiez le fichier à interpreter");
|
||||
exit(2);
|
||||
}
|
||||
extern FILE * yyin;
|
||||
yyin = fopen(argv[1], "r");
|
||||
yyparse();
|
||||
execute();
|
||||
return 0;
|
||||
|
|
|
@ -181,8 +181,10 @@ void execute() {
|
|||
eip = programme[eip].param1 - 1;
|
||||
|
||||
} else if (programme[eip].instruction == RET) {
|
||||
int lastebp = ebp;
|
||||
eip = mem[check_adresse(ebp - 1)] - 1;
|
||||
ebp = mem[check_adresse(ebp - 2)];
|
||||
mem[check_adresse(lastebp - 2)] = mem[check_adresse(lastebp)];
|
||||
|
||||
} else if (programme[eip].instruction == STOP) {
|
||||
if (programme[eip].param1 == 0) {
|
||||
|
|
Loading…
Reference in a new issue