X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ast.c;h=81cd3ca09bcb7abb76d5c015b0e368b0b0d6ab4a;hb=e66a2691d3291916ed2ec07ed1cdead2a95e1a9a;hp=8f497ee8833edfbf30bed14fcdd64f3cfbbd8a30;hpb=e8b00fcb80ff3fdcfab757444e94663f1d56c743;p=cparser diff --git a/ast.c b/ast.c index 8f497ee..81cd3ca 100644 --- a/ast.c +++ b/ast.c @@ -14,7 +14,6 @@ struct obstack ast_obstack; static FILE *out; static int indent; -static void print_expression(const expression_t *expression); static void print_statement(const statement_t *statement); static @@ -262,13 +261,30 @@ void print_method_parameters(const method_parameter_t *parameters, } #endif +static +void print_storage_class(storage_class_t storage_class) +{ + switch(storage_class) { + case STORAGE_CLASS_NONE: + break; + case STORAGE_CLASS_TYPEDEF: fputs("typedef ", out); break; + case STORAGE_CLASS_EXTERN: fputs("extern ", out); break; + case STORAGE_CLASS_STATIC: fputs("static ", out); break; + case STORAGE_CLASS_AUTO: fputs("auto ", out); break; + case STORAGE_CLASS_REGISTER: fputs("register ", out); break; + } +} + static void print_declaration(const declaration_t *declaration) { + print_storage_class(declaration->storage_class); print_type(declaration->type, declaration->symbol); - fprintf(out, "\n"); if(declaration->statement != NULL) { + fprintf(out, "\n"); print_statement(declaration->statement); + } else { + fprintf(out, ";\n"); } }