KCC - Kayte C Compiler
1.10.0
A C compiler implementation with preprocessor, lexer, parser, and code generator
Loading...
Searching...
No Matches
include
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
10
typedef
enum
{
11
SYMBOL_VARIABLE,
12
SYMBOL_FUNCTION,
13
SYMBOL_PARAMETER
14
} SymbolType;
15
16
// Symbol structure for hash table entries
17
typedef
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
26
typedef
struct
SymbolTable
{
27
Symbol
**table;
// Array of symbol pointers (hash table)
28
int
current_scope;
// Current scope level
29
}
SymbolTable
;
30
31
// Symbol table functions
32
SymbolTable
*symbol_table_create(
void
);
33
void
symbol_table_destroy(
SymbolTable
*table);
34
void
symbol_table_enter_scope(
SymbolTable
*table);
35
void
symbol_table_exit_scope(
SymbolTable
*table);
36
37
// Symbol management functions
38
bool
symbol_table_insert(
SymbolTable
*table,
const
char
*name, SymbolType symbol_type,
DataType
data_type);
39
Symbol
*symbol_table_lookup(
SymbolTable
*table,
const
char
*name);
40
Symbol
*symbol_table_lookup_current_scope(
SymbolTable
*table,
const
char
*name);
41
42
// Utility functions
43
unsigned
int
symbol_table_hash(
const
char
*name);
44
void
symbol_table_print(
SymbolTable
*table);
45
46
#endif
// SYMBOL_TABLE_H
SymbolTable
Definition
symbol_table.h:26
Symbol
Definition
symbol_table.h:17
types.h
Type definitions for KCC compiler with Objective-C support.
DataType
DataType
Data types supported by the compiler.
Definition
types.h:193
Generated by
1.14.0