ref: split parser into separate files
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#include <compiler/fzl_parser.h>
|
||||
#include <compiler/internals/parser.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Object construct parsing
|
||||
fzl_node_t *pa_new(fzl_parser_t *parser)
|
||||
{
|
||||
if (!is(parser, FZL_TOKTYPE_NEW))
|
||||
return pa_or(parser);
|
||||
|
||||
fzl_token_t *new = consume(parser);
|
||||
fzl_node_t *objname = pa_or(parser);
|
||||
if (!objname || (objname->type != FZL_NODETYPE_IDENTIFIER &&
|
||||
objname->type != FZL_NODETYPE_FIELD))
|
||||
{
|
||||
fzl_freeast(objname);
|
||||
snprintf(plast_err, sizeof(plast_err),
|
||||
"'%s': expected class name after 'new' keyword at %ld:%ld",
|
||||
last_known_tok->filename, last_known_tok->ln, last_known_tok->cn);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fzl_node_t *node = fzl_mknode(FZL_NODETYPE_CONSTRUCT, new);
|
||||
node->construct.name = objname;
|
||||
|
||||
return node;
|
||||
}
|
||||
Reference in New Issue
Block a user