ref: split parser into separate files
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
#include <compiler/fzl_parser.h>
|
||||
#include <compiler/internals/parser.h>
|
||||
|
||||
// Parse conditional &&
|
||||
fzl_node_t *pa_and(fzl_parser_t *parser)
|
||||
{
|
||||
if (!parser)
|
||||
return NULL;
|
||||
|
||||
fzl_node_t *left = pa_cond(parser);
|
||||
fzl_node_t *right = NULL;
|
||||
|
||||
if (!left)
|
||||
return NULL;
|
||||
|
||||
while (is(parser, FZL_TOKTYPE_DAMPERSAND))
|
||||
{
|
||||
fzl_token_t * or = consume(parser);
|
||||
right = pa_cond(parser);
|
||||
if (!right)
|
||||
{
|
||||
fzl_freeast(left);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
fzl_node_t *node = fzl_mknode(FZL_NODETYPE_AND, or);
|
||||
node->binary_op.left = left;
|
||||
node->binary_op.right = right;
|
||||
left = node;
|
||||
}
|
||||
|
||||
return left;
|
||||
}
|
||||
Reference in New Issue
Block a user