Debian Codegraph @

libgcobol/ec.h

raw
1 /*
2 * Copyright (c) 2021-2025 Symas Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of the Symas Corporation nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef _CBL_EC_H_
33 #define _CBL_EC_H_
34
35 #include <set>
36
37 #define EC_ALL_E 0xFFFFFF00
38
39 enum ec_type_t {
40 ec_none_e = 0x00000000,
41 ec_all_e = EC_ALL_E, // 0xFFFFFF00
42
43 ec_argument_e = 0x00000100,
44 ec_argument_function_e,
45 ec_argument_imp_e,
46 ec_argument_imp_command_e,
47 ec_argument_imp_environment_e,
48
49 ec_bound_e = 0x00000200,
50 ec_bound_func_ret_value_e,
51 ec_bound_imp_e,
52 ec_bound_odo_e,
53 ec_bound_overflow_e,
54 ec_bound_ptr_e,
55 ec_bound_ref_mod_e,
56 ec_bound_set_e,
57 ec_bound_subscript_e,
58 ec_bound_table_limit_e,
59
60 ec_data_e = 0x00000400,
61 ec_data_conversion_e,
62 ec_data_imp_e,
63 ec_data_incompatible_e,
64 ec_data_not_finite_e,
65 ec_data_overflow_e,
66 ec_data_ptr_null_e,
67
68 ec_external_e = 0x00000800,
69 ec_external_data_mismatch_e,
70 ec_external_file_mismatch_e,
71 ec_external_format_conflict_e,
72
73 ec_flow_e = 0x00001000,
74 ec_flow_global_exit_e,
75 ec_flow_global_goback_e,
76 ec_flow_imp_e,
77 ec_flow_release_e,
78 ec_flow_report_e,
79 ec_flow_return_e,
80 ec_flow_search_e,
81 ec_flow_use_e,
82
83 ec_function_e = 0x00002000,
84 ec_function_not_found_e,
85 ec_function_ptr_invalid_e,
86 ec_function_ptr_null_e,
87
88 ec_io_e = 0x00004000,
89 ec_io_at_end_e,
90 ec_io_invalid_key_e,
91 ec_io_permanent_error_e,
92 ec_io_logic_error_e,
93 ec_io_record_operation_e,
94 ec_io_file_sharing_e,
95 ec_io_record_content_e,
96 ec_io_imp_e,
97 ec_io_eop_e,
98 ec_io_eop_overflow_e,
99 ec_io_linage_e,
100
101 ec_imp_e = 0x00008000,
102 ec_imp_suffix_e,
103
104 ec_locale_e = 0x00010000,
105 ec_locale_imp_e,
106 ec_locale_incompatible_e,
107 ec_locale_invalid_e,
108 ec_locale_invalid_ptr_e,
109 ec_locale_missing_e,
110 ec_locale_size_e,
111
112 ec_oo_e = 0x00020000,
113 ec_oo_arg_omitted_e,
114 ec_oo_conformance_e,
115 ec_oo_exception_e,
116 ec_oo_imp_e,
117 ec_oo_method_e,
118 ec_oo_null_e,
119 ec_oo_resource_e,
120 ec_oo_universal_e,
121
122 ec_order_e = 0x00040000,
123 ec_order_imp_e,
124 ec_order_not_supported_e,
125
126 ec_overflow_e = 0x00080000,
127 ec_overflow_imp_e,
128 ec_overflow_string_e,
129 ec_overflow_unstring_e,
130
131 ec_program_e = 0x00100000,
132 ec_program_arg_mismatch_e,
133 ec_program_arg_omitted_e,
134 ec_program_cancel_active_e,
135 ec_program_imp_e,
136 ec_program_not_found_e,
137 ec_program_ptr_null_e,
138 ec_program_recursive_call_e,
139 ec_program_resources_e,
140
141 ec_raising_e = 0x00200000,
142 ec_raising_imp_e,
143 ec_raising_not_specified_e,
144
145 ec_range_e = 0x00400000,
146 ec_range_imp_e,
147 ec_range_index_e,
148 ec_range_inspect_size_e,
149 ec_range_invalid_e,
150 ec_range_perform_varying_e,
151 ec_range_ptr_e,
152 ec_range_search_index_e,
153 ec_range_search_no_match_e,
154
155 ec_report_e = 0x00800000,
156 ec_report_active_e,
157 ec_report_column_overlap_e,
158 ec_report_file_mode_e,
159 ec_report_imp_e,
160 ec_report_inactive_e,
161 ec_report_line_overlap_e,
162 ec_report_not_terminated_e,
163 ec_report_page_limit_e,
164 ec_report_page_width_e,
165 ec_report_sum_size_e,
166 ec_report_varying_e,
167
168 ec_screen_e = 0x01000000,
169 ec_screen_field_overlap_e,
170 ec_screen_imp_e,
171 ec_screen_item_truncated_e,
172 ec_screen_line_number_e,
173 ec_screen_starting_column_e,
174
175 ec_size_e = 0x02000000,
176 ec_size_address_e,
177 ec_size_exponentiation_e,
178 ec_size_imp_e,
179 ec_size_overflow_e,
180 ec_size_truncation_e,
181 ec_size_underflow_e,
182 ec_size_zero_divide_e,
183
184 ec_sort_merge_e = 0x04000000,
185 ec_sort_merge_active_e,
186 ec_sort_merge_file_open_e,
187 ec_sort_merge_imp_e,
188 ec_sort_merge_release_e,
189 ec_sort_merge_return_e,
190 ec_sort_merge_sequence_e,
191
192 ec_storage_e = 0x08000000,
193 ec_storage_imp_e,
194 ec_storage_not_alloc_e,
195 ec_storage_not_avail_e,
196
197 ec_user_e = 0x10000000,
198 ec_user_suffix_e,
199
200 ec_validate_e = 0x20000000,
201 ec_validate_content_e,
202 ec_validate_format_e,
203 ec_validate_imp_e,
204 ec_validate_relation_e,
205 ec_validate_varying_e,
206
207 ec_continue_e = 0x30000000,
208 ec_continue_less_than_zero,
209 };
210
211
212 // The following declarations are used by both gcc/cobol code and the libgcobol
213 // code
214
215 struct cblc_declarative_t
216 {
217 int format;
218 int culprit; //declarative_culprit_t
219 int nfiles;
220 };
221
222 /* According to the standard, the first digit of the file operation status
223 register is interpreted like this:
224
225 EC-I-O-AT-END '1'
226 EC-I-O-INVALID-KEY '2'
227 EC-I-O-PERMANENT-ERROR '3'
228 EC-I-O-LOGIC-ERROR '4'
229 EC-I-O-RECORD-OPERATION '5'
230 EC-I-O-FILE-SHARING '6'
231 EC-I-O-IMP '9'
232
233 When the tens digit is '0', there are a number of conditions for
234 successful completion. See section 9.1.12.1
235
236 00 unqualified success
237 02 duplicate key detected
238 04 the data read were either too short or too long
239 05 the operator couldn't find the tape
240 07 somebody tried to rewind the card reader.
241
242 For now, I am going to treat the io_status as an integer 00 through 99. I
243 anticipate mostly returning
244 00 for ordinary success,
245 04 for a mismatched record size
246 10 for an end-of-file
247
248 */
249
250 // This global variable is constantly being updated with the yylineno. This is
251 // useful for creating error messages, and for handling EXCEPTION_CONDITIONS
252 extern int __gg__exception_code;
253 extern int __gg__exception_line_number;
254 extern int __gg__exception_file_status;
255 extern const char *__gg__exception_file_name;
256 extern const char *__gg__exception_statement;
257 extern const char *__gg__exception_source_file;
258 extern const char *__gg__exception_program_id;
259 extern const char *__gg__exception_section;
260 extern const char *__gg__exception_paragraph;
261
262 extern "C" void __gg__set_exception_code( ec_type_t ec,
263 int from_raise_statement=0);
264
265 #if 1
266 static inline
267 void exception_raise(ec_type_t ec_code) { __gg__set_exception_code(ec_code); }
268 #else
269 # define exception_raise(ec_code)do{__gg__set_exception_code(ec_code);}while(0);
270 #endif
271
272 #endif