7 * An identifier with semantic meaning is a "symbol".
9 * There's a 1:n relationship: each symbol is always
10 * associated with one identifier, while each identifier
11 * can have one or more semantic meanings due to C scope
14 * The progression is symbol -> token -> identifier. The
15 * token contains the information on where the symbol was
42 enum namespace namespace:8;
44 struct token
*token
; /* Where this symbol was declared */
45 struct symbol
*next_id
; /* Next semantic symbol that shares this identifier */
46 struct symbol
**id_list
; /* Backpointer to symbol list head */
48 struct preprocessor_sym
{
50 struct token
*expansion
;
51 struct token
*arglist
;
54 struct symbol
*next
; /* Next symbol at this level */
56 unsigned long modifiers
;
57 struct symbol
*base_type
;
58 struct symbol
*children
;
59 struct statement
*stmt
;
60 struct symbol_list
*symbol_list
;
66 #define SYM_AUTO 0x0001
67 #define SYM_REGISTER 0x0002
68 #define SYM_STATIC 0x0004
69 #define SYM_EXTERN 0x0008
71 #define SYM_CONST 0x0010
72 #define SYM_VOLATILE 0x0020
73 #define SYM_SIGNED 0x0040
74 #define SYM_UNSIGNED 0x0080
76 #define SYM_CHAR 0x0100
77 #define SYM_SHORT 0x0200
78 #define SYM_LONG 0x0400
79 #define SYM_LONGLONG 0x0800
81 #define SYM_TYPEDEF 0x1000
82 #define SYM_STRUCTOF 0x2000
83 #define SYM_UNIONOF 0x4000
84 #define SYM_ENUMOF 0x8000
86 #define SYM_TYPEOF 0x10000
87 #define SYM_ATTRIBUTE 0x20000
90 extern struct symbol void_type
,
96 /* Basic identifiers */
97 extern struct ident sizeof_ident
,
114 extern struct ident __asm___ident
,
123 #define symbol_is_typename(sym) ((sym)->type == SYM_TYPE)
125 extern struct symbol
*lookup_symbol(struct ident
*, enum namespace);
126 extern void init_symbols(void);
127 extern struct symbol
*alloc_symbol(struct token
*, int type
);
128 extern void show_type(struct symbol
*);
129 extern const char *modifier_string(unsigned long mod
);
130 extern void show_symbol(struct symbol
*);
131 extern void show_type_list(struct symbol
*);
132 extern void show_symbol_list(struct symbol_list
*);
133 extern void add_symbol(struct symbol_list
**, struct symbol
*);
134 extern void bind_symbol(struct symbol
*, struct ident
*, enum namespace);
136 #endif /* SEMANTIC_H */