parser: error things

This commit is contained in:
2026-05-08 18:29:42 +02:00
parent fc9f7c05b4
commit 9f6b6e1eec
3 changed files with 279 additions and 180 deletions

View File

@@ -66,7 +66,8 @@ int main(int argc, char** argv) {
while (last_node) {
noomP_Node* next = last_node->previous_node;
noom_free(last_node->subnodes);
// subnodes could be null if we OOM'd during a realloc of it
if (last_node->subnodes) noom_free(last_node->subnodes);
noom_free(last_node);
last_node = next;
}

File diff suppressed because it is too large Load Diff

View File

@@ -68,6 +68,18 @@ typedef enum noomP_NodeType {
NOOMP_NODE_NCOUNT,
} noomP_NodeType;
typedef enum noomP_Error {
NOOMP_ERROR_NONE = 0,
NOOMP_ERROR_OOM,
NOOMP_ERROR_UNEXPECTED, // TODO: maybe split into multiple for better errors?
NOOMP_ERROR_FAKEATTRIBUTE,
NOOMP_ERROR_RETURN_NOT_END,
NOOMP_ERROR_FOR_WRONG_AMOUNT,
NOOMP_ERROR_LEXER = 1 << 31, // bitwise or'd with the lexer error number
} noomP_Error;
typedef struct noomP_Node {
noomP_NodeType type;
@@ -87,6 +99,8 @@ typedef struct noomP_Parser { // todo: track location in code with line/column?
const char* filename;
noom_uint_t lex_offset;
noom_uint_t error_state;
noomP_Node* last_node;
} noomP_Parser;