/* ************************** */ /*EU 4GL V 1.0 */ /* Ph BERGOUGNOUX */ /* phone/fax 00 33 2 47 28 58 19 */ /* ************************** */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "sysdict.h" #include "c:\EndUser4gl\4gl\bin\opcsys.h" /* ***************************** COMPILATEUR ************************ ****/ #define D_MOT_CLE 0x0001 #define D_MOT_CLE_BLOC_DEBUT 0x0002 #define D_MOT_CLE_BLOC_FIN 0x0004 #define D_MOT_CLE_BLOC_ELSE 0x0008 #define D_MOT_CLE_RETURN 0x0010 #define D_MOT_CLE_RETURNING 0x0020 #define D_MOT_CLE_PROC_DEBUT 0x0040 #define D_MOT_CLE_PROC_FIN 0x0080 #define D_MOT_CLE_BLOC_PGM_DEBUT 0x0100 #define D_MOT_CLE_BLOC_PGM_FIN 0x0200 #define D_MOT_CLE_BLOC_DEBUT_FOR 0x0400 #define D_MOT_CLE_BLOCTOBLOC_FIN 0x0800 /* si long "code" declare 32 bits 0x00000001 */ /* exclusivement utilis, dans table des symboles */ #define C_IMED 0x00000001 #define C_DEFINE_INST 0x00000002 #define C_DEFINE_LEX 0x00000004 #define C_DEFINE_MOT 0x00000008 #define C_DEFINE_EXE 0x00000010 #define C_TOKEN 0x00000020 #define C_STRING 0x00000040 #define C_STR_MOT 0x00000080 /* chaines non interpretees*/ #define C_EST_MARQUE 0x00000100 /* utilise dans les regles et tables des symboles*/ /* CONSTANTE */ #define C_FLOAT 0x00000200 #define C_ALNUM 0x00000400 #define C_INTEGER 0x00000800 #define C_LONG 0x00001000 #define C_DOUBLE 0x00002000 #define F_FUNCTION 0x00004000 #define C_STR_MOT_EXTERNE_C 0x00008000 /* chaines non interpretees :externe c*/ #define C_DEFINE 0x00001000 /* exclusivement utilise dans les regles */ #define C_DICT 0x00000001 #define C_CODE_EXE 0x00000002 #define C_REGLE_A_RESOUDRE 0x00000004 #define C_FIN_REGLE 0x00000008 #define LONG_LINE 2048 #define P_MOT 5 #define P_MOT_VIDE 6 #define FALSE 0 #define TRUE 1 #define cn '\0' #define MAX_ELEME_WHILE 100 /* 200 Nbre de IF/WHILE/DOWHILE/FOR /WHEN imbriqués */ #define MAX_ELEME_INDEX_BLOC 200 /* 300 Nbre de bloc if/while for...dans le pgm */ #define MAX_ELEME_INDEX_PROC 40 /* 50 Nbre de procèdure ou fonctions dans un pgm */ #define MAX_ELEME_OPC_TOKEN 1 /* nbre d'éléments Token ds table symbole */ #define MAX_ELEME_OPC_GLOBAL 1 #define MAX_ELEME_OPC_LOCAL 1 #define C_CMP_TAILLE_NOM_TABSYMB 35 /* longueur d'un token */ #define C_REG_NBR_PAR_CELLULE 35 /* nbre de regles dans un token */ /* Attn : debordement T_INSTRUCTION */ #define MAX_PILE 50 /* nbre d'éléments dans la pile */ #define C_CMP_TAILLE_NOM_DICT 60 /* longueur mot clé */ #define P_NB_P 7 #define P_FLOAT 0 #define P_XX 1 #define P_STRING 2 #define P_INTEGER 3 #define P_LONG 4 #define P_NAMEVAR 5 #define P_TABLE 6 #define P_DOUBLE 7 #define P_CONSTANT_LONG 15 #define P_CONSTANT_STRING 16 int locking(int handle, int cmd, long length); static LPSTR FAR OPCGlobalBuffer = NULL; /* **************************** PILES ****************************** */ /* PILES */ static double P_D[MAX_PILE]; /* double */ static float P_F[MAX_PILE]; /* float */ static LPTSTR FAR P_S[MAX_PILE]; /* adresse string */ // static LPTSTR FAR P_NV[MAX_PILE]; static short int P_I[MAX_PILE]; /* entiers: integer */ static long P_L[MAX_PILE]; /* longs */ //static char P_NV[C_CMP_TAILLE_NOM_DICT][MAX_PILE]; /* adresse des noms de variables */ struct NameZone{ char nameZone[C_CMP_TAILLE_NOM_DICT+1]; }P_NVs[MAX_PILE]; unsigned short int P_C_D = 0; unsigned short int P_C_I = 0; unsigned short int P_C_S = 0; unsigned short int P_C_F = 0; unsigned short int P_C_L = 0; unsigned short int P_C_NV = 0; FILE *outfileOUTQ; unsigned char bufferecran[MAXBUFLEN] ; char filenameOUTQ [MAXBUFLEN] ; unsigned static char bufferCharSpec [MAXBUFLEN] = "\0"; unsigned static char bufferCharSpecTable[10] ="\0" ; unsigned static char bufferCharSpecRecord[10] ="\0" ; static OPCt_dict *racine= NULL; static OPCt_dictGlobalInt *racineGlobalInt= NULL; static OPCt_dictGlobalLong *racineGlobalLong= NULL; static OPCt_dictGlobalFloat *racineGlobalFloat= NULL; static OPCt_dictGlobalDouble *racineGlobalDouble= NULL; static OPCt_dictGlobalChar *racineGlobalChar= NULL; static OPCt_dictLocalInt *racineLocalInt= NULL; static OPCt_dictLocalLong *racineLocalLong= NULL; static OPCt_dictLocalFloat *racineLocalFloat= NULL; static OPCt_dictLocalDouble *racineLocalDouble= NULL; static OPCt_dictLocalChar *racineLocalChar= NULL; struct stat status; /* table des symboles */ static struct TABSYM { char name[C_CMP_TAILLE_NOM_TABSYMB]; char val[C_CMP_TAILLE_NOM_TABSYMB]; long code; long codeexe; OPCt_dict *dict; } ; typedef struct TABSYM noeud[]; static noeud *v_tabsymb= NULL; #define TABSYMB (*v_tabsymb) static struct TABSYMGlobal { char name[C_CMP_TAILLE_NOM_TABSYMB]; OPCt_dictGlobalInt *GdictInt; OPCt_dictGlobalLong *GdictLong; OPCt_dictGlobalFloat *GdictFloat; OPCt_dictGlobalDouble *GdictDouble; OPCt_dictGlobalChar *GdictChar; } ; typedef struct TABSYMGlobal noeudGlobal[]; static noeudGlobal *v_tabsymbGlobal= NULL; #define TABSYMBGlobal (*v_tabsymbGlobal) static struct TABSYMLocal { char name[C_CMP_TAILLE_NOM_TABSYMB]; OPCt_dictLocalInt *LdictInt; OPCt_dictLocalLong *LdictLong; OPCt_dictLocalFloat *LdictFloat; OPCt_dictLocalDouble *LdictDouble; OPCt_dictLocalChar *LdictChar; } ; typedef struct TABSYMLocal noeudLocal[]; static noeudLocal *v_tabsymbLocal= NULL; #define TABSYMBLocal (*v_tabsymbLocal) typedef struct _REGLE { short nbr; /* nbre d'element */ BOOL IndFind; unsigned short IndexRule; struct{ union{ int symcur; long code; /* code exe */ struct _REGLE *regle; /* regle . suivre */ OPCt_dict *dict; }pt; unsigned long type; }elem[C_REG_NBR_PAR_CELLULE]; // struct _REGLE *prec ; /* pointe sur une structure de meme type */ struct _REGLE *suiv ; /* pointe sur une structure de meme type */ struct _REGLE *suivTurbo ; /* pointe sur une structure de meme type */ }REGLE; static struct _REGLE *RegleMain= NULL; /* offsets + nom précedents : procédures ou founctions appelés */ long P_PF[MAX_PILE]; LPSTR FAR P_PFS[MAX_PILE]; struct _P_REGLE { REGLE *RegleProcFuncPrec ; }P_REGLE[MAX_ELEME_INDEX_PROC ] ; short int P_C_PF = 0 ; short int P_C_PFS = 0 ; short int P_C_REGLE = 0 ; short int P_C_REGLE_TURBO = 0 ; short int P_CODE_ENCOURS = 99;