c-pretty-print.h revision 117395
1169691Skan/* Various declarations for the C and C++ pretty-printers. 2169691Skan Copyright (C) 2002 Free Software Foundation, Inc. 3169691Skan Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net> 4169691Skan 5169691SkanThis file is part of GCC. 6169691Skan 7169691SkanGCC is free software; you can redistribute it and/or modify it under 8169691Skanthe terms of the GNU General Public License as published by the Free 9169691SkanSoftware Foundation; either version 2, or (at your option) any later 10169691Skanversion. 11169691Skan 12169691SkanGCC is distributed in the hope that it will be useful, but WITHOUT ANY 13169691SkanWARRANTY; without even the implied warranty of MERCHANTABILITY or 14169691SkanFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 15169691Skanfor more details. 16169691Skan 17169691SkanYou should have received a copy of the GNU General Public License 18169691Skanalong with GCC; see the file COPYING. If not, write to the Free 19169691SkanSoftware Foundation, 59 Temple Place - Suite 330, Boston, MA 20169691Skan02111-1307, USA. */ 21169691Skan 22169691Skan#ifndef GCC_C_PRETTY_PRINTER 23169691Skan#define GCC_C_PRETTY_PRINTER 24169691Skan 25169691Skan#include "tree.h" 26169691Skan#include "c-common.h" 27169691Skan#include "pretty-print.h" 28169691Skan 29169691Skan 30169691Skan/* The data type used to bundle information necessary for pretty-printing 31169691Skan a C or C++ entity. */ 32169691Skantypedef struct c_pretty_print_info *c_pretty_printer; 33169691Skan 34169691Skan/* The type of a C pretty-printer 'member' function. */ 35169691Skantypedef void (*c_pretty_print_fn) PARAMS ((c_pretty_printer, tree)); 36169691Skan 37169691Skanstruct c_pretty_print_info 38169691Skan{ 39169691Skan struct pretty_print_info base; 40169691Skan /* Points to the first element of an array of offset-list. 41169691Skan Not used yet. */ 42169691Skan int *offset_list; 43169691Skan 44169691Skan /* These must be overriden by each of the C and C++ front-end to 45169691Skan reflect their understanding of syntatic productions when they differ. */ 46169691Skan c_pretty_print_fn declaration; 47169691Skan c_pretty_print_fn declaration_specifiers; 48169691Skan c_pretty_print_fn type_specifier; 49169691Skan c_pretty_print_fn declarator; 50169691Skan c_pretty_print_fn direct_declarator; 51169691Skan c_pretty_print_fn parameter_declaration; 52169691Skan c_pretty_print_fn type_id; 53169691Skan 54169691Skan c_pretty_print_fn statement; 55169691Skan 56169691Skan c_pretty_print_fn primary_expression; 57169691Skan c_pretty_print_fn postfix_expression; 58169691Skan c_pretty_print_fn unary_expression; 59169691Skan c_pretty_print_fn initializer; 60169691Skan c_pretty_print_fn multiplicative_expression; 61169691Skan c_pretty_print_fn conditional_expression; 62169691Skan c_pretty_print_fn assignment_expression; 63169691Skan}; 64169691Skan 65169691Skan#define pp_c_left_paren(PPI) \ 66169691Skan do { \ 67169691Skan pp_left_paren (PPI); \ 68169691Skan pp_c_base (PPI)->base.padding = pp_none; \ 69169691Skan } while (0) 70169691Skan#define pp_c_right_paren(PPI) \ 71169691Skan do { \ 72169691Skan pp_right_paren (PPI); \ 73169691Skan pp_c_base (PPI)->base.padding = pp_none; \ 74169691Skan } while (0) 75169691Skan#define pp_c_left_bracket(PPI) \ 76169691Skan do { \ 77169691Skan pp_left_bracket (PPI); \ 78169691Skan pp_c_base (PPI)->base.padding = pp_none; \ 79169691Skan } while (0) 80169691Skan#define pp_c_right_bracket(PPI) \ 81169691Skan do { \ 82169691Skan pp_right_bracket (PPI); \ 83169691Skan pp_c_base (PPI)->base.padding = pp_none; \ 84169691Skan } while (0) 85169691Skan#define pp_c_whitespace(PPI) \ 86169691Skan do { \ 87169691Skan pp_whitespace (PPI); \ 88169691Skan pp_c_base (PPI)->base.padding = pp_none; \ 89169691Skan } while (0) 90169691Skan#define pp_c_maybe_whitespace(PPI) \ 91169691Skan do { \ 92169691Skan if (pp_c_base (PPI)->base.padding != pp_none) \ 93169691Skan pp_c_whitespace (PPI); \ 94169691Skan } while (0) 95169691Skan#define pp_c_identifier(PPI, ID) \ 96169691Skan do { \ 97 pp_c_maybe_whitespace (PPI); \ 98 pp_identifier (PPI, ID); \ 99 pp_c_base (PPI)->base.padding = pp_before; \ 100 } while (0) 101 102#define pp_c_tree_identifier(PPI, ID) \ 103 pp_c_identifier (PPI, IDENTIFIER_POINTER (ID)) 104 105/* Returns the 'output_buffer *' associated with a PRETTY-PRINTER, the latter 106 being something digestible by pp_c_base. */ 107#define pp_buffer(PPI) pp_c_base (PPI)->base.buffer 108 109#define pp_declaration(PPI, T) \ 110 (*pp_c_base (PPI)->declaration) (pp_c_base (PPI), T) 111#define pp_declaration_specifiers(PPI, D) \ 112 (*pp_c_base (PPI)->declaration_specifiers) (pp_c_base (PPI), D) 113#define pp_type_specifier(PPI, D) \ 114 (*pp_c_base (PPI)->type_specifier) (pp_c_base (PPI), D) 115#define pp_declarator(PPI, D) \ 116 (*pp_c_base (PPI)->declarator) (pp_c_base (PPI), D) 117#define pp_direct_declarator(PPI, D) \ 118 (*pp_c_base (PPI)->direct_declarator) (pp_c_base (PPI), D) 119#define pp_parameter_declaration(PPI, T) \ 120 (*pp_c_base (PPI)->parameter_declaration) (pp_c_base (PPI), T) 121#define pp_type_id(PPI, D) \ 122 (*pp_c_base (PPI)->type_id) (pp_c_base (PPI), D) 123 124#define pp_statement(PPI, S) \ 125 (*pp_c_base (PPI)->statement) (pp_c_base (PPI), S) 126 127#define pp_primary_expression(PPI, E) \ 128 (*pp_c_base (PPI)->primary_expression) (pp_c_base (PPI), E) 129#define pp_postfix_expression(PPI, E) \ 130 (*pp_c_base (PPI)->postfix_expression) (pp_c_base (PPI), E) 131#define pp_unary_expression(PPI, E) \ 132 (*pp_c_base (PPI)->unary_expression) (pp_c_base (PPI), E) 133#define pp_initializer(PPI, E) \ 134 (*pp_c_base (PPI)->initializer) (pp_c_base (PPI), E) 135#define pp_multiplicative_expression(PPI, E) \ 136 (*pp_c_base (PPI)->multiplicative_expression) (pp_c_base (PPI), E) 137#define pp_conditional_expression(PPI, E) \ 138 (*pp_c_base (PPI)->conditional_expression) (pp_c_base (PPI), E) 139#define pp_assignment_expression(PPI, E) \ 140 (*pp_c_base (PPI)->assignment_expression) (pp_c_base (PPI), E) 141 142 143/* Returns the c_pretty_printer base object of PRETTY-PRINTER. This 144 macro must be overriden by any subclass of c_pretty_print_info. */ 145#define pp_c_base(PP) (PP) 146 147extern void pp_c_pretty_printer_init PARAMS ((c_pretty_printer)); 148 149/* Declarations. */ 150void pp_c_attributes PARAMS ((c_pretty_printer, tree)); 151void pp_c_cv_qualifier PARAMS ((c_pretty_printer, int)); 152void pp_c_parameter_declaration_clause PARAMS ((c_pretty_printer, tree)); 153void pp_c_declaration PARAMS ((c_pretty_printer, tree)); 154/* Statements. */ 155void pp_c_statement PARAMS ((c_pretty_printer, tree)); 156/* Expressions. */ 157void pp_c_expression PARAMS ((c_pretty_printer, tree)); 158void pp_c_logical_or_expression PARAMS ((c_pretty_printer, tree)); 159void pp_c_expression_list PARAMS ((c_pretty_printer, tree)); 160void pp_c_cast_expression PARAMS ((c_pretty_printer, tree)); 161void pp_c_postfix_expression PARAMS ((c_pretty_printer, tree)); 162void pp_c_initializer PARAMS ((c_pretty_printer, tree)); 163void pp_c_literal PARAMS ((c_pretty_printer, tree)); 164 165#endif /* GCC_C_PRETTY_PRINTER */ 166