ref: split parser into separate files
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
#include <compiler/fzl_parser.h>
|
||||
#include <compiler/internals/parser.h>
|
||||
|
||||
// Parse unary operations
|
||||
fzl_node_t *pa_unary(fzl_parser_t *parser)
|
||||
{
|
||||
if (!parser)
|
||||
return NULL;
|
||||
|
||||
if (!is(parser, FZL_TOKTYPE_MINUS) && !is(parser, FZL_TOKTYPE_PLUS) &&
|
||||
!is(parser, FZL_TOKTYPE_NOT))
|
||||
return pa_postfix(parser);
|
||||
|
||||
fzl_token_t *op = consume(parser);
|
||||
fzl_node_t *operand = pa_unary(parser);
|
||||
|
||||
if (!operand)
|
||||
return NULL;
|
||||
|
||||
fzl_node_t *result = fzl_mknode(unary_op_to_type(op->type), op);
|
||||
result->unary_op.operand = operand;
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user