1 /* Various declarations for the C and C++ pretty-printers.
2 Copyright (C) 2002 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
24 #include "pretty-print.h"
27 /* The data type used to bundle information necessary for pretty-printing
29 typedef struct c_pretty_print_info c_pretty_print_info;
31 /* The type of a C pretty-printer 'member' function. */
32 typedef void (*c_pretty_print_fn) PARAMS ((c_pretty_print_info *, tree));
34 struct c_pretty_print_info
36 struct pretty_print_info base;
37 /* Points to the first element of an array of offset-list.
41 /* These must be overriden by each of the C and C++ front-end to
42 reflect their understanding of syntatic productions when they differ. */
43 c_pretty_print_fn declaration;
44 c_pretty_print_fn declaration_specifiers;
45 c_pretty_print_fn type_specifier;
46 c_pretty_print_fn declarator;
47 c_pretty_print_fn direct_declarator;
48 c_pretty_print_fn parameter_declaration;
49 c_pretty_print_fn type_id;
51 c_pretty_print_fn statement;
53 c_pretty_print_fn primary_expression;
54 c_pretty_print_fn postfix_expression;
55 c_pretty_print_fn unary_expression;
56 c_pretty_print_fn multiplicative_expression;
57 c_pretty_print_fn conditional_expression;
58 c_pretty_print_fn assignment_expression;
61 #define pp_buffer(PPI) (PPI)->base.buffer
62 #define pp_c_left_paren(PPI) \
64 pp_left_paren (PPI); \
65 (PPI)->base.padding = pp_none; \
67 #define pp_c_right_paren(PPI) \
69 pp_right_paren (PPI); \
70 (PPI)->base.padding = pp_none; \
72 #define pp_c_left_bracket(PPI) \
74 pp_left_bracket (PPI); \
75 (PPI)->base.padding = pp_none; \
77 #define pp_c_right_bracket(PPI) \
79 pp_right_bracket (PPI); \
80 (PPI)->base.padding = pp_none; \
82 #define pp_c_whitespace(PPI) \
84 pp_whitespace (PPI); \
85 (PPI)->base.padding = pp_none; \
87 #define pp_c_maybe_whitespace(PPI) \
89 if ((PPI)->base.padding != pp_none) \
90 pp_c_whitespace (PPI); \
92 #define pp_c_identifier(PPI, ID) \
94 pp_c_maybe_whitespace (PPI); \
95 pp_identifier (PPI, ID); \
96 (PPI)->base.padding = pp_before; \
99 #define pp_c_tree_identifier(PPI, ID) \
100 pp_c_identifier (PPI, IDENTIFIER_POINTER (ID))
103 #define pp_declaration(PPI, T) (*(PPI)->declaration) (PPI, T)
104 #define pp_declaration_specifiers(PPI, D) \
105 (*(PPI)->declaration_specifiers) (PPI, D)
106 #define pp_type_specifier(PPI, D) (*(PPI)->type_specifier) (PPI, D)
107 #define pp_declarator(PPI, D) (*(PPI)->declarator) (PPI, D)
108 #define pp_direct_declarator(PPI, D) (*(PPI)->direct_declarator) (PPI, D)
109 #define pp_parameter_declaration(PPI, T) \
110 (*(PPI)->parameter_declaration) (PPI, T)
111 #define pp_type_id(PPI, D) (*(PPI)->type_id) (PPI, D)
113 #define pp_statement(PPI, S) (*(PPI)->statement) (PPI, S)
115 #define pp_primary_expression(PPI, E) (*(PPI)->primary_expression) (PPI, E)
116 #define pp_postfix_expression(PPI, E) (*(PPI)->postfix_expression) (PPI, E)
117 #define pp_unary_expression(PPI, E) (*(PPI)->unary_expression) (PPI, E)
118 #define pp_multiplicative_expression(PPI, E)\
119 (*(PPI)->multiplicative_expression) (PPI, E)
120 #define pp_conditional_expession(PPI, E) \
121 (*(PPI)->conditional_expression (PPI, E))
122 #define pp_assignment_expression(PPI, E) \
123 (*(PPI)->assignment_expression) (PPI, E)
127 void pp_c_cv_qualifier PARAMS ((c_pretty_print_info *, int));
128 void pp_c_parameter_declaration_clause PARAMS ((c_pretty_print_info *, tree));
129 void pp_c_declaration PARAMS ((c_pretty_print_info *, tree));
130 void pp_c_statement PARAMS ((c_pretty_print_info *, tree));
131 void pp_c_expression PARAMS ((c_pretty_print_info *, tree));
134 void pp_c_expression PARAMS ((c_pretty_print_info *, tree));
135 void pp_c_logical_or_expression PARAMS ((c_pretty_print_info *, tree));
136 void pp_c_expression_list PARAMS ((c_pretty_print_info *, tree));
137 void pp_c_cast_expression PARAMS ((c_pretty_print_info *, tree));
138 void pp_c_postfix_expression PARAMS ((c_pretty_print_info *, tree));
139 void pp_c_literal PARAMS ((c_pretty_print_info *, tree));