This commit is contained in:
Jacob Signorovitch 2024-11-16 10:00:40 -05:00
parent 139d6fcb22
commit 363188d7d6
3 changed files with 16 additions and 14 deletions

View File

@ -10,7 +10,7 @@ static char* asttype_names[] = {
}; };
#endif #endif
ASTTypeNum* ast_type_num_init(AST* val) { ASTTypeNum* ast_type_num_init(int val) {
talloc(ASTTypeNum, num); talloc(ASTTypeNum, num);
num->val = val; num->val = val;

View File

@ -24,7 +24,9 @@ void yyerror (char const *);
exp: exp:
NUM { $$ = ast_type_num_init($1); } NUM { $$ = ast_type_num_init($1); }
| NUM PLUS NUM { AST* argv[2] = {ast_type_num_init($1), ast_type_num_init($1)}; $$ = ast_type_call_init("+", 2, argv);} | NUM PLUS NUM {
; AST* argv[2] = {ast_type_num_init($1), ast_type_num_init($1)};
$$ = ast_type_call_init("+", 2, argv);
};
%% %%

View File

@ -18,10 +18,10 @@ AST* ast_init(ASTType type, void* data);
void ast_destroy(AST* ast); void ast_destroy(AST* ast);
typedef struct { typedef struct {
AST* val; int val;
} ASTTypeNum; } ASTTypeNum;
ASTTypeNum* ast_type_num_init(AST* val); ASTTypeNum* ast_type_num_init(int val);
void ast_type_num_destroy(ASTTypeNum* num); void ast_type_num_destroy(ASTTypeNum* num);
typedef struct { typedef struct {