This repository has been archived by the owner on Feb 1, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathscanner.h
117 lines (97 loc) · 2.43 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
/**
* Predmet: IFJ / IAL
* Projekt: Implementace interpretu imperativniho jazyka IFJ13
* Tym: 099
* Varianta: a/2/I
* Soubor: scanner.h
* Autori: Vlcek Michael <[email protected]>
* Svacek Radim <[email protected]>
* Blanco Roman <[email protected]>
* Micka Vojtech <[email protected]>
* Wolfert Richard <[email protected]>
*/
#ifndef SCANNER_H_INCLUDED
#define SCANNER_H_INCLUDED
#include <stdio.h>
#include <stdlib.h>
#define ALLOC_SIZE_BASE 8
#define RET_OK 0
/////////////////////////////////////
//Struktura, pomocí které se bude vracet token
/////////////////////////////////////
typedef struct{
char *strg;
int alok_velikost;
int konec;
}string;
/////////////////////////////////////
//Výčtový typ pro návratové hodnoty jednotlivých tokenů
/////////////////////////////////////
enum states{
start = 1,
php_entry,
///////////////
/////Základ
identificator,
kw_if,
kw_else,
kw_while,
kw_function,
kw_return,
const_true,
const_false,
const_null,
type_int,
type_double,
type_string,
type_boolean,
type_null,
type_undef,
type_end_par,
variable,
///////////////
/////Čísla a typ čísla (asi je to jedno, o jaký jde typ -> možno zredukovat)
int_num = 20, // int
double_num, // doube
double_num_exp, // double
///////////////
/////Řetězec a konkatenace
string_literal = 30, // "abcd"
concatenate, // .
///////////////
/////Logicke operatory
equal = 40, // ===
not_equal, // !==
assign, // =
less, // <
less_equal, // <=
greater_equal, // >=
greater, // >
///////////////
/////Komentář
comment = 50, // // or /**/
///////////////
/////Aritmetika
plus = 60, // +
minus, // -
multiply, // *
divide, // /
///////////////
/////Závorky a středníky
left_braces = 70, // {
right_braces, // }
left_parent, // (
right_parent, // )
comma, // ,
semicolon, // ;
php_entry_wrong
};
int init_string(string *s);
int add_string(string *s, char add);
void free_string(string *s);
int del_string(string *s);
int is_keyword(char* string);
int is_const(char* string);
int is_type(char* string);
int get_token(FILE *f, string *str);
#endif