#ifndef h_compiler #define h_compiler /****************************************************************************** * * Declarations for uniVerse compilers * * Module %M% Version %I% Date %H% * * (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved * This is unpublished proprietary source code of Ardent Software Inc. * The copyright notice above does not evidence any actual or intented * publication of such source code. * ******************************************************************************* * * Maintenence log - insert most recent change descriptions at top * * Date.... GTAR# WHO Description......................................... * 06/30/99 25276 JSM Added $OPTIONS PIOPEN.EXECUTE * 10/14/98 23801 SAP Change copyrights. * 08/20/98 23592 WSM Add $OPTION PIOPEN.MATREAD * 06/08/98 23063 SAP Define yylenguc, yytextuc & yytextuc for HP-UX 11. * 05/08/98 22411 KAM Remove opt_CONVERT from default INFORMATION options * 12/08/97 18190 KAM Added $OPTION PIOPEN.MATCHFIELD * 04/30/97 19665 JWT/FTW/JSM Add partial Advanced PICK READU constraints. * 04/24/96 18241 DJL Added $OPTION INPUT.RETAIN * 01/04/96 17851 DPB Added STRING.MATH compiler option for Temenos. * 09/21/95 17377 DPB Added TIME.MICROSECONDS $OPTION. * 02/08/95 14946 GMH Added opt_LOCATE.R83 * 01/04/95 15424 EAP Added PI/open flavor opt_INPUTAT * 12/16/94 14947 JSW Added opt_PISELIDX for IMP * 09/27/94 14961 DTM Added fWAIT and fUNTIL for GET/GETX * 06/23/94 12568 DPB Add option INT.PRECISION for precision rounding in * the Fint() function. * 05/20/94 14010 JSW added fINPUT for CLEAR INPUT * 05/12/94 13933 JSW Added opt_REMOD for IMP * 05/11/94 13836 RM Added flags for ISOLATION LEVEL * 04/28/94 12586 DPB Added opt_COMPPREC (precision based comparisions) * 04/28/94 13817 JSW Added opt_ECALL (make enter same as call) * 03/08/94 12297 JSW Added opt_PIOPENINC * 03/08/94 12297 JSW Add HEADER.BRK and room for 32 more initial options. * 03/08/94 12297 JSW Added FSELECT option. * 03/08/94 12307 EAP Added RAW.OUTPUT plus room for 32 more options. * 03/08/94 12297 JSW Add PI/Open Flavour options. * 03/08/94 12297 JSW Add $IFDEF globals. * 03/08/94 12297 JSW Add Vdefined for $DEFINE symbols. * 03/08/94 12297 JSW Add keywords START,COMMIT and ABORT and keyflag1 * 03/08/94 12297 JSW Add ERROR special case for ON ERROR. * 08/02/93 10978 SHK Port to DEC AXP * 05/11/93 11417 JWT Allow functions to require lvalues for arguments * 05/06/93 9781 JWT added SENTENCE() as synonym for @SENTENCE * 04/28/93 10132 DTM Added opt_S to opt_REAL to support reality SELECT * 10/27/92 10355 JWT Add ultix format support * 08/18/92 7571 JWT Wide 0 support for boolean tests * 02/14/92 8826 JWT enlarge error message buffer * 10/25/91 8806 RM Support for transaction management in BASIC * 10/25/91 6820 JWT add optimizer options * 06/05/91 6820 JWT add optimizer options * 12/12/90 7364 JWT add IN2 $OPTIONS RADIANS for radiand trig functs * 08/24/90 7394 JWT add support for DEFFUN statement * 04/24/90 6845 JWT pick printer close (options Z) * 11/14/89 6183 JWT Longer variable name support * 11/14/89 6133 JWT support INPUT ELSE syntax in pick flavor * 11/13/89 5694 JWT turn on option W (IN2 insert) for prime flavor * 03/17/89 5329 PHH IN2 compiler options * 01/16/89 4050 PHH Make REALITY HEADING's same as PICK * 10/14/88 5331 CT Added Fnego * 08/16/88 4161 PHH Flavor dependant reads * 07/25/88 - - Maintenence log purged at 5.2.1, see release 5.1.10. * *****************************************************************************/ #include "tree.h" #include "DBFILE.h" #include "param.h" /************************************************************************ * * * Symbol table definition * * * ************************************************************************/ /* See words.c for a warning about these values. */ #define SYM_ATSYS_RETCODE 0 #define SYM_STDFIL 1 #define SYM_SELECTED 2 #define SYMDEF struct symdef struct symdef { #ifdef NBASIC char *name; /* Symbol name */ #else char name[SYMsiz]; /* Symbol name */ #endif int type; /* Symbol type (see above) */ int domain; /* Domain ( DOM_loc, DOM_com etc ) */ UVADDR address; /* Symbol address * Variable number for local, common, and subroutine arguments. * Program location for labels. -1 means not yet defined. * The address of a null terminated string for equates. */ int value; /* Misc value * Flag for local variables having been assigned a value * Named common segment number for common. * Address of the chain for undefined labels (see above) */ int xdim; /* the x dimension of non redimensionable arrays */ int ydim; /* the y dimension of non redimensionable arrays */ }; /************************************************************************ * * * Symbol types * * * ************************************************************************/ #define Vlvariable 1 /* local scaler */ #define Vcvariable 2 /* COMMON scaler */ #define Vuvariable 3 /* Unused variable(subarg only) */ #define Vsvariable 4 /* scaler subroutine argument */ #define Vavariable 5 /* @ Variable (read/write) */ #define Vrvariable 6 /* @ Variable (read only) */ #define Vrarray 7 /* run-time array */ #define Vfarray 8 /* 'fixed' array */ #define Vsarray 9 /* subroutine argument array */ #define Vlabel 10 /* Label */ #define Vcommon 11 /* Named common block */ #define Vprequate 12 /* Pre-defined equate */ #define Vequate 13 /* Equated symbol */ #define Vatvariable 14 /* @ Variable */ #define Vregister 15 /* Compiler generated register */ #define Vstring 16 /* String constant */ #define Vkstring 17 /* String constant (CALL name) */ #define Vinteger 18 /* Integer constant */ #define Vnumber 19 /* Floating point constant */ #define Vgci 20 /* General Call Interface */ #define Vdeffun 21 /* User DEFined FUNction */ #define Vdefined 22 /* defined symbol */ /************************************************************************ * * * Lexical scanner flags * * * ************************************************************************/ #define Lbflag 1 /* Check bosflag, then keyflag */ #define Lbfunc 2 /* Check bosflag, then Check for following '(' */ #define Lbos 3 /* Check bosflag */ #define Lelse 4 /* Special case: 'ELSE' */ #define Lend 5 /* Special case: 'END' */ #define Lflag 6 /* Check keyflag */ #define Lfunct 7 /* Check for following '(' */ #define Lloc 8 /* Special case: 'LOCATE' */ #define Llock 9 /* Special case: 'LOCKED' (also checks keyflag) */ #define Lloop 10 /* Special case: 'UNTIL' & 'WHILE' */ #define Lnext 11 /* Special case: 'NEXT' */ #define Lsub 12 /* Special case: 'SUBROUTINE' */ #define Lthen 13 /* Special case: 'THEN' */ #define Lget 14 /* Special case: 'GET(' */ #define Lseek 15 /* Special case: 'SEEK(' */ #define Lprntr 16 /* Special case: 'PRINTERR' */ #define Lexec 17 /* Special case: 'PERFORM' on Microdata */ #define Lstat 18 /* Special case: 'STATUS' */ #define Lerror 19 /* Special case: '(ON) ERROR */ #define Lbig 20 /* Special case: '$DEFINE, $UNDEFINE */ #define Lcdir 21 /* Special case: '$ELSE, $ENDIF */ /************************************************************************ * * * Function flags * * * ************************************************************************/ #define Fone 0x01 /* Fill optional paramaters with 1 (default 0) */ #define Fsemi 0x02 /* Allow last paramater to be seperated by ';' */ #define Fovlap 0x04 /* Use overlap counting functions or not */ #define Fseq 0x08 /* Use SEQ('') rule */ #define Fptrim 0x10 /* flags for new trim */ #define Fnull 0x20 /* Fill optional paramaters with null strings */ #define Fnego 0x40 /* Fill optional paramaters with -1 */ #define Ftrig 0x80 /* Set for trig functions */ #define Fatsentence -20 /* Special tag for SENTENCE() function */ /************************************************************************ * * * Function lvalue argument flags * * * ************************************************************************/ #define LVA_1 0x0001 #define LVA_2 0x0002 #define LVA_3 0x0004 #define LVA_4 0x0008 #define LVA_5 0x0010 #define LVA_6 0x0020 #define LVA_7 0x0040 #define LVA_8 0x0080 #define LVA_9 0x0100 #define LVA_10 0x0200 #define LVA_11 0x0400 /************************************************************************ * * * Keyword flags * * * ************************************************************************/ #define fALL 0x00000001 /* "ALL" */ #define fBEFORE 0x00000002 /* "BEFORE" */ #define fBY 0x00000004 /* "BY" */ #define fCASE 0x00000008 /* "CASE" */ #define fCLOSE 0x00000010 /* "CLOSE" */ #define fCOMMON 0x00000020 /* "COMMON" */ #define fDO 0x00000040 /* "DO" */ #define fEXE 0x00000080 /* Keywords for EXECUTE */ #define fFROM 0x00000100 /* "FROM" */ #define fGO 0x00000200 /* "GO", "GOSUB", "GOTO" */ #define fIN 0x00000400 /* "IN" */ #define fKEY 0x00000800 /* "KEY" */ #define fLIT 0x00001000 /* "LIT", "LITERALLY" */ #define fLOCK 0x00002000 /* "LOCKED" */ #define fMAT 0x00004000 /* "MAT" */ #define fOFF 0x00008000 /* "OFF" */ #define fON 0x00010000 /* "ON" */ #define fRESET 0x00020000 /* "RESET" */ #define fSET 0x00040000 /* "SETTING" */ #define fSTEP 0x00080000 /* "STEP" */ #define fTO 0x00100000 /* "TO" */ #define fARG 0x00200000 /* "ARG." */ #define fUSE 0x00400000 /* "USING" */ #define fCALLING 0x00400000 /* "CALLING" */ #define fDEC 0x08000000 /* Arguments of DECLARE */ #define fLPTR 0x10000000 /* "LPTR", "MTU" */ #define fWORK 0x20000000 /* "WORK" */ #define fERROR 0x40000000 /* "ERROR" */ #define fTRANSACT 0x80000000 /* "TRANSACTION" */ /* keyword1 flags */ #define fABORT 0x00000001 /* "ABORT" */ #define fCOMMIT 0x00000002 /* "COMMIT" */ #define fSTART 0x00000004 /* "START" */ #define fSETISO 0x00000010 /* ISOLATION */ #define fISOLEVEL 0x00000020 /* NO.ISOLATION ... SERIALIZABLE */ #define fINPUT 0x00000040 /* "INPUT" for CLEAR INPUT */ #define fWAIT 0x00000080 /* Wait flag for GET/GETX */ #define fUNTIL 0x00000100 /* UNTILCOND flag for GET/GETX */ /************************************************************************ * * * Domain reference definitions * * * ************************************************************************/ #define DOM_KON 0 /* Constants */ #define DOM_MAT 1 /* Special $MATRIX operator */ #define DOM_LOC 2 /* Local variables */ #define DOM_ARG 3 /* Subroutine arguments */ #define DOM_COM 4 /* Common variables */ /************************************************************************ * * * Constant definitions * * * ************************************************************************/ #define Kundef 0 /* this is not a constant */ #define Kstr 1 /* String */ #define Knum 2 /* Floating point number */ #define Kint 3 /* Integer */ #define Kkstr 4 /* Call String */ #define Kreg 5 /* Register */ #define Katv 6 /* @Variable */ #define KON union kon union kon { STRING str; double number; int integer; int regnum; int atvnum; }; #define KONST struct konst struct konst { short type; KON data; }; /************************************************************************ * * * Compiler option flags * * * * ABCDEFGHIJKLMNOPQRSTUVWXYZ * * XXXXXXXXXXXXXXXXXXXXXXXXXX options all used 04/24/90 * * * * * ************************************************************************/ /* Don't use opt_A */ #define opt_E 0x00000001 /* ERRMSG file on STOP & ABORT statments*/ #define opt_F 0x00000002 /* FOR-NEXT termination value */ #define opt_H 0x00000004 /* HEADING statment automatic eject */ #define opt_I 0x00000008 /* INPUT statments suppress echo from DATA*/ #define opt_L 0x00000010 /* Locate <> beginning expression */ #define opt_M 0x00000020 /* create matrices at comp time,not runtime */ #define opt_P 0x00000040 /* PERFORM instead of EXECUTE */ #define opt_R 0x00000080 /* Print warning for no final end stmt */ #define opt_S 0x00000100 /* SELECT TO variable instead of number */ #define opt_V 0x00000200 /* + - * / Vector math routines */ #define opt_G 0x00000400 /* determines behaviour of ONGOTO, ONGOSUB*/ #define opt_O 0x00000800 /* turn on overlap counting in count,index */ #define opt_D 0x00001000 /* Treatment of data/time within HEADINGS*/ #define opt_N 0x00002000 /* Treatment of SEQ('') */ #define opt_X 0x00004000 /* Treatment of READNEXT */ #define opt_B 0x00008000 /* reality or ultimate PRINTERR */ #define opt_C 0x00010000 /* Microdata gets perfrom not exec */ #define opt_J 0x00020000 /* Prime flavored abort statement */ #define opt_K 0x00040000 /* REALITY flavored subtrsings */ #define opt_Q 0x00080000 /* PICK & REALITY flavored READ & READV */ #define opt_T 0x00100000 /* IN2 flavored subtrsings */ #define opt_U 0x00200000 /* SELECT is a noop when Select#0 active*/ #define opt_W 0x00400000 /* Inserting null elements difference */ #define opt_Y 0x00800000 /* INPUT statement may have THEN/ELSE */ #define opt_Z 0x01000000 /* Pick style PRINTER CLOSE statement */ #define opt_OCINFMT 0x02000000 /* allow oconv in by format */ #define opt_RADIANS 0x04000000 /* trig operations are in radians*/ #define opt_WIDEIF 0x08000000 /* testfw and testtw are used */ #define opt_ULTFMT 0x10000000 /* Ult/ix treatment of format */ #define opt_NOCASE 0x20000000 /* casing is not significant */ #define opt_MARKS 0x40000000 /* use PI/Open subset of mark chars */ #define opt_CONVERT 0x80000000 /* PI/ope style FMT, I/OCONV */ /* * Added room for another 32 options */ #define opt_RAWOUTPUT 0x00000001 /* PI/open style RAW.OUTPUT */ #define opt_FSELECT 0x00000002 /* full Basic Select */ #define opt_HEADERBRK 0x00000004 /* PI/Open style header at brkpt */ #define opt_PIOPENINC 0x00000008 /* PI/Open insert/include */ #define opt_ECALL 0x00000010 /* PI/Open style call */ #define opt_COMPPREC 0x00000020 /* Precision based comparisions */ #define opt_REMOD 0x00000040 /* PI/open style REM/MOD */ #define opt_INTPREC 0x00000080 /* Precision rouding in Fint() */ #define opt_PISELIDX 0x00000100 /* PI/open style SELECTINDEX */ #define opt_INPUTAT 0x00000200 /* PI/open flavor INPUT @() */ #define opt_LOCATER83 0x00000400 /* Pick R83 AR locate */ #define opt_MILLITIME 0x00000800 /* Millisecond time from SYSTEM(12) */ #define opt_STRMATH 0x00001000 /* Use string math routines +,-,/,* */ #define opt_INPUTRET 0x00002000 /* $OPTION INPUT.RETAIN */ #define opt_APREADU 0x00004000 /*Partially emulate AP readu behavior */ #define opt_PIMATCHFLD 0x00008000 /* PI/open style MATCHFIELD */ #define opt_PIMATREAD 0x00010000 /* PI/open style MATREAD */ #define opt_PIEXECUTE 0x00020000 /* PI/open style EXECUTE */ #define opt0_IN2 (opt_E|opt_S|opt_F|opt_I|opt_M|opt_G|opt_O|opt_N|opt_Q|opt_T|opt_U|opt_W|opt_Z|opt_RADIANS|opt_WIDEIF) #define opt1_IN2 0 #define opt0_PICK (opt_E|opt_S|opt_F|opt_I|opt_M|opt_G|opt_O|opt_N|opt_Q|opt_U|opt_Y|opt_Z|opt_WIDEIF) #define opt1_PICK 0 #ifdef NBASIC #define opt0_INFO (opt_H|opt_L|opt_R|opt_V|opt_P|opt_D|opt_X|opt_J|opt_W|opt_WIDEIF) #define opt1_INFO 0 #else #define opt0_INFO (opt_H|opt_L|opt_R|opt_V|opt_P|opt_D|opt_X|opt_J|opt_WIDEIF) #define opt1_INFO 0 #endif #define opt0_REAL (opt_E|opt_S|opt_F|opt_R|opt_I|opt_M|opt_O|opt_N|opt_B|opt_C|opt_K|opt_Q|opt_Z|opt_OCINFMT|opt_WIDEIF) #define opt1_REAL 0 /* for PI/open compatability */ #define opt0_PIOPEN (opt0_INFO | opt_NOCASE | opt_MARKS) #define opt1_PIOPEN (opt_HEADERBRK | opt_PIOPENINC | opt_ECALL | opt_REMOD | opt_PISELIDX | opt_INPUTAT) /* #define opt0_SMA (opt_O|opt_P|opt_W|opt_F|opt_H|opt_Q|opt_X|opt_N|opt_M|opt_E|opt_S|opt_V|opt_NOCASE|opt_WIDEIF) #define opt1_SMA 0 */ /* #define opt0_INFOA (opt_R|opt_P|opt_W|opt_F|opt_D|opt_H|opt_W|opt_J|opt_L|opt_Q|opt_X|opt_M|opt_V|opt_NOCASE|opt_WIDEIF) #define opt1_INFOA 0 */ /************************************************************************ * * * Optimization flags * * * ************************************************************************/ #define NBOreduce_const 0x00000001 /* Recude constant expressions */ #define NBOignore_widez 0x00000002 /* Reduce WIDE_ZERO operations */ #define NBOjump_peep 0x00000004 /* Peephole jump optimization */ #define NBOdisplay_stat 0x80000000 /* Show optimization statistics */ #define NBOfull_optim 0xFFFFFFFF /* Preform all optimizations */ #define PEEP_JMP_MAX 10 /* Size of jump peephole */ #define DEFINED (0) #define UNDEFINED (-1) /************************************************************************ * * * Error message definition * * * ************************************************************************/ #define ERRDEF struct err struct err { int lc; /* Line number error occured on */ int cc; /* Character count within line */ int cp; /* Used by error printing routine */ int yylast; /* Parser condition: */ int yychar; /* Parser condition: */ int yystate; /* Parser condition: */ char msg[100]; /* Text of the error message */ ERRDEF *next; }; /************************************************************************ * * * Include file state save record * * * ************************************************************************/ #define ISAVE struct isave struct isave { int fnum; long pos; long line; }; /************************************************************************ * * * Automatic token definition * * * ************************************************************************/ #define TOKEN struct token struct token { int lexeme; int state; YYSTYPE value; }; #define nexttok(a) { autostk[autoptr].lexeme =(a); \ autostk[autoptr].state =lexstate; \ autostk[autoptr].value.count = 0 ; \ autoptr++; \ } #define nextstate(a,b) { autostk[autoptr].lexeme =(a); \ autostk[autoptr].state =(b); \ autostk[autoptr].value.count = 0 ; \ autoptr++; \ } #define nextval(a,b,c) { autostk[autoptr].lexeme = (a); \ autostk[autoptr].value.b = (c) ; \ autoptr++; \ } /************************************************************************ * * * $IFDEF * * * ************************************************************************/ #define MAX_NESTED_IFDEFS 10 EXTERN int else_allowed[]; /* else allowed on ifdef */ EXTERN int nested_ifdefs; /* current level of nesting */ /************************************************************************ * * * External variable declarations * * * ************************************************************************/ EXTERN TREE *rootnode; EXTERN DBFILE *VOC; EXTERN ERRDEF *error, **errlast; EXTERN FILE *fline, *fobj, *fxref, *yyin; EXTERN ISAVE *iptr, istack[]; EXTERN KONST *constant; EXTERN STRING nulstr, AMSTR, whitespace; EXTERN TOKEN autostk[]; EXTERN YYSTYPE yylval; EXTERN char errmsg[], *filein, *fileobj, *fileot, *filesrc, *ifile[], *lexsave, yysbuf[]; EXTERN char *yysptr; EXTERN int *DOMbase; EXTERN int EQUnum, Hcc, Lcc, Llc, SYMnum, WRDmax, autoptr, bosflag, whileflag, cc, ccompile, condcode, clrcommon, comseen, comc, comn, comv, cvc, cxref, dynstate, ec, errc, errflg, ewarn, fpc, genflg, ifptr, keyflag, keyflag1, kvc, lastline, lastpc, lblflag, lblc, lc, lexflag, lexlook, lexstate, lfflag, lpflag, lptr, lvc, tvc, uarg, uflag, ueof, lsc,csc, objf, options[2], pc, sc, ss, svc, wc, yyleng; EXTERN short l_flag, p_flag, x_flag; #if defined(HPUX11) int yylenguc; char yytextuc[16], yytextarr[16]; #endif /************************************************************************ * * * External function definitions * * * ************************************************************************/ EXTERN STRING callname(); EXTERN void addsym(), intsym(), evalinit(), evalclose(), eval(), inckon(), setkon(), out_op(), out_ref(), out_int(), out_short(); EXTERN int out_jump(), yyparse(); EXTERN void align_pad(), change_op(), fix_address(), incsym(), lock_op(), yyerror(), xref(); struct rtab { char ucnt; char dfnd; ushort varnum; }; #endif /* end of compiler */