]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/c-pretty-print.h
Change copyright header to refer to version 3 of the GNU General Public License and...
[thirdparty/gcc.git] / gcc / c-pretty-print.h
CommitLineData
61ccbcfd 1/* Various declarations for the C and C++ pretty-printers.
9dcd6f09 2 Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
61ccbcfd
GDR
3 Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it under
8the terms of the GNU General Public License as published by the Free
9dcd6f09 9Software Foundation; either version 3, or (at your option) any later
61ccbcfd
GDR
10version.
11
12GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13WARRANTY; without even the implied warranty of MERCHANTABILITY or
14FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15for more details.
16
17You should have received a copy of the GNU General Public License
9dcd6f09
NC
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
61ccbcfd 20
6bf346d4
GDR
21#ifndef GCC_C_PRETTY_PRINTER
22#define GCC_C_PRETTY_PRINTER
23
61ccbcfd
GDR
24#include "tree.h"
25#include "c-common.h"
26#include "pretty-print.h"
27
28
4b780675
GDR
29typedef enum
30 {
31 pp_c_flag_abstract = 1 << 1,
c22cacf3 32 pp_c_flag_last_bit = 2
4b780675
GDR
33 } pp_c_pretty_print_flags;
34
35
61ccbcfd
GDR
36/* The data type used to bundle information necessary for pretty-printing
37 a C or C++ entity. */
12ea3302 38typedef struct c_pretty_print_info c_pretty_printer;
61ccbcfd
GDR
39
40/* The type of a C pretty-printer 'member' function. */
12ea3302
GDR
41typedef void (*c_pretty_print_fn) (c_pretty_printer *, tree);
42
43/* The datatype that contains information necessary for pretty-printing
44 a tree that represents a C construct. Any pretty-printer for a
45 language using C/c++ syntax can derive from this datatype and reuse
46 facilities provided here. It can do so by having a subobject of type
47 c_pretty_printer and override the macro pp_c_base to return a pointer
2067c116 48 to that subobject. Such a pretty-printer has the responsibility to
12ea3302
GDR
49 initialize the pp_base() part, then call pp_c_pretty_printer_init
50 to set up the components that are specific to the C pretty-printer.
51 A derived pretty-printer can override any function listed in the
52 vtable below. See cp/cxx-pretty-print.h and cp/cxx-pretty-print.c
53 for an example of derivation. */
61ccbcfd
GDR
54struct c_pretty_print_info
55{
12ea3302 56 pretty_printer base;
61ccbcfd
GDR
57 /* Points to the first element of an array of offset-list.
58 Not used yet. */
59 int *offset_list;
60
4b780675 61 pp_flags flags;
c22cacf3 62
5bdc5878 63 /* These must be overridden by each of the C and C++ front-end to
95bd1dd7 64 reflect their understanding of syntactic productions when they differ. */
61ccbcfd
GDR
65 c_pretty_print_fn declaration;
66 c_pretty_print_fn declaration_specifiers;
61ccbcfd 67 c_pretty_print_fn declarator;
4b780675 68 c_pretty_print_fn abstract_declarator;
12ea3302
GDR
69 c_pretty_print_fn direct_abstract_declarator;
70 c_pretty_print_fn type_specifier_seq;
61ccbcfd 71 c_pretty_print_fn direct_declarator;
12ea3302
GDR
72 c_pretty_print_fn ptr_operator;
73 c_pretty_print_fn parameter_list;
61ccbcfd 74 c_pretty_print_fn type_id;
12ea3302 75 c_pretty_print_fn simple_type_specifier;
4b780675
GDR
76 c_pretty_print_fn function_specifier;
77 c_pretty_print_fn storage_class_specifier;
12ea3302 78 c_pretty_print_fn initializer;
61ccbcfd
GDR
79
80 c_pretty_print_fn statement;
81
a176426f 82 c_pretty_print_fn constant;
4b780675 83 c_pretty_print_fn id_expression;
61ccbcfd
GDR
84 c_pretty_print_fn primary_expression;
85 c_pretty_print_fn postfix_expression;
86 c_pretty_print_fn unary_expression;
87 c_pretty_print_fn multiplicative_expression;
88 c_pretty_print_fn conditional_expression;
89 c_pretty_print_fn assignment_expression;
12ea3302 90 c_pretty_print_fn expression;
61ccbcfd
GDR
91};
92
12ea3302
GDR
93/* Override the pp_base macro. Derived pretty-printers should not
94 touch this macro. Instead they should override pp_c_base instead. */
b6fe0bb8
GDR
95#undef pp_base
96#define pp_base(PP) (&pp_c_base (PP)->base)
97
6de9cd9a 98
6bf346d4 99#define pp_c_tree_identifier(PPI, ID) \
61ccbcfd
GDR
100 pp_c_identifier (PPI, IDENTIFIER_POINTER (ID))
101
6bf346d4 102#define pp_declaration(PPI, T) \
4b780675 103 pp_c_base (PPI)->declaration (pp_c_base (PPI), T)
6bf346d4 104#define pp_declaration_specifiers(PPI, D) \
4b780675
GDR
105 pp_c_base (PPI)->declaration_specifiers (pp_c_base (PPI), D)
106#define pp_abstract_declarator(PP, D) \
107 pp_c_base (PP)->abstract_declarator (pp_c_base (PP), D)
12ea3302 108#define pp_type_specifier_seq(PPI, D) \
53de5204 109 pp_c_base (PPI)->type_specifier_seq (pp_c_base (PPI), D)
6bf346d4 110#define pp_declarator(PPI, D) \
4b780675 111 pp_c_base (PPI)->declarator (pp_c_base (PPI), D)
6bf346d4 112#define pp_direct_declarator(PPI, D) \
4b780675 113 pp_c_base (PPI)->direct_declarator (pp_c_base (PPI), D)
12ea3302
GDR
114#define pp_direct_abstract_declarator(PP, D) \
115 pp_c_base (PP)->direct_abstract_declarator (pp_c_base (PP), D)
116#define pp_ptr_operator(PP, D) \
117 pp_c_base (PP)->ptr_operator (pp_c_base (PP), D)
118#define pp_parameter_list(PPI, T) \
119 pp_c_base (PPI)->parameter_list (pp_c_base (PPI), T)
6bf346d4 120#define pp_type_id(PPI, D) \
4b780675 121 pp_c_base (PPI)->type_id (pp_c_base (PPI), D)
12ea3302
GDR
122#define pp_simple_type_specifier(PP, T) \
123 pp_c_base (PP)->simple_type_specifier (pp_c_base (PP), T)
4b780675
GDR
124#define pp_function_specifier(PP, D) \
125 pp_c_base (PP)->function_specifier (pp_c_base (PP), D)
126#define pp_storage_class_specifier(PP, D) \
127 pp_c_base (PP)->storage_class_specifier (pp_c_base (PP), D);
6bf346d4
GDR
128
129#define pp_statement(PPI, S) \
4b780675 130 pp_c_base (PPI)->statement (pp_c_base (PPI), S)
6bf346d4 131
a176426f
GDR
132#define pp_constant(PP, E) \
133 pp_c_base (PP)->constant (pp_c_base (PP), E)
4b780675
GDR
134#define pp_id_expression(PP, E) \
135 pp_c_base (PP)->id_expression (pp_c_base (PP), E)
6bf346d4 136#define pp_primary_expression(PPI, E) \
4b780675 137 pp_c_base (PPI)->primary_expression (pp_c_base (PPI), E)
6bf346d4 138#define pp_postfix_expression(PPI, E) \
4b780675 139 pp_c_base (PPI)->postfix_expression (pp_c_base (PPI), E)
6bf346d4 140#define pp_unary_expression(PPI, E) \
4b780675 141 pp_c_base (PPI)->unary_expression (pp_c_base (PPI), E)
6bf346d4 142#define pp_initializer(PPI, E) \
4b780675 143 pp_c_base (PPI)->initializer (pp_c_base (PPI), E)
6bf346d4 144#define pp_multiplicative_expression(PPI, E) \
4b780675 145 pp_c_base (PPI)->multiplicative_expression (pp_c_base (PPI), E)
6bf346d4 146#define pp_conditional_expression(PPI, E) \
4b780675 147 pp_c_base (PPI)->conditional_expression (pp_c_base (PPI), E)
6bf346d4 148#define pp_assignment_expression(PPI, E) \
4b780675 149 pp_c_base (PPI)->assignment_expression (pp_c_base (PPI), E)
12ea3302
GDR
150#define pp_expression(PP, E) \
151 pp_c_base (PP)->expression (pp_c_base (PP), E)
6bf346d4
GDR
152
153
154/* Returns the c_pretty_printer base object of PRETTY-PRINTER. This
5bdc5878 155 macro must be overridden by any subclass of c_pretty_print_info. */
6bf346d4 156#define pp_c_base(PP) (PP)
61ccbcfd 157
12ea3302
GDR
158extern void pp_c_pretty_printer_init (c_pretty_printer *);
159void pp_c_whitespace (c_pretty_printer *);
160void pp_c_left_paren (c_pretty_printer *);
161void pp_c_right_paren (c_pretty_printer *);
a2a9e21c
GDR
162void pp_c_left_brace (c_pretty_printer *);
163void pp_c_right_brace (c_pretty_printer *);
41fd3bac
GDR
164void pp_c_left_bracket (c_pretty_printer *);
165void pp_c_right_bracket (c_pretty_printer *);
12ea3302
GDR
166void pp_c_dot (c_pretty_printer *);
167void pp_c_ampersand (c_pretty_printer *);
41fd3bac 168void pp_c_star (c_pretty_printer *);
12ea3302
GDR
169void pp_c_arrow (c_pretty_printer *);
170void pp_c_semicolon (c_pretty_printer *);
41fd3bac
GDR
171void pp_c_complement (c_pretty_printer *);
172void pp_c_exclamation (c_pretty_printer *);
12ea3302 173void pp_c_space_for_pointer_operator (c_pretty_printer *, tree);
f076f0ce 174
61ccbcfd 175/* Declarations. */
6de9cd9a 176void pp_c_tree_decl_identifier (c_pretty_printer *, tree);
12ea3302
GDR
177void pp_c_function_definition (c_pretty_printer *, tree);
178void pp_c_attributes (c_pretty_printer *, tree);
179void pp_c_type_qualifier_list (c_pretty_printer *, tree);
180void pp_c_parameter_type_list (c_pretty_printer *, tree);
181void pp_c_declaration (c_pretty_printer *, tree);
182void pp_c_declaration_specifiers (c_pretty_printer *, tree);
183void pp_c_declarator (c_pretty_printer *, tree);
184void pp_c_direct_declarator (c_pretty_printer *, tree);
185void pp_c_specifier_qualifier_list (c_pretty_printer *, tree);
186void pp_c_function_specifier (c_pretty_printer *, tree);
187void pp_c_type_id (c_pretty_printer *, tree);
188void pp_c_direct_abstract_declarator (c_pretty_printer *, tree);
189void pp_c_type_specifier (c_pretty_printer *, tree);
190void pp_c_storage_class_specifier (c_pretty_printer *, tree);
7ff4a7ef 191/* Statements. */
12ea3302 192void pp_c_statement (c_pretty_printer *, tree);
61ccbcfd 193/* Expressions. */
12ea3302
GDR
194void pp_c_expression (c_pretty_printer *, tree);
195void pp_c_logical_or_expression (c_pretty_printer *, tree);
196void pp_c_expression_list (c_pretty_printer *, tree);
4038c495 197void pp_c_constructor_elts (c_pretty_printer *, VEC(constructor_elt,gc) *);
12ea3302
GDR
198void pp_c_call_argument_list (c_pretty_printer *, tree);
199void pp_c_unary_expression (c_pretty_printer *, tree);
200void pp_c_cast_expression (c_pretty_printer *, tree);
201void pp_c_postfix_expression (c_pretty_printer *, tree);
202void pp_c_primary_expression (c_pretty_printer *, tree);
203void pp_c_init_declarator (c_pretty_printer *, tree);
204void pp_c_constant (c_pretty_printer *, tree);
205void pp_c_id_expression (c_pretty_printer *, tree);
206void pp_c_identifier (c_pretty_printer *, const char *);
207void pp_c_string_literal (c_pretty_printer *, tree);
6bf346d4 208
6de9cd9a
DN
209void print_c_tree (FILE *file, tree t);
210
6bf346d4 211#endif /* GCC_C_PRETTY_PRINTER */