34 lines
661 B
C
34 lines
661 B
C
#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;
|
|
}
|