From 78c21f45ee983d08dcab9c302870632dd25546bd Mon Sep 17 00:00:00 2001 From: gallois Date: Thu, 29 Apr 2021 13:12:45 +0200 Subject: [PATCH] =?UTF-8?q?interpreteur=20=C3=A0=20tester=20pour=20pointeu?= =?UTF-8?q?rs=20et=20fonctions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interpreteur/input.txt | 11 +++++++++++ Interpreteur/makefile | 14 ++++++++++++++ Interpreteur/src/instructions.c | 34 +++++++++++++++++++++++++-------- 3 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 Interpreteur/input.txt create mode 100755 Interpreteur/makefile 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