Calling functions is working, same syntax as compound stmts
This commit is contained in:
30
new_ast.cpp
30
new_ast.cpp
@@ -88,8 +88,8 @@ enum Ast_Kind: U32{
|
||||
AST_INDEX,
|
||||
AST_UNARY,
|
||||
AST_BINARY,
|
||||
AST_COMPOUND_ITEM,
|
||||
AST_COMPOUND,
|
||||
AST_CALL_ITEM,
|
||||
AST_CALL,
|
||||
|
||||
AST_POINTER,
|
||||
AST_ARRAY,
|
||||
@@ -133,16 +133,16 @@ struct Ast_Atom: Ast_Expr{
|
||||
};
|
||||
};
|
||||
|
||||
struct Ast_Compound_Item: Ast_Expr{
|
||||
struct Ast_Call_Item: Ast_Expr{
|
||||
Ast_Atom *name; // index | name
|
||||
Ast_Expr *index;
|
||||
Ast_Expr *item;
|
||||
};
|
||||
|
||||
struct Ast_Compound: Ast_Expr{
|
||||
Ast_Resolved_Type *type;
|
||||
Ast_Expr *typespec;
|
||||
Array<Ast_Compound_Item *> exprs;
|
||||
struct Ast_Call: Ast_Expr{
|
||||
Ast_Resolved_Type *type; // @todo: to map
|
||||
Ast_Expr *name;
|
||||
Array<Ast_Call_Item *> exprs;
|
||||
};
|
||||
|
||||
struct Ast_Unary: Ast_Expr{
|
||||
@@ -283,19 +283,19 @@ ast_expr_binary(Ast_Expr *left, Ast_Expr *right, Token *op){
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Compound *
|
||||
ast_expr_compound(Token *pos, Ast_Expr *typespec, Array<Ast_Compound_Item *> exprs){
|
||||
AST_NEW(Compound, COMPOUND, pos, AST_EXPR);
|
||||
result->typespec = typespec;
|
||||
function Ast_Call *
|
||||
ast_call(Token *pos, Ast_Expr *name, Array<Ast_Call_Item *> exprs){
|
||||
AST_NEW(Call, CALL, pos, AST_EXPR);
|
||||
result->name = name;
|
||||
result->exprs = exprs.tight_copy(pctx->perm);
|
||||
if(result->typespec) result->typespec->parent = result;
|
||||
if(result->name) result->name->parent = result;
|
||||
For(result->exprs) it[0]->parent = result;
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Compound_Item *
|
||||
ast_expr_compound_item(Token *pos, Ast_Expr *index, Ast_Atom *name, Ast_Expr *item){
|
||||
AST_NEW(Compound_Item, COMPOUND_ITEM, pos, AST_EXPR);
|
||||
function Ast_Call_Item *
|
||||
ast_call_item(Token *pos, Ast_Expr *index, Ast_Atom *name, Ast_Expr *item){
|
||||
AST_NEW(Call_Item, CALL_ITEM, pos, AST_EXPR);
|
||||
result->name = name;
|
||||
result->index = index;
|
||||
result->item = item;
|
||||
|
||||
Reference in New Issue
Block a user