Mercurial > hg > CbC > CbC_gcc
comparison gcc/c-family/c-pretty-print.h @ 111:04ced10e8804
gcc 7
author | kono |
---|---|
date | Fri, 27 Oct 2017 22:46:09 +0900 |
parents | 561a7518be6b |
children | 84e7813d76e9 |
comparison
equal
deleted
inserted
replaced
68:561a7518be6b | 111:04ced10e8804 |
---|---|
1 /* Various declarations for the C and C++ pretty-printers. | 1 /* Various declarations for the C and C++ pretty-printers. |
2 Copyright (C) 2002, 2003, 2004, 2007, 2009, 2010 | 2 Copyright (C) 2002-2017 Free Software Foundation, Inc. |
3 Free Software Foundation, Inc. | |
4 Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net> | 3 Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net> |
5 | 4 |
6 This file is part of GCC. | 5 This file is part of GCC. |
7 | 6 |
8 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
21 | 20 |
22 #ifndef GCC_C_PRETTY_PRINTER | 21 #ifndef GCC_C_PRETTY_PRINTER |
23 #define GCC_C_PRETTY_PRINTER | 22 #define GCC_C_PRETTY_PRINTER |
24 | 23 |
25 #include "tree.h" | 24 #include "tree.h" |
26 #include "c-common.h" | 25 #include "c-family/c-common.h" |
27 #include "pretty-print.h" | 26 #include "pretty-print.h" |
28 | 27 |
29 | 28 |
30 typedef enum | 29 enum pp_c_pretty_print_flags |
31 { | 30 { |
32 pp_c_flag_abstract = 1 << 1, | 31 pp_c_flag_abstract = 1 << 1, |
33 pp_c_flag_last_bit = 2 | 32 pp_c_flag_gnu_v3 = 1 << 2, |
34 } pp_c_pretty_print_flags; | 33 pp_c_flag_last_bit = 3 |
34 }; | |
35 | 35 |
36 | 36 |
37 /* The data type used to bundle information necessary for pretty-printing | 37 /* The data type used to bundle information necessary for pretty-printing |
38 a C or C++ entity. */ | 38 a C or C++ entity. */ |
39 typedef struct c_pretty_print_info c_pretty_printer; | 39 struct c_pretty_printer; |
40 | 40 |
41 /* The type of a C pretty-printer 'member' function. */ | 41 /* The type of a C pretty-printer 'member' function. */ |
42 typedef void (*c_pretty_print_fn) (c_pretty_printer *, tree); | 42 typedef void (*c_pretty_print_fn) (c_pretty_printer *, tree); |
43 | 43 |
44 /* The datatype that contains information necessary for pretty-printing | 44 /* The datatype that contains information necessary for pretty-printing |
45 a tree that represents a C construct. Any pretty-printer for a | 45 a tree that represents a C construct. Any pretty-printer for a |
46 language using C/c++ syntax can derive from this datatype and reuse | 46 language using C syntax can derive from this datatype and reuse |
47 facilities provided here. It can do so by having a subobject of type | 47 facilities provided here. A derived pretty-printer can override |
48 c_pretty_printer and override the macro pp_c_base to return a pointer | 48 any function listed in the vtable below. See cp/cxx-pretty-print.h |
49 to that subobject. Such a pretty-printer has the responsibility to | 49 and cp/cxx-pretty-print.c for an example of derivation. */ |
50 initialize the pp_base() part, then call pp_c_pretty_printer_init | 50 struct c_pretty_printer : pretty_printer |
51 to set up the components that are specific to the C pretty-printer. | |
52 A derived pretty-printer can override any function listed in the | |
53 vtable below. See cp/cxx-pretty-print.h and cp/cxx-pretty-print.c | |
54 for an example of derivation. */ | |
55 struct c_pretty_print_info | |
56 { | 51 { |
57 pretty_printer base; | 52 c_pretty_printer (); |
53 | |
54 // Format string, possibly translated. | |
55 void translate_string (const char *); | |
56 | |
57 virtual void constant (tree); | |
58 virtual void id_expression (tree); | |
59 virtual void primary_expression (tree); | |
60 virtual void postfix_expression (tree); | |
61 virtual void unary_expression (tree); | |
62 virtual void multiplicative_expression (tree); | |
63 virtual void conditional_expression (tree); | |
64 virtual void assignment_expression (tree); | |
65 virtual void expression (tree); | |
66 | |
67 virtual void type_id (tree); | |
68 virtual void statement (tree); | |
69 | |
70 virtual void declaration (tree); | |
71 virtual void declaration_specifiers (tree); | |
72 virtual void simple_type_specifier (tree); | |
73 virtual void function_specifier (tree); | |
74 virtual void storage_class_specifier (tree); | |
75 virtual void declarator (tree); | |
76 virtual void direct_declarator (tree); | |
77 virtual void abstract_declarator (tree); | |
78 virtual void direct_abstract_declarator (tree); | |
79 | |
80 virtual void initializer (tree); | |
58 /* Points to the first element of an array of offset-list. | 81 /* Points to the first element of an array of offset-list. |
59 Not used yet. */ | 82 Not used yet. */ |
60 int *offset_list; | 83 int *offset_list; |
61 | 84 |
62 pp_flags flags; | 85 pp_flags flags; |
63 | 86 |
64 /* These must be overridden by each of the C and C++ front-end to | 87 /* These must be overridden by each of the C and C++ front-end to |
65 reflect their understanding of syntactic productions when they differ. */ | 88 reflect their understanding of syntactic productions when they differ. */ |
66 c_pretty_print_fn declaration; | |
67 c_pretty_print_fn declaration_specifiers; | |
68 c_pretty_print_fn declarator; | |
69 c_pretty_print_fn abstract_declarator; | |
70 c_pretty_print_fn direct_abstract_declarator; | |
71 c_pretty_print_fn type_specifier_seq; | 89 c_pretty_print_fn type_specifier_seq; |
72 c_pretty_print_fn direct_declarator; | |
73 c_pretty_print_fn ptr_operator; | 90 c_pretty_print_fn ptr_operator; |
74 c_pretty_print_fn parameter_list; | 91 c_pretty_print_fn parameter_list; |
75 c_pretty_print_fn type_id; | |
76 c_pretty_print_fn simple_type_specifier; | |
77 c_pretty_print_fn function_specifier; | |
78 c_pretty_print_fn storage_class_specifier; | |
79 c_pretty_print_fn initializer; | |
80 | |
81 c_pretty_print_fn statement; | |
82 | |
83 c_pretty_print_fn constant; | |
84 c_pretty_print_fn id_expression; | |
85 c_pretty_print_fn primary_expression; | |
86 c_pretty_print_fn postfix_expression; | |
87 c_pretty_print_fn unary_expression; | |
88 c_pretty_print_fn multiplicative_expression; | |
89 c_pretty_print_fn conditional_expression; | |
90 c_pretty_print_fn assignment_expression; | |
91 c_pretty_print_fn expression; | |
92 }; | 92 }; |
93 | |
94 /* Override the pp_base macro. Derived pretty-printers should not | |
95 touch this macro. Instead they should override pp_c_base instead. */ | |
96 #undef pp_base | |
97 #define pp_base(PP) (&pp_c_base (PP)->base) | |
98 | |
99 | 93 |
100 #define pp_c_tree_identifier(PPI, ID) \ | 94 #define pp_c_tree_identifier(PPI, ID) \ |
101 pp_c_identifier (PPI, IDENTIFIER_POINTER (ID)) | 95 pp_c_identifier (PPI, IDENTIFIER_POINTER (ID)) |
102 | 96 |
103 #define pp_declaration(PPI, T) \ | 97 #define pp_type_specifier_seq(PP, D) (PP)->type_specifier_seq (PP, D) |
104 pp_c_base (PPI)->declaration (pp_c_base (PPI), T) | 98 #define pp_ptr_operator(PP, D) (PP)->ptr_operator (PP, D) |
105 #define pp_declaration_specifiers(PPI, D) \ | 99 #define pp_parameter_list(PP, T) (PP)->parameter_list (PP, T) |
106 pp_c_base (PPI)->declaration_specifiers (pp_c_base (PPI), D) | |
107 #define pp_abstract_declarator(PP, D) \ | |
108 pp_c_base (PP)->abstract_declarator (pp_c_base (PP), D) | |
109 #define pp_type_specifier_seq(PPI, D) \ | |
110 pp_c_base (PPI)->type_specifier_seq (pp_c_base (PPI), D) | |
111 #define pp_declarator(PPI, D) \ | |
112 pp_c_base (PPI)->declarator (pp_c_base (PPI), D) | |
113 #define pp_direct_declarator(PPI, D) \ | |
114 pp_c_base (PPI)->direct_declarator (pp_c_base (PPI), D) | |
115 #define pp_direct_abstract_declarator(PP, D) \ | |
116 pp_c_base (PP)->direct_abstract_declarator (pp_c_base (PP), D) | |
117 #define pp_ptr_operator(PP, D) \ | |
118 pp_c_base (PP)->ptr_operator (pp_c_base (PP), D) | |
119 #define pp_parameter_list(PPI, T) \ | |
120 pp_c_base (PPI)->parameter_list (pp_c_base (PPI), T) | |
121 #define pp_type_id(PPI, D) \ | |
122 pp_c_base (PPI)->type_id (pp_c_base (PPI), D) | |
123 #define pp_simple_type_specifier(PP, T) \ | |
124 pp_c_base (PP)->simple_type_specifier (pp_c_base (PP), T) | |
125 #define pp_function_specifier(PP, D) \ | |
126 pp_c_base (PP)->function_specifier (pp_c_base (PP), D) | |
127 #define pp_storage_class_specifier(PP, D) \ | |
128 pp_c_base (PP)->storage_class_specifier (pp_c_base (PP), D); | |
129 | 100 |
130 #define pp_statement(PPI, S) \ | |
131 pp_c_base (PPI)->statement (pp_c_base (PPI), S) | |
132 | |
133 #define pp_constant(PP, E) \ | |
134 pp_c_base (PP)->constant (pp_c_base (PP), E) | |
135 #define pp_id_expression(PP, E) \ | |
136 pp_c_base (PP)->id_expression (pp_c_base (PP), E) | |
137 #define pp_primary_expression(PPI, E) \ | |
138 pp_c_base (PPI)->primary_expression (pp_c_base (PPI), E) | |
139 #define pp_postfix_expression(PPI, E) \ | |
140 pp_c_base (PPI)->postfix_expression (pp_c_base (PPI), E) | |
141 #define pp_unary_expression(PPI, E) \ | |
142 pp_c_base (PPI)->unary_expression (pp_c_base (PPI), E) | |
143 #define pp_initializer(PPI, E) \ | |
144 pp_c_base (PPI)->initializer (pp_c_base (PPI), E) | |
145 #define pp_multiplicative_expression(PPI, E) \ | |
146 pp_c_base (PPI)->multiplicative_expression (pp_c_base (PPI), E) | |
147 #define pp_conditional_expression(PPI, E) \ | |
148 pp_c_base (PPI)->conditional_expression (pp_c_base (PPI), E) | |
149 #define pp_assignment_expression(PPI, E) \ | |
150 pp_c_base (PPI)->assignment_expression (pp_c_base (PPI), E) | |
151 #define pp_expression(PP, E) \ | |
152 pp_c_base (PP)->expression (pp_c_base (PP), E) | |
153 | |
154 | |
155 /* Returns the c_pretty_printer base object of PRETTY-PRINTER. This | |
156 macro must be overridden by any subclass of c_pretty_print_info. */ | |
157 #define pp_c_base(PP) (PP) | |
158 | |
159 extern void pp_c_pretty_printer_init (c_pretty_printer *); | |
160 void pp_c_whitespace (c_pretty_printer *); | 101 void pp_c_whitespace (c_pretty_printer *); |
161 void pp_c_left_paren (c_pretty_printer *); | 102 void pp_c_left_paren (c_pretty_printer *); |
162 void pp_c_right_paren (c_pretty_printer *); | 103 void pp_c_right_paren (c_pretty_printer *); |
163 void pp_c_left_brace (c_pretty_printer *); | 104 void pp_c_left_brace (c_pretty_printer *); |
164 void pp_c_right_brace (c_pretty_printer *); | 105 void pp_c_right_brace (c_pretty_printer *); |
175 | 116 |
176 /* Declarations. */ | 117 /* Declarations. */ |
177 void pp_c_tree_decl_identifier (c_pretty_printer *, tree); | 118 void pp_c_tree_decl_identifier (c_pretty_printer *, tree); |
178 void pp_c_function_definition (c_pretty_printer *, tree); | 119 void pp_c_function_definition (c_pretty_printer *, tree); |
179 void pp_c_attributes (c_pretty_printer *, tree); | 120 void pp_c_attributes (c_pretty_printer *, tree); |
121 void pp_c_attributes_display (c_pretty_printer *, tree); | |
180 void pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, bool func_type); | 122 void pp_c_cv_qualifiers (c_pretty_printer *pp, int qualifiers, bool func_type); |
181 void pp_c_type_qualifier_list (c_pretty_printer *, tree); | 123 void pp_c_type_qualifier_list (c_pretty_printer *, tree); |
182 void pp_c_parameter_type_list (c_pretty_printer *, tree); | 124 void pp_c_parameter_type_list (c_pretty_printer *, tree); |
183 void pp_c_declaration (c_pretty_printer *, tree); | |
184 void pp_c_declaration_specifiers (c_pretty_printer *, tree); | |
185 void pp_c_declarator (c_pretty_printer *, tree); | |
186 void pp_c_direct_declarator (c_pretty_printer *, tree); | |
187 void pp_c_specifier_qualifier_list (c_pretty_printer *, tree); | 125 void pp_c_specifier_qualifier_list (c_pretty_printer *, tree); |
188 void pp_c_function_specifier (c_pretty_printer *, tree); | |
189 void pp_c_type_id (c_pretty_printer *, tree); | |
190 void pp_c_direct_abstract_declarator (c_pretty_printer *, tree); | |
191 void pp_c_type_specifier (c_pretty_printer *, tree); | |
192 void pp_c_storage_class_specifier (c_pretty_printer *, tree); | |
193 /* Statements. */ | |
194 void pp_c_statement (c_pretty_printer *, tree); | |
195 /* Expressions. */ | 126 /* Expressions. */ |
196 void pp_c_expression (c_pretty_printer *, tree); | |
197 void pp_c_logical_or_expression (c_pretty_printer *, tree); | 127 void pp_c_logical_or_expression (c_pretty_printer *, tree); |
198 void pp_c_expression_list (c_pretty_printer *, tree); | 128 void pp_c_expression_list (c_pretty_printer *, tree); |
199 void pp_c_constructor_elts (c_pretty_printer *, VEC(constructor_elt,gc) *); | 129 void pp_c_constructor_elts (c_pretty_printer *, vec<constructor_elt, va_gc> *); |
200 void pp_c_call_argument_list (c_pretty_printer *, tree); | 130 void pp_c_call_argument_list (c_pretty_printer *, tree); |
201 void pp_c_unary_expression (c_pretty_printer *, tree); | |
202 void pp_c_cast_expression (c_pretty_printer *, tree); | 131 void pp_c_cast_expression (c_pretty_printer *, tree); |
203 void pp_c_postfix_expression (c_pretty_printer *, tree); | |
204 void pp_c_primary_expression (c_pretty_printer *, tree); | |
205 void pp_c_init_declarator (c_pretty_printer *, tree); | 132 void pp_c_init_declarator (c_pretty_printer *, tree); |
206 void pp_c_constant (c_pretty_printer *, tree); | |
207 void pp_c_id_expression (c_pretty_printer *, tree); | |
208 void pp_c_ws_string (c_pretty_printer *, const char *); | 133 void pp_c_ws_string (c_pretty_printer *, const char *); |
209 void pp_c_identifier (c_pretty_printer *, const char *); | 134 void pp_c_identifier (c_pretty_printer *, const char *); |
210 void pp_c_string_literal (c_pretty_printer *, tree); | 135 void pp_c_string_literal (c_pretty_printer *, tree); |
211 | 136 |
212 void print_c_tree (FILE *file, tree t); | 137 void print_c_tree (FILE *file, tree t); |