feat(ast): 修改函数调用表达式的结构定义
在AST定义中将函数调用表达式的name字段替换为callee字段, 以支持更复杂的函数调用场景。同时更新了相关的初始化函数、 转储函数和解析逻辑,使函数调用表达式能够正确处理callee节点。 BREAKING CHANGE: 函数调用表达式的结构发生了改变,从使用name字符串 改为使用callee表达式节点。
This commit is contained in:
@@ -145,7 +145,7 @@ A.2.4 External definitions
|
||||
function-definition
|
||||
declaration
|
||||
(6.9.1) function-definition:
|
||||
declaration-specifiers declarator declaration-listopt compound-statement
|
||||
declaration-specifiers declarator declaration-list(opt) compound-statement
|
||||
(6.9.1) declaration-list:
|
||||
declaration
|
||||
declaration-list declaration
|
||||
@@ -210,6 +210,9 @@ scc_ast_decl_t *scc_parse_declaration(scc_parser_t *parser) {
|
||||
scc_ast_expr_t *init = scc_parse_expression(parser);
|
||||
scc_ast_decl_val_init(decl, type, scc_cstring_as_cstr(&tok.lexeme),
|
||||
init);
|
||||
if (!scc_parser_consume_if(parser, SCC_TOK_SEMICOLON)) {
|
||||
LOG_ERROR("expect semicolon");
|
||||
}
|
||||
goto RETURN;
|
||||
}
|
||||
// TODO
|
||||
@@ -250,7 +253,9 @@ scc_ast_decl_t *scc_parse_declaration(scc_parser_t *parser) {
|
||||
Assert(decl->func.body->base.type == SCC_AST_STMT_COMPOUND);
|
||||
|
||||
RETURN:
|
||||
parser->sema_callbacks.on_decl(parser->sema_callbacks.context,
|
||||
decl->base.type, decl);
|
||||
if (decl) {
|
||||
parser->sema_callbacks.on_decl(parser->sema_callbacks.context,
|
||||
decl->base.type, decl);
|
||||
}
|
||||
return decl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user