diff --git a/Interpreteur/input.txt b/Interpreteur/input.txt new file mode 100644 index 0000000..c5e310b --- /dev/null +++ b/Interpreteur/input.txt @@ -0,0 +1,11 @@ +AFC 0 1 +AFC 10 20 +ADD 0 0 10 +AFC 1 8888 +SUP 2 0 1 +JMF 2 7 +PRI 1 +PRI 0 +CALL +COPR +RET diff --git a/Interpreteur/makefile b/Interpreteur/makefile new file mode 100755 index 0000000..d5b9ffa --- /dev/null +++ b/Interpreteur/makefile @@ -0,0 +1,14 @@ +SRCC:= ./src/*.c + +all: interpreter + +interpreter: ./src/interpreter.y ./src/interpreter.l ./src/instructions.c + yacc -d ./src/interpreter.y + lex ./src/interpreter.l + gcc lex.yy.c y.tab.c ./src/instructions.c -Isrc -o interpreter + +run: interpreter + ./interpreter < input.txt + +clean: + rm -f lex.yy.c interpreter y.tab.h y.tab.c *.o diff --git a/Interpreteur/src/instructions.c b/Interpreteur/src/instructions.c index 5baa24b..2e78f15 100755 --- a/Interpreteur/src/instructions.c +++ b/Interpreteur/src/instructions.c @@ -39,6 +39,14 @@ void push(int arg){ } } +void print_stack(int tab[], int taille){ + for (int i=0; i