-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbase.h
More file actions
executable file
·73 lines (62 loc) · 1.4 KB
/
base.h
File metadata and controls
executable file
·73 lines (62 loc) · 1.4 KB
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
#ifndef BASE_H
#define BASE_H
#define VOID(var) ((void *) &var)
#define IS_LITERAL(k) (k == BOOL_LITERAL || \
k == CHAR_LITERAL || \
k == INT_LITERAL)
typedef enum {
FALSE = 0,
TRUE
} bool;
typedef enum TypeEnum {
ERROR = -1,
VOID,
INTEGER,
BOOLEAN,
CHAR
} Type;
typedef enum KindEnum {
NONE_KIND = -1,
PROGRAM,
PROGRAM_DECL,
VARDECL_LIST,
VARDECL,
IDENT_LIST,
PROCFUNC_LIST,
PROCEDURE,
FUNCTION,
PARAM_LIST,
PARAMETER,
STATEMENT_LIST,
PRINTINT_STMT,
PRINTCHAR_STMT,
PRINTBOOL_STMT,
PRINTLINE_STMT,
ASSIGNMENT_STMT,
IF_STMT,
WHILE_STMT,
FOR_STMT,
REL_EXPR,
ADD_EXPR,
MUL_EXPR,
NOTFACTOR,
CALL,
CALLPARAM_LIST,
CALLPARAM,
//IDENTIFIER defined as token
//INT_LITERAL, BOOL_LITERAL, CHAR_LITERAL defined as tokens
} Kind;
typedef union {
int integer;
bool boolean;
char character;
} Value;
char *type_get_lexeme(Type type);
Type type_get_from_lexeme(const char *lexeme);
void value_get(Value *value, Type type, void *val);
void value_set(Value *value, Type type, void *val);
void value_set_from_int(Value *value, int val);
void value_set_from_bool(Value *value, bool val);
void value_set_from_char(Value *value, char val);
void value_print(FILE *file, Value *value, Type type);
#endif // BASE_H