SayoriOS 0.3.3

eBat.h
1 #ifndef DEBUG
2 #define bat_debug(M, ...) \
3
4 #endif
5
6
7 #ifdef DEBUG
8 #define bat_debug(M, ...) \
9 qemu_log("[%s:%d] " M "", __FILE__, __LINE__, ##__VA_ARGS__);
10 #endif // DEBUG
11
12
13 #ifndef EBAT_H
14 #define EBAT_H
15
16 #include <stdarg.h>
17 #define bat_fatalerror(Line, M, ...) \
18 qemu_err("\033[31;1mError on line %d: " M "\033[0m\n", Line, ##__VA_ARGS__); \
19 tty_printf("Error on line %d: " M "\n", Line, ##__VA_ARGS__);
20
21 #define BAT_VERSION "1.2.9.3"
22
23 typedef enum {
24 BEC_OK = 0,
25 BEC_MEMORY = 1,
26 } BAT_ERROR_CODE;
27
28 typedef enum {
29 BAT_TOKEN_TYPE_ECHO,
30 BAT_TOKEN_TYPE_IF,
31 BAT_TOKEN_TYPE_SET,
32 BAT_TOKEN_TYPE_TRUE,
33 BAT_TOKEN_TYPE_FALSE,
34 BAT_TOKEN_TYPE_EXIT,
35 BAT_TOKEN_TYPE_DEBUG,
36
37 BAT_TOKEN_TYPE_GOTO,
38 BAT_TOKEN_TYPE_PAUSE,
39
40 BAT_TOKEN_TYPE_NOT,
41 BAT_TOKEN_TYPE_EXIST,
42 BAT_TOKEN_TYPE_ISSET,
43 // Операторы сравнения
44 BAT_TOKEN_TYPE_EQUAL,
45 BAT_TOKEN_TYPE_NOT_EQUAL,
46 BAT_TOKEN_TYPE_GREATER,
47 BAT_TOKEN_TYPE_LESS,
48 BAT_TOKEN_TYPE_LESS_EQUAL,
49 BAT_TOKEN_TYPE_GREATER_EQUAL,
50
51 // Операторы циклов
52 BAT_TOKEN_TYPE_FOR,
53 BAT_TOKEN_TYPE_WHILE,
54 BAT_TOKEN_TYPE_DO,
55 BAT_TOKEN_TYPE_IN,
56 BAT_TOKEN_TYPE_STEP,
57 BAT_TOKEN_TYPE_BREAK,
58 BAT_TOKEN_TYPE_CONTINUE,
59
60 BAT_TOKEN_TYPE_STRING,
61 BAT_TOKEN_TYPE_NUMBER,
62 BAT_TOKEN_TYPE_OPERATOR,
63 BAT_TOKEN_TYPE_VARIABLE,
64 BAT_TOKEN_TYPE_COMMENT,
65 BAT_TOKEN_TYPE_START,
66 BAT_TOKEN_TYPE_ALIAS,
67 BAT_TOKEN_TYPE_UNKNOWN,
68 BAT_TOKEN_TYPE_RUN
69 } BAT_TOKEN_TYPE;
70
71
72 typedef struct BAT_TOKEN {
73 BAT_TOKEN_TYPE type;
74 char* value;
75 } BAT_TOKEN_T;
76
77 typedef struct BAT_GROUP {
78 int Size;
79 int Capacity;
80 size_t* Tokens;
81 } BAT_GROUP_T;
82
83 typedef struct Bat_GOTO {
84 char* Identifier; // Строковый идентификатор
85 int Line;
86 int Size;
87 int Capacity;
88 BAT_GROUP_T** Groups;
89 } BAT_GoTo_T;
90
91 typedef struct BAT {
92 int Echo;
93 int ErrorCode;
94 int Debug;
95 int Size;
96 int Capacity;
97 size_t* Group;
98 int Size_GT;
99 int Capacity_GT;
100 size_t* GoTo;
101 BAT_GoTo_T* CurGoTo;
102 } BAT_T;
103
104 char* bat_toLower(char* str);
105 BAT_T* bat_create_session();
106 void bat_add_token(BAT_GROUP_T* bat, size_t element);
107 BAT_TOKEN_T* bat_create_token(BAT_TOKEN_TYPE type, char* value);
108 char* bat_debug_type(BAT_TOKEN_TYPE Type);
109 BAT_TOKEN_TYPE bat_parse_token(char* str);
110 BAT_GROUP_T* bat_parse_line(BAT_T* bat, char* Line);
111 BAT_T* bat_parse_string(char* String);
112
113 #endif //EBAT_H
BAT_GROUP
Definition: eBat.h:77
BAT_TOKEN
Definition: eBat.h:72
BAT
Definition: eBat.h:91
Bat_GOTO
Definition: eBat.h:83