fix: add separate assign to identifier statement
This commit is contained in:
@@ -381,7 +381,7 @@ fzl_node_t *parse_expression(fzl_parser_t *parser)
|
||||
// Statement parsing
|
||||
fzl_node_t *parse_statement(fzl_parser_t *parser)
|
||||
{
|
||||
if (is(parser, FZL_TOKTYPE_TYPE) || is(parser, FZL_TOKTYPE_NAME))
|
||||
if (is(parser, FZL_TOKTYPE_TYPE))
|
||||
{
|
||||
fzl_token_t *type = peek(parser);
|
||||
if (type->type == FZL_TOKTYPE_TYPE)
|
||||
@@ -424,6 +424,29 @@ fzl_node_t *parse_statement(fzl_parser_t *parser)
|
||||
}
|
||||
}
|
||||
|
||||
if (is(parser, FZL_TOKTYPE_NAME) && next(parser)->type == FZL_TOKTYPE_EQ)
|
||||
{
|
||||
fzl_token_t *name = consume(parser);
|
||||
fzl_node_t *left = fzl_mknode(FZL_NODETYPE_IDENTIFIER, name);
|
||||
|
||||
while (is(parser, FZL_TOKTYPE_EQ))
|
||||
{
|
||||
fzl_token_t *eq = consume(parser);
|
||||
|
||||
fzl_node_t *right = parse_expression(parser);
|
||||
if (!right)
|
||||
return NULL;
|
||||
|
||||
fzl_node_t *assn = fzl_mknode(FZL_NODETYPE_ASSIGN, eq);
|
||||
assn->binary_op.left = left;
|
||||
assn->binary_op.right = right;
|
||||
|
||||
left = assn;
|
||||
}
|
||||
|
||||
return left;
|
||||
}
|
||||
|
||||
return parse_expression(parser);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user