-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse_hfile.h
71 lines (63 loc) · 2.64 KB
/
parse_hfile.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
/*
* parse_hfile.h
*
* Created on: 22 дек. 2017 г.
* Author: Иван
*/
#ifndef PARSE_HFILE_H_
#define PARSE_HFILE_H_
enum statements
{
ST_NONE = 0, // Не выражение
ST_PREPROC, // Выражение препроцессора (#)
ST_DEFINE_NAME, // имя считываемого define
ST_DEFINE_VALUE, // значение считываемого define
ST_INCLUDE_VALUE, // значение считываемого include
ST_TYPEDEF_STRUCT, // Выражение typedef struct
ST_TS_OPEN, // ожидания символа {
ST_FIELD, // считывание полей структуры
ST_TS_CLOSE // ожидания имени структуры
};
enum comments
{
COMMENT_NONE = 0, // Не коментарий
COMMENT_START, // предположенеи на начало коментария
COMMENT_1, // коментарий вида /* */
COMMENT_1_END, // коментарий вида /* */ (предположение на конец коментария)
COMMENT_2 // комментарий вида //
};
enum fields
{
F_TYPE = 0, // тип переменной
F_NAME, // имя переменной
F_INDEX // индексы ( если они есть)
};
typedef struct
{
enum statements s; // состояния
enum comments c; // комментарии
enum fields f; // если обрабатываются поля структуры
char ch; // текущий считываемый символ
char word[MAX_STR_SIZE];
int wi; // индекс записи символа в слово
int in_word;
char file_path[MAX_LEN_FILE_PATH];
char file_name[MAX_LEN_FILE_PATH];
size_t max_len_word; // максимальная длина считываемого слова (или слов в случае коментариев)
int comment_s; // признак для сохранения коментария к структуре
int pz; // признак запятой
} read_hfile_t;
typedef struct
{
read_hfile_t h[MAX_DEPTH];
int depth;
} read_hfiles_t;
int write_in_word(read_hfile_t *h);
int delete_with_word(read_hfile_t *h);
int free_word(read_hfile_t *h);
int process_word(all_structs_t *all_s, read_hfiles_t *hs, char *file_dir);
int read_h_file(all_structs_t *all_s, read_hfiles_t *hs, char *file_dir, char *file_name);
int calc_sizes(all_structs_t *all_s, config_t *c);
int calc_indexes(all_structs_t *all_s);
int read_file_types(config_t *c, all_structs_t *all_s);
#endif /* PARSE_HFILE_H_ */