-
Notifications
You must be signed in to change notification settings - Fork 3
/
declarations.h
executable file
·62 lines (52 loc) · 1.72 KB
/
declarations.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
/* declarations.h by William Ho */
#ifndef DECLARATIONS_H
#define DECLARATIONS_H
enum spec_type {
TS /* type specifier */,
SC /* storage class */,
TQ /* type qualifier */
};
enum type_specs {
TS_VOID, TS_CHAR, TS_SHORT, TS_INT, TS_LONG,
TS_FLOAT, TS_DOUBLE, TS_BOOL, TS_COMPLEX,
TS_STRUCT, TS_ENUM, TS_TYPENAME,
TS_SIGNED, TS_UNSIGNED,
TS_COUNT
};
enum storage_classes {
SC_AUTO, SC_TYPEDEF, SC_EXTERN, SC_STATIC, SC_REGISTER, SC_COUNT
};
enum type_quals {
TQ_CONST, TQ_RESTRICT, TQ_VOLATILE, TQ_COUNT
};
struct decl_spec {
char type;
char storage;
char qualifier;
struct generic_node *node; // for structs, enums, typedefs
struct decl_spec *next; // next decl spec in the list
};
struct declarator {
struct generic_node *top, *deepest;
struct declarator *next; // Next declarator in list
};
struct declarator_list {
struct declarator *leftmost, *rightmost;
};
struct generic_node;
struct symtable;
struct decl_spec *new_spec(char which, char val);
struct decl_spec *new_typename_spec(char *typename);
struct declarator *new_declarator(struct generic_node *n);
void add_declarator(struct declarator *d, struct generic_node *n);
void new_declarator_list(struct declarator_list *dl, struct declarator *d);
void add_declarator_list(struct declarator_list *to, struct declarator_list *from, struct declarator *d);
void new_declaration(struct decl_spec *d, struct declarator_list *dl);
void new_decl(struct decl_spec *d, struct declarator_list *dl, struct symtable *st);
void print_node_info(struct generic_node *node);
void print_node_info_r(struct generic_node *node);
char *check_decl_specs(struct decl_spec *spec);
int check_storage_classes(char *sc);
int check_type_specs(char *ts);
void reset_storage_flags(char *sc);
#endif