diff options
author | Galin Simeonov <gts@volconst.com> | 2021-05-31 22:02:10 +0300 |
---|---|---|
committer | Galin Simeonov <gts@volconst.com> | 2021-07-15 18:00:15 +0300 |
commit | 255a49ba5a41b3854dbdfebdec75fb6229450507 (patch) | |
tree | 616ea5786cb91d03ef609d32b402941dc30e926b /src/frontend/lexer.h | |
parent | f768d9bdb84e846d89aac66a4f3433a44241c298 (diff) | |
download | MEGATRON-255a49ba5a41b3854dbdfebdec75fb6229450507.tar.gz |
added cmake file
Diffstat (limited to 'src/frontend/lexer.h')
-rw-r--r-- | src/frontend/lexer.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/frontend/lexer.h b/src/frontend/lexer.h new file mode 100644 index 0000000..320146c --- /dev/null +++ b/src/frontend/lexer.h @@ -0,0 +1,54 @@ +#ifndef LEXER_H +#define LEXER_H +#include <ctype.h> //isspace +#include <program.h> +#include <queue.h> +#include <map.h> + +struct Translation_Data; +struct Source; + +enum Keyword +{ + KW_MACHINE, + KW_FROM, + 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, + KW_STATES, + KW_EVENTS, + KW_EVENT, + KW_EXECUTE, + KW_TRANSITIONS, + KW_COMMA, +}; +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* 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 push_token_into_map(struct token *token,struct Map *map,void *thing); + + +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 |