diff options
Diffstat (limited to 'dimension/common.rules')
-rw-r--r-- | dimension/common.rules | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/dimension/common.rules b/dimension/common.rules index e477df5..e604b9f 100644 --- a/dimension/common.rules +++ b/dimension/common.rules @@ -29,10 +29,7 @@ IDENTIFIER: "identifier" { symbol = dmnsn_find_symbol(symtable, id); } $$ = dmnsn_new_astnode(DMNSN_AST_IDENTIFIER, @$); - $$.ptr = strdup(id); - if (!$$.ptr) - dmnsn_error(DMNSN_SEVERITY_HIGH, - "Couldn't allocate room for identifier."); + $$.ptr = dmnsn_strdup(id); free($1); } ; @@ -410,21 +407,13 @@ FLOAT: ARITH_EXPR { FLOAT_LITERAL: "integer" { $$ = dmnsn_new_astnode(DMNSN_AST_INTEGER, @$); - $$.ptr = malloc(sizeof(long)); - if (!$$.ptr) - dmnsn_error(DMNSN_SEVERITY_HIGH, - "Failed to allocate room for integer."); - + $$.ptr = dmnsn_malloc(sizeof(long)); *(long *)$$.ptr = strtol($1, NULL, 0); free($1); } | "float" { $$ = dmnsn_new_astnode(DMNSN_AST_FLOAT, @$); - $$.ptr = malloc(sizeof(double)); - if (!$$.ptr) - dmnsn_error(DMNSN_SEVERITY_HIGH, - "Failed to allocate room for float."); - + $$.ptr = dmnsn_malloc(sizeof(double)); *(double *)$$.ptr = strtod($1, NULL); free($1); } |