391 lines
12 KiB
C
391 lines
12 KiB
C
/*
|
|
* Copyright (C) 1999 - 2002, Glen Colbert, David Essex, Rildo Pragana.
|
|
* Copyright (C) 1993, 1991 Rildo Pragana.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this software; see the file COPYING. If not, write to
|
|
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
* Boston, MA 02111-1307 USA
|
|
*/
|
|
|
|
#ifndef _HTGLOBALS_H
|
|
#define _HTGLOBALS_H
|
|
|
|
/* ***********************************************
|
|
* * Global compiler variables *
|
|
* ***********************************************/
|
|
|
|
#define PATHMAX 120
|
|
#define PATHMAX1 (1024 * 4)
|
|
#define PATHMAX2 256
|
|
#define PATHMAX3 1024
|
|
|
|
#define CHR_SQUOTE '\''
|
|
#define CHR_DQUOTE '"'
|
|
#define CHR_EOS '\0'
|
|
#define CHR_ASTERIX '*'
|
|
#define CHR_CR '\r'
|
|
#define CHR_LF '\n'
|
|
#define STR_DASH '-'
|
|
#define STR_UNDERSCORE '_'
|
|
#define CHR_SLASH '/'
|
|
|
|
#ifndef __MINGW32__
|
|
#define STR_SEARCH_SUFFIXES ".cpy:.CPY:.cob:.COB:.cbl:.CBL::"
|
|
#define CHR_COLEN ':'
|
|
#define STR_COLEN ":"
|
|
#else
|
|
#define STR_SEARCH_SUFFIXES ".cpy;.CPY;.cob;.COB;.cbl;.CBL;;"
|
|
#define CHR_COLEN ';'
|
|
#define STR_COLEN ";"
|
|
#endif
|
|
|
|
/* #define DEBUG_COBPP 1 */
|
|
#ifdef DEBUG_COBPP
|
|
#define DEBUG_COBPP_PP 1
|
|
#define DEBUG_COBPP_SCANNER 1
|
|
#define DEBUG_COBPP_PARSER 1
|
|
#endif
|
|
|
|
#define STATE_FLIT_LNONE 1
|
|
#define STATE_FNAME_LNONE 2
|
|
#define STATE_FLIT_LLIT 3
|
|
#define STATE_FLIT_LNAME 4
|
|
#define STATE_FNAME_LLIT 5
|
|
#define STATE_FNAME_LNAME 6
|
|
|
|
#define FORMAT_FIXED 'f'
|
|
#define FORMAT_FREE 'x'
|
|
|
|
#ifndef __MINGW32__
|
|
|
|
#ifndef LT_DIRSEP_CHAR
|
|
#define LT_DIRSEP_CHAR '/'
|
|
#endif
|
|
#ifndef LT_DIRSEP_STR
|
|
#define LT_DIRSEP_STR "/"
|
|
#endif
|
|
|
|
|
|
# ifndef LT_PATHSEP_CHAR
|
|
# define LT_PATHSEP_CHAR ':'
|
|
# endif
|
|
# ifndef LT_PATHSEP_STR
|
|
# define LT_PATHSEP_STR ":"
|
|
# endif
|
|
# ifndef TMPDIR_DEFAULT_STR
|
|
# define TMPDIR_DEFAULT_STR "/tmp"
|
|
# endif
|
|
|
|
#define HTG_PGM_SUFFIXES ".cob:.COB:.cbl:.CBL:"
|
|
|
|
#else /* __MINGW32__*/
|
|
|
|
#ifndef LT_DIRSEP_CHAR
|
|
#define LT_DIRSEP_CHAR '\\'
|
|
#endif
|
|
#ifndef LT_DIRSEP_STR
|
|
#define LT_DIRSEP_STR "\\"
|
|
#endif
|
|
|
|
# ifndef LT_PATHSEP_CHAR
|
|
# define LT_PATHSEP_CHAR ';'
|
|
# endif
|
|
# ifndef LT_PATHSEP_STR
|
|
# define LT_PATHSEP_STR ";"
|
|
# endif
|
|
# ifndef TMPDIR_DEFAULT_STR
|
|
/*#define TMPDIR_DEFAULT_STR "C:/windows/temp" */
|
|
# define TMPDIR_DEFAULT_STR "G:/tmp"
|
|
# endif
|
|
|
|
# define HTG_PGM_SUFFIXES ".cob;.COB;.cbl;.CBL;"
|
|
|
|
#endif /*__MINGW32__*/
|
|
|
|
|
|
#define SUFFIX_SEP_STR "."
|
|
#define SUFFIX_SEP_CHAR '.'
|
|
#define SHLIB_SEP_STR "$"
|
|
#define SHLIB_SONAME_STR "-soname,"
|
|
|
|
#define HTG_FILE_GAS_SUFFIX ".s"
|
|
#define HTG_FILE_PPOUT_SUFFIX ".i"
|
|
#define HTG_FILE_OBJECT_SUFFIX ".o"
|
|
#define HTG_FILE_LIB_SUFFIX ".a"
|
|
|
|
#if defined (__WINDOWS__)
|
|
#define HTG_FILE_SHLIB_SUFFIX ".dll"
|
|
#else
|
|
#define HTG_FILE_SHLIB_SUFFIX ".so"
|
|
#endif
|
|
|
|
#define RTL_CALL(module) (emt_cobrtl_call(module, lib_prefix))
|
|
|
|
#define HTG_COBOPT "TCOB_OPTIONS"
|
|
#define HTG_COBDIR "TCOB_OPTIONS_PATH"
|
|
/* #define HTG_COBPPDIR "TCOB_PP_PATH" */
|
|
|
|
#ifndef TRUE
|
|
#define TRUE 1
|
|
#define FALSE 0
|
|
#endif
|
|
|
|
#define MAXWORDSIZE 64000
|
|
|
|
#define MAXNAMEBUF 300
|
|
#define START_STACK_ADJUST 20
|
|
#define SYMBUF_SIZE 128
|
|
#define HASHLEN 100
|
|
#define INIT 1
|
|
|
|
/*#define ARGCOUNT 17 */
|
|
|
|
/* Define if you have the dl library (-ldl). */
|
|
/* Set run time library loading feature. */
|
|
/* #undef WANT_DYNAMIC_LIBS */
|
|
/* #undef HAVE_LIBDL */
|
|
|
|
/* Define if you have the readline library (-lreadline). */
|
|
/* Set use readline library features. */
|
|
/* #undef HAVE_LIBREADLINE */
|
|
/* #undef WANT_READLINE */
|
|
|
|
#define HTG_CMDOPTION_LIST "aB:cCDe:EFghI:kL:l:mM:no:PST:tXxW:vVz"
|
|
|
|
/*#define HTG_RESOPT_ANS85 2000 */
|
|
/*#define HTG_RESOPT_NOANS85 2001 */
|
|
/*#define HTG_RESOPT_COPYEXT 2002 */
|
|
/*#define HTG_RESOPT_COPYLBR 2003 */
|
|
#define HTG_RESOPT_COPYLIST 2004
|
|
#define HTG_RESOPT_NOCOPYLIST 2005
|
|
#define HTG_RESOPT_LIST 2006
|
|
#define HTG_RESOPT_NOLIST 2007
|
|
#define HTG_RESOPT_LD_PATH 2008
|
|
/*#define HTG_RESOPT_LD_LIBS 2009 */
|
|
#define HTG_RESOPT_XREF 2010
|
|
#define HTG_RESOPT_NOXREF 2011
|
|
#define HTG_RESOPT_PGM_SUFFIXES 2012
|
|
#define HTG_RESOPT_LD_IO_LIBS 2013
|
|
#define HTG_RESOPT_LD_TERM_LIBS 2014
|
|
#define HTG_RESOPT_LD_DCALL_LIBS 2015
|
|
#define HTG_RESOPT_LD_HT1_LIBS 2016
|
|
#define HTG_RESOPT_LD_HT2_LIBS 2017
|
|
#define HTG_RESOPT_LD_EXTRA_LIBS 2018
|
|
#define HTG_RESOPT_LD_READLINE_LIBS 2019
|
|
#define HTG_RESOPT_PGM_FORMAT_FREE 2020
|
|
#define HTG_RESOPT_PGM_FORMAT_FIXED 2021
|
|
#define HTG_RESOPT_INCLUDE_PATH 2022
|
|
#define HTG_RESOPT_COPYBOOK_SUFFIXES 2023
|
|
#define HTG_RESOPT_CCX_CMD 2024
|
|
#define HTG_RESOPT_ASX_CMD 2025
|
|
#define HTG_RESOPT_ARX_CMD 2026
|
|
#define HTG_RESOPT_RANLIBX_CMD 2027
|
|
#define HTG_RESOPT_LD_MATH_LIBS 2040
|
|
#define HTG_RESOPT_PGMLIST_SUFFIX 2041
|
|
#define HTG_RESOPT_DEBUG_LINES 2042
|
|
#define HTG_RESOPT_NODEBUG_LINES 2043
|
|
#define HTG_RESOPT_COMPILE_DEFAULT 2044
|
|
#define HTG_RESOPT_SHLIB_NAME_DEFAULT 2045
|
|
#define HTG_RESOPT_LD_FLAGS 2046
|
|
#define HTG_RESOPT_PGM_ENTRY_POINT_AUTO 2050
|
|
#define HTG_RESOPT_PGM_ENTRY_POINT_FIRST 2051
|
|
#define HTG_RESOPT_PGM_ENTRY_POINT_NONE 2052
|
|
|
|
/*
|
|
*-----------------------------------------------------------------------*
|
|
Defines for HTG_compile_level_flag
|
|
10 - P - Preprocess only
|
|
20 - PC - Preprocess and compile (generate assembler code) only
|
|
30 - PCA - Preprocess, compile, assemble only
|
|
40 - PCAL - Preprocess, compile, assemble, link to executable
|
|
50 - PCAX - Preprocess, compile, assemble, link to executable
|
|
60 - PCAS - Preprocess, compile, assemble, archive to static library
|
|
70 - PCAM - Preprocess, compile, assemble, link to shared library
|
|
*-----------------------------------------------------------------------*
|
|
*/
|
|
#define HTG_COMPILE_LEVEL 0
|
|
#define HTG_COMPILE_LEVEL_P 10
|
|
#define HTG_COMPILE_LEVEL_PC 20
|
|
#define HTG_COMPILE_LEVEL_PCA 30
|
|
#define HTG_COMPILE_LEVEL_PCAL 40
|
|
#define HTG_COMPILE_LEVEL_PCAX 50
|
|
#define HTG_COMPILE_LEVEL_PCAS 60
|
|
#define HTG_COMPILE_LEVEL_PCAM 70
|
|
|
|
#define HTG_COMPILE_LEVEL_STR_P "P"
|
|
#define HTG_COMPILE_LEVEL_STR_PC "PC"
|
|
#define HTG_COMPILE_LEVEL_STR_PCA "PCA"
|
|
#define HTG_COMPILE_LEVEL_STR_PCAL "PCAL"
|
|
#define HTG_COMPILE_LEVEL_STR_PCAX "PCAX"
|
|
#define HTG_COMPILE_LEVEL_STR_PCAS "PCAS"
|
|
#define HTG_COMPILE_LEVEL_STR_PCAM "PCAM"
|
|
|
|
/* command line options */
|
|
#define HTG_CMDOPT_NIL 0
|
|
#define HTG_CMDOPT_LIB_STATIC 'a'
|
|
#define HTG_CMDOPT_BIND_MODE 'B'
|
|
#define HTG_CMDOPT_ASSEMBLE 'c'
|
|
#define HTG_CMDOPT_CALLS_DYNAMIC 'C'
|
|
#define HTG_CMDOPT_DEBUG_LINES 'D'
|
|
#define HTG_CMDOPT_ENTRY_NAME 'e'
|
|
#define HTG_CMDOPT_PREPROCESSOR 'E'
|
|
#define HTG_CMDOPT_SOURCE_FIXED 'F'
|
|
#define HTG_CMDOPT_DEBUG 'g'
|
|
#define HTG_CMDOPT_HELP 'h'
|
|
#define HTG_CMDOPT_INCLUDE_PATH 'I'
|
|
#define HTG_CMDOPT_INCLUDE_LIB 'l'
|
|
#define HTG_CMDOPT_LIB_PATH 'L'
|
|
#define HTG_CMDOPT_LIB_SHARED 'm'
|
|
#define HTG_CMDOPT_MAIN_ENTRY 'M'
|
|
#define HTG_CMDOPT_OUTPUT_NAME 'o'
|
|
#define HTG_CMDOPT_LISTING 'P'
|
|
#define HTG_CMDOPT_COMPILE 'S'
|
|
#define HTG_CMDOPT_TAB_NUMBER 'T'
|
|
#define HTG_CMDOPT_SOURCE_OPEN 'X'
|
|
#define HTG_CMDOPT_EXECUTABLE 'x'
|
|
#define HTG_CMDOPT_PASS_OPTIONS 'W'
|
|
#define HTG_CMDOPT_VERBOSE 'v'
|
|
#define HTG_CMDOPT_VERSION 'V'
|
|
#define HTG_CMDOPT_VERY_VERBOSE 'z'
|
|
|
|
#define HTG_CMDOPT_TESTMODE 't'
|
|
#define HTG_CMDOPT_NORUN 'n'
|
|
#define HTG_CMDOPT_LIBCOB 'k'
|
|
|
|
#define HTG_PGM_NAME "TinyCOBOL"
|
|
#define HTG_COPYWR "(C) 2009,2010 TinyCOBOL Development Team\n"
|
|
|
|
struct opt_sel {
|
|
char *opt;
|
|
unsigned int iopt;
|
|
};
|
|
|
|
|
|
extern int wrncnt;
|
|
extern int errcnt;
|
|
extern unsigned int source_lineno;
|
|
extern unsigned int source_colno;
|
|
extern char *source_filename;
|
|
extern char *include_filename;
|
|
extern char input_filename[];
|
|
extern char working_filename[];
|
|
extern char output_filename[];
|
|
extern char list_filename[];
|
|
extern char sys_buf[];
|
|
|
|
extern int HTG_RETURN_CODE;
|
|
extern int HTG_temporary_error_code;
|
|
extern int HTG_temporary_severity;
|
|
extern int HTG_tab2space;
|
|
/*extern short HTG_compiler_PCAL_flag; */
|
|
extern short HTG_assemble_flag;
|
|
extern short HTG_full_compile_flag;
|
|
extern short HTG_make_object_flag;
|
|
extern short HTG_list_flag;
|
|
/*extern short HTG_sym_flag; */
|
|
extern short HTG_xref_flag;
|
|
extern short HTG_debug_lines_flag;
|
|
extern short HTG_offset_flag;
|
|
extern short HTG_verbose;
|
|
extern short HTG_verbose_verbose;
|
|
extern short HTG_all_calls_dynamic;
|
|
extern short HTG_remove_source_flag;
|
|
extern short HTG_retain_symbols;
|
|
extern short HTG_dynamic_flag;
|
|
extern short HTG_shlib_soname_flag;
|
|
extern short HTG_libcob;
|
|
|
|
extern char HTG_codeFormat;
|
|
extern char HTG_COPYDIR[];
|
|
extern char HTG_TMPDIR[];
|
|
extern char HTG_CCX_CMD[];
|
|
extern char HTG_ASX_CMD[];
|
|
extern char HTG_ASX_CMD[];
|
|
extern char HTG_ARX_CMD[];
|
|
extern char HTG_RANLIBX_CMD[];
|
|
/*extern char HTG_ASMLST[]; */
|
|
extern char HTG_OBJECT[];
|
|
extern char HTG_EXECUTABLE[];
|
|
extern char HTG_LD_OPTIONS[];
|
|
extern char HTG_LD_PATHS[];
|
|
extern char HTG_LD_ARGS[];
|
|
extern char HTG_LD_RESOPT_ARGS[];
|
|
extern char HTG_LD_CMDLINE_ARGS[];
|
|
extern char HTG_LD_DCALL_ARGS[];
|
|
extern char HTG_LD_TERM_ARGS[];
|
|
extern char HTG_LD_IO_ARGS[];
|
|
extern char HTG_LD_DYNAMIC[];
|
|
extern char HTG_LD_HT1_ARGS[];
|
|
extern char HTG_LD_HT2_ARGS[];
|
|
extern char HTG_LD_EXTRA_ARGS[];
|
|
extern char HTG_LD_MATH_ARGS[];
|
|
extern char HTG_LD_READLINE_ARGS[];
|
|
|
|
extern char HTG_PCAL_RESOPT_ARGS[];
|
|
extern char HTG_SHLIB_NAME_DEFAULT[];
|
|
|
|
extern char HTG_LD_FLAGS[];
|
|
|
|
#if defined(__MINGW32__ )
|
|
extern char COBINSTDIR[];
|
|
#endif
|
|
|
|
extern FILE *yyin;
|
|
extern FILE *o_src;
|
|
extern FILE *o_lst;
|
|
|
|
extern char include_full_filename[];
|
|
|
|
extern void process_bind_options (char *arglist);
|
|
extern void process_verbose_options (int ac, char *av[]);
|
|
extern void initialize_setup (void);
|
|
extern void append_include_path (char *ap);
|
|
extern void setup_filenames (void);
|
|
extern void print_compiler_banner (void);
|
|
extern void print_copybooks_path (void);
|
|
extern void setup_ld_paths (void);
|
|
extern void setup_ld_paths_defaults (void);
|
|
extern void print_listing_file (void);
|
|
extern int process_pp (void);
|
|
extern int process_compile (void);
|
|
extern void process_select_verify (char compile_level);
|
|
extern void pass_options_ld (char *s);
|
|
extern void pp_setup_scanner_state(void);
|
|
|
|
int find_copybook_file(char *fname, char *lname);
|
|
int find_copybook_file2 (char *fname, char *lname);
|
|
int find_filename_text (char *fname, char *fp, char *fs);
|
|
int find_filename_literal (char *fname, char *fp);
|
|
char *find_env_variable (char *ev);
|
|
char *find_token(char *p, const char *d, int sw);
|
|
void append_include_path(char *ap);
|
|
|
|
extern short HTG_compile_level_flag;
|
|
extern short HTG_compile_level_default;
|
|
|
|
extern char file_path[];
|
|
extern char *prg_name;
|
|
extern char lib_prefix[];
|
|
|
|
extern int HTG_prg_uses_fileio;
|
|
extern int HTG_prg_uses_term;
|
|
extern int HTG_prg_uses_dcall;
|
|
|
|
extern int HTG_norun;
|
|
|
|
extern int HTG_fld_desc_len;
|
|
extern int HTG_grp_desc_len;
|
|
|
|
#endif /* _HTGLOBALS_H */
|