diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2017-05-19 18:47:35 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2017-05-21 13:19:46 +0200 |
commit | 846f560979d14b82e348cdf83d93994dee909d70 (patch) | |
tree | ab00cfaad575a5383cf93fdfd12534cd89d9352f | |
parent | e9b426db412680de1888056c5a643b3ed8c7ded6 (diff) | |
download | ell-846f560979d14b82e348cdf83d93994dee909d70.tar.gz ell-846f560979d14b82e348cdf83d93994dee909d70.tar.xz ell-846f560979d14b82e348cdf83d93994dee909d70.zip |
Mark memory allocation issues in the parser
-rwxr-xr-x | ell.c | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -412,8 +412,6 @@ lexer_errorf (struct lexer *self, const char *fmt, ...) { // --- Parsing ----------------------------------------------------------------- -// FIXME: the parser generally ignores memory allocation errors - static void print_string (const char *s) { putc ('\'', stdout); @@ -523,8 +521,10 @@ static struct item * parse_line (struct parser *self, jmp_buf out); static struct item * parse_prefix_list (struct item *list, const char *name) { + // TODO: check memory error struct item *prefix = new_string (name, strlen (name)); prefix->next = list; + // TODO: check memory error return new_list (prefix); } @@ -540,6 +540,7 @@ parse_item (struct parser *self, jmp_buf out) { SKIP_NL (); if (ACCEPT (T_STRING)) + // TODO: check memory error, also in "self->lexer.string" return new_string (self->lexer.string.s, self->lexer.string.len); if (ACCEPT (T_AT)) { result = parse_item (self, out); @@ -551,6 +552,7 @@ parse_item (struct parser *self, jmp_buf out) { tail = &(*tail)->next; SKIP_NL (); } + // TODO: check memory error return new_list (result); } if (ACCEPT (T_LBRACKET)) { @@ -565,6 +567,7 @@ parse_item (struct parser *self, jmp_buf out) { while ((*tail = parse_line (self, err))) tail = &(*tail)->next; EXPECT (T_RBRACE); + // TODO: check memory error return parse_prefix_list (new_list (result), "quote"); } @@ -585,15 +588,16 @@ parse_line (struct parser *self, jmp_buf out) { } while (PEEK () != T_RBRACE && PEEK () != T_ABORT) { - if (ACCEPT (T_NEWLINE)) { - if (result) - return new_list (result); - } else { + if (!ACCEPT (T_NEWLINE)) { *tail = parse_item (self, err); tail = &(*tail)->next; + } else if (result) { + // TODO: check memory error + return new_list (result); } } if (result) + // TODO: check memory error return new_list (result); return NULL; } |