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:
samsonium
2026-10-10 21:03:23 +03:00
parent f49a54c878
commit 1db985ecb5
7 changed files with 47 additions and 14 deletions
+10 -2
View File
@@ -100,7 +100,8 @@ bool walk(fzl_walker_t *walker, fzl_node_t *node)
// NOTE: create block env here
if (node->list.entry_count > 0)
for (size_t i = 0; i < node->list.entry_count; i++)
walk(walker, node->list.entries[i]);
if (!walk(walker, node->list.entries[i]))
return false;
// NOTE: destroy block env here
break;
@@ -109,7 +110,8 @@ bool walk(fzl_walker_t *walker, fzl_node_t *node)
{
for (size_t i = 0; i < node->list.entry_count; i++)
{
walk(walker, node->list.entries[i]);
if (!walk(walker, node->list.entries[i]))
return false;
push_op(walker, FZL_OPCODE_PUSHARG);
}
}
@@ -146,6 +148,12 @@ bool walk(fzl_walker_t *walker, fzl_node_t *node)
// Walk entire AST recursevily
int fzl_walk(fzl_walker_t *walker)
{
if (!walker)
{
snprintf(wlast_err, sizeof(wlast_err), "walker is null");
return -1;
}
bool result = walk(walker, walker->root);
return !result && wlast_err[0] ? -1 : 0;
}