KCC - Kayte C Compiler 1.10.0
A C compiler implementation with preprocessor, lexer, parser, and code generator
Loading...
Searching...
No Matches
symbol_table.h
1#ifndef SYMBOL_TABLE_H
2#define SYMBOL_TABLE_H
3
4#include "types.h"
5#include <stdbool.h>
6
7#define SYMBOL_TABLE_SIZE 127
8
9// Symbol types for the symbol table
10typedef enum {
11 SYMBOL_VARIABLE,
12 SYMBOL_FUNCTION,
13 SYMBOL_PARAMETER
14} SymbolType;
15
16// Symbol structure for hash table entries
17typedef struct Symbol {
18 char *name;
19 SymbolType symbol_type;
20 DataType data_type;
21 int scope_level;
22 struct Symbol *next; // For chaining in hash table
23} Symbol;
24
25// Symbol table structure
26typedef struct SymbolTable {
27 Symbol **table; // Array of symbol pointers (hash table)
28 int current_scope; // Current scope level
30
31// Symbol table functions
32SymbolTable *symbol_table_create(void);
33void symbol_table_destroy(SymbolTable *table);
34void symbol_table_enter_scope(SymbolTable *table);
35void symbol_table_exit_scope(SymbolTable *table);
36
37// Symbol management functions
38bool symbol_table_insert(SymbolTable *table, const char *name, SymbolType symbol_type, DataType data_type);
39Symbol *symbol_table_lookup(SymbolTable *table, const char *name);
40Symbol *symbol_table_lookup_current_scope(SymbolTable *table, const char *name);
41
42// Utility functions
43unsigned int symbol_table_hash(const char *name);
44void symbol_table_print(SymbolTable *table);
45
46#endif // SYMBOL_TABLE_H
Type definitions for KCC compiler with Objective-C support.
DataType
Data types supported by the compiler.
Definition types.h:193