feat+fix: make compiler STRONGAAA
- FEAT: add source code length field in `fzl_reader_t` struct - FIX: check name, lpair (lparen) and rpair (rparen) when lexing call - FIX: check string literal termination - FIX: increment position even on empty string to prevent infinite lexing loop - FIX: add string terminator in `fzl_mktoken` when allocating space for string value - FIX: add check for errors in recursevly called `walk` - FIX: change source code holder from stack-stored `char[8192]` to dynamically allocated with actual file size holder - FIX: correct constant hasing util to hash actual string value instead of link
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#include "compiler/fzl_token.h"
|
||||
#include <compiler/fzl_parser.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -92,7 +93,12 @@ fzl_node_t *parse_expression(fzl_parser_t *parser, int precedence);
|
||||
fzl_node_t *parse_call(fzl_parser_t *parser)
|
||||
{
|
||||
fzl_token_t *tok = consume(parser); // <NAME>
|
||||
consume(parser); // (
|
||||
if (tok->type != FZL_TOKTYPE_NAME)
|
||||
return NULL;
|
||||
|
||||
fzl_token_t *lpair = consume(parser); // (
|
||||
if (lpair->type != FZL_TOKTYPE_LPAIR)
|
||||
return NULL;
|
||||
|
||||
fzl_node_t *node = fzl_mknode(FZL_NODETYPE_CALL, tok);
|
||||
node->list.entry_count = 0;
|
||||
@@ -132,7 +138,10 @@ fzl_node_t *parse_call(fzl_parser_t *parser)
|
||||
}
|
||||
}
|
||||
|
||||
consume(parser);
|
||||
fzl_token_t *rpair = consume(parser);
|
||||
if (rpair->type != FZL_TOKTYPE_RPAIR)
|
||||
return NULL;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user