X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ast.c;h=164c8646160d7790595f0eb173371c4f93cdb37a;hb=610d20bcf83b946c7c97835c7bb87707853a44dd;hp=201039e06757ac9a9cc521527fbd2b155e65d70a;hpb=c2564629583b7a0969aa0102d628f065b1ed66d3;p=cparser diff --git a/ast.c b/ast.c index 201039e..164c864 100644 --- a/ast.c +++ b/ast.c @@ -1477,6 +1477,34 @@ static void print_ms_modifiers(const declaration_t *declaration) fputs(") ", out); } +static void print_scope(const scope_t *scope) +{ + const entity_t *entity = scope->entities; + for ( ; entity != NULL; entity = entity->base.next) { + print_indent(); + print_entity(entity); + fputs("\n", out); + } +} + +static void print_namespace(const namespace_t *namespace) +{ + fputs("namespace ", out); + if (namespace->base.symbol != NULL) { + fputs(namespace->base.symbol->string, out); + fputc(' ', out); + } + + fputs("{\n", out); + ++indent; + + print_scope(&namespace->members); + + --indent; + print_indent(); + fputs("}\n", out); +} + /** * Print a variable or function declaration */ @@ -1543,10 +1571,12 @@ void print_entity(const entity_t *entity) switch ((entity_kind_tag_t) entity->kind) { case ENTITY_VARIABLE: - case ENTITY_FUNCTION: case ENTITY_COMPOUND_MEMBER: print_declaration(entity); return; + case ENTITY_FUNCTION: + print_declaration(entity); + return; case ENTITY_TYPEDEF: print_typedef(entity); return; @@ -1575,6 +1605,9 @@ void print_entity(const entity_t *entity) print_enum_definition(&entity->enume); fputc(';', out); return; + case ENTITY_NAMESPACE: + print_namespace(&entity->namespacee); + return; case ENTITY_LABEL: case ENTITY_ENUM_VALUE: case ENTITY_LOCAL_LABEL: