return(pexp);
}
+void primary_expression_free(struct primary_expression *pexpr)
+{
+ switch(pexpr->type) {
+ case PRIMARY_EXPR_IDENTIFIER:
+ if(pexpr->data.identifier) {
+ identifier_free(pexpr->data.identifier);
+ }
+
+ break;
+
+ case PRIMARY_EXPR_CONSTANT:
+ if(pexpr->data.constant) {
+ constant_free(pexpr->data.constant);
+ }
+
+ break;
+
+ case PRIMARY_EXPR_STRING:
+ if(pexpr->data.string) {
+ string_free(pexpr->data.string);
+ }
+
+ break;
+
+ case PRIMARY_EXPR_EXPR:
+ if(pexpr->data.expr.expr) {
+ expression_free(pexpr->data.expr.expr);
+ }
+
+ break;
+
+ default:
+ break;
+ }
+
+ memset(pexpr, 0, sizeof(*pexpr));
+ free(pexpr);
+
+ return;
+}
+
void primary_expression_debug(struct primary_expression *pexpr)
{
switch(pexpr->type) {
return(iconst);
}
+void integer_constant_free(struct integer_constant *iconst)
+{
+ memset(iconst, 0, sizeof(*iconst));
+ free(iconst);
+
+ return;
+}
+
struct character_constant *character_constant_new(void)
{
struct character_constant *cconst;
return(cconst);
}
+void character_constant_free(struct character_constant *cconst)
+{
+ memset(cconst, 0, sizeof(*cconst));
+ free(cconst);
+
+ return;
+}
+
struct floating_constant *floating_constant_new(void)
{
struct floating_constant *fconst;
return(fconst);
}
+void floating_constant_free(struct floating_constant *fconst)
+{
+ memset(fconst, 0, sizeof(*fconst));
+ free(fconst);
+
+ return;
+}
+
struct enumeration_constant *enumeration_constant_new(void)
{
struct enumeration_constant *econst;
return(econst);
}
+void enumeration_constant_free(struct enumeration_constant *econst)
+{
+ memset(econst, 0, sizeof(*econst));
+ free(econst);
+
+ return;
+}
+
struct constant *constant_new(void)
{
struct constant *c;
return(c);
}
+void constant_free(struct constant *c)
+{
+ switch(c->type) {
+ case CONST_TYPE_INTEGER:
+ integer_constant_free(c->data.iconst);
+ break;
+
+ case CONST_TYPE_CHARACTER:
+ character_constant_free(c->data.cconst);
+ break;
+
+ case CONST_TYPE_FLOATING:
+ floating_constant_free(c->data.fconst);
+ break;
+
+ case CONST_TYPE_ENUMERATION:
+ enumeration_constant_free(c->data.econst);
+ break;
+
+ default:
+ break;
+ }
+
+ memset(c, 0, sizeof(*c));
+ free(c);
+
+ return;
+}
+
struct identifier *identifier_new(void)
{
struct identifier *id;
return(s);
}
+void string_free(struct string *str)
+{
+ memset(str, 0, sizeof(*str));
+ free(str);
+
+ return;
+}
+
struct argument_expression_list* argument_expression_list_new(void)
{
struct argument_expression_list *aelist;
return(ce);
}
+void conditional_expression_free(struct conditional_expression *expr)
+{
+ if(expr->lorexpr) {
+ logical_or_expression_free(expr->lorexpr);
+ }
+
+ if(expr->expr) {
+ expression_free(expr->expr);
+ }
+
+ if(expr->cexpr) {
+ conditional_expression_free(expr->cexpr);
+ }
+
+ memset(expr, 0, sizeof(*expr));
+ free(expr);
+
+ return;
+}
+
struct constant_expression *constant_expression_new(void)
{
struct constant_expression *ce;
return(ce);
}
+void constant_expression_free(struct constant_expression *cexpr)
+{
+ if(cexpr->cexpr) {
+ conditional_expression_free(cexpr->cexpr);
+ }
+
+ memset(cexpr, 0, sizeof(*cexpr));
+ free(cexpr);
+
+ return;
+}
+
struct logical_or_expression *logical_or_expression_new(void)
{
struct logical_or_expression *loe;
void primary_expression_debug(struct primary_expression*);
struct integer_constant *integer_constant_new(void);
+void integer_constant_free(struct integer_constant*);
+
struct character_constant *character_constant_new(void);
+void character_constant_free(struct character_constant*);
+
struct floating_constant *floating_constant_new(void);
+void floating_constant_free(struct floating_constant*);
+
struct enumeration_constant *enumeration_constant_new(void);
+void enumeration_constant_free(struct enumeration_constant*);
struct argument_expression_list *argument_expression_list_new(void);
void argument_expression_list_free(struct argument_expression_list*);
void declaration_specifiers_debug(struct declaration_specifiers*);
struct constant *constant_new(void);
+void constant_free(struct constant*);
-struct integer_constant *integer_constant_new(void);
-struct character_constant *character_constant_new(void);
-struct floating_constant *floating_constant_new(void);
-struct enumeration_constant *enueration_constant_new(void);
struct string *string_new(void);
+void string_free(struct string*);
struct identifier* identifier_new(void);
void identifier_free(struct identifier*);
struct enumerator_list *enumerator_list_new(void);
void enumerator_list_free(struct enumerator_list*);
+struct expression *expression_new(void);
+void expression_free(struct expression*);
+
#endif /* GRAMMAR_H */