OpenCOBOL 1.1pre-rel
|
00001 /* 00002 * Copyright (C) 2001-2009 Keisuke Nishida 00003 * Copyright (C) 2007-2009 Roger While 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2, or (at your option) 00008 * any later version. 00009 * 00010 * This program is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this software; see the file COPYING. If not, write to 00017 * the Free Software Foundation, 51 Franklin Street, Fifth Floor 00018 * Boston, MA 02110-1301 USA 00019 */ 00020 00021 #ifndef CB_COBC_H 00022 #define CB_COBC_H 00023 00024 #include <stdio.h> 00025 00026 #include <libcob.h> 00027 #include "lib/gettext.h" 00028 00029 #if !defined(__i386__) && !defined(__x86_64__) && !defined(__powerpc__) && !defined(__powerpc64__) && !defined(__ppc__) && !defined(__amd64__) 00030 #define COB_NON_ALIGNED 00031 /* Some DEC Alphas can only directly load shorts at 4-byte aligned addresses */ 00032 #ifdef __alpha 00033 #define COB_SHORT_BORK 00034 #endif 00035 #endif 00036 00037 #define ABORT() cobc_abort(__FILE__,__LINE__) 00038 00039 #define CB_FORMAT_FIXED 0 00040 #define CB_FORMAT_FREE 1 00041 00042 extern int cb_source_format; 00043 00044 extern int cb_display_sign; 00045 00046 extern struct cb_exception { 00047 const char *name; /* exception name */ 00048 const int code; /* exception code */ 00049 int enable; /* if turned on */ 00050 } cb_exception_table[]; 00051 00052 #define CB_EXCEPTION_NAME(id) cb_exception_table[id].name 00053 #define CB_EXCEPTION_CODE(id) cb_exception_table[id].code 00054 #define CB_EXCEPTION_ENABLE(id) cb_exception_table[id].enable 00055 00056 #undef CB_FLAG 00057 #define CB_FLAG(var,name,doc) extern int var; 00058 #include "flag.def" 00059 #undef CB_FLAG 00060 00061 #undef CB_WARNDEF 00062 #define CB_WARNDEF(var,name,wall,doc) extern int var; 00063 #include "warning.def" 00064 #undef CB_WARNDEF 00065 00066 struct cb_text_list { 00067 const char *text; 00068 struct cb_text_list *next; 00069 }; 00070 00071 struct cb_replace_list { 00072 struct cb_text_list *old_text; 00073 struct cb_text_list *new_text; 00074 struct cb_replace_list *next; 00075 }; 00076 00077 struct local_filename { 00078 struct local_filename *next; 00079 char *local_name; 00080 FILE *local_fp; 00081 }; 00082 00083 struct filename { 00084 struct filename *next; 00085 char *source; /* foo.cob */ 00086 char *preprocess; /* foo.i */ 00087 char *translate; /* foo.c */ 00088 char *trstorage; /* foo.c.h */ 00089 char *object; /* foo.o */ 00090 char *demangle_source; /* foo */ 00091 struct local_filename *localfile; /* foo.c.l[n].h */ 00092 int need_preprocess; 00093 int need_translate; 00094 int need_assemble; 00095 }; 00096 00097 extern int cb_id; 00098 extern int cb_attr_id; 00099 extern int cb_literal_id; 00100 extern int cb_field_id; 00101 extern int cb_storage_id; 00102 extern int cb_flag_main; 00103 00104 extern int errorcount; 00105 extern int warningcount; 00106 extern int alt_ebcdic; 00107 extern int optimize_flag; 00108 extern int has_external; 00109 00110 extern char *cb_oc_build_stamp; 00111 extern char *cb_source_file; 00112 extern int cb_source_line; 00113 00114 extern const char *cob_config_dir; 00115 00116 extern char *source_name; 00117 extern char *demangle_name; 00118 extern FILE *cb_storage_file; 00119 extern char *cb_storage_file_name; 00120 00121 extern char **cb_saveargv; 00122 extern int cb_saveargc; 00123 00124 extern FILE *cb_listing_file; 00125 extern FILE *cb_depend_file; 00126 extern char *cb_depend_target; 00127 extern struct cb_text_list *cb_depend_list; 00128 extern struct cb_text_list *cb_include_list; 00129 extern struct cb_text_list *cb_extension_list; 00130 00131 extern struct cb_program *current_program; 00132 extern struct cb_statement *current_statement; 00133 extern struct cb_label *current_section; 00134 extern struct cb_label *current_paragraph; 00135 extern size_t functions_are_all; 00136 00137 extern struct cb_text_list *cb_text_list_add (struct cb_text_list *list, const char *name); 00138 extern void *cobc_malloc (const size_t size); 00139 extern void *cobc_realloc (void *prevptr, const size_t size); 00140 00141 #ifdef __GNUC__ 00142 extern void cobc_abort (const char *filename, const int linenum) __attribute__ ((noreturn)); 00143 #else 00144 extern void cobc_abort (const char *filename, const int linenum); 00145 #endif 00146 00147 extern size_t cobc_check_valid_name (char *name); 00148 00149 /* config.c */ 00150 00151 struct noreserve { 00152 struct noreserve *next; 00153 char *noresword; 00154 }; 00155 00156 extern struct noreserve *norestab; 00157 00158 enum cb_assign_clause { 00159 CB_ASSIGN_COBOL2002, /* COBOL 2002 standard */ 00160 CB_ASSIGN_MF, /* Micro Focus COBOL compatibility */ 00161 CB_ASSIGN_IBM /* IBM COBOL compatibility */ 00162 }; 00163 00164 enum cb_binary_byteorder { 00165 CB_BYTEORDER_NATIVE, 00166 CB_BYTEORDER_BIG_ENDIAN 00167 }; 00168 00169 enum cb_binary_size { 00170 CB_BINARY_SIZE_2_4_8, /* 2,4,8 bytes */ 00171 CB_BINARY_SIZE_1_2_4_8, /* 1,2,4,8 bytes */ 00172 CB_BINARY_SIZE_1__8 /* 1,2,3,4,5,6,7,8 bytes */ 00173 }; 00174 00175 enum cb_operation_type { 00176 CB_OPERATION_READ, 00177 CB_OPERATION_WRITE, 00178 CB_OPERATION_ASSIGN 00179 }; 00180 00181 enum cb_support { 00182 CB_OK, 00183 CB_WARNING, 00184 CB_ARCHAIC, 00185 CB_OBSOLETE, 00186 CB_SKIP, 00187 CB_IGNORE, 00188 CB_ERROR, 00189 CB_UNCONFORMABLE 00190 }; 00191 00192 #undef CB_CONFIG_ANY 00193 #undef CB_CONFIG_INT 00194 #undef CB_CONFIG_STRING 00195 #undef CB_CONFIG_BOOLEAN 00196 #undef CB_CONFIG_SUPPORT 00197 00198 #define CB_CONFIG_ANY(type,var,name) extern type var; 00199 #define CB_CONFIG_INT(var,name) extern int var; 00200 #define CB_CONFIG_STRING(var,name) extern const char *var; 00201 #define CB_CONFIG_BOOLEAN(var,name) extern int var; 00202 #define CB_CONFIG_SUPPORT(var,name) extern enum cb_support var; 00203 #include "config.def" 00204 #undef CB_CONFIG_ANY 00205 #undef CB_CONFIG_INT 00206 #undef CB_CONFIG_STRING 00207 #undef CB_CONFIG_BOOLEAN 00208 #undef CB_CONFIG_SUPPORT 00209 00210 extern int cb_load_std (const char *name); 00211 extern int cb_load_conf (const char *fname, const int check_nodef, 00212 const int prefix_dir); 00213 00214 /* preprocessor (in pplex.l, ppparse.y) */ 00215 extern FILE *ppin; 00216 extern FILE *ppout; 00217 extern int pplex (void); 00218 extern int ppparse (void); 00219 extern int ppopen (const char *name, struct cb_replace_list *replace_list); 00220 extern int ppcopy (const char *name, const char *lib, 00221 struct cb_replace_list *replace_list); 00222 extern void pp_set_replace_list (struct cb_replace_list *replace_list); 00223 00224 /* parser (in scanner.l, parser.y) */ 00225 extern FILE *yyin; 00226 extern FILE *yyout; 00227 extern int yylex (void); 00228 extern int yyparse (void); 00229 00230 /* typeck.c */ 00231 extern size_t sending_id; 00232 extern size_t suppress_warn; 00233 00234 /* error.c */ 00235 #ifdef __GNUC__ 00236 extern void cb_warning (const char *fmt, ...) 00237 __attribute__ ((__format__ (__printf__, 1, 2))); 00238 extern void cb_error (const char *fmt, ...) 00239 __attribute__ ((__format__ (__printf__, 1, 2))); 00240 #else 00241 extern void cb_warning (const char *fmt, ...); 00242 extern void cb_error (const char *fmt, ...); 00243 #endif 00244 00245 extern int cb_verify (const enum cb_support tag, const char *feature); 00246 00247 #endif /* CB_COBC_H */