-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscanner.h
124 lines (110 loc) · 2.24 KB
/
scanner.h
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
///////////////////////////////////////////////////////////////////////////////////
// School: Brno University of Technology, Faculty of Information Technology //
// Course: Formal Languages and Compilers //
// Project: IFJ17 //
// Module: Header file of lexical analysis //
// Authors: Kristián Liščinský (xlisci01) //
// Matúš Liščinský (xlisci02) //
// Šimon Stupinský (xstupi00) //
// Vladimír Marcin (xmarci10) //
///////////////////////////////////////////////////////////////////////////////////
#ifndef SCANNER_H
#define SCANNER_H
#include "strlib.h"
//States of finite automaton
typedef enum{
S_START,
S_IDENTIFIER,
S_NUMBER,
S_STRING_NUMBERS,
S_DIV_COM,
S_NOT_EQ,
S_GR_EQ,
S_LESS_EQ,
S_STR
}states_t;
typedef enum {
AS,
DECLARE,
DIM,
DO,
DOUBLE,
ELSE,
END,
T_FUNCTION,
IF,
INPUT,
INTEGER,
LENGTH,
SUBSTR,
ASC,
CHR,
LOOP,
PRINT,
RETURN,
SCOPE,
STRING,
THEN,
WHILE,
AND,
BOOLEAN,
CONTINUE,
ELSEIF,
EXIT,
T_FALSE,
FOR,
NEXT,
NOT,
OR,
SHARED,
STATIC,
ADD,
SUB,
MUL,
DIV,
INT_DIV = 40,
LESS,
GREATER,
LESS_EQ,
GREATER_EQ,
ASSIGNMENT_EQ,
NEQ,
ID,
INT_NUMBER,
DOUBLE_NUMBER,
TEXT,
BACKSLASH,
END_OF_FILE,
COMMA,
LEFT_R_BRACKET,
RIGHT_R_BRACKET,
SEMICOLON,
T_TRUE,
EOL,
DOT
} tokens_t;
//structure of token
typedef struct token_t{
int type; //identification of token
string_t * str; //attribute of token
}token_t;
/**
* @brief Function to get previous token
*/
void ungetToken();
/**
* @brief Function to initialize structure of token
*/
void initToken();
/**
* @brief Function to get next token
*/
token_t *getToken();
/**
* @brief Function to save token
*
* @param type identification of token
* @param string attribute of token
*/
token_t *saveToken(int type, bool string);
#endif