1 /*
2    Copyright (C) 2001-2012, 2014-2020 Free Software Foundation, Inc.
3    Written by Keisuke Nishida, Roger While, Simon Sobisch,
4    Edward Hart, Ron Norman, Dave Pitts
5 
6    This file is part of GnuCOBOL.
7 
8    The GnuCOBOL compiler is free software: you can redistribute it
9    and/or modify it under the terms of the GNU General Public License
10    as published by the Free Software Foundation, either version 3 of the
11    License, or (at your option) any later version.
12 
13    GnuCOBOL is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with GnuCOBOL.  If not, see <https://www.gnu.org/licenses/>.
20 */
21 
22 
23 #ifndef CB_COBC_H
24 #define CB_COBC_H
25 
26 #include <stdio.h>
27 #ifdef	HAVE_UNISTD_H
28 #include <unistd.h>
29 #endif
30 #ifdef	HAVE_STRINGS_H
31 #include <strings.h>
32 #endif
33 
34 #include "libcob.h"
35 
36 #ifdef	ENABLE_NLS
37 #include "gettext.h"	/* from lib/ */
38 #define _(s)		gettext(s)
39 #define N_(s)		gettext_noop(s)
40 #else
41 #define _(s)		s
42 #define N_(s)		s
43 #endif
44 
45 /* TODO: recheck these options (got into libcob/common.h by OC 2.0, moved to cobc.h in 3.1, should be moved to config.h) */
46 #if defined (COB_NON_ALIGNED)	/* allow explicit check of generated code and to skip this part in checks of undefined behavior) */
47 	/* Some DEC Alphas can only load shorts at 4-byte aligned addresses */
48 	#ifdef	__alpha
49 		#define COB_SHORT_BORK
50 	#endif
51 	#define COB_NO_UNALIGNED_ATTRIBUTE
52 #elif !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__) && !defined(__powerpc64__) && !defined(__ppc__) && !defined(__amd64__)
53 	#define	COB_NON_ALIGNED
54 	/* Some DEC Alphas can only load shorts at 4-byte aligned addresses */
55 	#ifdef	__alpha
56 		#define COB_SHORT_BORK
57 	#endif
58 	#if defined(_MSC_VER)
59 		#define COB_ALLOW_UNALIGNED
60 	#else
61 		#define COB_NO_UNALIGNED_ATTRIBUTE
62 	#endif
63 #else
64 	#if !defined(__hpux) && !defined(_HPUX_SOURCE) && !defined(__LP64__)
65 		#define COB_ALLOW_UNALIGNED
66 	#endif
67 	#define COB_NO_UNALIGNED_ATTRIBUTE
68 #endif
69 
70 /* Defines for access() */
71 #ifndef	F_OK
72 #define	F_OK		0
73 #endif
74 
75 #ifndef	X_OK
76 #define	X_OK		1
77 #endif
78 
79 #ifndef	W_OK
80 #define	W_OK		2
81 #endif
82 
83 #ifndef	R_OK
84 #define	R_OK		4
85 #endif
86 
87 #define COBC_ABORT()			cobc_abort(__FILE__, __LINE__)
88 #define YY_FATAL_ERROR(msg)		\
89 	flex_fatal_error (msg, __FILE__, __LINE__)
90 
91 /* Source format enum */
92 enum cb_format {
93 	CB_FORMAT_FIXED = 0,
94 	CB_FORMAT_FREE
95 };
96 
97 /* COPY extended syntax defines */
98 #define CB_REPLACE_LEADING		1U
99 #define CB_REPLACE_TRAILING		2U
100 
101 /* Stringify macros */
102 #define CB_STRINGIFY(s)			#s
103 #define CB_XSTRINGIFY(s)		CB_STRINGIFY(s)
104 #define CB_XRANGE(min,max)		CB_XSTRINGIFY(min) ".." CB_XSTRINGIFY(max)
105 
106 /* Flex directive actions */
107 #define PLEX_ACT_IF			0
108 #define PLEX_ACT_ELSE			1U
109 #define PLEX_ACT_END			2U
110 #define PLEX_ACT_ELIF			3U
111 
112 /* Flex value types */
113 #define PLEX_DEF_NONE			0
114 #define PLEX_DEF_LIT			1U
115 #define PLEX_DEF_NUM			2U
116 #define PLEX_DEF_DEL			3U
117 
118 /* Context sensitive keyword defines (trigger words) */
119 #define	CB_CS_ACCEPT			(1U << 0)	/* within ACCEPT statement */
120 #define CB_CS_ALLOCATE			(1U << 1)	/* within ALLOCATE statement */
121 #define	CB_CS_ALPHABET			(1U << 2)
122 #define	CB_CS_ASSIGN			(1U << 3)
123 #define	CB_CS_CALL			(1U << 4)	/* within CALL statement */
124 #define	CB_CS_CONSTANT			(1U << 5)
125 #define	CB_CS_DATE			(1U << 6)
126 #define	CB_CS_DAY			(1U << 7)
127 #define	CB_CS_DISPLAY			(1U << 8)	/* within DISPLAY statement */
128 #define	CB_CS_ERASE			(1U << 9)
129 #define	CB_CS_EXIT			(1U << 10)	/* within EXIT statement */
130 #define	CB_CS_FROM			(1U << 11)
131 #define	CB_CS_OCCURS			(1U << 12)
132 #define CB_CS_OPTIONS			(1U << 13)
133 #define	CB_CS_PERFORM			(1U << 14)	/* within PERFORM statement */
134 #define	CB_CS_PROGRAM_ID		(1U << 15)	/* within PROGRAM-ID definition */
135 #define	CB_CS_READ			(1U << 16)	/* within READ statement */
136 #define	CB_CS_RECORDING			(1U << 17)
137 #define	CB_CS_RETRY			(1U << 18)
138 #define	CB_CS_ROUNDED			(1U << 19)
139 #define	CB_CS_SET			(1U << 20)	/* within SET statement */
140 #define	CB_CS_STOP			(1U << 21)
141 #define	CB_CS_OBJECT_COMPUTER		(1U << 22)
142 #define	CB_CS_DELIMITER			(1U << 23)
143 #define	CB_CS_SCREEN			(1U << 24)	/* within SCREEN section */
144 #define	CB_CS_INQUIRE_MODIFY		(1U << 25)	/* within INQUIRE or MODIFY statement */
145 #define	CB_CS_GRAPHICAL_CONTROL		(1U << 26)	/* within ACUCOBOL-GT graphical control */
146 #define	CB_CS_SELECT			(1U << 27)	/* within SELECT */
147 #define	CB_CS_XML_GENERATE		(1U << 28)
148 #define	CB_CS_XML_PARSE			(1U << 29)
149 #define	CB_CS_OPEN			(1U << 30)	/* within OPEN */
150 #define	CB_CS_JSON_GENERATE		(1U << 31)
151 /* HACK: no more space - using minor one until re-written */
152 #define	CB_CS_I_O_CONTROL		CB_CS_DAY
153 #define	CB_CS_TYPEDEF			CB_CS_DAY
154 #define	CB_CS_EXHIBIT			CB_CS_DAY
155 
156 /* Support for cobc from stdin */
157 #define COB_DASH			"-"
158 #define COB_DASH_NAME			"a.cob"
159 #define COB_DASH_OUT			"a.out"
160 
161 
162 /* Operand operation type */
163 enum cb_operation_type {
164 	CB_OPERATION_READ = 0,
165 	CB_OPERATION_WRITE,
166 	CB_OPERATION_ASSIGN
167 };
168 
169 /* Config dialect support types */
170 enum cb_support {
171 	CB_OK = 0,
172 	CB_WARNING,
173 	CB_ARCHAIC,
174 	CB_OBSOLETE,
175 	CB_SKIP,
176 	CB_IGNORE,
177 	CB_ERROR,
178 	CB_UNCONFORMABLE
179 };
180 
181 /* Config dialect support types */
182 enum cb_std_def {
183 	CB_STD_GC = 0,
184 	CB_STD_MF,
185 	CB_STD_IBM,
186 	CB_STD_MVS,
187 	CB_STD_BS2000,
188 	CB_STD_ACU,
189 	CB_STD_RM,
190 	/* the following must contain ANSI/ISO standards in order */
191 	CB_STD_85,
192 	CB_STD_2002,
193 	CB_STD_2014,
194 	/* the following must be the last and is invalid */
195 	CB_STD_MAX
196 };
197 
198 /* Binary field sizes */
199 enum cb_binary_size_options {
200 	CB_BINARY_SIZE_1_2_4_8 = 0,	/* 1,2,4,8 bytes */
201 	CB_BINARY_SIZE_1__8,		/* 1,2,3,4,5,6,7,8 bytes */
202 	CB_BINARY_SIZE_2_4_8	/* 2,4,8 bytes */
203 };
204 
205 /* COMP/BINARY byte order */
206 enum cb_binary_byteorder_options {
207 	CB_BYTEORDER_BIG_ENDIAN = 0,
208 	CB_BYTEORDER_NATIVE
209 };
210 
211 /* Type of device specified in ASSIGN clause */
212 enum cb_assign_device {
213 	CB_ASSIGN_NO_DEVICE,
214 	CB_ASSIGN_GENERAL_DEVICE,
215 	CB_ASSIGN_LINE_SEQ_DEVICE,
216 	CB_ASSIGN_DISPLAY_DEVICE,
217 	CB_ASSIGN_KEYBOARD_DEVICE,
218 	CB_ASSIGN_PRINTER_DEVICE,
219 	CB_ASSIGN_PRINTER_1_DEVICE,
220 	CB_ASSIGN_PRINT_DEVICE
221 };
222 
223 /* Clauses an elementary screen item is required to have */
224 enum cb_screen_clauses_rules {
225 	CB_ACU_SCREEN_RULES,
226 	CB_GC_SCREEN_RULES,
227 	CB_MF_SCREEN_RULES,
228 	CB_RM_SCREEN_RULES,
229 	CB_STD_SCREEN_RULES,
230 	CB_XOPEN_SCREEN_RULES
231 };
232 
233 /* DECIMAL-POINT IS COMMA effect in XML/JSON GENERATE statements */
234 enum cb_dpc_in_data_options {
235 	CB_DPC_IN_NONE,
236 	CB_DPC_IN_XML,
237 	CB_DPC_IN_JSON,
238 	CB_DPC_IN_ALL
239 };
240 
241 /* Generic text list structure */
242 struct cb_text_list {
243 	struct cb_text_list	*next;			/* next pointer */
244 	struct cb_text_list	*last;
245 	const char		*text;
246 };
247 
248 /* Generic replace list structure */
249 struct cb_replace_list {
250 	int				line_num;
251 	struct cb_replace_list		*next;			/* next pointer */
252 	struct cb_replace_list		*last;
253 	struct cb_replace_list		*prev;
254 	const struct cb_text_list	*old_text;
255 	const struct cb_text_list	*new_text;
256 	unsigned int			lead_trail;
257 };
258 
259 /* Generic define list structure */
260 struct cb_define_struct {
261 	struct cb_define_struct	*next;			/* next pointer */
262 	struct cb_define_struct	*last;
263 	char			*name;
264 	char			*value;
265 	unsigned int		deftype;
266 	int			sign;
267 	int			int_part;
268 	int			dec_part;
269 };
270 
271 /* Structure for extended filenames */
272 struct local_filename {
273 	struct local_filename	*next;			/* next pointer */
274 	char			*local_name;			/* foo.c.l[n].h (full path) */
275 	char			*local_include_name;	/* foo.c.l[n].h (for #include)*/
276 	FILE			*local_fp;
277 };
278 
279 /* Structure for filename */
280 struct filename {
281 	struct filename		*next;
282 	const char		*source;		/* foo.cob (path from command line) */
283 	const char		*preprocess;		/* foo.i / foo.cob (possibly full path) */
284 	const char		*translate;		/* foo.c (possibly full path) */
285 	const char		*trstorage;		/* foo.c.h (possibly full path) */
286 	const char		*object;		/* foo.o (possibly full path) */
287 	const char		*demangle_source;	/* foo */
288 	const char		*listing_file;		/* foo.lst */
289 	struct local_filename	*localfile;		/* foo.c.l[n].h */
290 	size_t			translate_len;		/* strlen translate */
291 	size_t			object_len;		/* strlen object */
292 	unsigned int		need_preprocess;	/* Needs preprocess */
293 	unsigned int		need_translate;		/* Needs parse */
294 	unsigned int		need_assemble;		/* Needs C compile */
295 	int			has_error;		/* Error detected */
296 	int			file_is_stdin;		/* dash used as filename */
297 };
298 
299 /* Exception structure */
300 struct cb_exception {
301 	const char	*name;			/* Exception name */
302 	const int	code;			/* Exception code */
303 	int		enable;			/* If turned on */
304 	int		explicit_enable_val;	/* enable has been set explicitly */
305 };
306 
307 /* >>TURN directive list */
308 struct cb_turn_list {
309 	struct cb_turn_list	*next;
310 	struct cb_text_list	*ec_names;
311 	int		line;
312 	int		enable;
313 	int		with_location;
314 };
315 
316 /* Type of name to check in cobc_check_valid_name */
317 enum cobc_name_type {
318 	FILE_BASE_NAME = 0,
319 	ENTRY_NAME,
320 	PROGRAM_ID_NAME
321 };
322 
323 /* Listing structures and externals */
324 
325 /* List of error messages */
326 struct list_error {
327 	struct list_error	*next;
328 	struct list_error	*prev;
329 	int			line;		/* Line number for error */
330 	char			*file;		/* File name */
331 	char			*prefix;	/* Error prefix */
332 	char			*msg;		/* Error Message text */
333 };
334 
335 /* List of REPLACE text blocks */
336 struct list_replace {
337 	struct list_replace	*next;
338 	int			firstline;	/* First line for replace */
339 	int			lastline;	/* Last line for replace */
340 	int			lead_trail;	/* LEADING/TRAILING flag */
341 	char			*from;		/* Old (from) text */
342 	char			*to;		/* New (to) text */
343 };
344 
345 /* List of skipped lines (conditional compilation) */
346 struct list_skip {
347 	struct list_skip	*next;
348 	int			skipline;	/* line number of skipped line */
349 };
350 
351 /* Listing file control structure */
352 struct list_files {
353 	struct list_files	*next;
354 	struct list_files	*copy_head;	/* COPY book list head */
355 	struct list_files	*copy_tail;	/* COPY book list tail */
356 	struct list_error	*err_head;	/* Error message list head */
357 	struct list_replace	*replace_head;	/* REPLACE list head */
358 	struct list_replace	*replace_tail;	/* REPLACE list tail */
359 	struct list_skip	*skip_head;	/* Skip list head */
360 	struct list_skip	*skip_tail;	/* Skip list tail */
361 	int 			copy_line;	/* Line start for copy book */
362 	int 			listing_on;	/* Listing flag for this file */
363 	enum cb_format		source_format;	/* source format for file */
364 	const char		*name;		/* Name of this file */
365 };
366 
367 extern struct list_files	*cb_listing_files;
368 extern struct list_files	*cb_current_file;
369 
370 extern enum cb_format		cb_source_format;
371 extern int			cb_text_column;	/* end of area B (in single-byte characters) */
372 
373 extern struct cb_exception	cb_exception_table[];
374 extern const struct cb_exception	cb_io_exception_table[];
375 extern const size_t		cb_io_exception_table_len;
376 
377 #define CB_EXCEPTION_NAME(id)	cb_exception_table[id].name
378 #define CB_EXCEPTION_CODE(id)	cb_exception_table[id].code
379 #define CB_EXCEPTION_ENABLE(id)	cb_exception_table[id].enable
380 #define CB_EXCEPTION_EXPLICIT(id)	cb_exception_table[id].explicit_enable_val
381 
382 extern struct cb_turn_list	*cb_turn_list;
383 
384 /* undef macros that are only for internal use with def-files */
385 
386 #undef	CB_FLAG
387 #undef	CB_FLAG_ON
388 #undef	CB_FLAG_RQ
389 #undef	CB_FLAG_NQ
390 #undef	CB_FLAG_OP
391 #undef	CB_FLAG_NO
392 
393 #undef	CB_WARNDEF
394 #undef	CB_ONWARNDEF
395 #undef	CB_NOWARNDEF
396 
397 #undef	CB_OPTIM_DEF
398 
399 #undef	CB_CONFIG_ANY
400 #undef	CB_CONFIG_INT
401 #undef	CB_CONFIG_STRING
402 #undef	CB_CONFIG_BOOLEAN
403 #undef	CB_CONFIG_SUPPORT
404 
405 #undef	COB_EXCEPTION
406 
407 
408 #define	CB_FLAG(var,print_help,name,doc)		extern int var;
409 #define	CB_FLAG_ON(var,print_help,name,doc)		extern int var;
410 #define CB_FLAG_RQ(var,print_help,name,def,opt,doc)	extern int var;
411 #define CB_FLAG_NQ(print_help,name,opt,doc)
412 #define CB_FLAG_OP(print_help,name,opt,doc)
413 #define CB_FLAG_NO(print_help,name,opt,doc)
414 #include "flag.def"
415 #undef	CB_FLAG
416 #undef	CB_FLAG_ON
417 #undef	CB_FLAG_RQ
418 #undef	CB_FLAG_NQ
419 #undef	CB_FLAG_OP
420 #undef	CB_FLAG_NO
421 
422 /* Flag to emit Old style: cob_set_location, cob_trace_section */
423 extern int cb_old_trace;
424 
425 
426 #define	CB_WARNDEF(opt,name,doc)	opt,
427 #define	CB_ONWARNDEF(opt,name,doc)	opt,
428 #define	CB_NOWARNDEF(opt,name,doc)	opt,
429 enum cb_warn_opt
430 {
431 	COB_WARNOPT_NONE = 0,
432 #include "warning.def"
433 	COB_WARNOPT_MAX
434 };
435 #undef	CB_WARNDEF
436 #undef	CB_ONWARNDEF
437 #undef	CB_NOWARNDEF
438 
439 #define COBC_WARN_FILLER  cb_warn_filler
440 
441 enum cb_warn_val {
442 	COBC_WARN_DISABLED = 0,
443 	COBC_WARN_ENABLED  = 1,
444 	COBC_WARN_AS_ERROR = 2
445 };
446 
447 extern int cb_warn_opt_val[COB_WARNOPT_MAX];
448 
449 
450 #define	CB_OPTIM_DEF(x)			x,
451 enum cb_optim {
452 	COB_OPTIM_MIN = 0,
453 #include "codeoptim.def"
454 	COB_OPTIM_MAX
455 };
456 #undef	CB_OPTIM_DEF
457 
458 extern int			cb_id;
459 extern int			cb_pic_id;
460 extern int			cb_attr_id;
461 extern int			cb_literal_id;
462 extern int			cb_field_id;
463 extern int			cb_ml_attr_id;
464 extern int			cb_ml_tree_id;
465 extern int			cb_flag_functions_all;
466 
467 extern int			cb_flag_dump;
468 #define COB_DUMP_NONE	0x0000	/* No dump */
469 #define COB_DUMP_FD	0x0001	/* FILE SECTION -> FILE DESCRIPTION */
470 #define COB_DUMP_WS	0x0002  /* WORKING-STORAGE SECTION */
471 #define COB_DUMP_RD	0x0004	/* REPORT SECTION */
472 #define COB_DUMP_SD	0x0008	/* FILE SECTION -> SORT DESCRIPTION */
473 #define COB_DUMP_SC	0x0010	/* SCREEN SECTION */
474 #define COB_DUMP_LS	0x0020  /* LINKAGE SECTION */
475 #define COB_DUMP_LO	0x0040  /* LOCAL-STORAGE SECTION */
476 #define COB_DUMP_ALL	(COB_DUMP_FD|COB_DUMP_WS|COB_DUMP_RD|COB_DUMP_SD|COB_DUMP_SC|COB_DUMP_LS|COB_DUMP_LO)
477 
478 
479 extern int			cb_unix_lf;
480 
481 extern int			cb_flag_main;	/* set if "main" requested by -x */
482 extern int			cobc_flag_main;	/* set only until first program compiled, for general: use cb_flag_main*/
483 extern int			cobc_wants_debug;
484 extern int			cb_listing_xref;
485 extern int			cobc_seen_stdin;
486 
487 extern int			errorcount;
488 extern int			warningcount;
489 extern int			no_physical_cancel;
490 extern cob_u32_t		optimize_defs[];
491 
492 extern const char		*cb_cobc_build_stamp;
493 extern const char		*cb_source_file;
494 extern int			cb_source_line;
495 extern const char		*cb_call_extfh;
496 
497 extern struct cob_time		current_compile_time;
498 extern struct tm			current_compile_tm;
499 
500 extern const char		*cob_config_dir;
501 
502 extern unsigned int		cobc_gen_listing;
503 
504 extern const char		*demangle_name;
505 extern FILE			*cb_storage_file;
506 extern const char		*cb_storage_file_name;
507 
508 extern char			**cb_saveargv;
509 extern int			cb_saveargc;
510 
511 extern FILE			*cb_listing_file;
512 extern FILE			*cb_src_list_file;
513 extern struct cb_text_list	*cb_include_list;
514 extern struct cb_text_list	*cb_intrinsic_list;
515 extern struct cb_text_list	*cb_extension_list;
516 extern struct cb_text_list	*cb_static_call_list;
517 extern struct cb_text_list	*cb_early_exit_list;
518 
519 extern struct cb_program	*current_program;
520 extern struct cb_statement	*current_statement;
521 extern struct cb_label		*current_section;
522 extern struct cb_label		*current_paragraph;
523 extern int			cb_exp_line;
524 extern int			functions_are_all;
525 extern struct cb_tree_common	*defined_prog_list;
526 extern int			current_call_convention;
527 extern struct cb_field		*external_defined_fields_ws;
528 extern struct cb_field		*external_defined_fields_global;
529 
530 /* Functions */
531 
532 /* cobc.c */
533 
534 extern struct reserved_word_list	*cob_user_res_list;
535 
536 extern void			*cobc_malloc (const size_t);
537 extern void			cobc_free (void *);
538 extern void			*cobc_strdup (const char *);
539 extern void			*cobc_realloc (void *, const size_t);
540 
541 extern void			*cobc_main_malloc (const size_t);
542 extern void			*cobc_main_strdup (const char *);
543 extern void			*cobc_main_realloc (void *, const size_t);
544 extern void			cobc_main_free (void *);
545 
546 extern void			*cobc_parse_malloc (const size_t);
547 extern void			*cobc_parse_strdup (const char *);
548 extern void			*cobc_parse_realloc (void *, const size_t);
549 extern void			cobc_parse_free (void *);
550 
551 extern void			*cobc_plex_malloc (const size_t);
552 extern void			*cobc_plex_strdup (const char *);
553 
554 extern void			*cobc_check_string (const char *);
555 extern void			cobc_err_msg (const char *, ...) COB_A_FORMAT12;
556 
557 DECLNORET extern void		cobc_abort (const char *,
558 					    const int) COB_A_NORETURN;
559 DECLNORET extern void		cobc_abort_terminate (int) COB_A_NORETURN;
560 
561 
562 extern size_t			cobc_check_valid_name (const char *,
563 						       const enum cobc_name_type);
564 
565 extern unsigned int		cobc_turn_ec (struct cb_text_list *, const cob_u32_t, struct cb_tree_common *);
566 extern void			cobc_apply_turn_directives (void);
567 
568 /* help.c (used only within cobc.c) */
569 
570 extern void		cobc_print_usage (char *);
571 extern void		cobc_print_usage_common_options (void);
572 extern void		cobc_print_usage_dialect (void);
573 extern void		cobc_print_usage_warnings (void);
574 extern void		cobc_print_usage_flags (void);
575 
576 /* config.c */
577 
578 #define	CB_CONFIG_ANY(type,var,name,doc)	\
579 extern type			var;
580 #define	CB_CONFIG_INT(var,name,min,max,odoc,doc)	\
581 extern unsigned int		var;
582 #define	CB_CONFIG_STRING(var,name,doc)	\
583 extern const char		*var;
584 #define	CB_CONFIG_BOOLEAN(var,name,doc)	\
585 extern int				var;
586 #define	CB_CONFIG_SUPPORT(var,name,doc)	\
587 extern enum				cb_support var;
588 
589 #include "config.def"
590 
591 #undef	CB_CONFIG_ANY
592 #undef	CB_CONFIG_INT
593 #undef	CB_CONFIG_STRING
594 #undef	CB_CONFIG_BOOLEAN
595 #undef	CB_CONFIG_SUPPORT
596 
597 extern int		cb_load_std (const char *);
598 extern int		cb_config_entry (char *, const char *, const int);
599 extern int		cb_load_conf (const char *, const int);
600 extern int		cb_load_words (void);
601 
602 #ifndef	HAVE_DESIGNATED_INITS
603 /* Initialization routines in typeck.c and reserved.c */
604 extern void		cobc_init_typeck (void);
605 extern void		cobc_init_reserved (void);
606 #endif
607 
608 /* preprocessor (in pplex.l, ppparse.y) */
609 #if	!defined (COB_IN_SCANNER ) && !defined (COB_IN_PPLEX)
610 extern FILE		*ppin;
611 extern FILE		*ppout;
612 extern int		pplex (void);
613 #endif
614 
615 #ifndef	COB_IN_PPPARSE
616 extern int		ppparse (void);
617 #endif
618 
619 extern int		ppopen (const char *, struct cb_replace_list *);
620 extern int		ppcopy (const char *, const char *,
621 				struct cb_replace_list *);
622 extern void		pp_set_replace_list (struct cb_replace_list *,
623 					     const cob_u32_t);
624 extern void		ppparse_error (const char *);
625 extern void		ppparse_clear_vars (const struct cb_define_struct *);
626 extern struct cb_define_struct *ppp_search_lists (const char *name);
627 extern void		ppp_clear_lists (void);
628 extern void		plex_clear_vars (void);
629 extern void		plex_clear_all (void);
630 extern void		plex_call_destroy (void);
631 extern void		plex_action_directive (const unsigned int,
632 					       const unsigned int);
633 
634 /* parser (in scanner.l, parser.y) */
635 #if	!defined (COB_IN_SCANNER ) && !defined (COB_IN_PPLEX) && \
636 	!defined (COB_IN_PPPARSE)
637 extern FILE		*yyin;
638 extern FILE		*yyout;
639 extern int		yylex (void);
640 #endif
641 
642 #if	!defined (COB_IN_PPPARSE) && !defined (COB_IN_PARSER)
643 extern int		yyparse (void);
644 #endif
645 
646 extern void		ylex_clear_all (void);
647 extern void		ylex_call_destroy (void);
648 
649 /* typeck.c */
650 extern size_t		suppress_warn;	/* no warnings for internal generated stuff */
651 
652 /* codeoptim.c */
653 extern void		cob_gen_optim (const enum cb_optim);
654 
655 /* codegen.c */
656 extern void		cb_init_codegen (void);
657 
658 /* error.c */
659 #define CB_MSG_STYLE_GCC	0
660 #define CB_MSG_STYLE_MSC	1U
661 
662 #define CB_PENDING_X(x,s) \
663 	do { cb_warning_x (cb_warn_pending, x, _("%s is not implemented"), s); } ONCE_COB
664 
665 #define CB_UNFINISHED_X(x,s) \
666 	do { cb_warning_x (cb_warn_unfinished, x, \
667 		_("handling of %s is unfinished; implementation is likely to be changed"), s); \
668 	} ONCE_COB
669 #define CB_PENDING(s)		CB_PENDING_X	(cb_error_node, s)
670 #define CB_UNFINISHED(s)	CB_UNFINISHED_X	(cb_error_node, s)
671 
672 extern size_t		cb_msg_style;
673 
674 extern enum cb_warn_val		cb_warning (const enum cb_warn_opt, const char *, ...) COB_A_FORMAT23;
675 extern enum cb_warn_val		cb_error (const char *, ...) COB_A_FORMAT12;
676 extern void		cb_error_always (const char *, ...) COB_A_FORMAT12;
677 extern void		cb_perror (const int, const char *, ...) COB_A_FORMAT23;
678 extern void		cb_plex_warning (const enum cb_warn_opt, const size_t,
679 					 const char *, ...) COB_A_FORMAT34;
680 extern void		cb_plex_error (const size_t,
681 					 const char *, ...) COB_A_FORMAT23;
682 extern unsigned int	cb_plex_verify (const size_t, const enum cb_support,
683 					const char *);
684 extern void		configuration_warning (const char *, const int,
685 					 const char *, ...) COB_A_FORMAT34;
686 extern void		configuration_error (const char *, const int,
687 					 const int, const char *, ...) COB_A_FORMAT45;
688 extern char *		cb_get_strerror (void);
689 extern void		cb_add_error_to_listing (const char *, int, const char *, char *);
690 DECLNORET extern void		flex_fatal_error (const char *, const char *,
691 					 const int) COB_A_NORETURN;
692 
693 /* reserved.c */
694 extern struct reserved_word_list	*cobc_user_res_list;
695 
696 extern void		remove_reserved_word (const char *, const char *, const int);
697 extern void		add_reserved_word (const char *, const char *, const int);
698 extern void		remove_reserved_word_now (char * const);
699 extern void		add_reserved_word_now (char * const, char * const);
700 
701 extern void		remove_register (const char *, const char *, const int);
702 extern void		add_register (const char *, const char *, const int);
703 
704 extern void		deactivate_intrinsic (const char *, const char *, const int);
705 extern void		activate_intrinsic (const char *, const char *, const int);
706 
707 extern void		deactivate_system_name (const char *, const char *, const int);
708 extern void		activate_system_name (const char *, const char *, const int);
709 
710 #endif /* CB_COBC_H */
711