OSDN Git Service

* c-pretty-print.h (pp_c_statement): Declare.
[pf3gnuchains/gcc-fork.git] / gcc / c-pretty-print.h
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>
4
5 This file is part of GCC.
6
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
10 version.
11
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
15 for more details.
16
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
20 02111-1307, USA.  */
21
22 #include "tree.h"
23 #include "c-common.h"
24 #include "pretty-print.h"
25
26
27 /* The data type used to bundle information necessary for pretty-printing
28    a C or C++ entity.  */
29 typedef struct c_pretty_print_info c_pretty_print_info;
30
31 /* The type of a C pretty-printer 'member' function.  */
32 typedef void (*c_pretty_print_fn) PARAMS ((c_pretty_print_info *, tree));
33
34 struct c_pretty_print_info
35 {
36   struct pretty_print_info base;
37   /* Points to the first element of an array of offset-list.
38      Not used yet.  */
39   int *offset_list;
40
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;
50
51   c_pretty_print_fn statement;
52
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 initializer;
57   c_pretty_print_fn multiplicative_expression;
58   c_pretty_print_fn conditional_expression;
59   c_pretty_print_fn assignment_expression;
60 };
61
62 #define pp_buffer(PPI) (PPI)->base.buffer
63 #define pp_c_left_paren(PPI)             \
64    do {                                  \
65      pp_left_paren (PPI);                \
66      (PPI)->base.padding = pp_none;      \
67    } while (0)
68 #define pp_c_right_paren(PPI)            \
69    do {                                  \
70      pp_right_paren (PPI);               \
71      (PPI)->base.padding = pp_none;      \
72    } while (0)
73 #define pp_c_left_bracket(PPI)           \
74    do {                                  \
75      pp_left_bracket (PPI);              \
76      (PPI)->base.padding = pp_none;      \
77    } while (0)
78 #define pp_c_right_bracket(PPI)          \
79    do {                                  \
80      pp_right_bracket (PPI);             \
81      (PPI)->base.padding = pp_none;      \
82    } while (0)
83 #define pp_c_whitespace(PPI)             \
84    do {                                  \
85      pp_whitespace (PPI);                \
86      (PPI)->base.padding = pp_none;      \
87    } while (0)
88 #define pp_c_maybe_whitespace(PPI)       \
89    do {                                  \
90      if ((PPI)->base.padding != pp_none) \
91        pp_c_whitespace (PPI);            \
92    } while (0)
93 #define pp_c_identifier(PPI, ID)         \
94    do {                                  \
95      pp_c_maybe_whitespace (PPI);        \
96      pp_identifier (PPI, ID);            \
97      (PPI)->base.padding = pp_before;    \
98    } while (0)
99      
100 #define pp_c_tree_identifier(PPI, ID)    \
101    pp_c_identifier (PPI, IDENTIFIER_POINTER (ID))
102
103
104 #define pp_declaration(PPI, T)            (*(PPI)->declaration) (PPI, T)
105 #define pp_declaration_specifiers(PPI, D) \
106    (*(PPI)->declaration_specifiers) (PPI, D)
107 #define pp_type_specifier(PPI, D)         (*(PPI)->type_specifier) (PPI, D)
108 #define pp_declarator(PPI, D)             (*(PPI)->declarator) (PPI, D)
109 #define pp_direct_declarator(PPI, D)      (*(PPI)->direct_declarator) (PPI, D)
110 #define pp_parameter_declaration(PPI, T)  \
111   (*(PPI)->parameter_declaration) (PPI, T)
112 #define pp_type_id(PPI, D)                (*(PPI)->type_id) (PPI, D)
113
114 #define pp_statement(PPI, S)              (*(PPI)->statement) (PPI, S)
115
116 #define pp_primary_expression(PPI, E)     (*(PPI)->primary_expression) (PPI, E)
117 #define pp_postfix_expression(PPI, E)     (*(PPI)->postfix_expression) (PPI, E)
118 #define pp_unary_expression(PPI, E)       (*(PPI)->unary_expression) (PPI, E)
119 #define pp_initializer(PPI, E)            (*(PPI)->initializer) (PPI, E)
120 #define pp_multiplicative_expression(PPI, E)\
121    (*(PPI)->multiplicative_expression) (PPI, E)
122 #define pp_conditional_expression(PPI, E)  \
123    (*(PPI)->conditional_expression) (PPI, E)
124 #define pp_assignment_expression(PPI, E)  \
125    (*(PPI)->assignment_expression) (PPI, E)
126
127
128 /* Declarations.  */
129 void pp_c_cv_qualifier PARAMS ((c_pretty_print_info *, int));
130 void pp_c_parameter_declaration_clause PARAMS ((c_pretty_print_info *, tree));
131 void pp_c_declaration PARAMS ((c_pretty_print_info *, tree));
132 void pp_c_statement PARAMS ((c_pretty_print_info *, tree));
133 void pp_c_expression PARAMS ((c_pretty_print_info *, tree));
134 /* Statements.  */
135 void pp_c_statement PARAMS ((c_pretty_print_info *, tree));
136 /* Expressions.  */
137 void pp_c_expression PARAMS ((c_pretty_print_info *, tree));
138 void pp_c_logical_or_expression PARAMS ((c_pretty_print_info *, tree));
139 void pp_c_expression_list PARAMS ((c_pretty_print_info *, tree));
140 void pp_c_cast_expression PARAMS ((c_pretty_print_info *, tree));
141 void pp_c_postfix_expression PARAMS ((c_pretty_print_info *, tree));
142 void pp_c_initializer PARAMS ((c_pretty_print_info *, tree));
143 void pp_c_literal PARAMS ((c_pretty_print_info *, tree));