From f7be91496f388402b8f2e924e2efdef17a2181ea Mon Sep 17 00:00:00 2001 From: Zhengli Wang Date: Sun, 1 Oct 2023 13:36:59 +0200 Subject: [PATCH] modifications --- .vscode/settings.json | 3 ++- src/modules/instructions/instructions.c | 2 +- src/modules/translating/translating.c | 5 +++++ tests/testInstructionList.c | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3cac6c3..7c0d616 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -12,7 +12,8 @@ "files.associations": { "instructionlist.h": "c", "cstdio": "c", - "cwchar": "c" + "cwchar": "c", + "instructions.h": "c" }, "C_Cpp.default.configurationProvider": "ms-vscode.makefile-tools" } \ No newline at end of file diff --git a/src/modules/instructions/instructions.c b/src/modules/instructions/instructions.c index ea0e870..c912257 100644 --- a/src/modules/instructions/instructions.c +++ b/src/modules/instructions/instructions.c @@ -1,6 +1,6 @@ #include "instructions.h" -InstructionType instructionChar(const char instruction) +inline InstructionType instructionChar(const char instruction) { switch(instruction) { diff --git a/src/modules/translating/translating.c b/src/modules/translating/translating.c index 1319186..bfdd380 100644 --- a/src/modules/translating/translating.c +++ b/src/modules/translating/translating.c @@ -59,12 +59,17 @@ char * action(InstructionType type, size_t repeatCount) case OUTPUT: snprintf(buffer, CODELINE_BUF_SIZE, "putchar(*ptr);"); break; + case INPUT: + snprintf(buffer, CODELINE_BUF_SIZE, "getchar(ptr);"); + break; case CONDITIONAL_START: snprintf(buffer, CODELINE_BUF_SIZE, "while(*ptr){"); break; case CONDITIONAL_END: snprintf(buffer, CODELINE_BUF_SIZE, "}"); break; + default: + break; } return buffer; } \ No newline at end of file diff --git a/tests/testInstructionList.c b/tests/testInstructionList.c index 24bcd9b..b5053f8 100644 --- a/tests/testInstructionList.c +++ b/tests/testInstructionList.c @@ -25,6 +25,7 @@ #include #include #include "../src/modules/instructionList/instructionList.h" +#include "../src/modules/instructions/instructions.h" int main(void) { InstructionList * testInstructionList = newInstructionList();