Makefile.in (C_OBJS): Include c-pretty-print.o
[platform/upstream/gcc.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 multiplicative_expression;
57   c_pretty_print_fn conditional_expression;
58   c_pretty_print_fn assignment_expression;
59 };
60
61 #define pp_buffer(PPI) (PPI)->base.buffer
62 #define pp_c_left_paren(PPI)             \
63    do {                                  \
64      pp_left_paren (PPI);                \
65      (PPI)->base.padding = pp_none;      \
66    } while (0)
67 #define pp_c_right_paren(PPI)            \
68    do {                                  \
69      pp_right_paren (PPI);               \
70      (PPI)->base.padding = pp_none;      \
71    } while (0)
72 #define pp_c_left_bracket(PPI)           \
73    do {                                  \
74      pp_left_bracket (PPI);              \
75      (PPI)->base.padding = pp_none;      \
76    } while (0)
77 #define pp_c_right_bracket(PPI)          \
78    do {                                  \
79      pp_right_bracket (PPI);             \
80      (PPI)->base.padding = pp_none;      \
81    } while (0)
82 #define pp_c_whitespace(PPI)             \
83    do {                                  \
84      pp_whitespace (PPI);                \
85      (PPI)->base.padding = pp_none;      \
86    } while (0)
87 #define pp_c_maybe_whitespace(PPI)       \
88    do {                                  \
89      if ((PPI)->base.padding != pp_none) \
90        pp_c_whitespace (PPI);            \
91    } while (0)
92 #define pp_c_identifier(PPI, ID)         \
93    do {                                  \
94      pp_c_maybe_whitespace (PPI);        \
95      pp_identifier (PPI, ID);            \
96      (PPI)->base.padding = pp_before;    \
97    } while (0)
98      
99 #define pp_c_tree_identifier(PPI, ID)    \
100    pp_c_identifier (PPI, IDENTIFIER_POINTER (ID))
101
102
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)
112
113 #define pp_statement(PPI, S)              (*(PPI)->statement) (PPI, S)
114
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)
124
125
126 /* Declarations.  */
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));
132
133 /* Expressions.  */
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));