diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-03 17:29:12 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-03 18:42:58 +0900 |
| commit | 3654ce578e6fff53950874adf7e0e4ae0a6eb956 (patch) | |
| tree | 5b6c04273de38dba70b7c25e55da144f5f7c37da /src/cc1/parse.h | |
| parent | 1b406b13b03055d2b2d08e8279a4a80c41ca7c20 (diff) | |
| download | ducc-3654ce578e6fff53950874adf7e0e4ae0a6eb956.tar.gz ducc-3654ce578e6fff53950874adf7e0e4ae0a6eb956.tar.zst ducc-3654ce578e6fff53950874adf7e0e4ae0a6eb956.zip | |
Diffstat (limited to 'src/cc1/parse.h')
| -rw-r--r-- | src/cc1/parse.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/cc1/parse.h b/src/cc1/parse.h new file mode 100644 index 0000000..f229b77 --- /dev/null +++ b/src/cc1/parse.h @@ -0,0 +1,43 @@ +#ifndef DUCC_PARSE_H +#define DUCC_PARSE_H + +#include "../lib/common.h" +#include "ast.h" +#include "preprocess.h" + +Program* parse(TokenArray* tokens); +bool pp_eval_constant_expr(TokenArray* pp_tokens); + +typedef enum { + InitDataBlockKind_addr, + InitDataBlockKind_bytes, +} InitDataBlockKind; + +// Static address to global variable or ROM area. +typedef struct { + const char* label; +} InitDataBlockAddr; + +// Static byte array. +typedef struct { + size_t len; + const char* buf; +} InitDataBlockBytes; + +typedef struct { + InitDataBlockKind kind; + union { + InitDataBlockAddr addr; + InitDataBlockBytes bytes; + } as; +} InitDataBlock; + +typedef struct { + size_t len; + size_t capacity; + InitDataBlock* blocks; +} InitData; + +InitData* eval_init_expr(AstNode* expr, Type* ty); + +#endif |
