ref: split parser into separate files

This commit is contained in:
samsonium
2026-10-29 00:08:44 +03:00
parent 62b0030e4a
commit 8c90d54782
27 changed files with 1444 additions and 1307 deletions
+42
View File
@@ -0,0 +1,42 @@
#include <compiler/fzl_parser.h>
#include <compiler/internals/parser.h>
#include <stdio.h>
// Internal parsing entry point
fzl_node_t *pa_program(fzl_parser_t *parser)
{
if (!peek(parser))
return NULL;
fzl_node_t *first = NULL;
fzl_node_t *last = NULL;
fzl_node_t *node = NULL;
while (peek(parser) != NULL)
{
node = pa_statement(parser);
if (!node)
{
fzl_freeast(first);
return NULL;
}
if (!last)
{
first = node;
last = node;
}
else
{
last->next = node;
last = node;
}
}
if (!first)
{
snprintf(plast_err, sizeof(plast_err), "nothing to parse >:(");
return NULL;
}
return first;
}