Basic compound parsing, maybe I should unify with calls again
This commit is contained in:
35
ast.cpp
35
ast.cpp
@@ -17,6 +17,8 @@ enum Ast_Kind: U32{
|
||||
AST_CALL_ITEM,
|
||||
AST_CALL,
|
||||
|
||||
AST_COMPOUND,
|
||||
AST_COMPOUND_ITEM,
|
||||
AST_TYPE,
|
||||
AST_VAR,
|
||||
AST_CONST,
|
||||
@@ -80,13 +82,25 @@ struct Ast_Atom: Ast_Expr{
|
||||
INLINE_VALUE_FIELDS;
|
||||
};
|
||||
|
||||
struct Ast_Compound_Item: Ast_Expr{
|
||||
Ast_Atom *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_Item: Ast_Expr{
|
||||
Ast_Atom *name; // index | name
|
||||
Ast_Atom *name;
|
||||
Ast_Expr *item;
|
||||
};
|
||||
|
||||
struct Ast_Call: Ast_Expr{
|
||||
Ast_Resolved_Type *type; // @todo: to map
|
||||
Ast_Resolved_Type *type;
|
||||
Ast_Expr *name;
|
||||
Array<Ast_Call_Item *> exprs;
|
||||
};
|
||||
@@ -283,6 +297,23 @@ ast_expr_binary(Ast_Expr *left, Ast_Expr *right, Token *op){
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Compound *
|
||||
ast_compound(Token *pos, Ast_Expr *typespec, Array<Ast_Compound_Item *> exprs){
|
||||
AST_NEW(Compound, COMPOUND, pos, AST_EXPR);
|
||||
result->typespec = typespec;
|
||||
result->exprs = exprs.tight_copy(pctx->perm);
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Compound_Item *
|
||||
ast_compound_item(Token *pos, Ast_Atom *name, Ast_Expr *index, Ast_Expr *item){
|
||||
AST_NEW(Compound_Item, COMPOUND_ITEM, pos, AST_EXPR);
|
||||
result->name = name;
|
||||
result->index = index;
|
||||
result->item = item;
|
||||
return result;
|
||||
}
|
||||
|
||||
function Ast_Call *
|
||||
ast_call(Token *pos, Ast_Expr *name, Array<Ast_Call_Item *> exprs){
|
||||
AST_NEW(Call, CALL, pos, AST_EXPR);
|
||||
|
||||
Reference in New Issue
Block a user