GnuCOBOL
2.0
A free COBOL compiler
Main Page
Data Structures
Files
File List
Globals
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
cobc.h
Go to the documentation of this file.
1
/*
2
Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Keisuke Nishida
3
Copyright (C) 2007-2012 Roger While
4
5
This file is part of GNU Cobol.
6
7
The GNU Cobol compiler is free software: you can redistribute it
8
and/or modify it under the terms of the GNU General Public License
9
as published by the Free Software Foundation, either version 3 of the
10
License, or (at your option) any later version.
11
12
GNU Cobol is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
16
17
You should have received a copy of the GNU General Public License
18
along with GNU Cobol. If not, see <http://www.gnu.org/licenses/>.
19
*/
20
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 "
lib/gettext.h
"
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
/* Defines for access() */
46
#ifndef F_OK
47
#define F_OK 0
48
#endif
49
50
#ifndef X_OK
51
#define X_OK 1
52
#endif
53
54
#ifndef W_OK
55
#define W_OK 2
56
#endif
57
58
#ifndef R_OK
59
#define R_OK 4
60
#endif
61
62
#define COBC_ABORT() cobc_abort(__FILE__, __LINE__)
63
#define COBC_DUMB_ABORT() cobc_dumb_abort(__FILE__, __LINE__)
64
65
/* Source format defines */
66
#define CB_FORMAT_FIXED 0
67
#define CB_FORMAT_FREE 1
68
69
/* COPY extended syntax defines */
70
#define CB_REPLACE_LEADING 1U
71
#define CB_REPLACE_TRAILING 2U
72
73
/* Stringify macros */
74
#define CB_STRINGIFY(s) #s
75
#define CB_XSTRINGIFY(s) CB_STRINGIFY(s)
76
77
/* ASSIGN clause interpretation */
78
#define CB_ASSIGN_MF 0
/* Micro Focus compatibility */
79
#define CB_ASSIGN_IBM 1U
/* IBM compatibility */
80
#define CB_ASSIGN_COBOL2002 2U
/* COBOL 2002 standard */
81
82
/* COMP/BINARY byte order */
83
#define CB_BYTEORDER_BIG_ENDIAN 0
84
#define CB_BYTEORDER_NATIVE 1U
85
86
/* Binary field sizes */
87
#define CB_BINARY_SIZE_1_2_4_8 0
/* 1,2,4,8 bytes */
88
#define CB_BINARY_SIZE_1__8 1U
/* 1,2,3,4,5,6,7,8 bytes */
89
#define CB_BINARY_SIZE_2_4_8 2U
/* 2,4,8 bytes */
90
91
/* Flex directive actions */
92
#define PLEX_ACT_IF 0
93
#define PLEX_ACT_ELSE 1U
94
#define PLEX_ACT_END 2U
95
#define PLEX_ACT_ELIF 3U
96
97
/* Flex value types */
98
#define PLEX_DEF_NONE 0
99
#define PLEX_DEF_LIT 1U
100
#define PLEX_DEF_NUM 2U
101
#define PLEX_DEF_DEL 3U
102
103
/* Context sensitive keyword defines (trigger words) */
104
#define CB_CS_ACCEPT (1U << 0)
105
#define CB_CS_ALPHABET (1U << 1)
106
#define CB_CS_ASSIGN (1U << 2)
107
#define CB_CS_CALL (1U << 3)
108
#define CB_CS_CONSTANT (1U << 4)
109
#define CB_CS_DATE (1U << 5)
110
#define CB_CS_DAY (1U << 6)
111
#define CB_CS_DISPLAY (1U << 7)
112
#define CB_CS_ERASE (1U << 8)
113
#define CB_CS_EXIT (1U << 9)
114
#define CB_CS_FROM (1U << 10)
115
#define CB_CS_PROGRAM_ID (1U << 11)
116
#define CB_CS_ROUNDED (1U << 12)
117
#define CB_CS_SET (1U << 13)
118
#define CB_CS_STOP (1U << 14)
119
#define CB_CS_WITH (1U << 15)
120
121
/* Operand operation type */
122
enum
cb_operation_type
{
123
CB_OPERATION_READ
= 0,
124
CB_OPERATION_WRITE
,
125
CB_OPERATION_ASSIGN
126
};
127
128
/* Config dialect support types */
129
enum
cb_support
{
130
CB_OK
= 0,
131
CB_WARNING
,
132
CB_ARCHAIC
,
133
CB_OBSOLETE
,
134
CB_SKIP
,
135
CB_IGNORE
,
136
CB_ERROR
,
137
CB_UNCONFORMABLE
138
};
139
140
/* Config dialect support types */
141
enum
cb_std_def
{
142
CB_STD_OC
= 0,
143
CB_STD_MF
,
144
CB_STD_IBM
,
145
CB_STD_MVS
,
146
CB_STD_BS2000
,
147
CB_STD_85
,
148
CB_STD_2002
149
};
150
151
/* Generic text list structure */
152
struct
cb_text_list
{
153
struct
cb_text_list
*
next
;
/* next pointer */
154
struct
cb_text_list
*
last
;
155
const
char
*
text
;
156
};
157
158
/* Generic replace list structure */
159
struct
cb_replace_list
{
160
struct
cb_replace_list
*
next
;
/* next pointer */
161
struct
cb_replace_list
*
last
;
162
struct
cb_replace_list
*
prev
;
163
const
struct
cb_text_list
*
old_text
;
164
const
struct
cb_text_list
*
new_text
;
165
unsigned
int
lead_trail
;
166
};
167
168
/* Generic define list structure */
169
struct
cb_define_struct
{
170
struct
cb_define_struct
*
next
;
/* next pointer */
171
struct
cb_define_struct
*
last
;
172
char
*
name
;
173
char
*
value
;
174
unsigned
int
deftype
;
175
int
sign
;
176
int
int_part
;
177
int
dec_part
;
178
};
179
180
/* Structure for extended filenames */
181
struct
local_filename
{
182
struct
local_filename
*
next
;
/* next pointer */
183
char
*
local_name
;
184
FILE *
local_fp
;
185
};
186
187
/* Structure for filename */
188
struct
filename
{
189
struct
filename
*
next
;
190
const
char
*
source
;
/* foo.cob (path from command line) */
191
const
char
*
preprocess
;
/* foo.i (full path) */
192
const
char
*
translate
;
/* foo.c (full path) */
193
const
char
*
trstorage
;
/* foo.c.h (full path) */
194
const
char
*
object
;
/* foo.o (full path) */
195
const
char
*
demangle_source
;
/* foo */
196
const
char
*
listing_file
;
/* foo.lst */
197
struct
local_filename
*
localfile
;
/* foo.c.l[n].h */
198
size_t
translate_len
;
/* strlen translate */
199
size_t
object_len
;
/* strlen object */
200
unsigned
int
need_preprocess
;
/* Needs preprocess */
201
unsigned
int
need_translate
;
/* Needs parse */
202
unsigned
int
need_assemble
;
/* Needs C compile */
203
int
has_error
;
/* Error detected */
204
};
205
206
/* Exception structure */
207
struct
cb_exception
{
208
const
char
*
name
;
/* Exception name */
209
const
int
code
;
/* Exception code */
210
int
enable
;
/* If turned on */
211
};
212
213
/* Structure for reserved words that have been reverted */
214
struct
noreserve
{
215
struct
noreserve
*
next
;
/* next pointer */
216
char
*
noresword
;
217
};
218
219
/* Basic memory structure */
220
struct
cobc_mem_struct
{
221
struct
cobc_mem_struct
*
next
;
/* next pointer */
222
void
*
memptr
;
223
size_t
memlen
;
224
};
225
226
227
extern
int
cb_source_format
;
228
229
extern
struct
cb_exception
cb_exception_table
[];
230
231
#define CB_EXCEPTION_NAME(id) cb_exception_table[id].name
232
#define CB_EXCEPTION_CODE(id) cb_exception_table[id].code
233
#define CB_EXCEPTION_ENABLE(id) cb_exception_table[id].enable
234
235
#undef CB_FLAG
236
#undef CB_FLAG_RQ
237
#undef CB_FLAG_NQ
238
#define CB_FLAG(var,pdok,name,doc) extern int var;
239
#define CB_FLAG_RQ(var,pdok,name,def,opt,doc) extern int var;
240
#define CB_FLAG_NQ(pdok,name,opt,doc)
241
#include "
flag.def
"
242
#undef CB_FLAG
243
#undef CB_FLAG_RQ
244
#undef CB_FLAG_nQ
245
246
#undef CB_WARNDEF
247
#undef CB_NOWARNDEF
248
#define CB_WARNDEF(var,name,doc) extern int var;
249
#define CB_NOWARNDEF(var,name,doc) extern int var;
250
#include "
warning.def
"
251
#undef CB_WARNDEF
252
#undef CB_NOWARNDEF
253
254
#undef CB_OPTIM_DEF
255
#define CB_OPTIM_DEF(x) x,
256
enum
cb_optim
{
257
COB_OPTIM_MIN
= 0,
258
#include "
codeoptim.def
"
259
COB_OPTIM_MAX
260
};
261
#undef CB_OPTIM_DEF
262
263
extern
int
cb_id
;
264
extern
int
cb_attr_id
;
265
extern
int
cb_literal_id
;
266
extern
int
cb_field_id
;
267
extern
int
cobc_flag_main
;
268
extern
int
cb_flag_functions_all
;
269
extern
int
cb_flag_main
;
270
extern
int
cobc_wants_debug
;
271
272
extern
int
errorcount
;
273
extern
int
warningcount
;
274
extern
int
warningopt
;
275
extern
int
no_physical_cancel
;
276
extern
cob_u32_t
optimize_defs
[];
277
278
extern
char
*
cb_oc_build_stamp
;
279
extern
const
char
*
cb_source_file
;
280
extern
int
cb_source_line
;
281
282
extern
const
char
*
cob_config_dir
;
283
284
extern
unsigned
int
cobc_gen_listing
;
285
286
extern
const
char
*
demangle_name
;
287
extern
FILE *
cb_storage_file
;
288
extern
const
char
*
cb_storage_file_name
;
289
290
extern
char
**
cb_saveargv
;
291
extern
int
cb_saveargc
;
292
293
extern
FILE *
cb_listing_file
;
294
extern
struct
cb_text_list
*
cb_include_list
;
295
extern
struct
cb_text_list
*
cb_intrinsic_list
;
296
extern
struct
cb_text_list
*
cb_extension_list
;
297
extern
struct
cb_text_list
*
cb_static_call_list
;
298
extern
struct
cb_text_list
*
cb_early_exit_list
;
299
300
extern
struct
cb_program
*
current_program
;
301
extern
struct
cb_statement
*
current_statement
;
302
extern
struct
cb_label
*
current_section
;
303
extern
struct
cb_label
*
current_paragraph
;
304
extern
int
functions_are_all
;
305
306
/* Functions */
307
308
/* cobc.c */
309
310
extern
struct
noreserve
*
cobc_nores_base
;
311
317
extern
void
*
cobc_malloc
(
const
size_t
);
318
320
extern
void
cobc_free
(
void
*);
321
323
extern
void
*
cobc_strdup
(
const
char
*);
324
extern
void
*
cobc_realloc
(
void
*,
const
size_t
);
325
326
extern
void
*
cobc_main_malloc
(
const
size_t
);
327
extern
void
*
cobc_main_strdup
(
const
char
*);
328
extern
void
*
cobc_main_realloc
(
void
*,
const
size_t
);
329
extern
void
cobc_main_free
(
void
*);
330
331
extern
void
*
cobc_parse_malloc
(
const
size_t
);
332
extern
void
*
cobc_parse_strdup
(
const
char
*);
333
extern
void
*
cobc_parse_realloc
(
void
*,
const
size_t
);
334
extern
void
cobc_parse_free
(
void
*);
335
336
extern
void
*
cobc_plex_malloc
(
const
size_t
);
337
extern
void
*
cobc_plex_strdup
(
const
char
*);
338
339
extern
void
*
cobc_check_string
(
const
char
*);
340
extern
void
cobc_abort_pr
(
const
char
*, ...) COB_A_FORMAT12;
341
342
DECLNORET extern
void
cobc_abort
(const
char
*,
343
const
int
) COB_A_NORETURN;
344
DECLNORET extern
void
cobc_too_many_errors
(
void
) COB_A_NORETURN;
345
DECLNORET extern
void
cobc_dumb_abort
(const
char
*, const
int
);
346
347
extern
size_t
cobc_check_valid_name
(const
char
*,
348
const
unsigned
int
);
349
350
/* config.c */
351
352
#undef CB_CONFIG_ANY
353
#undef CB_CONFIG_INT
354
#undef CB_CONFIG_STRING
355
#undef CB_CONFIG_BOOLEAN
356
#undef CB_CONFIG_SUPPORT
357
358
#define CB_CONFIG_ANY(type,var,name) extern type var;
359
#define CB_CONFIG_INT(var,name) extern int var;
360
#define CB_CONFIG_STRING(var,name) extern const char *var;
361
#define CB_CONFIG_BOOLEAN(var,name) extern int var;
362
#define CB_CONFIG_SUPPORT(var,name) extern enum cb_support var;
363
364
#include "
config.def
"
365
366
#undef CB_CONFIG_ANY
367
#undef CB_CONFIG_INT
368
#undef CB_CONFIG_STRING
369
#undef CB_CONFIG_BOOLEAN
370
#undef CB_CONFIG_SUPPORT
371
372
extern
int
cb_load_std
(
const
char
*);
373
extern
int
cb_config_entry
(
char
*,
const
char
*,
const
int
);
374
extern
int
cb_load_conf
(
const
char
*,
const
int
,
const
int
);
375
376
#ifndef HAVE_DESIGNATED_INITS
377
/* Initialization routines in scanner.l, typeck.c, reserved.c */
378
extern
void
cobc_init_scanner
(
void
);
379
extern
void
cobc_init_typeck
(
void
);
380
extern
void
cobc_init_reserved
(
void
);
381
#endif
382
383
/* preprocessor (in pplex.l, ppparse.y) */
384
#if !defined (COB_IN_SCANNER ) && !defined (COB_IN_PPLEX)
385
extern
FILE *
ppin
;
386
extern
FILE *
ppout
;
387
extern
int
pplex
(
void
);
388
#endif
389
390
#ifndef COB_IN_PPPARSE
391
extern
int
ppparse
(
void
);
392
#endif
393
394
extern
int
ppopen
(
const
char
*,
struct
cb_replace_list
*);
395
extern
int
ppcopy
(
const
char
*,
const
char
*,
396
struct
cb_replace_list
*);
397
extern
void
pp_set_replace_list
(
struct
cb_replace_list
*,
398
const
cob_u32_t);
399
extern
void
ppparse_error
(
const
char
*);
400
extern
void
ppparse_clear_vars
(
const
struct
cb_define_struct
*);
401
extern
void
plex_clear_vars
(
void
);
402
extern
void
plex_clear_all
(
void
);
403
extern
void
plex_call_destroy
(
void
);
404
extern
void
plex_action_directive
(
const
unsigned
int
,
405
const
unsigned
int
);
406
407
/* parser (in scanner.l, parser.y) */
408
extern
char
*
cobc_glob_line
;
409
410
#if !defined (COB_IN_SCANNER ) && !defined (COB_IN_PPLEX) && \
411
!defined (COB_IN_PPPARSE)
412
extern
FILE *
yyin
;
413
extern
FILE *
yyout
;
414
extern
int
yylex
(
void
);
415
#endif
416
417
#if !defined (COB_IN_PPPARSE) && !defined (COB_IN_PARSER)
418
extern
int
yyparse
(
void
);
419
#endif
420
421
extern
void
ylex_clear_all
(
void
);
422
extern
void
ylex_call_destroy
(
void
);
423
424
/* typeck.c */
425
extern
size_t
suppress_warn
;
426
427
/* codeoptim.c */
428
extern
void
cob_gen_optim
(
const
enum
cb_optim
);
429
430
/* error.c */
431
#define CB_MSG_STYLE_GCC 0
432
#define CB_MSG_STYLE_MSC 1U
433
434
extern
size_t
cb_msg_style
;
435
436
extern
void
cb_warning
(
const
char
*, ...) COB_A_FORMAT12;
437
extern
void
cb_error
(const
char
*, ...) COB_A_FORMAT12;
438
extern
void
cb_plex_warning
(const
size_t
,
439
const
char
*, ...) COB_A_FORMAT23;
440
extern
void
cb_plex_error
(const
size_t
,
441
const
char
*, ...) COB_A_FORMAT23;
442
extern
void
configuration_error
(const
char
*,
443
const
int
, const
char
*, ...) COB_A_FORMAT34;
444
445
extern
unsigned
int
cb_verify
(const enum
cb_support
, const
char
*);
446
447
#endif
/* CB_COBC_H */
cobc
cobc.h
Generated by
1.8.3.1