diff options
author | Adam Branes <adam@adam> | 2021-05-02 17:46:29 +0300 |
---|---|---|
committer | Galin Simeonov <gts@volconst.com> | 2021-07-15 18:00:07 +0300 |
commit | 679cbe58c4e53f0163588a7731154f3afe2d25aa (patch) | |
tree | a2dbc2317a3f107899d60f5e68c8d6cf8d27e146 /lexer.h | |
parent | a3e36c1918e63761dfc4d2221cca3636b98e93aa (diff) | |
download | MEGATRON-679cbe58c4e53f0163588a7731154f3afe2d25aa.tar.gz |
lexer formed
Diffstat (limited to 'lexer.h')
-rw-r--r-- | lexer.h | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -1,8 +1,12 @@ #ifndef LEXER_H #define LEXER_H +#include <ctype.h> //isspace #include <program.h> #include <queue.h> +struct Translation_Data; +struct Source; + enum Keyword { KW_MACHINE, @@ -11,16 +15,33 @@ enum Keyword KW_TO, KW_ON, KW_ID, + KW_STRING, + KW_NOP, + KW_EOF, + KW_OPEN_SQUARE, + KW_CLOSE_SQUARE, + KW_PIPE, + KW_SEMI_COLUMN, + KW_STARTING, }; struct token { size_t size; enum Keyword type; char *data; + size_t row; + size_t column; }; + void lex(struct Queue *token_destination,struct Source *src,struct Translation_Data *translation_data); -struct token* get_token(char *data,size_t size); -void delete_token(struct token *token); +struct token* lex_step(struct Source *src,struct Translation_Data *translation_data); +struct token* get_token(char *data,size_t size,enum Keyword type,size_t row,size_t column); +void skip_white_space(struct Source *src); + +void delete_token(struct token *token); +/*:X*/ +static char check_and_move_if_on_word(char *word,size_t word_size,struct Source *src,char needs_space_after); + #endif |