aboutsummaryrefslogtreecommitdiffstats
path: root/src/frontend/lexer.h
blob: 266beea798c2c3ff985e90a4331dfb46739fbe15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#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_OPEN_NORMAL,
	KW_CLOSE_NORMAL,
	KW_PIPE,
	KW_SEMI_COLUMN,
	KW_STARTING,
	KW_STATES,
	KW_EVENTS,
	KW_EVENT,
	KW_EXECUTE,
	KW_TRANSITIONS,
	KW_COMMA,
	KW_DOT,
	KW_AND,
	KW_OR,
	KW_NOT,
};
struct token
{
	enum Keyword type;
	size_t size;
	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 id_token_to_upper_case(struct token *token);


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