diff --git a/Exercise 2/C/Lexer.h b/Exercise 2/C/Lexer.h new file mode 100644 index 0000000..8aee3bf --- /dev/null +++ b/Exercise 2/C/Lexer.h @@ -0,0 +1,17 @@ +/* symbols */ +#define _LETTER_ 1 +#define _DIGIT_ 2 +#define _OPERATOR_ 3 +#define _PUNCTUATION_ 4 +#define _END_OF_LINE_ 5 +#define _UNKNOWN_ 10 + +/* state */ +#define _START_ 100 +#define _GET_NEXT_CHARACTER_ 110 +#define _READ_IDENTIFIER_ 120 +#define _READ_NUM_LIT_ 130 +#define _READ_OPERATOR_ 140 +#define _READ_PUNCTUATION_ 150 +#define _STOP_ 999 +#define _ERROR_ 1000 diff --git a/Exercise 2/C/TestLexer.c b/Exercise 2/C/TestLexer.c new file mode 100644 index 0000000..7212b40 --- /dev/null +++ b/Exercise 2/C/TestLexer.c @@ -0,0 +1,8 @@ +#include +#include "Lexer.h" + +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;\""; + printf(sourcecode); + return 0; +}