feat(lexer, preprocessor): replace cstring conversion with copy and refactor macro expansion

- Replace `scc_cstring_from_cstr(scc_cstring_as_cstr(...))` with `scc_cstring_copy()` in lexer to fix memory leaks
- Extract macro expansion logic into separate `expand_macro.c` file
- Remove `expand_stack` parameter from `scc_pp_expand_macro()` function
- Add new parsing functions for macro replacement lists and arguments
- Add string utility functions for whitespace trimming and string joining
- Update memory stream documentation for clarity
This commit is contained in:
zzy committed 2025-12-15 20:24:39 +08:00
1 parent 73d74f5e13
commit 07f5d9331b
15 files changed
+574 -346

No files matched your search

@@ -1,12 +1,12 @@
/**
* @file hashmap.h
* @file hashtable.h
* @brief 开放寻址法哈希表实现
*
* 提供基于向量容器的哈希表实现,支持动态扩容和墓碑机制
*/
#ifndef __SCC_HASHMAP_H__
#define __SCC_HASHMAP_H__
#ifndef __SCC_HASHTABLE_H__
#define __SCC_HASHTABLE_H__
#include <libcore.h>
@@ -121,4 +121,4 @@ typedef int (*scc_hashtable_iter_fn)(const void *key, void *value,
void scc_hashtable_foreach(scc_hashtable_t *ht, scc_hashtable_iter_fn iter_func,
void *context);
#endif /* __SCC_HASHMAP_H__ */
#endif /* __SCC_HASHTABLE_H__ */
+2 -2
View File
@@ -1,9 +1,9 @@
#ifndef __SMCC_UTILS_H__
#define __SMCC_UTILS_H__
#include "hashmap.h"
#include "hashtable.h"
#include "kllist.h"
#include "strpool.h"
#include <libcore.h>
#endif // __SMCC_UTILS_H__
#endif /* __SMCC_UTILS_H__ */
+1 -1
View File
@@ -8,7 +8,7 @@
#ifndef __SCC_STRPOOL_H__
#define __SCC_STRPOOL_H__
#include "hashmap.h"
#include "hashtable.h"
#include <libcore.h>
/**