1 /* Various declarations for the C and C++ pretty-printers.
2 Copyright (C) 2002, 2003 Free Software Foundation, Inc.
3 Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to the Free
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #ifndef GCC_C_PRETTY_PRINTER
23 #define GCC_C_PRETTY_PRINTER
27 #include "pretty-print.h"
30 /* The data type used to bundle information necessary for pretty-printing
32 typedef struct c_pretty_print_info
*c_pretty_printer
;
34 /* The type of a C pretty-printer 'member' function. */
35 typedef void (*c_pretty_print_fn
) (c_pretty_printer
, tree
);
37 struct c_pretty_print_info
39 struct pretty_print_info base
;
40 /* Points to the first element of an array of offset-list.
44 /* These must be overridden by each of the C and C++ front-end to
45 reflect their understanding of syntactic productions when they differ. */
46 c_pretty_print_fn declaration
;
47 c_pretty_print_fn declaration_specifiers
;
48 c_pretty_print_fn type_specifier
;
49 c_pretty_print_fn declarator
;
50 c_pretty_print_fn direct_declarator
;
51 c_pretty_print_fn parameter_declaration
;
52 c_pretty_print_fn type_id
;
54 c_pretty_print_fn statement
;
56 c_pretty_print_fn primary_expression
;
57 c_pretty_print_fn postfix_expression
;
58 c_pretty_print_fn unary_expression
;
59 c_pretty_print_fn initializer
;
60 c_pretty_print_fn multiplicative_expression
;
61 c_pretty_print_fn conditional_expression
;
62 c_pretty_print_fn assignment_expression
;
66 #define pp_base(PP) (&pp_c_base (PP)->base)
68 #define pp_c_left_paren(PPI) \
70 pp_left_paren (PPI); \
71 pp_c_base (PPI)->base.padding = pp_none; \
73 #define pp_c_right_paren(PPI) \
75 pp_right_paren (PPI); \
76 pp_c_base (PPI)->base.padding = pp_none; \
78 #define pp_c_left_bracket(PPI) \
80 pp_left_bracket (PPI); \
81 pp_c_base (PPI)->base.padding = pp_none; \
83 #define pp_c_right_bracket(PPI) \
85 pp_right_bracket (PPI); \
86 pp_c_base (PPI)->base.padding = pp_none; \
88 #define pp_c_whitespace(PPI) \
91 pp_c_base (PPI)->base.padding = pp_none; \
93 #define pp_c_maybe_whitespace(PPI) \
95 if (pp_c_base (PPI)->base.padding != pp_none) \
96 pp_c_whitespace (PPI); \
98 #define pp_c_identifier(PPI, ID) \
100 pp_c_maybe_whitespace (PPI); \
101 pp_identifier (PPI, ID); \
102 pp_c_base (PPI)->base.padding = pp_before; \
105 #define pp_c_tree_identifier(PPI, ID) \
106 pp_c_identifier (PPI, IDENTIFIER_POINTER (ID))
108 #define pp_declaration(PPI, T) \
109 (*pp_c_base (PPI)->declaration) (pp_c_base (PPI), T)
110 #define pp_declaration_specifiers(PPI, D) \
111 (*pp_c_base (PPI)->declaration_specifiers) (pp_c_base (PPI), D)
112 #define pp_type_specifier(PPI, D) \
113 (*pp_c_base (PPI)->type_specifier) (pp_c_base (PPI), D)
114 #define pp_declarator(PPI, D) \
115 (*pp_c_base (PPI)->declarator) (pp_c_base (PPI), D)
116 #define pp_direct_declarator(PPI, D) \
117 (*pp_c_base (PPI)->direct_declarator) (pp_c_base (PPI), D)
118 #define pp_parameter_declaration(PPI, T) \
119 (*pp_c_base (PPI)->parameter_declaration) (pp_c_base (PPI), T)
120 #define pp_type_id(PPI, D) \
121 (*pp_c_base (PPI)->type_id) (pp_c_base (PPI), D)
123 #define pp_statement(PPI, S) \
124 (*pp_c_base (PPI)->statement) (pp_c_base (PPI), S)
126 #define pp_primary_expression(PPI, E) \
127 (*pp_c_base (PPI)->primary_expression) (pp_c_base (PPI), E)
128 #define pp_postfix_expression(PPI, E) \
129 (*pp_c_base (PPI)->postfix_expression) (pp_c_base (PPI), E)
130 #define pp_unary_expression(PPI, E) \
131 (*pp_c_base (PPI)->unary_expression) (pp_c_base (PPI), E)
132 #define pp_initializer(PPI, E) \
133 (*pp_c_base (PPI)->initializer) (pp_c_base (PPI), E)
134 #define pp_multiplicative_expression(PPI, E) \
135 (*pp_c_base (PPI)->multiplicative_expression) (pp_c_base (PPI), E)
136 #define pp_conditional_expression(PPI, E) \
137 (*pp_c_base (PPI)->conditional_expression) (pp_c_base (PPI), E)
138 #define pp_assignment_expression(PPI, E) \
139 (*pp_c_base (PPI)->assignment_expression) (pp_c_base (PPI), E)
142 /* Returns the c_pretty_printer base object of PRETTY-PRINTER. This
143 macro must be overridden by any subclass of c_pretty_print_info. */
144 #define pp_c_base(PP) (PP)
146 extern void pp_c_pretty_printer_init (c_pretty_printer
);
149 void pp_c_attributes (c_pretty_printer
, tree
);
150 void pp_c_cv_qualifier (c_pretty_printer
, int);
151 void pp_c_parameter_declaration_clause (c_pretty_printer
, tree
);
152 void pp_c_declaration (c_pretty_printer
, tree
);
154 void pp_c_statement (c_pretty_printer
, tree
);
156 void pp_c_expression (c_pretty_printer
, tree
);
157 void pp_c_logical_or_expression (c_pretty_printer
, tree
);
158 void pp_c_expression_list (c_pretty_printer
, tree
);
159 void pp_c_cast_expression (c_pretty_printer
, tree
);
160 void pp_c_postfix_expression (c_pretty_printer
, tree
);
161 void pp_c_initializer (c_pretty_printer
, tree
);
162 void pp_c_literal (c_pretty_printer
, tree
);
164 #endif /* GCC_C_PRETTY_PRINTER */