From 9cde0cf1dfaa1c4230347fd20ee5d640f832584c Mon Sep 17 00:00:00 2001 From: SinusFox Date: Tue, 9 May 2023 15:25:14 +0200 Subject: [PATCH] moved lexer functions to Lexer.c and included Lexer.c --- Exercise 2/C/Lexer.c | 31 +++++++++++++++++++++++++++++++ Exercise 2/C/TestLexer.c | 33 ++------------------------------- 2 files changed, 33 insertions(+), 31 deletions(-) create mode 100644 Exercise 2/C/Lexer.c diff --git a/Exercise 2/C/Lexer.c b/Exercise 2/C/Lexer.c new file mode 100644 index 0000000..d29ce55 --- /dev/null +++ b/Exercise 2/C/Lexer.c @@ -0,0 +1,31 @@ +#include "Lexer.h" + +int start(char* src) { + // if (src != NULL) { + // return _GET_NEXT_CHARACTER_; + // } else { + // return _STOP_; + // } + + return _STOP_; // placeholder +} + +int getNextCharacter() { + return _STOP_; // placeholder +} + +int readIdentifier() { + return _STOP_; // placeholder +} + +int readNumLit() { + return _STOP_; // placeholder +} + +int readOperator() { + return _STOP_; // placeholder +} + +int readPunctuation() { + return _STOP_; // placeholder +} diff --git a/Exercise 2/C/TestLexer.c b/Exercise 2/C/TestLexer.c index 26fef6f..8fdb189 100644 --- a/Exercise 2/C/TestLexer.c +++ b/Exercise 2/C/TestLexer.c @@ -1,35 +1,6 @@ #include #include "Lexer.h" - -int start(char* sourcecode) { - // if (sourcecode != NULL) { - // return _GET_NEXT_CHARACTER_; - // } else { - // return _STOP_; - // } - - return _STOP_; // placeholder -} - -int getNextCharacter() { - return _STOP_; // placeholder -} - -int readIdentifier() { - return _STOP_; // placeholder -} - -int readNumLit() { - return _STOP_; // placeholder -} - -int readOperator() { - return _STOP_; // placeholder -} - -int readPunctuation() { - return _STOP_; // placeholder -} +#include "Lexer.c" int main() { char* sourcecode = "Hello World the second - I coded this before. So yeah, FOXES ARE SUPERIOR.\nBut the professor wants us to write the following: \"index = 2 * count + 42;\"\n\n"; @@ -60,7 +31,7 @@ int main() { } } while (lexer_state != _STOP_); - printf("Lexer exited with code "); + // printf("Lexer exited with code "); // printf(lexer_state); return 0;