Lime Parser Generator 0.1.0
Runtime-extensible LALR(1) parser with SIMD tokenization and LLVM JIT
Loading...
Searching...
No Matches
lime_ast.h
1#ifndef LIME_AST_H
2#define LIME_AST_H
3
4#include <stddef.h>
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
17typedef struct LimeArena {
18 char *base;
19 size_t used;
20 size_t capacity;
21 struct LimeArena *next;
22} LimeArena;
23
24/* Create an arena with the given initial block size. Returns NULL on failure. */
25LimeArena *lime_arena_create(size_t initial_size);
26
27/* Allocate size bytes from the arena with pointer alignment.
28** Returns NULL only if malloc fails for a new block. Never fails
29** for sizes smaller than the block size. */
30void *lime_arena_alloc(LimeArena *arena, size_t size);
31
32/* Allocate and zero-fill size bytes from the arena. */
33void *lime_arena_calloc(LimeArena *arena, size_t size);
34
35/* Duplicate a string into the arena. */
36char *lime_arena_strdup(LimeArena *arena, const char *s);
37
38/* Destroy the arena and all its blocks. Passing NULL is safe. */
39void lime_arena_destroy(LimeArena *arena);
40
41/* Return total bytes allocated across all blocks. */
42size_t lime_arena_total_allocated(const LimeArena *arena);
43
44/* Return total bytes used across all blocks. */
45size_t lime_arena_total_used(const LimeArena *arena);
46
47#ifdef __cplusplus
48}
49#endif
50
51#endif /* LIME_AST_H */
Arena allocator for AST nodes.
Definition lime_ast.h:17
struct LimeArena * next
Next block in the linked list of blocks.
Definition lime_ast.h:21
size_t capacity
Total bytes in the current block.
Definition lime_ast.h:20
size_t used
Bytes used in the current block.
Definition lime_ast.h:19
char * base
Base pointer of the current block.
Definition lime_ast.h:18