Lexer using struct

This commit is contained in:
SinusFox
2023-06-06 15:30:02 +02:00
parent a9baf4f223
commit 6827ad66c1
4 changed files with 59 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
/* 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
// lexer struct
struct Lexer_s {
int state;
char* source_code;
char** current_pos;
};
// typedef
typedef struct Lexer_s Lexer_t;
// methods
void init_Lexer(Lexer_t*, char*);
void run_Lexer(Lexer_t*);