Modules |
Files |
Inheritance Tree |
Inheritance Graph |
Name Index |
Config
File: Synopsis/Parser/C++/syn/dumper.hh
1| // Synopsis C++ Parser: dumper.hh header file
2| // The TypeFormatter and Dumper classes
3|
4| // $Id: dumper.hh,v 1.15 2003/01/27 06:53:37 chalky Exp $
5| //
6| // This file is a part of Synopsis.
7| // Copyright (C) 2002 Stephen Davies
8| //
9| // Synopsis is free software; you can redistribute it and/or modify it
10| // under the terms of the GNU General Public License as published by
11| // the Free Software Foundation; either version 2 of the License, or
12| // (at your option) any later version.
13| //
14| // This program is distributed in the hope that it will be useful,
15| // but WITHOUT ANY WARRANTY; without even the implied warranty of
16| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17| // General Public License for more details.
18| //
19| // You should have received a copy of the GNU General Public License
20| // along with this program; if not, write to the Free Software
21| // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22| // 02111-1307, USA.
23|
24| #ifndef H_SYNOPSIS_CPP_DUMPER
25| #define H_SYNOPSIS_CPP_DUMPER
26|
27| #include "ast.hh"
28| #include "type.hh"
29|
30|
31| class TypeFormatter : public Types::Visitor
32| {
33| public:
34| TypeFormatter();
35|
36|
37| void push_scope(const ScopedName& scope);
38|
39| void pop_scope();
40|
41|
42|
43|
44|
45|
46|
47|
48|
49| std::string format(const Types::Type*, const std::string** id = NULL);
50| virtual void visit_type(Types::Type*);
51| virtual void visit_unknown(Types::Unknown*);
52| virtual void visit_modifier(Types::Modifier*);
53| virtual void visit_named(Types::Named*);
54| virtual void visit_base(Types::Base*);
55| virtual void visit_declared(Types::Declared*);
56| virtual void visit_template_type(Types::Template*);
57| virtual void visit_parameterized(Types::Parameterized*);
58| virtual void visit_func_ptr(Types::FuncPtr*);
59|
60| protected:
61|
62| std::string m_type;
63|
64| ScopedName m_scope;
65|
66| std::string colonate(const ScopedName& name);
67|
68| std::vector<ScopedName> m_scope_stack;
69|
70| const std::string** m_fptr_id;
71| };
72|
73|
74| class Dumper : public AST::Visitor, public TypeFormatter
75| {
76| public:
77| Dumper();
78|
79|
80| void onlyShow(const std::string& fname);
81|
82| std::string formatParam(AST::Parameter*);
83|
84|
85|
86| void visit(const std::vector<AST::Declaration*>&);
87| void visit(const std::vector<AST::Comment*>&);
88| virtual void visit_macro(AST::Macro*);
89| virtual void visit_declaration(AST::Declaration*);
90| virtual void visit_scope(AST::Scope*);
91| virtual void visit_namespace(AST::Namespace*);
92| virtual void visit_forward(AST::Forward*);
93| virtual void visit_class(AST::Class*);
94| virtual void visit_function(AST::Function*);
95| virtual void visit_variable(AST::Variable*);
96| virtual void visit_typedef(AST::Typedef*);
97| virtual void visit_enum(AST::Enum*);
98| virtual void visit_enumerator(AST::Enumerator*);
99|
100| private:
101|
102| int m_indent;
103|
104| std::string m_indent_string;
105|
106| void indent();
107|
108| void undent();
109|
110| std::string m_filename;
111|
112| };
113|
114| #endif // header guard
115|