Debian Codegraph @

libgfortran/io/format.h

raw
1 /* Copyright (C) 2009-2025 Free Software Foundation, Inc.
2 Contributed by Janne Blomqvist
3
4 This file is part of the GNU Fortran runtime library (libgfortran).
5
6 Libgfortran is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3, or (at your option)
9 any later version.
10
11 Libgfortran is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
19
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
24
25 #ifndef GFOR_FORMAT_H
26 #define GFOR_FORMAT_H
27
28 #include "io.h"
29
30 /* Format nodes. A format string is converted into a tree of these
31 structures, which is traversed as part of a data transfer statement. */
32
33 struct fnode
34 {
35 format_token format;
36 format_token pushed;
37 int repeat;
38 struct fnode *next;
39 char *source;
40
41 union
42 {
43 struct
44 {
45 int w, d, e;
46 }
47 real;
48
49 struct
50 {
51 int length;
52 char *p;
53 }
54 string;
55
56 struct
57 {
58 int w, m;
59 }
60 integer;
61
62 struct
63 {
64 char *string;
65 int string_len;
66 gfc_full_array_i4 *vlist;
67 }
68 udf; /* User Defined Format. */
69
70 int w;
71 int k;
72 int r;
73 int n;
74
75 struct fnode *child;
76 }
77 u;
78
79 /* Members for traversing the tree during data transfer. */
80
81 int count;
82 struct fnode *current;
83
84 };
85
86
87 /* A storage structures for format node data. */
88
89 #define FARRAY_SIZE 64
90
91 typedef struct fnode_array
92 {
93 struct fnode_array *next;
94 fnode array[FARRAY_SIZE];
95 }
96 fnode_array;
97
98
99 typedef struct format_data
100 {
101 char *format_string, *string;
102 const char *error;
103 char error_element;
104 format_token saved_token;
105 int value, format_string_len, reversion_ok;
106 fnode *avail;
107 const fnode *saved_format;
108 fnode_array *last;
109 fnode_array array;
110 }
111 format_data;
112
113 extern void parse_format (st_parameter_dt *);
114 internal_proto(parse_format);
115
116 extern const fnode *next_format (st_parameter_dt *);
117 internal_proto(next_format);
118
119 extern void unget_format (st_parameter_dt *, const fnode *);
120 internal_proto(unget_format);
121
122 extern void format_error (st_parameter_dt *, const fnode *, const char *);
123 internal_proto(format_error);
124
125 extern void free_format_data (struct format_data *);
126 internal_proto(free_format_data);
127
128 extern void free_format (st_parameter_dt *);
129 internal_proto(free_format);
130
131 extern void free_format_hash_table (gfc_unit *);
132 internal_proto(free_format_hash_table);
133
134 extern void init_format_hash (st_parameter_dt *);
135 internal_proto(init_format_hash);
136
137 extern void free_format_hash (st_parameter_dt *);
138 internal_proto(free_format_hash);
139
140 #endif