forked from NeoFlock/noom
parser: error things
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
442
src/parser.c
442
src/parser.c
File diff suppressed because it is too large
Load Diff
14
src/parser.h
14
src/parser.h
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user