1 /* nice_printf -- same arguments as fprintf.
2 
3 	All output which is to become C code must be directed through this
4    function.  For now, no buffering is done.  Later on, every line of
5    output will be filtered to accomodate the style definitions (e.g. one
6    statement per line, spaces between function names and argument lists,
7    etc.)
8 */
9 #include "niceprintf.h"
10 
11 
12 /* Definitions for the opcode table.  The table is indexed by the macros
13    which are #defined in   defines.h   */
14 
15 #define UNARY_OP 01
16 #define BINARY_OP 02
17 
18 #define SPECIAL_FMT NULL
19 
20 #define is_unary_op(x) (opcode_table[x].type == UNARY_OP)
21 #define is_binary_op(x) (opcode_table[x].type == BINARY_OP)
22 #define op_precedence(x) (opcode_table[x].prec)
23 #define op_format(x) (opcode_table[x].format)
24 
25 /* _assoc_table -- encodes left-associativity and right-associativity
26    information; indexed by precedence level.  Only 2, 3, 14 are
27    right-associative.  Source:  Kernighan & Ritchie, p. 49 */
28 
29 extern char _assoc_table[];
30 
31 #define is_right_assoc(x) (_assoc_table [x])
32 #define is_left_assoc(x) (! _assoc_table [x])
33 
34 
35 typedef struct {
36     int type;			/* UNARY_OP or BINARY_OP */
37     int prec;			/* Precedence level, useful for adjusting
38 				   number of parens to insert.  Zero is a
39 				   special level, and 2, 3, 14 are
40 				   right-associative */
41     char *format;
42 } table_entry;
43 
44 
45 extern char *fl_fmt_string;	/* Float constant format string */
46 extern char *db_fmt_string;	/* Double constant format string */
47 extern char *cm_fmt_string;	/* Complex constant format string */
48 extern char *dcm_fmt_string;	/* Double Complex constant format string */
49 
50 extern int indent;		/* Number of spaces to indent; this is a
51 				   temporary fix */
52 extern int tab_size;		/* Number of spaces in each tab */
53 extern int in_string;
54 
55 extern table_entry opcode_table[];
56 
57 
58 void	compgoto_out Argdcl((FILEP, tagptr, tagptr));
59 void	endif_out Argdcl((FILEP));
60 void	expr_out Argdcl((FILEP, tagptr));
61 void	out_and_free_statement Argdcl((FILEP, tagptr));
62 void	out_end_for Argdcl((FILEP));
63 void	out_if Argdcl((FILEP, tagptr));
64 void	out_name Argdcl((FILEP, Namep));
65