diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9990f6a647..295fc01635 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,67 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2006-02-08 20:23 UTC+0100 Antonio Linares + * makefile.nt + * makefile64.nt + * updated with recent changes + +2006-02-08 18:02 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/gtwin/gtwin.c + + added PreExt() and PostExt() methods + +2006-02-08 15:17 UTC+0100 Przemyslaw32.cf + * harbour/config/w32/gcc.cf + * harbour/config/w32/mingw32.cf + * harbour/include/hbcomp.h + * harbour/include/hbcompdf.h + * harbour/include/hberrors.h + * harbour/include/hbexpra.c + * h may no flush data in PreExt() + + * harbour/source/rtl/gtwin/gtwin.c + ! fixed Init() code by adding missing SUPER_INIT() + * modified a little bit PreExt() and PostExt() methods + +2006-02-08 20:23 UTC+0100 Antonio Linares + * makefile.nt + * makefile64.nt + * updated with recent changes + +2006-02-08 18:02 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/gtwin/gtwin.c + + added PreExt() and PostExt() methods + +2006-02-08 15:17 UTC+0100 Przemyslawurce/compiler/harbour.y + * harbour/source/compiler/hbgenerr.c + - harbour/source/compiler/hbslex.c + - harbour/source/compiler/hbstrong.c + * harbour/source/compiler/hbusage.c + - harbour/source/compiler/simplex.c + * harbour/source/macro/Makefile + - harbour/source/macro/macro.slx + - harbour/source/macro/macroslx.c + * harbour/source/pp/ppcore.c + * harbour/utils/hbpp/hbppcomp.c + - removed SIMPLEX references + ! fixed memory leak in request _GET_ + * use hb_compIdentifiersNew() in INLINE and AUTOOPEN structures + members + * eliminated all internal exit() calls. Now hb_compGenError() with + fatal errors does not interrupt application but only sets + HB_COMP_PARAM->fExit = TRUE; + What should cause silent clean application close. + Please keep it in mind making future modifications and do not + introduce and exit() function call. + + added support for \x and \ quoting in extended strings + (just like in C). Warning !!!. Embedded 0 bytes are supported by + PP, lexer and expression optimizer but not by bison. To make them + working it will be necessary to change Literal terminal symbol + holder and add length field in bison rules and also change the hash + table used to hold identifiers, literals and macros to store and use + real string length. If /hbgtcore.c + * include/hbapigt.h + * source/rtl/gtpca/gtpca.c * source/rtl/gtstd/gtstd.c ! Fixed recent compiler warnings. diff --git a/harbour/config/bsd/gcc.cf b/harbour/config/bsd/gcc.cf index a005cf3fad..49563bdf2e 100644 --- a/harbour/config/bsd/gcc.cf +++ b/harbour/config/bsd/gcc.cf @@ -13,11 +13,7 @@ CC = gcc CC_IN = -c CC_OUT = -o CPPFLAGS = -I. -I$(HB_INC_COMPILE) -ifeq ($(HB_LEX),SIMPLEX) -CFLAGS = -Wall -g -DHB_OS_BSD -DSIMPLEX -else CFLAGS = -Wall -g -DHB_OS_BSD -endif LD = gcc LD_OUT = -o diff --git a/harbour/config/darwin/gcc.cf b/harbour/config/darwin/gcc.cf index 988671b0a6..a9e583b678 100644 --- a/harbour/config/darwin/gcc.cf +++ b/harbour/config/darwin/gcc.cf @@ -25,9 +25,6 @@ CFLAGS = -fno-common -fsigned-char -Wall -W # remove it if you have newer compiler version CFLAGS += -Wno-long-double -ifeq ($(HB_LEX),SIMPLEX) -CFLAGS += -DSIMPLEX -endif CFLAGS += -DHB_OS_DARWIN LD = cc diff --git a/harbour/config/dos/djgpp.cf b/harbour/config/dos/djgpp.cf index 28d6997a74..90a24991d5 100644 --- a/harbour/config/dos/djgpp.cf +++ b/harbour/config/dos/djgpp.cf @@ -17,9 +17,6 @@ ifneq ($(HB_INC_COMPILE),) CPPFLAGS = -I. -I$(HB_INC_COMPILE) endif CFLAGS = -Wall -W -ifeq ($(HB_LEX),SIMPLEX) - CFLAGS += -DSIMPLEX -endif LD = gcc LD_OUT = -o diff --git a/harbour/config/dos/owatcom.cf b/harbour/config/dos/owatcom.cf index 2e126a9ea7..9452847311 100644 --- a/harbour/config/dos/owatcom.cf +++ b/harbour/config/dos/owatcom.cf @@ -33,10 +33,6 @@ ifneq ($(HB_LIB_COMPILE),) CPPFLAGS += -i$(HB_INC_COMPILE) endif -ifeq ($(HB_LEX),SIMPLEX) - CFLAGS += -DSIMPLEX -endif - # work arround to DOS command line size limit export WPP386 := $(strip $(CPPFLAGS)) CPPFLAGS = diff --git a/harbour/config/hpux/gcc.cf b/harbour/config/hpux/gcc.cf index 7ece507e24..8dfb342722 100644 --- a/harbour/config/hpux/gcc.cf +++ b/harbour/config/hpux/gcc.cf @@ -20,10 +20,6 @@ CFLAGS = -DHB_OS_HPUX -Wall -W -fsigned-char # it's necessary on some platforms but can reduce performance #CFLAGS += -fPIC -ifeq ($(HB_LEX),SIMPLEX) -CFLAGS += -DSIMPLEX -endif - LD = $(HB_CCACHE) gcc LD_OUT = -o diff --git a/harbour/config/linux/gcc.cf b/harbour/config/linux/gcc.cf index d987a3c457..0de0c2404d 100644 --- a/harbour/config/linux/gcc.cf +++ b/harbour/config/linux/gcc.cf @@ -27,11 +27,6 @@ CFLAGS = -DHB_OS_LINUX -Wall -W -fsigned-char # it's necessary on some platforms but can reduce performance #CFLAGS += -fPIC -ifeq ($(HB_LEX),SIMPLEX) -CFLAGS += -DSIMPLEX -endif - - LD = $(HB_CCACHE) $(HB_CMP) LD_OUT = -o diff --git a/harbour/config/linux/owatcom.cf b/harbour/config/linux/owatcom.cf index 7d8df1d7b1..c51adaf29a 100644 --- a/harbour/config/linux/owatcom.cf +++ b/harbour/config/linux/owatcom.cf @@ -31,10 +31,6 @@ ifneq ($(HB_LIB_COMPILE),) CPPFLAGS += -i$(HB_INC_COMPILE) endif -ifeq ($(HB_LEX),SIMPLEX) - CFLAGS += -DSIMPLEX -endif - empty:= space:= $(empty) $(empty) comma:= , diff --git a/harbour/config/os2/gcc.cf b/harbour/config/os2/gcc.cf index d6392130bd..d4f32c7e0a 100644 --- a/harbour/config/os2/gcc.cf +++ b/harbour/config/os2/gcc.cf @@ -20,10 +20,6 @@ CFLAGS = -W -Wall -O2 -DHB_OS_OS2 -fsigned-char # to be removed if compiled on a tcp/ip stack >= 4.1 (eComStation, for example) CFLAGS += -DTCPV40HDRS -ifeq ($(HB_LEX),SIMPLEX) -CFLAGS += -DSIMPLEX -endif - LD = gcc LDFLAGS = LD_OUT = -o $(SPACE) diff --git a/harbour/config/sunos/gcc.cf b/harbour/config/sunos/gcc.cf index 0c64dc0d5e..c18d09a79f 100644 --- a/harbour/config/sunos/gcc.cf +++ b/harbour/config/sunos/gcc.cf @@ -20,10 +20,6 @@ CFLAGS = -DHB_OS_SUNOS -Wall -W -fsigned-char # it's necessary on some platforms but can reduce performance #CFLAGS += -fPIC -ifeq ($(HB_LEX),SIMPLEX) -CFLAGS += -DSIMPLEX -endif - LD = $(HB_CCACHE) gcc LD_OUT = -o diff --git a/harbour/config/w32/bcc32.cf b/harbour/config/w32/bcc32.cf index 32c593116d..9de0d85bb0 100644 --- a/harbour/config/w32/bcc32.cf +++ b/harbour/config/w32/bcc32.cf @@ -24,11 +24,7 @@ CC = bcc32 CC_IN = -c CC_OUT = -o CPPFLAGS = -I$(GRANDP) -I$(HB_INC_COMPILE) -ifeq ($(HB_LEX),SIMPLEX) -CFLAGS = -O2 -d -DSIMPLEX -else CFLAGS = -O2 -d -endif LD = bcc32 LDFLAGS = -O2 diff --git a/harbour/config/w32/gcc.cf b/harbour/config/w32/gcc.cf index 84d8197bf3..c99a7116e9 100644 --- a/harbour/config/w32/gcc.cf +++ b/harbour/config/w32/gcc.cf @@ -13,11 +13,7 @@ CC = gcc CC_IN = -c CC_OUT = -o CPPFLAGS = -I. -I$(HB_INC_COMPILE) -ifeq ($(HB_LEX),SIMPLEX) -CFLAGS = -Wall -DSIMPLEX -else -CFLAGS = -Wall -endif +CFLAGS = -Wall -W LD = gcc LD_OUT = -o diff --git a/harbour/config/w32/mingw32.cf b/harbour/config/w32/mingw32.cf index a824938aa2..064ac9c7e2 100644 --- a/harbour/config/w32/mingw32.cf +++ b/harbour/config/w32/mingw32.cf @@ -14,9 +14,6 @@ CC_IN = -c CC_OUT = -o CPPFLAGS = -I. -I$(HB_INC_COMPILE) -mno-cygwin CFLAGS = -Wall -W -ifeq ($(HB_LEX),SIMPLEX) -CFLAGS += -DSIMPLEX -endif LD = $(CCPREFIX)gcc LD_OUT = -o diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index 29b82653a5..3498db951a 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -131,8 +131,6 @@ extern int hb_compVariableScope( HB_COMP_DECL, char * ); #define FUN_USES_LOCAL_PARAMS 16 /* parameters are declared using () */ #define FUN_WITH_RETURN 32 /* there was RETURN statement in previous line */ -extern void hb_compMainExit( void ); /* main cleanup function */ - extern void hb_compFunctionAdd( HB_COMP_DECL, char * szFunName, HB_SYMBOLSCOPE cScope, int iType ); /* starts a new Clipper language function definition */ extern PFUNCTION hb_compFunctionFind( HB_COMP_DECL, char * szFunName ); /* locates a previously defined function */ extern PINLINE hb_compInlineFind( HB_COMP_DECL, char * szFunName ); @@ -283,7 +281,6 @@ extern ULONG hb_compExprListEval( HB_COMP_DECL, HB_EXPR_PTR pExpr, HB_CARGO_FUNC extern ULONG hb_compExprListEval2( HB_COMP_DECL, HB_EXPR_PTR pExpr1, HB_EXPR_PTR pExpr2, HB_CARGO2_FUNC_PTR pEval ); extern void hb_compChkCompilerSwitch( HB_COMP_DECL, int, char * Args[] ); -extern void hb_compChkEnvironVar( HB_COMP_DECL, char * ); extern void hb_compChkPaths( HB_COMP_DECL ); extern void hb_compChkDefines( HB_COMP_DECL, int iArg, char * Args[] ); diff --git a/harbour/include/hbcompdf.h b/harbour/include/hbcompdf.h index 137a28b0a1..46930cea19 100644 --- a/harbour/include/hbcompdf.h +++ b/harbour/include/hbcompdf.h @@ -527,6 +527,7 @@ typedef struct _HB_COMP int iLanguage; /* default Harbour generated output language */ int iGenCOutput; /* C code generation should be verbose (use comments) or not */ + BOOL fExit; /* force breaking compilation process */ BOOL fQuiet; /* be quiet during compilation (-q) */ BOOL fPPO; /* flag indicating, is ppo output needed */ BOOL fStartProc; /* holds if we need to create the starting procedure */ @@ -563,15 +564,15 @@ extern void hb_comp_free( HB_COMP_PTR ); extern HB_COMP_PTR hb_comp_data; -# define HB_COMP_PARAM pComp -# define HB_COMP_DECL HB_COMP_PTR HB_COMP_PARAM +#define HB_COMP_PARAM pComp +#define HB_COMP_DECL HB_COMP_PTR HB_COMP_PARAM #else -# define HB_COMP_PARAM pMacro -# define HB_COMP_DECL HB_MACRO_PTR HB_COMP_PARAM +#define HB_COMP_PARAM pMacro +#define HB_COMP_DECL HB_MACRO_PTR HB_COMP_PARAM -#endif +#endif /* !HB_MACRO_SUPPORT */ #define HB_MACRO_DATA HB_COMP_PARAM #define HB_PCODE_DATA ( HB_MACRO_DATA->pCodeInfo ) diff --git a/harbour/include/hberrors.h b/harbour/include/hberrors.h index 1d442452de..ef17b8c475 100644 --- a/harbour/include/hberrors.h +++ b/harbour/include/hberrors.h @@ -121,6 +121,7 @@ HB_EXTERN_BEGIN #define HB_COMP_ERR_MEMCORRUPT 59 #define HB_COMP_ERR_WITHOBJECT 60 #define HB_COMP_ERR_BUFFER_OVERFLOW 61 +#define HB_COMP_ERR_UNSUPPORTED_LANG 62 #define HB_COMP_WARN_AMBIGUOUS_VAR 1 #define HB_COMP_WARN_MEMVAR_ASSUMED 2 diff --git a/harbour/include/hbexpra.c b/harbour/include/hbexpra.c index 2dffb542f9..80ab6f9ba6 100644 --- a/harbour/include/hbexpra.c +++ b/harbour/include/hbexpra.c @@ -378,8 +378,6 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM HB_EXPR_PCODE1( hb_compExprDelete, pName ); return pEval; } -#ifndef SIMPLEX - else if( ( strcmp( "_GET_", pName->value.asSymbol ) == 0 ) && iCount ) { /* Reserved Clipper function used to handle GET variables @@ -578,9 +576,6 @@ HB_EXPR_PTR hb_compExprNewFunCall( HB_EXPR_PTR pName, HB_EXPR_PTR pParms, HB_COM pParms->value.asList.pExprList = pArg; } } - -#endif - } else if( pName->ExprType == HB_ET_MACRO ) @@ -969,7 +964,6 @@ HB_EXPR_PTR hb_compExprReduce( HB_EXPR_PTR pExpr, HB_COMP_DECL ) } #endif -#ifndef SIMPLEX /* Creates a set/get codeblock for passed expression used in __GET * * {|var| IIF( var==NIL, , :=var )} @@ -1003,5 +997,3 @@ HB_EXPR_PTR hb_compExprSetGetBlock( HB_EXPR_PTR pExpr, HB_COMP_DECL ) hb_compExprNewCodeBlock( NULL, 0, 0, HB_COMP_PARAM ), "~1", ' ', HB_COMP_PARAM ), pIIF ); } - -#endif diff --git a/harbour/include/hbexprb.c b/harbour/include/hbexprb.c index a22cc335fc..5a2a2c6774 100644 --- a/harbour/include/hbexprb.c +++ b/harbour/include/hbexprb.c @@ -146,10 +146,8 @@ static HB_EXPR_FUNC( hb_compExprUseNegate ); static void hb_compExprCodeblockPush( HB_EXPR_PTR, HB_COMP_DECL ); #else static void hb_compExprCodeblockPush( HB_EXPR_PTR, BOOL, HB_COMP_DECL ); -#if !defined(SIMPLEX) static void hb_compExprCodeblockEarly( HB_EXPR_PTR, HB_COMP_DECL ); #endif -#endif const HB_EXPR_FUNC_PTR hb_comp_ExprTable[ HB_EXPR_COUNT ] = { hb_compExprUseDummy, @@ -426,15 +424,11 @@ static HB_EXPR_FUNC( hb_compExprUseCodeblock ) #if defined(HB_MACRO_SUPPORT) HB_EXPR_PCODE1( hb_compExprCodeblockPush, pSelf ); #else -# if defined(SIMPLEX) - HB_EXPR_PCODE2( hb_compExprCodeblockPush, pSelf, TRUE, HB_COMP_PARAM ); -# else if( !pSelf->value.asCodeblock.isMacro || pSelf->value.asCodeblock.lateEval ) hb_compExprCodeblockPush( pSelf, TRUE, HB_COMP_PARAM ); else /* early evaluation of a macro */ hb_compExprCodeblockEarly( pSelf, HB_COMP_PARAM ); -# endif #endif break; } @@ -557,7 +551,6 @@ static void hb_compExprCodeblockPush( HB_EXPR_PTR pSelf, BOOL bLateEval, HB_COMP /* This generates a push pcode for early evaluation of a macro */ -#if !defined(SIMPLEX) #if !defined(HB_MACRO_SUPPORT) static void hb_compExprCodeblockEarly( HB_EXPR_PTR pSelf, HB_COMP_DECL ) { @@ -599,7 +592,6 @@ static void hb_compExprCodeblockEarly( HB_EXPR_PTR pSelf, HB_COMP_DECL ) } } #endif /*HB_MACRO_SUPPORT*/ -#endif /*SIMPLEX*/ /* actions for HB_ET_LOGICAL expression */ diff --git a/harbour/include/hbver.h b/harbour/include/hbver.h index 936bd4390b..0faf5bf6f3 100644 --- a/harbour/include/hbver.h +++ b/harbour/include/hbver.h @@ -53,12 +53,6 @@ #ifndef HB_VER_H_ #define HB_VER_H_ -#if defined(SIMPLEX) - #define HB_VER_LEX "SimpLex" -#else - #define HB_VER_LEX "Flex" -#endif - /* NOTE: One of these next three fields can be incremented by the hbverfix program */ #define HB_VER_MAJOR 0 /* Major version number */ diff --git a/harbour/source/common/hbstr.c b/harbour/source/common/hbstr.c index a83b0dca57..ec1a3eb3ad 100644 --- a/harbour/source/common/hbstr.c +++ b/harbour/source/common/hbstr.c @@ -853,8 +853,8 @@ HB_EXPORT char * hb_strncpyTrim( char * pDest, const char * pSource, ULONG ulLen char * hb_strRemEscSeq( char *str, ULONG *pLen ) { - char *ptr, *dst, ch; ULONG ul = *pLen, ulStripped = 0; + char *ptr, *dst, ch; ptr = dst = str; while( ul ) @@ -889,6 +889,40 @@ char * hb_strRemEscSeq( char *str, ULONG *pLen ) case 'b': ch = '\b'; break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + ch -= '0'; + if( ul && *ptr >= '0' && *ptr <= '7' ) + { + ch = ( ch << 3 ) | ( *ptr++ - '0' ); + if( --ul && *ptr >= '0' && *ptr <= '7' ) + { + ch = ( ch << 3 ) | ( *ptr++ - '0' ); + --ul; + } + } + break; + case 'x': + ch = 0; + while( ul ) + { + if( *ptr >= '0' && *ptr <= '9' ) + ch = ch << 4 | ( *ptr++ - '0' ); + else if( *ptr >= 'A' && *ptr <= 'F' ) + ch = ch << 4 | ( *ptr++ - 'A' + 10 ); + else if( *ptr >= 'a' && *ptr <= 'f' ) + ch = ch << 4 | ( *ptr++ - 'a' + 10 ); + else + break; + --ul; + } + break; case '\\': default: break; diff --git a/harbour/source/common/hbver.c b/harbour/source/common/hbver.c index bb37d6cbb2..bf8c463dfb 100644 --- a/harbour/source/common/hbver.c +++ b/harbour/source/common/hbver.c @@ -516,8 +516,8 @@ char * hb_verHarbour( void ) pszVersion = ( char * ) hb_xgrab( 80 ); - sprintf( pszVersion, "Harbour Alpha build %d.%d Intl. (%s)", - HB_VER_MINOR, HB_VER_REVISION, HB_VER_LEX ); + sprintf( pszVersion, "Harbour Alpha build %d.%d Intl.", + HB_VER_MINOR, HB_VER_REVISION ); return pszVersion; } diff --git a/harbour/source/compiler/Makefile b/harbour/source/compiler/Makefile index 29b469bca1..64a8ff1a92 100644 --- a/harbour/source/compiler/Makefile +++ b/harbour/source/compiler/Makefile @@ -4,70 +4,53 @@ ROOT = ../../ -ifeq ($(HB_LEX),SIMPLEX) - -YACC_SOURCE=harbour.sly - -else +#LEX_FLAGS = -Phb_macro -C +#LEX_SOURCE=harbour.l +#LEX_HEADERS=\ +# hbsetup.h \ +# hberrors.h \ +# hbdefs.h #YACC_FLAGS = -p hb_comp YACC_SOURCE=harbour.y - -endif - YACC_HEADERS=\ - hbcomp.h \ - hbsetup.h \ - hbpcode.h \ - hbdefs.h \ - hberrors.h \ - hbpp.h - -ifeq ($(HB_LEX),SIMPLEX) - -C_EXTRA=hbslex.c - -else - -#LEX_SOURCE=harbour.l -C_EXTRA=complex.c - -LEX_HEADERS=\ - hbsetup.h \ - hberrors.h \ - hbdefs.h -endif + hbcomp.h \ + hbsetup.h \ + hbpcode.h \ + hbdefs.h \ + hberrors.h \ + hbpp.h C_SOURCES=\ - cmdcheck.c \ - genc.c \ - gencc.c \ - gencobj.c \ - genhrb.c \ - genjava.c \ - genobj32.c \ - gencli.c \ - hbcomp.c \ - hbfunchk.c \ - hbgenerr.c \ - hbpcode.c \ - hbfix.c \ - hbdead.c \ - hblbl.c \ - hbstripl.c \ - hbusage.c \ - hbident.c \ - ppcomp.c \ - expropta.c \ - exproptb.c \ - exproptc.c \ - $(C_EXTRA) + cmdcheck.c \ + genc.c \ + gencc.c \ + gencobj.c \ + genhrb.c \ + genjava.c \ + genobj32.c \ + gencli.c \ + hbcomp.c \ + hbfunchk.c \ + hbgenerr.c \ + hbpcode.c \ + hbfix.c \ + hbdead.c \ + hblbl.c \ + hbstripl.c \ + hbusage.c \ + hbident.c \ + ppcomp.c \ + expropta.c \ + exproptb.c \ + exproptc.c \ + complex.c \ C_MAIN=harbour.c LIBS=\ - pp \ - common \ + pp \ + common \ include $(TOP)$(ROOT)config/bin.cf diff --git a/harbour/source/compiler/cmdcheck.c b/harbour/source/compiler/cmdcheck.c index 2c7a570e5f..0048961708 100644 --- a/harbour/source/compiler/cmdcheck.c +++ b/harbour/source/compiler/cmdcheck.c @@ -102,369 +102,9 @@ static ULONG PackDateTime( void ) return HB_MKLONG( szString[3], szString[2], szString[1], szString[0] ); } -void hb_compChkCompilerSwitch( HB_COMP_DECL, int iArg, char *Args[] ) +static void hb_compChkEnvironVar( HB_COMP_DECL, char *szSwitch ) { - /* If iArg is passed check the command line options */ - if( iArg ) - { - int i; - - /* Check all switches in command line - They start with an OS_OPT_DELIMITER char - */ - for( i = 0; i < iArg; i++ ) - { - if( !HB_ISOPTSEP( Args[i][0] ) ) - continue; - - if( Args[i][0] == '-' ) - { - int j = 1; - char Switch[7]; - - Switch[0] = '-'; - - while( Args[i][j] ) - { - Switch[1] = Args[i][j]; - - if( Args[i][j + 1] == '-' ) - { - Switch[2] = '-'; - Switch[3] = '\0'; - - hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); - - j += 2; - continue; - } - else - { - switch( Switch[1] ) - { - case 'b': - case 'B': - if( Args[i][j + 1] && toupper( ( BYTE ) Args[i][j + 1] ) == 'U' && - Args[i][j + 2] && toupper( ( BYTE ) Args[i][j + 2] ) == 'I' && - Args[i][j + 3] && toupper( ( BYTE ) Args[i][j + 3] ) == 'L' && - Args[i][j + 4] && toupper( ( BYTE ) Args[i][j + 4] ) == 'D' ) - { - Switch[2] = 'U'; - Switch[3] = 'I'; - Switch[4] = 'L'; - Switch[5] = 'D'; - Switch[6] = '\0'; - - hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); - - j += 5; - continue; - } - else if( !Args[i][j + 1] ) - { - Switch[2] = '\0'; - hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); - j += 1; - continue; - } - break; - - case 'c': - case 'C': - if( Args[i][j + 1] && toupper( ( BYTE ) Args[i][j + 1] ) == 'R' && - Args[i][j + 2] && toupper( ( BYTE ) Args[i][j + 2] ) == 'E' && - Args[i][j + 3] && toupper( ( BYTE ) Args[i][j + 3] ) == 'D' ) - { - Switch[2] = 'R'; - Switch[3] = 'E'; - Switch[4] = 'D'; - Switch[5] = '\0'; - - j += 4; - - if( Args[i][j] && toupper( ( BYTE ) Args[i][j] ) == 'I' ) - { - j++; - if( Args[i][j] && toupper( ( BYTE ) Args[i][j] ) == 'T' ) - { - j++; - if( Args[i][j] && toupper( ( BYTE ) Args[i][j] ) == 'S' ) - { - j++; - } - } - } - - hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); - - continue; - } - else - { - Switch[2] = '\0'; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, ( char * ) Switch, NULL ); - } - - case 'd': - case 'D': - Args[i] += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); - - /* Accept rest as part of #define and continue with next Args[]. */ - j = strlen( Args[i] ); - continue; - - case 'e': - case 'E': - if( toupper( ( BYTE ) Args[i][j + 1] ) == 'S' && isdigit( ( BYTE ) Args[i][j + 2] ) ) - { - Switch[2] = 'S'; - Switch[3] = Args[i][j + 2]; - Switch[4] = '\0'; - - hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); - - j += 3; - continue; - } - else - { - Switch[2] = '\0'; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, ( char * ) Switch, NULL ); - } - - break; - - case 'g': - case 'G': - /* Required argument */ - Switch[2] = Args[i][j + 1]; - if( Switch[2] ) - { - if( isdigit( ( BYTE ) Args[i][j + 2] ) ) - { - /* Optional argument */ - Switch[3] = Args[i][j + 2]; - Switch[4] = '\0'; - j += 3; - } - else - { - /* No optional argument */ - Switch[3] = '\0'; - j += 2; - } - hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); - continue; - } - else - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, ( char * ) Switch, NULL ); - - case 'i': - case 'I': - Args[i] += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); - - /* Accept rest as IncludePath and continue with next Args[]. */ - j = strlen( Args[i] ); - continue; - - case 'k': - case 'K': - Args[i] += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); - - /* Accept rest as part of #define and continue with next Args[]. */ - j = strlen( Args[i] ); - continue; - - case 'n': - case 'N': - /* Required argument */ - if( Args[i][j + 1] ) - { - /* Optional argument */ - Switch[2] = Args[i][j + 1]; - Switch[3] = '\0'; - j += 2; - } - else - { - /* No optional argument */ - Switch[2] = '\0'; - j += 1; - } - hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); - continue; - - case 'o': - case 'O': - Args[i] += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); - - /* Accept rest as OutputPath and continue with next Args[]. */ - j = strlen( Args[i] ); - continue; - - case 'p': - case 'P': - if( Args[i][j + 1] ) - { - Args[i] += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); - - /* Accept rest as PPOPath and continue with next Args[]. */ - j += strlen( Args[i] ) - 1; - } - else - { - Switch[2] = '\0'; - hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); - j++; - } - continue; - - case 'q': - case 'Q': - if( Args[i][j + 1] && isdigit( ( BYTE ) Args[i][j + 1] ) ) - { - Switch[2] = Args[i][j + 1]; - Switch[3] = '\0'; - - hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); - - j += 2; - continue; - } - else - { - Switch[2] = '\0'; - hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); - } - - break; - - case 'r': - case 'R': - hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); - j = strlen( Args[i] ) - 1; - break; - - case 'u': - case 'U': - Args[i] += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); - - /* Accept rest as part of .CH Path or "undef:" and continue with next Args[]. */ - j = strlen( Args[i] ); - continue; - - case 'w': - case 'W': - if( Args[i][j + 1] && isdigit( ( BYTE ) Args[i][j + 1] ) ) - { - Switch[2] = Args[i][j + 1]; - Switch[3] = '\0'; - - hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); - - j += 2; - continue; - } - else - { - Switch[2] = '\0'; - hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); - } - - break; - - case 'x': - case 'X': - Args[i] += ( j - 1 ); - hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); - - /* Accept rest as INIT Symbol and continue with next Args[]. */ - j = strlen( Args[i] ); - continue; - - default: - Switch[2] = '\0'; - hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); - } - } - - j++; - } - - continue; - } - - CheckMultiSlashSwitch: - { - int j = 1; - - while( Args[i][j] && !HB_ISOPTSEP( Args[i][j] ) ) - j++; - - if( Args[i][j] && Args[i][j] == '/' ) - { - char cSep = Args[i][j]; - - Args[i][j] = 0; - - hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); - - Args[i] += j; - Args[i][0] = cSep; - - goto CheckMultiSlashSwitch; - } - else - { - hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); - } - } - } - } - else - /* Chech the environment variables */ - { - /* NOTE: CLIPPERCMD enviroment variable - is overriden if HARBOURCMD exists - */ - char *szStrEnv = hb_getenv( "HARBOURCMD" ); - - if( !szStrEnv || szStrEnv[0] == '\0' ) - { - if( szStrEnv ) - hb_xfree( ( void * ) szStrEnv ); - - szStrEnv = hb_getenv( "CLIPPERCMD" ); - } - - if( szStrEnv && szStrEnv[0] != '\0' ) - { - char *szSwitch = strtok( szStrEnv, " " ); - - /* Check the environment var - while it isn't empty. - */ - while( szSwitch != NULL ) - { - hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); - szSwitch = strtok( NULL, " " ); - } - } - - if( szStrEnv ) - hb_xfree( ( void * ) szStrEnv ); - } -} - -void hb_compChkEnvironVar( HB_COMP_DECL, char *szSwitch ) -{ - if( szSwitch ) + if( szSwitch && !HB_COMP_PARAM->fExit ) { char *s = szSwitch; @@ -515,8 +155,8 @@ void hb_compChkEnvironVar( HB_COMP_DECL, char *szSwitch ) } hb_xfree( szOption ); - } break; + } case 'c': case 'C': @@ -535,8 +175,8 @@ void hb_compChkEnvironVar( HB_COMP_DECL, char *szSwitch ) hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, szOption, NULL ); hb_xfree( szOption ); - } break; + } case 'd': case 'D': @@ -629,9 +269,8 @@ void hb_compChkEnvironVar( HB_COMP_DECL, char *szSwitch ) break; default: - printf( "\nUnsupported output language option\n" ); - hb_compMainExit( ); - exit( EXIT_FAILURE ); + hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_UNSUPPORTED_LANG, NULL, NULL ); + break; } break; @@ -656,7 +295,7 @@ void hb_compChkEnvironVar( HB_COMP_DECL, char *szSwitch ) { int i = 1; - while( s[i] ) + while( s[i] && !HB_COMP_PARAM->fExit ) { switch( s[i++] ) { @@ -707,8 +346,8 @@ void hb_compChkEnvironVar( HB_COMP_DECL, char *szSwitch ) break; } } - } break; + } case 'l': case 'L': @@ -746,9 +385,6 @@ void hb_compChkEnvironVar( HB_COMP_DECL, char *szSwitch ) */ else if( *( s + 1 ) == '-' ) HB_COMP_PARAM->fStartProc = TRUE; - /* - invalid command - */ else hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, s, NULL ); break; @@ -891,6 +527,359 @@ void hb_compChkEnvironVar( HB_COMP_DECL, char *szSwitch ) } } +void hb_compChkCompilerSwitch( HB_COMP_DECL, int iArg, char *Args[] ) +{ + /* If iArg is passed check the command line options */ + if( iArg ) + { + int i; + + /* Check all switches in command line + They start with an OS_OPT_DELIMITER char + */ + for( i = 0; i < iArg && !HB_COMP_PARAM->fExit; i++ ) + { + if( !HB_ISOPTSEP( Args[i][0] ) ) + continue; + + if( Args[i][0] == '-' ) + { + int j = 1; + char Switch[7]; + + Switch[0] = '-'; + + while( Args[i][j] && !HB_COMP_PARAM->fExit ) + { + Switch[1] = Args[i][j]; + + if( Args[i][j + 1] == '-' ) + { + Switch[2] = '-'; + Switch[3] = '\0'; + + hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); + + j += 2; + continue; + } + else + { + switch( Switch[1] ) + { + case 'b': + case 'B': + if( Args[i][j + 1] && toupper( ( BYTE ) Args[i][j + 1] ) == 'U' && + Args[i][j + 2] && toupper( ( BYTE ) Args[i][j + 2] ) == 'I' && + Args[i][j + 3] && toupper( ( BYTE ) Args[i][j + 3] ) == 'L' && + Args[i][j + 4] && toupper( ( BYTE ) Args[i][j + 4] ) == 'D' ) + { + Switch[2] = 'U'; + Switch[3] = 'I'; + Switch[4] = 'L'; + Switch[5] = 'D'; + Switch[6] = '\0'; + + hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); + + j += 5; + continue; + } + else if( !Args[i][j + 1] ) + { + Switch[2] = '\0'; + hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); + j += 1; + continue; + } + break; + + case 'c': + case 'C': + if( Args[i][j + 1] && toupper( ( BYTE ) Args[i][j + 1] ) == 'R' && + Args[i][j + 2] && toupper( ( BYTE ) Args[i][j + 2] ) == 'E' && + Args[i][j + 3] && toupper( ( BYTE ) Args[i][j + 3] ) == 'D' ) + { + Switch[2] = 'R'; + Switch[3] = 'E'; + Switch[4] = 'D'; + Switch[5] = '\0'; + + j += 4; + + if( Args[i][j] && toupper( ( BYTE ) Args[i][j] ) == 'I' ) + { + j++; + if( Args[i][j] && toupper( ( BYTE ) Args[i][j] ) == 'T' ) + { + j++; + if( Args[i][j] && toupper( ( BYTE ) Args[i][j] ) == 'S' ) + { + j++; + } + } + } + hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); + } + else + { + Switch[2] = '\0'; + hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, ( char * ) Switch, NULL ); + } + continue; + + case 'd': + case 'D': + Args[i] += ( j - 1 ); + hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); + + /* Accept rest as part of #define and continue with next Args[]. */ + j = strlen( Args[i] ); + continue; + + case 'e': + case 'E': + if( toupper( ( BYTE ) Args[i][j + 1] ) == 'S' && isdigit( ( BYTE ) Args[i][j + 2] ) ) + { + Switch[2] = 'S'; + Switch[3] = Args[i][j + 2]; + Switch[4] = '\0'; + + hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); + j += 3; + } + else + { + Switch[2] = '\0'; + hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, ( char * ) Switch, NULL ); + } + continue; + + case 'g': + case 'G': + /* Required argument */ + Switch[2] = Args[i][j + 1]; + if( Switch[2] ) + { + if( isdigit( ( BYTE ) Args[i][j + 2] ) ) + { + /* Optional argument */ + Switch[3] = Args[i][j + 2]; + Switch[4] = '\0'; + j += 3; + } + else + { + /* No optional argument */ + Switch[3] = '\0'; + j += 2; + } + hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); + } + else + hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BADOPTION, ( char * ) Switch, NULL ); + continue; + + case 'i': + case 'I': + Args[i] += ( j - 1 ); + hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); + + /* Accept rest as IncludePath and continue with next Args[]. */ + j = strlen( Args[i] ); + continue; + + case 'k': + case 'K': + Args[i] += ( j - 1 ); + hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); + + /* Accept rest as part of #define and continue with next Args[]. */ + j = strlen( Args[i] ); + continue; + + case 'n': + case 'N': + /* Required argument */ + if( Args[i][j + 1] ) + { + /* Optional argument */ + Switch[2] = Args[i][j + 1]; + Switch[3] = '\0'; + j += 2; + } + else + { + /* No optional argument */ + Switch[2] = '\0'; + j += 1; + } + hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); + continue; + + case 'o': + case 'O': + Args[i] += ( j - 1 ); + hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); + + /* Accept rest as OutputPath and continue with next Args[]. */ + j = strlen( Args[i] ); + continue; + + case 'p': + case 'P': + if( Args[i][j + 1] ) + { + Args[i] += ( j - 1 ); + hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); + + /* Accept rest as PPOPath and continue with next Args[]. */ + j += strlen( Args[i] ) - 1; + } + else + { + Switch[2] = '\0'; + hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); + j++; + } + continue; + + case 'q': + case 'Q': + if( Args[i][j + 1] && isdigit( ( BYTE ) Args[i][j + 1] ) ) + { + Switch[2] = Args[i][j + 1]; + Switch[3] = '\0'; + + hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); + + j += 2; + continue; + } + else + { + Switch[2] = '\0'; + hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); + } + + break; + + case 'r': + case 'R': + hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); + j = strlen( Args[i] ) - 1; + break; + + case 'u': + case 'U': + Args[i] += ( j - 1 ); + hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); + + /* Accept rest as part of .CH Path or "undef:" and continue with next Args[]. */ + j = strlen( Args[i] ); + continue; + + case 'w': + case 'W': + if( Args[i][j + 1] && isdigit( ( BYTE ) Args[i][j + 1] ) ) + { + Switch[2] = Args[i][j + 1]; + Switch[3] = '\0'; + + hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); + + j += 2; + continue; + } + else + { + Switch[2] = '\0'; + hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); + } + + break; + + case 'x': + case 'X': + Args[i] += ( j - 1 ); + hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); + + /* Accept rest as INIT Symbol and continue with next Args[]. */ + j = strlen( Args[i] ); + continue; + + default: + Switch[2] = '\0'; + hb_compChkEnvironVar( HB_COMP_PARAM, ( char * ) Switch ); + } + } + + j++; + } + continue; + } + + while( !HB_COMP_PARAM->fExit ) + { + int j = 1; + + while( Args[i][j] && !HB_ISOPTSEP( Args[i][j] ) ) + j++; + + if( Args[i][j] && Args[i][j] == '/' ) + { + char cSep = Args[i][j]; + + Args[i][j] = 0; + + hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); + + Args[i] += j; + Args[i][0] = cSep; + } + else + { + hb_compChkEnvironVar( HB_COMP_PARAM, Args[i] ); + break; + } + } + } + } + else + /* Chech the environment variables */ + { + /* NOTE: CLIPPERCMD enviroment variable + is overriden if HARBOURCMD exists + */ + char *szStrEnv = hb_getenv( "HARBOURCMD" ); + + if( !szStrEnv || szStrEnv[0] == '\0' ) + { + if( szStrEnv ) + hb_xfree( ( void * ) szStrEnv ); + + szStrEnv = hb_getenv( "CLIPPERCMD" ); + } + + if( szStrEnv && szStrEnv[0] != '\0' ) + { + char *szSwitch = strtok( szStrEnv, " " ); + + /* Check the environment var + while it isn't empty. + */ + while( szSwitch != NULL && !HB_COMP_PARAM->fExit ) + { + hb_compChkEnvironVar( HB_COMP_PARAM, szSwitch ); + szSwitch = strtok( NULL, " " ); + } + } + + if( szStrEnv ) + hb_xfree( ( void * ) szStrEnv ); + } +} + void hb_compChkPaths( HB_COMP_DECL ) { char *szInclude = hb_getenv( "INCLUDE" ); diff --git a/harbour/source/compiler/complex.c b/harbour/source/compiler/complex.c index be229cb6ca..df71473b01 100644 --- a/harbour/source/compiler/complex.c +++ b/harbour/source/compiler/complex.c @@ -270,7 +270,7 @@ int yylex( YYSTYPE *yylval_ptr, HB_COMP_DECL ) PHB_COMP_LEX pLex = ( PHB_COMP_LEX ) HB_COMP_PARAM->pLex; PHB_PP_TOKEN pToken = hb_pp_tokenGet( pLex->pPP ); - if( !pToken ) + if( !pToken || HB_COMP_PARAM->fExit ) return 0; pLex->lasttok = pToken->value; diff --git a/harbour/source/compiler/gencli.c b/harbour/source/compiler/gencli.c index 4e3f7746af..aeb9c3b9fb 100644 --- a/harbour/source/compiler/gencli.c +++ b/harbour/source/compiler/gencli.c @@ -58,7 +58,7 @@ typedef HB_GENC_FUNC_ * HB_GENC_FUNC_PTR; void hb_compGenILCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the IL output */ { - char szFileName[ _POSIX_PATH_MAX ]; + char szFileName[ _POSIX_PATH_MAX ], * szVer; PFUNCTION pFunc = HB_COMP_PARAM->functions.pFirst; PCOMSYMBOL pSym = HB_COMP_PARAM->symbols.pFirst; PCOMDECLARED pDeclared; @@ -74,7 +74,6 @@ void hb_compGenILCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the IL HB_SYMBOL_UNUSED( pFunc ); HB_SYMBOL_UNUSED( pSym ); - HB_SYMBOL_UNUSED( pInline ); if( ! pFileName->szExtension ) pFileName->szExtension = ".il"; @@ -93,8 +92,9 @@ void hb_compGenILCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the IL fflush( stdout ); } - fprintf( yyc, "// Harbour Compiler, Alpha build %d.%d (%s)\n", - HB_VER_MINOR, HB_VER_REVISION, HB_VER_LEX ); + szVer = hb_verHarbour(); + fprintf( yyc, "// %s\n", szVer ); + hb_xfree( szVer ); fprintf( yyc, "// Generated .NET IL source code\n\n" ); if( HB_COMP_PARAM->iFunctionCnt ) @@ -189,19 +189,6 @@ void hb_compGenILCode( HB_COMP_DECL, PHB_FNAME pFileName ) /* generates the IL pFunc = HB_COMP_PARAM->funcalls.pFirst; } - pInline = HB_COMP_PARAM->inlines.pFirst; - while( pInline ) - { - HB_COMP_PARAM->inlines.pFirst = pInline->pNext; - if( pInline->pCode ) - { - hb_xfree( ( void * ) pInline->pCode ); - } - hb_xfree( ( void * ) pInline->szFileName ); - hb_xfree( ( void * ) pInline ); /* NOTE: szName will be released by hb_compSymbolKill() */ - pInline = HB_COMP_PARAM->inlines.pFirst; - } - if ( HB_COMP_PARAM->iWarnings >= 3 ) { pDeclared = HB_COMP_PARAM->pReleaseDeclared->pNext; @@ -1329,7 +1316,6 @@ static HB_GENC_FUNC( hb_p_pushlonglong ) HB_SYMBOL_UNUSED( lPCodePos ); fprintf( cargo->yyc, "LONG LONG unsupported\n" ); - exit(1); return 9; } diff --git a/harbour/source/compiler/genjava.c b/harbour/source/compiler/genjava.c index c4332070c6..0eff337604 100644 --- a/harbour/source/compiler/genjava.c +++ b/harbour/source/compiler/genjava.c @@ -41,7 +41,7 @@ static int s_nChar = 0; void hb_compGenJava( HB_COMP_DECL, PHB_FNAME pFileName ) { - char szFileName[ _POSIX_PATH_MAX ]; + char szFileName[ _POSIX_PATH_MAX ], * szVer; PFUNCTION pFunc /*= HB_COMP_PARAM->functions.pFirst */; PCOMSYMBOL pSym = HB_COMP_PARAM->symbols.pFirst; ULONG lPCodePos; @@ -67,9 +67,9 @@ void hb_compGenJava( HB_COMP_DECL, PHB_FNAME pFileName ) s_nChar = 0; - fprintf( s_yyc, "/*\n * Harbour Compiler, Alpha build %d.%d (%s)\n", - HB_VER_MINOR, HB_VER_REVISION, HB_VER_LEX ); - fprintf( s_yyc, " * Generated JAVA source code\n */\n\n" ); + szVer = hb_verHarbour(); + fprintf( s_yyc, "/*\n * %s\n * Generated JAVA source code\n */\n\n", szVer ); + hb_xfree( szVer ); fprintf( s_yyc, "public class %s\n", pFileName->szName ); fprintf( s_yyc, "{\n" ); diff --git a/harbour/source/compiler/genobj32.c b/harbour/source/compiler/genobj32.c index d4d91cc403..06a2929ef4 100644 --- a/harbour/source/compiler/genobj32.c +++ b/harbour/source/compiler/genobj32.c @@ -66,7 +66,7 @@ void hb_compGenObj32( HB_COMP_DECL, PHB_FNAME pFileName ) { char szFileName[ _POSIX_PATH_MAX ]; FILE * hObjFile; /* file handle for OBJ output */ - char compiler[ 70 ]; + char compiler[ 70 ], * szVer; if( ! pFileName->szExtension ) pFileName->szExtension = ".obj"; @@ -84,8 +84,9 @@ void hb_compGenObj32( HB_COMP_DECL, PHB_FNAME pFileName ) fflush( stdout ); } - sprintf( compiler, "Harbour Compiler Alpha build %d.%d (%s)", - HB_VER_MINOR, HB_VER_REVISION, HB_VER_LEX ); + szVer = hb_verHarbour(); + sprintf( compiler, "%s\n", szVer ); + hb_xfree( szVer ); CompiledFileName( hObjFile, szFileName ); CompilerVersion( hObjFile, compiler ); diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 007b32fe1f..72d1709a3f 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -91,20 +91,45 @@ static void hb_compDeclaredInit( HB_COMP_DECL ); static int hb_compAutoOpen( HB_COMP_DECL, char * szPrg, BOOL * bSkipGen, BOOL bSingleFile ); /* global variables */ -HB_COMP_PTR hb_comp_data; - FILE * hb_comp_errFile = NULL; + extern int yyparse( HB_COMP_DECL ); /* main yacc parsing function */ +HB_COMP_PTR hb_comp_data = NULL; /* ************************************************************************* */ +static void hb_compMainExit( HB_COMP_DECL ) +{ + hb_compCompileEnd( HB_COMP_PARAM ); + hb_compParserStop( HB_COMP_PARAM ); + hb_compIdentifierClose( HB_COMP_PARAM ); + + if( HB_COMP_PARAM->pOutPath ) + hb_xfree( HB_COMP_PARAM->pOutPath ); + + if( HB_COMP_PARAM->pPpoPath ) + hb_xfree( HB_COMP_PARAM->pPpoPath ); + + while( HB_COMP_PARAM->autoopen ) + { + PAUTOOPEN pAutoOpen = HB_COMP_PARAM->autoopen; + + HB_COMP_PARAM->autoopen = HB_COMP_PARAM->autoopen->pNext; + hb_xfree( pAutoOpen ); + } + + hb_comp_free( HB_COMP_PARAM ); + + hb_xexit(); +} + int main( int argc, char * argv[] ) { HB_COMP_DECL; int iStatus = EXIT_SUCCESS; + BOOL bAnyFiles = FALSE; int i; - BOOL bAnyFiles; #if defined( HOST_OS_UNIX_COMPATIBLE ) hb_comp_errFile = stderr; @@ -114,7 +139,8 @@ int main( int argc, char * argv[] ) HB_TRACE(HB_TR_DEBUG, ("main()")); - hb_comp_data = HB_COMP_PARAM = hb_comp_new(); + HB_COMP_PARAM = hb_comp_new(); + hb_comp_data = HB_COMP_PARAM; HB_COMP_PARAM->pOutPath = NULL; @@ -124,41 +150,40 @@ int main( int argc, char * argv[] ) /* Then check command line arguments This will override duplicated environment settings */ hb_compChkCompilerSwitch( HB_COMP_PARAM, argc, argv ); - - if( HB_COMP_PARAM->fLogo ) - hb_compPrintLogo(); - - if( HB_COMP_PARAM->fBuildInfo ) + if( !HB_COMP_PARAM->fExit ) { - printf( "\n" ); - hb_verBuildInfo(); - return iStatus; + if( HB_COMP_PARAM->fLogo ) + hb_compPrintLogo(); + + if( HB_COMP_PARAM->fBuildInfo ) + { + printf( "\n" ); + hb_verBuildInfo(); + return iStatus; + } + + if( HB_COMP_PARAM->fCredits ) + { + hb_compPrintCredits(); + return iStatus; + } + + /* Set Search Path */ + hb_compChkPaths( HB_COMP_PARAM ); + + /* Set standard rules */ + hb_compInitPP( HB_COMP_PARAM, argc, argv ); + + /* Prepare the table of identifiers */ + hb_compIdentifierOpen( HB_COMP_PARAM ); + + /* Load standard Declarations. */ + if( HB_COMP_PARAM->iWarnings >= 3 ) + hb_compDeclaredInit( HB_COMP_PARAM ); } - if( HB_COMP_PARAM->fCredits ) - { - hb_compPrintCredits(); - return iStatus; - } - - /* Set Search Path */ - hb_compChkPaths( HB_COMP_PARAM ); - - /* Set standard rules */ - hb_compInitPP( HB_COMP_PARAM, argc, argv ); - - /* Prepare the table of identifiers */ - hb_compIdentifierOpen( HB_COMP_PARAM ); - - /* Load standard Declarations. */ - if( HB_COMP_PARAM->iWarnings >= 3 ) - hb_compDeclaredInit( HB_COMP_PARAM ); - /* Process all files passed via the command line. */ - - bAnyFiles = FALSE; - - for( i = 1; i < argc; i++ ) + for( i = 1; i < argc && !HB_COMP_PARAM->fExit; i++ ) { HB_TRACE(HB_TR_DEBUG, ("main LOOP(%i,%s)", i, argv[i])); if( ! HB_ISOPTSEP( argv[ i ][ 0 ] ) ) @@ -184,51 +209,12 @@ int main( int argc, char * argv[] ) if( HB_COMP_PARAM->iErrorCount > 0 ) iStatus = EXIT_FAILURE; - hb_compMainExit(); + hb_compMainExit( HB_COMP_PARAM ); + hb_comp_data = NULL; return iStatus; } -void hb_compMainExit( void ) -{ - HB_COMP_DECL = hb_comp_data; - static BOOL inProcess = FALSE; - - if( inProcess || !HB_COMP_PARAM ) - return; - - inProcess = TRUE; - - hb_compCompileEnd( HB_COMP_PARAM ); - hb_compIdentifierClose( HB_COMP_PARAM ); - hb_compParserStop( HB_COMP_PARAM ); - - if( HB_COMP_PARAM->pOutPath ) - { - hb_xfree( HB_COMP_PARAM->pOutPath ); - HB_COMP_PARAM->pOutPath = NULL; - } - - if( HB_COMP_PARAM->pPpoPath ) - { - hb_xfree( HB_COMP_PARAM->pPpoPath ); - HB_COMP_PARAM->pPpoPath = NULL; - } - - while( HB_COMP_PARAM->autoopen ) - { - PAUTOOPEN pAutoOpen = HB_COMP_PARAM->autoopen; - - HB_COMP_PARAM->autoopen = HB_COMP_PARAM->autoopen->pNext; - hb_xfree( pAutoOpen->szName ); - hb_xfree( pAutoOpen ); - } - - hb_comp_free( HB_COMP_PARAM ); - hb_comp_data = NULL; - hb_xexit(); -} - static int hb_compProcessRSPFile( HB_COMP_DECL, char * szRspName ) { char szFile[ _POSIX_PATH_MAX + 1 ]; @@ -255,7 +241,7 @@ static int hb_compProcessRSPFile( HB_COMP_DECL, char * szRspName ) { int i = 0, ch; BOOL bAutoOpen = HB_COMP_PARAM->fAutoOpen; - + HB_COMP_PARAM->fAutoOpen = TRUE; do @@ -285,7 +271,8 @@ static int hb_compProcessRSPFile( HB_COMP_DECL, char * szRspName ) szFile[ i ] = '\0'; if( i > 0 ) - hb_compAutoOpenAdd( HB_COMP_PARAM, szFile ); + hb_compAutoOpenAdd( HB_COMP_PARAM, + hb_compIdentifierNew( HB_COMP_PARAM, szFile, TRUE ) ); i = 0; while( ch != EOF && ch != '\n' ) ch = fgetc( inFile ); @@ -652,8 +639,8 @@ void hb_compExternAdd( HB_COMP_DECL, char * szExternName ) /* defines a new exte if( strcmp( "_GET_", szExternName ) == 0 ) { /* special function to implement @ GET statement */ - hb_compExternAdd( HB_COMP_PARAM, hb_strdup("__GETA") ); - pExtern->szName = hb_strdup("__GET"); + hb_compExternAdd( HB_COMP_PARAM, "__GETA" ); + pExtern->szName = "__GET"; } else { @@ -1271,7 +1258,7 @@ PCOMDECLARED hb_compMethodFind( PCOMCLASS pClass, char * szMethodName ) return NULL; } -void hb_compDeclaredInit( HB_COMP_DECL ) +static void hb_compDeclaredInit( HB_COMP_DECL ) { #define _DECL static COMDECLARED @@ -1821,7 +1808,8 @@ static PINLINE hb_compInlineNew( HB_COMP_DECL, char * szName, int iLine ) pInline->pCode = NULL; pInline->lPCodeSize = 0; pInline->pNext = NULL; - pInline->szFileName = hb_strdup( hb_pp_fileName( HB_COMP_PARAM->pLex->pPP ) ); + pInline->szFileName = hb_compIdentifierNew( HB_COMP_PARAM, + hb_pp_fileName( HB_COMP_PARAM->pLex->pPP ), TRUE ); pInline->iLine = iLine; return pInline; @@ -2016,7 +2004,6 @@ PFUNCTION hb_compFunctionKill( HB_COMP_DECL, PFUNCTION pFunc ) { pVar = pFunc->pLocals; pFunc->pLocals = pVar->pNext; - hb_xfree( ( void * ) pVar ); } @@ -2024,7 +2011,6 @@ PFUNCTION hb_compFunctionKill( HB_COMP_DECL, PFUNCTION pFunc ) { pVar = pFunc->pStatics; pFunc->pStatics = pVar->pNext; - hb_xfree( ( void * ) pVar ); } @@ -2032,7 +2018,6 @@ PFUNCTION hb_compFunctionKill( HB_COMP_DECL, PFUNCTION pFunc ) { pVar = pFunc->pFields; pFunc->pFields = pVar->pNext; - hb_xfree( ( void * ) pVar ); } @@ -2040,7 +2025,6 @@ PFUNCTION hb_compFunctionKill( HB_COMP_DECL, PFUNCTION pFunc ) { pVar = pFunc->pMemvars; pFunc->pMemvars = pVar->pNext; - hb_xfree( ( void * ) pVar ); } @@ -2048,7 +2032,6 @@ PFUNCTION hb_compFunctionKill( HB_COMP_DECL, PFUNCTION pFunc ) { pVar = pFunc->pPrivates; pFunc->pPrivates = pVar->pNext; - hb_xfree( ( void * ) pVar ); } @@ -2068,7 +2051,6 @@ PFUNCTION hb_compFunctionKill( HB_COMP_DECL, PFUNCTION pFunc ) hb_xfree( ( void * ) pFunc->pJumps ); hb_xfree( ( void * ) pFunc->pCode ); -/* hb_xfree( ( void * ) pFunc->szName ); The name will be released in hb_compSymbolKill() */ hb_xfree( ( void * ) pFunc ); hb_compLoopKill( HB_COMP_PARAM ); @@ -2572,15 +2554,10 @@ static void hb_compPrepareOptimize( HB_COMP_DECL ) ULONG hb_compGenJump( LONG lOffset, HB_COMP_DECL ) { - if( HB_LIM_INT24( lOffset ) ) - { - hb_compGenPCode4( HB_P_JUMPFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BYTE ) ( ( lOffset >> 16 ) & 0xFF ), HB_COMP_PARAM ); - } - else - { + if( !HB_LIM_INT24( lOffset ) ) hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_JUMP_TOO_LONG, NULL, NULL ); - } + hb_compGenPCode4( HB_P_JUMPFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BYTE ) ( ( lOffset >> 16 ) & 0xFF ), HB_COMP_PARAM ); hb_compPrepareOptimize( HB_COMP_PARAM ); return HB_COMP_PARAM->functions.pLast->lPCodePos - 3; @@ -2588,15 +2565,10 @@ ULONG hb_compGenJump( LONG lOffset, HB_COMP_DECL ) ULONG hb_compGenJumpFalse( LONG lOffset, HB_COMP_DECL ) { - if( HB_LIM_INT24( lOffset ) ) - { - hb_compGenPCode4( HB_P_JUMPFALSEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BYTE ) ( ( lOffset >> 16 ) & 0xFF ), HB_COMP_PARAM ); - } - else - { + if( !HB_LIM_INT24( lOffset ) ) hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_JUMP_TOO_LONG, NULL, NULL ); - } + hb_compGenPCode4( HB_P_JUMPFALSEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BYTE ) ( ( lOffset >> 16 ) & 0xFF ), HB_COMP_PARAM ); hb_compPrepareOptimize( HB_COMP_PARAM ); return HB_COMP_PARAM->functions.pLast->lPCodePos - 3; @@ -2604,15 +2576,10 @@ ULONG hb_compGenJumpFalse( LONG lOffset, HB_COMP_DECL ) ULONG hb_compGenJumpTrue( LONG lOffset, HB_COMP_DECL ) { - if( HB_LIM_INT24( lOffset ) ) - { - hb_compGenPCode4( HB_P_JUMPTRUEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BYTE ) ( ( lOffset >> 16 ) & 0xFF ), HB_COMP_PARAM ); - } - else - { + if( !HB_LIM_INT24( lOffset ) ) hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_JUMP_TOO_LONG, NULL, NULL ); - } + hb_compGenPCode4( HB_P_JUMPTRUEFAR, HB_LOBYTE( lOffset ), HB_HIBYTE( lOffset ), ( BYTE ) ( ( lOffset >> 16 ) & 0xFF ), HB_COMP_PARAM ); hb_compPrepareOptimize( HB_COMP_PARAM ); return HB_COMP_PARAM->functions.pLast->lPCodePos - 3; @@ -2641,7 +2608,8 @@ void hb_compLinePush( HB_COMP_DECL ) /* generates the pcode with the currently c if( HB_COMP_PARAM->fLineNumbers && ! HB_COMP_PARAM->fDontGenLineNum ) { int iLine = hb_pp_line( HB_COMP_PARAM->pLex->pPP ); - if( ( ( HB_COMP_PARAM->functions.pLast->lPCodePos - HB_COMP_PARAM->lastLinePos ) > 3 ) || HB_COMP_PARAM->fDebugInfo ) + if( HB_COMP_PARAM->functions.pLast->lPCodePos - HB_COMP_PARAM->lastLinePos > 3 || + HB_COMP_PARAM->fDebugInfo ) { HB_COMP_PARAM->lastLinePos = HB_COMP_PARAM->functions.pLast->lPCodePos; hb_compGenPCode3( HB_P_LINE, HB_LOBYTE( iLine ), HB_HIBYTE( iLine ), HB_COMP_PARAM ); @@ -3749,7 +3717,7 @@ static void hb_compOptimizeJumps( HB_COMP_DECL ) hb_compCodeTraceMarkDead( HB_COMP_PARAM, HB_COMP_PARAM->functions.pLast ); - for( iPass = 0; iPass < 3; ++iPass ) + for( iPass = 0; iPass < 3 && !HB_COMP_PARAM->fExit; ++iPass ) { LONG lOffset; @@ -4631,7 +4599,7 @@ static int hb_compCompile( HB_COMP_DECL, char * szPrg, BOOL bSingleFile ) /* Open refernced modules (using DO ... WITh statement * or from @.clp command line option */ - while( HB_COMP_PARAM->autoopen ) + while( HB_COMP_PARAM->autoopen && !HB_COMP_PARAM->fExit ) { PAUTOOPEN pAutoOpen = HB_COMP_PARAM->autoopen; @@ -4639,8 +4607,6 @@ static int hb_compCompile( HB_COMP_DECL, char * szPrg, BOOL bSingleFile ) hb_compAutoOpen( HB_COMP_PARAM, pAutoOpen->szName, &bSkipGen, bSingleFile ); HB_COMP_PARAM->autoopen = HB_COMP_PARAM->autoopen->pNext; - - hb_xfree( pAutoOpen->szName ); hb_xfree( pAutoOpen ); } @@ -4698,7 +4664,8 @@ static int hb_compCompile( HB_COMP_DECL, char * szPrg, BOOL bSingleFile ) } } - if( ! HB_COMP_PARAM->fSyntaxCheckOnly && ! bSkipGen && ( HB_COMP_PARAM->iErrorCount == 0 ) ) + if( ! HB_COMP_PARAM->fSyntaxCheckOnly && ! bSkipGen && + HB_COMP_PARAM->iErrorCount == 0 ) { char * szFirstFunction = NULL; PFUNCTION *pFunPtr; @@ -4715,7 +4682,7 @@ static int hb_compCompile( HB_COMP_DECL, char * szPrg, BOOL bSingleFile ) HB_COMP_PARAM->iFunctionCnt--; } - while( *pFunPtr ) + while( *pFunPtr && !HB_COMP_PARAM->fExit ) { /* remove function frames with no names */ if( ! HB_COMP_PARAM->fStartProc && ! (*pFunPtr)->szName[0] ) @@ -4812,16 +4779,12 @@ static void hb_compCompileEnd( HB_COMP_DECL ) HB_COMP_PARAM->functions.pFirst = NULL; } - if( HB_COMP_PARAM->funcalls.pFirst ) + while( HB_COMP_PARAM->funcalls.pFirst ) { PFUNCTION pFunc = HB_COMP_PARAM->funcalls.pFirst; - while( pFunc ) - { - HB_COMP_PARAM->funcalls.pFirst = pFunc->pNext; - hb_xfree( ( void * ) pFunc ); /* NOTE: szName will be released by hb_compSymbolKill() */ - pFunc = HB_COMP_PARAM->funcalls.pFirst; - } - HB_COMP_PARAM->funcalls.pFirst = NULL; + + HB_COMP_PARAM->funcalls.pFirst = pFunc->pNext; + hb_xfree( ( void * ) pFunc ); } while( HB_COMP_PARAM->externs ) @@ -4832,68 +4795,45 @@ static void hb_compCompileEnd( HB_COMP_DECL ) hb_xfree( pExtern ); } - if( HB_COMP_PARAM->inlines.pFirst ) + while( HB_COMP_PARAM->inlines.pFirst ) { PINLINE pInline = HB_COMP_PARAM->inlines.pFirst; - while( pInline ) - { - HB_COMP_PARAM->inlines.pFirst = pInline->pNext; - if( pInline->pCode ) - { - hb_xfree( ( void * ) pInline->pCode ); - } - hb_xfree( ( void * ) pInline->szFileName ); - hb_xfree( ( void * ) pInline ); /* NOTE: szName will be released by hb_compSymbolKill() */ - pInline = HB_COMP_PARAM->inlines.pFirst; - } - HB_COMP_PARAM->inlines.pFirst = NULL; + HB_COMP_PARAM->inlines.pFirst = pInline->pNext; + if( pInline->pCode ) + hb_xfree( pInline->pCode ); + hb_xfree( ( void * ) pInline ); } - if( HB_COMP_PARAM->pReleaseDeclared ) + while( HB_COMP_PARAM->pReleaseDeclared ) { PCOMDECLARED pDeclared = HB_COMP_PARAM->pReleaseDeclared; - - while( pDeclared ) - { - HB_COMP_PARAM->pFirstDeclared = pDeclared->pNext; - hb_xfree( ( void * ) pDeclared ); - pDeclared = HB_COMP_PARAM->pFirstDeclared; - } - HB_COMP_PARAM->pFirstDeclared = NULL; + HB_COMP_PARAM->pReleaseDeclared = pDeclared->pNext; + hb_xfree( ( void * ) pDeclared ); } + HB_COMP_PARAM->pFirstDeclared = HB_COMP_PARAM->pLastDeclared = NULL; - if( HB_COMP_PARAM->pReleaseClass ) + while( HB_COMP_PARAM->pReleaseClass ) { PCOMCLASS pClass = HB_COMP_PARAM->pReleaseClass; - PCOMDECLARED pDeclared; - - while( pClass ) + HB_COMP_PARAM->pReleaseClass = pClass->pNext; + while( pClass->pMethod ) { - HB_COMP_PARAM->pFirstClass = pClass->pNext; - pDeclared = pClass->pMethod; - while ( pDeclared ) - { - HB_COMP_PARAM->pFirstDeclared = pDeclared->pNext; - hb_xfree( ( void * ) pDeclared ); - pDeclared = HB_COMP_PARAM->pFirstDeclared; - } - - hb_xfree( ( void * ) pClass ); - pClass = HB_COMP_PARAM->pFirstClass; + PCOMDECLARED pDeclared = pClass->pMethod; + pClass->pMethod = pDeclared->pNext; + hb_xfree( ( void * ) pDeclared ); } - HB_COMP_PARAM->pReleaseClass = NULL; + hb_xfree( ( void * ) pClass ); } + HB_COMP_PARAM->pFirstClass = HB_COMP_PARAM->pLastClass = NULL; if( HB_COMP_PARAM->symbols.pFirst ) { PCOMSYMBOL pSym = HB_COMP_PARAM->symbols.pFirst; while( pSym ) pSym = hb_compSymbolKill( pSym ); - HB_COMP_PARAM->symbols.pFirst = NULL; } - } static BOOL hb_compAutoOpenFind( HB_COMP_DECL, char * szName ) @@ -4928,7 +4868,7 @@ void hb_compAutoOpenAdd( HB_COMP_DECL, char * szName ) { PAUTOOPEN pAutoOpen = ( PAUTOOPEN ) hb_xgrab( sizeof( AUTOOPEN ) ), pLast; - pAutoOpen->szName = hb_strdup( szName ); + pAutoOpen->szName = szName; pAutoOpen->pNext = NULL; if( HB_COMP_PARAM->autoopen == NULL ) @@ -4973,7 +4913,7 @@ static int hb_compAutoOpen( HB_COMP_DECL, char * szPrg, BOOL * pbSkipGen, BOOL b iStatus = EXIT_FAILURE; } - if( iStatus == EXIT_SUCCESS ) + if( iStatus == EXIT_SUCCESS && !HB_COMP_PARAM->fExit ) { /* Minimal Init. */ if( hb_pp_inFile( HB_COMP_PARAM->pLex->pPP, szFileName, FALSE, NULL, FALSE ) ) @@ -4992,6 +4932,7 @@ static int hb_compAutoOpen( HB_COMP_DECL, char * szPrg, BOOL * pbSkipGen, BOOL b else if( ! bSingleFile ) hb_compFunctionAdd( HB_COMP_PARAM, "", HB_FS_PUBLIC, FUN_PROCEDURE ); + if( !HB_COMP_PARAM->fExit ) { int i = HB_COMP_PARAM->iExitLevel ; BOOL b = HB_COMP_PARAM->fAnyWarning; @@ -5037,5 +4978,5 @@ static int hb_compAutoOpen( HB_COMP_DECL, char * szPrg, BOOL * pbSkipGen, BOOL b hb_xfree( HB_COMP_PARAM->pFileName ); HB_COMP_PARAM->pFileName = pMainFileName; - return iStatus; + return HB_COMP_PARAM->fExit ? EXIT_FAILURE : iStatus; } diff --git a/harbour/source/compiler/harbour.simple b/harbour/source/compiler/harbour.simple deleted file mode 100644 index 2c9924515c..0000000000 --- a/harbour/source/compiler/harbour.simple +++ /dev/null @@ -1,761 +0,0 @@ -/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ -#line 3 "/usr/share/bison.simple" -/* This file comes from bison-1.28. */ - -/* Skeleton output parser for bison, - Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. - - 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 program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. */ - -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ - -/* This is the parser code that is written into each bison parser - when the %semantic_parser declaration is not specified in the grammar. - It was written by Richard Stallman by simplifying the hairy parser - used when %semantic_parser is specified. */ - -#ifndef YYSTACK_USE_ALLOCA -#ifdef alloca -#define YYSTACK_USE_ALLOCA -#else /* alloca not defined */ -#ifdef __GNUC__ -#define YYSTACK_USE_ALLOCA -#define alloca __builtin_alloca -#else /* not GNU C. */ -#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) -#define YYSTACK_USE_ALLOCA -#include -#else /* not sparc */ -/* We think this test detects Watcom and Microsoft C. */ -/* This used to test MSDOS, but that is a bad idea - since that symbol is in the user namespace. */ -#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) -#if 0 /* No need for malloc.h, which pollutes the namespace; - instead, just don't use alloca. */ -#include -#endif -#else /* not MSDOS, or __TURBOC__ */ -#if defined(_AIX) -/* I don't know what this was needed for, but it pollutes the namespace. - So I turned it off. rms, 2 May 1997. */ -/* #include */ - #pragma alloca -#define YYSTACK_USE_ALLOCA -#else /* not MSDOS, or __TURBOC__, or _AIX */ -#if 0 -#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, - and on HPUX 10. Eventually we can turn this on. */ -#define YYSTACK_USE_ALLOCA -#define alloca __builtin_alloca -#endif /* __hpux */ -#endif -#endif /* not _AIX */ -#endif /* not MSDOS, or __TURBOC__ */ -#endif /* not sparc */ -#endif /* not GNU C */ -#endif /* alloca not defined */ -#endif /* YYSTACK_USE_ALLOCA not defined */ - -#ifdef YYSTACK_USE_ALLOCA -#define YYSTACK_ALLOC alloca -#else -#define YYSTACK_ALLOC malloc -#endif - -/* Note: there must be only one dollar sign in this file. - It is replaced by the list of actions, each action - as one case of the switch. */ - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY -2 -#define YYEOF 0 -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrlab1 -/* Like YYERROR except do call yyerror. - This remains here temporarily to ease the - transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. */ -#define YYFAIL goto yyerrlab -#define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(token, value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { yychar = (token), yylval = (value); \ - yychar1 = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ - goto yybackup; \ - } \ - else \ - { yyerror ("syntax error: cannot back up"); YYERROR; } \ -while (0) - -#define YYTERROR 1 -#define YYERRCODE 256 - -#ifndef YYPURE -#define YYLEX yylex() -#endif - -#ifdef YYPURE -#ifdef YYLSP_NEEDED -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval, &yylloc) -#endif -#else /* not YYLSP_NEEDED */ -#ifdef YYLEX_PARAM -#define YYLEX yylex(&yylval, YYLEX_PARAM) -#else -#define YYLEX yylex(&yylval) -#endif -#endif /* not YYLSP_NEEDED */ -#endif - -/* If nonreentrant, generate the variables here */ - -#ifndef YYPURE - -int yychar; /* the lookahead symbol */ -YYSTYPE yylval; /* the semantic value of the */ - /* lookahead symbol */ - -#ifdef YYLSP_NEEDED -YYLTYPE yylloc; /* location data for the lookahead */ - /* symbol */ -#endif - -int yynerrs; /* number of parse errors so far */ -#endif /* not YYPURE */ - -#if YYDEBUG != 0 -int yydebug; /* nonzero means print parse trace */ -/* Since this is uninitialized, it does not stop multiple parsers - from coexisting. */ -#endif - -/* YYINITDEPTH indicates the initial size of the parser's stacks */ - -#ifndef YYINITDEPTH -#define YYINITDEPTH 200 -#endif - -/* YYMAXDEPTH is the maximum size the stacks can grow to - (effective only if the built-in stack extension method is used). */ - -#if YYMAXDEPTH == 0 -#undef YYMAXDEPTH -#endif - -#ifndef YYMAXDEPTH -#define YYMAXDEPTH 10000 -#endif - -/* Define __yy_memcpy. Note that the size argument - should be passed with type unsigned int, because that is what the non-GCC - definitions require. With GCC, __builtin_memcpy takes an arg - of type size_t, but it can handle unsigned int. */ - -#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ -#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) -#else /* not GNU C or C++ */ -#ifndef __cplusplus - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (to, from, count) - char *to; - char *from; - unsigned int count; -{ - register char *f = from; - register char *t = to; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#else /* __cplusplus */ - -/* This is the most reliable way to avoid incompatibilities - in available built-in functions on various systems. */ -static void -__yy_memcpy (char *to, char *from, unsigned int count) -{ - register char *t = to; - register char *f = from; - register int i = count; - - while (i-- > 0) - *t++ = *f++; -} - -#endif -#endif - -#line 217 "/usr/share/bison.simple" - -/* The user can define YYPARSE_PARAM as the name of an argument to be passed - into yyparse. The argument should have type void *. - It should actually point to an object. - Grammar actions can access the variable by casting it - to the proper pointer type. */ - -#ifdef YYPARSE_PARAM -#ifdef __cplusplus -#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM -#define YYPARSE_PARAM_DECL -#else /* not __cplusplus */ -#define YYPARSE_PARAM_ARG YYPARSE_PARAM -#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; -#endif /* not __cplusplus */ -#else /* not YYPARSE_PARAM */ -#define YYPARSE_PARAM_ARG -#define YYPARSE_PARAM_DECL -#endif /* not YYPARSE_PARAM */ - -/* Prevent warning if -Wstrict-prototypes. */ -#ifdef __GNUC__ -#ifdef YYPARSE_PARAM -int yyparse (void *); -#else -int yyparse (void); -#endif -#endif - -int -yyparse(YYPARSE_PARAM_ARG) - YYPARSE_PARAM_DECL -{ - register int yystate; - register int yyn; - register short *yyssp; - register YYSTYPE *yyvsp; - int yyerrstatus; /* number of tokens to shift before error messages enabled */ - int yychar1 = 0; /* lookahead token as an internal (translated) token number */ - - short yyssa[YYINITDEPTH]; /* the state stack */ - YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ - - short *yyss = yyssa; /* refer to the stacks thru separate pointers */ - YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ - -#ifdef YYLSP_NEEDED - YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ - YYLTYPE *yyls = yylsa; - YYLTYPE *yylsp; - -#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) -#else -#define YYPOPSTACK (yyvsp--, yyssp--) -#endif - - int yystacksize = YYINITDEPTH; - int yyfree_stacks = 0; - -#ifdef YYPURE - int yychar; - YYSTYPE yylval; - int yynerrs; -#ifdef YYLSP_NEEDED - YYLTYPE yylloc; -#endif -#endif - - YYSTYPE yyval; /* the variable used to return */ - /* semantic values from the action */ - /* routines */ - - int yylen; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Starting parse\n"); -#endif - - yystate = 0; - yyerrstatus = 0; - yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - - yyssp = yyss - 1; - yyvsp = yyvs; -#ifdef YYLSP_NEEDED - yylsp = yyls; -#endif - -/* Push a new state, which is found in yystate . */ -/* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. */ -yynewstate: - - *++yyssp = yystate; - - if (yyssp >= yyss + yystacksize - 1) - { - /* Give user a chance to reallocate the stack */ - /* Use copies of these so that the &'s don't force the real ones into memory. */ - YYSTYPE *yyvs1 = yyvs; - short *yyss1 = yyss; -#ifdef YYLSP_NEEDED - YYLTYPE *yyls1 = yyls; -#endif - - /* Get the current used size of the three stacks, in elements. */ - int size = yyssp - yyss + 1; - -#ifdef yyoverflow - /* Each stack pointer address is followed by the size of - the data in use in that stack, in bytes. */ -#ifdef YYLSP_NEEDED - /* This used to be a conditional around just the two extra args, - but that might be undefined if yyoverflow is a macro. */ - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yyls1, size * sizeof (*yylsp), - &yystacksize); -#else - yyoverflow("parser stack overflow", - &yyss1, size * sizeof (*yyssp), - &yyvs1, size * sizeof (*yyvsp), - &yystacksize); -#endif - - yyss = yyss1; yyvs = yyvs1; -#ifdef YYLSP_NEEDED - yyls = yyls1; -#endif -#else /* no yyoverflow */ - /* Extend the stack our own way. */ - if (yystacksize >= YYMAXDEPTH) - { - yyerror("parser stack overflow"); - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 2; - } - yystacksize *= 2; - if (yystacksize > YYMAXDEPTH) - yystacksize = YYMAXDEPTH; -#ifndef YYSTACK_USE_ALLOCA - yyfree_stacks = 1; -#endif - yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); - __yy_memcpy ((char *)yyss, (char *)yyss1, - size * (unsigned int) sizeof (*yyssp)); - yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); - __yy_memcpy ((char *)yyvs, (char *)yyvs1, - size * (unsigned int) sizeof (*yyvsp)); -#ifdef YYLSP_NEEDED - yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); - __yy_memcpy ((char *)yyls, (char *)yyls1, - size * (unsigned int) sizeof (*yylsp)); -#endif -#endif /* no yyoverflow */ - - yyssp = yyss + size - 1; - yyvsp = yyvs + size - 1; -#ifdef YYLSP_NEEDED - yylsp = yyls + size - 1; -#endif - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Stack size increased to %d\n", yystacksize); -#endif - - if (yyssp >= yyss + yystacksize - 1) - YYABORT; - } - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Entering state %d\n", yystate); -#endif - - goto yybackup; - yybackup: - -/* Do appropriate processing given the current state. */ -/* Read a lookahead token if we need one and don't already have one. */ -/* yyresume: */ - - /* First try to decide what to do without reference to lookahead token. */ - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yydefault; - - /* Not known => get a lookahead token if don't already have one. */ - - /* yychar is either YYEMPTY or YYEOF - or a valid token in external form. */ - - if (yychar == YYEMPTY) - { -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Reading a token: "); -#endif - yychar = YYLEX; - } - - /* Convert token to internal form (in yychar1) for indexing tables with */ - - if (yychar <= 0) /* This means end of input. */ - { - yychar1 = 0; - yychar = YYEOF; /* Don't call YYLEX any more */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Now at end of input.\n"); -#endif - } - else - { - yychar1 = YYTRANSLATE(yychar); - -#if YYDEBUG != 0 - if (yydebug) - { - fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); - /* Give the individual parser a way to print the precise meaning - of a token, for further debugging info. */ -#ifdef YYPRINT - YYPRINT (stderr, yychar, yylval); -#endif - fprintf (stderr, ")\n"); - } -#endif - } - - yyn += yychar1; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) - goto yydefault; - - yyn = yytable[yyn]; - - /* yyn is what to do for this token type in this state. - Negative => reduce, -yyn is rule number. - Positive => shift, yyn is new state. - New state is final state => don't bother to shift, - just return success. - 0, or most negative number => error. */ - - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrlab; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrlab; - - if (yyn == YYFINAL) - YYACCEPT; - - /* Shift the lookahead token. */ - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); -#endif - - /* Discard the token being shifted unless it is eof. */ - if (yychar != YYEOF) - yychar = YYEMPTY; - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - /* count tokens shifted since error; after three, turn off error status. */ - if (yyerrstatus) yyerrstatus--; - - yystate = yyn; - goto yynewstate; - -/* Do the default action for the current state. */ -yydefault: - - yyn = yydefact[yystate]; - if (yyn == 0) - goto yyerrlab; - -/* Do a reduction. yyn is the number of a rule to reduce with. */ -yyreduce: - yylen = yyr2[yyn]; - if (yylen > 0) - yyval = yyvsp[1-yylen]; /* implement default value of the action */ - -#if YYDEBUG != 0 - if (yydebug) - { - int i; - - fprintf (stderr, "Reducing via rule %d (line %d), ", - yyn, yyrline[yyn]); - - /* Print the symbols being reduced, and their result. */ - for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) - fprintf (stderr, "%s ", yytname[yyrhs[i]]); - fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); - } -#endif - -$ /* the action file gets copied in in place of this dollarsign */ -#line 543 "/usr/share/bison.simple" - - yyvsp -= yylen; - yyssp -= yylen; -#ifdef YYLSP_NEEDED - yylsp -= yylen; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - - *++yyvsp = yyval; - -#ifdef YYLSP_NEEDED - yylsp++; - if (yylen == 0) - { - yylsp->first_line = yylloc.first_line; - yylsp->first_column = yylloc.first_column; - yylsp->last_line = (yylsp-1)->last_line; - yylsp->last_column = (yylsp-1)->last_column; - yylsp->text = 0; - } - else - { - yylsp->last_line = (yylsp+yylen-1)->last_line; - yylsp->last_column = (yylsp+yylen-1)->last_column; - } -#endif - - /* Now "shift" the result of the reduction. - Determine what state that goes to, - based on the state we popped back to - and the rule number reduced by. */ - - yyn = yyr1[yyn]; - - yystate = yypgoto[yyn - YYNTBASE] + *yyssp; - if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) - yystate = yytable[yystate]; - else - yystate = yydefgoto[yyn - YYNTBASE]; - - goto yynewstate; - -yyerrlab: /* here on detecting error */ - - if (! yyerrstatus) - /* If not already recovering from an error, report this error. */ - { - ++yynerrs; - -#ifdef YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (yyn > YYFLAG && yyn < YYLAST) - { - int size = 0; - char *msg; - int x, count; - - count = 0; - /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - size += strlen(yytname[x]) + 15, count++; - msg = (char *) malloc(size + 15); - if (msg != 0) - { - strcpy(msg, "parse error"); - - if (count < 5) - { - count = 0; - for (x = (yyn < 0 ? -yyn : 0); - x < (sizeof(yytname) / sizeof(char *)); x++) - if (yycheck[x + yyn] == x) - { - strcat(msg, count == 0 ? ", expecting `" : " or `"); - strcat(msg, yytname[x]); - strcat(msg, "'"); - count++; - } - } - yyerror(msg); - free(msg); - } - else - yyerror ("parse error; also virtual memory exceeded"); - } - else -#endif /* YYERROR_VERBOSE */ - yyerror("parse error"); - } - - goto yyerrlab1; -yyerrlab1: /* here on error raised explicitly by an action */ - - if (yyerrstatus == 3) - { - /* if just tried and failed to reuse lookahead token after an error, discard it. */ - - /* return failure if at end of input */ - if (yychar == YYEOF) - YYABORT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); -#endif - - yychar = YYEMPTY; - } - - /* Else will try to reuse lookahead token - after shifting the error token. */ - - yyerrstatus = 3; /* Each real token shifted decrements this */ - - goto yyerrhandle; - -yyerrdefault: /* current state does not do anything special for the error token. */ - -#if 0 - /* This is wrong; only states that explicitly want error tokens - should shift them. */ - yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ - if (yyn) goto yydefault; -#endif - -yyerrpop: /* pop the current state because it cannot handle the error token */ - - if (yyssp == yyss) YYABORT; - yyvsp--; - yystate = *--yyssp; -#ifdef YYLSP_NEEDED - yylsp--; -#endif - -#if YYDEBUG != 0 - if (yydebug) - { - short *ssp1 = yyss - 1; - fprintf (stderr, "Error: state stack now"); - while (ssp1 != yyssp) - fprintf (stderr, " %d", *++ssp1); - fprintf (stderr, "\n"); - } -#endif - -yyerrhandle: - - yyn = yypact[yystate]; - if (yyn == YYFLAG) - goto yyerrdefault; - - yyn += YYTERROR; - if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) - goto yyerrdefault; - - yyn = yytable[yyn]; - if (yyn < 0) - { - if (yyn == YYFLAG) - goto yyerrpop; - yyn = -yyn; - goto yyreduce; - } - else if (yyn == 0) - goto yyerrpop; - - if (yyn == YYFINAL) - YYACCEPT; - -#if YYDEBUG != 0 - if (yydebug) - fprintf(stderr, "Shifting error token, "); -#endif - - *++yyvsp = yylval; -#ifdef YYLSP_NEEDED - *++yylsp = yylloc; -#endif - - yystate = yyn; - goto yynewstate; - - yyacceptlab: - /* YYACCEPT comes here. */ - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 0; - - yyabortlab: - /* YYABORT comes here. */ - if (yyfree_stacks) - { - free (yyss); - free (yyvs); -#ifdef YYLSP_NEEDED - free (yyls); -#endif - } - return 1; -} diff --git a/harbour/source/compiler/harbour.slx b/harbour/source/compiler/harbour.slx deleted file mode 100644 index 423d81656e..0000000000 --- a/harbour/source/compiler/harbour.slx +++ /dev/null @@ -1,1152 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Compiler SimpLex rules - * - * Copyright 2000 Ron Pinkas - * www - http://www.harbour-project.org - * - * 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 (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -//#define SHOW_LEX_TOKENS -//#define DEBUG_LEX - -#ifdef DEBUG_LEX - #undef DEBUG_INFO - #define DEBUG_INFO(x) x -#endif - -#undef LEX_ABBREVIATE - #define LEX_ABBREVIATE 4 - -#undef YY_BUF_SIZE - #define YY_BUF_SIZE HB_PP_STR_SIZE - -static int iCloseSquare = 0, iWantsEOL, iWantsEXP, iWantsID, iWantsVAR; - -static unsigned char iIdentifier = 0; -static char *sIdOnHold, *s_sLastBlock = NULL; - -char * hb_comp_SLX_LastBlock( BOOL bReset ); - -static int hb_comp_SLX_Str2Num( char* szNum, HB_LONG * lVal, double * dVal, int * iDec, int * iWidth ); -static int hb_comp_SLX_ElementToken( char* szToken, unsigned int iTokenLen ); -static int hb_comp_SLX_InterceptAction( int iRet, char *sToken ); -static int hb_comp_SLX_CustomAction( int x, int aiHold[], int *ptr_iHold, BOOL *ptr_bIgnoreWords, int iLastToken, char *sToken, char *s_szBuffer ); - -/* ----------------------------------------------------- Language Definitions. ---------------------------------------------------- */ - -/* Delimiters. */ -ACCEPT_TOKEN_AND_DROP_DELIMITER_IF_ONE_OF_THESE( " \t" ); - -#define HB_CHK_BLOCK LEX_CUSTOM_ACTION - 1 - -ACCEPT_TOKEN_AND_RETURN_DELIMITERS { - LEX_DELIMITER( ',' ) AS_TOKEN( ',' ), - LEX_DELIMITER( '(' ) AS_TOKEN( '(' ), - LEX_DELIMITER( ')' ) AS_TOKEN( ')' ), - LEX_DELIMITER( '[' ) AS_TOKEN( '[' ), - LEX_DELIMITER( ']' ) AS_TOKEN( ']' + DONT_REDUCE ), - LEX_DELIMITER( '}' ) AS_TOKEN( '}' + DONT_REDUCE ), - LEX_DELIMITER( ':' ) AS_TOKEN( ':' ), - LEX_DELIMITER( '=' ) AS_TOKEN( '=' ), - LEX_DELIMITER( '#' ) AS_TOKEN( NE1 ), - LEX_DELIMITER( '@' ) AS_TOKEN( '@' ), - LEX_DELIMITER( '<' ) AS_TOKEN( '<' + DONT_REDUCE ), - LEX_DELIMITER( '>' ) AS_TOKEN( '>' + DONT_REDUCE ), - LEX_DELIMITER( '!' ) AS_TOKEN( NOT + DONT_REDUCE ), - LEX_DELIMITER( '{' ) AS_TOKEN( HB_CHK_BLOCK ), - LEX_DELIMITER( '|' ) AS_TOKEN( '|' + DONT_REDUCE ), - LEX_DELIMITER( '^' ) AS_TOKEN( POWER + DONT_REDUCE ), - LEX_DELIMITER( '%' ) AS_TOKEN( '%' + DONT_REDUCE ), - LEX_DELIMITER( '*' ) AS_TOKEN( '*' + DONT_REDUCE ), - LEX_DELIMITER( '/' ) AS_TOKEN( '/' + DONT_REDUCE ), - LEX_DELIMITER( '+' ) AS_TOKEN( '+' + DONT_REDUCE ), - LEX_DELIMITER( '-' ) AS_TOKEN( '-' + DONT_REDUCE ), - LEX_DELIMITER( '$' ) AS_TOKEN( '$' + DONT_REDUCE ) - }; - -/* Custom Intermediate Token needed to be expanded. */ -#define HB_LIT_ACT LEX_CUSTOM_ACTION - 2 -#define HB_NESTED_LIT LEX_CUSTOM_ACTION - 3 -#define HB_QOUT_ACT LEX_CUSTOM_ACTION - 4 -#define HB_RET_QOUT_LIT LEX_CUSTOM_ACTION - 5 - -/* Stream Pairs. */ -DEFINE_STREAM_AS_ONE_OF_THESE { - START_WITH("\"") END_WITH("\"" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_LIT_ACT), - START_WITH("'") END_WITH("'") STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_LIT_ACT), - START_WITH("QOUT([") END_WITH("])\n") STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_QOUT_ACT), - START_WITH("[") END_WITH("]" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(TRUE ) AS_PAIR_TOKEN(HB_LIT_ACT), - START_WITH("[\"") END_WITH("\"]" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_NESTED_LIT), - START_WITH("['") END_WITH("\']" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_NESTED_LIT), - START_WITH("[[") END_WITH("]]" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_NESTED_LIT) - }; - -START_NEW_LINE_IF_ONE_OF_THESE( "\n;" ); - - -#define HB_SELF LEX_CUSTOM_ACTION - 6 - -SELF_CONTAINED_WORDS_ARE { - LEX_WORD( ".AND." ) AS_TOKEN( AND + DONT_REDUCE ), - LEX_WORD( ".NOT." ) AS_TOKEN( NOT + DONT_REDUCE ), - LEX_WORD( ".OR." ) AS_TOKEN( OR + DONT_REDUCE ), - LEX_WORD( ":=" ) AS_TOKEN( INASSIGN ), - LEX_WORD( "::" ) AS_TOKEN( HB_SELF ), - LEX_WORD( "==" ) AS_TOKEN( EQ + DONT_REDUCE ), - LEX_WORD( "<>" ) AS_TOKEN( NE2 + DONT_REDUCE ), - LEX_WORD( "<=" ) AS_TOKEN( LE + DONT_REDUCE ), - LEX_WORD( ">=" ) AS_TOKEN( GE + DONT_REDUCE ), - LEX_WORD( "!=" ) AS_TOKEN( NE2 + DONT_REDUCE ), - LEX_WORD( "++" ) AS_TOKEN( INC ), - LEX_WORD( "+=" ) AS_TOKEN( PLUSEQ ), - LEX_WORD( "--" ) AS_TOKEN( DEC ), - LEX_WORD( "-=" ) AS_TOKEN( MINUSEQ ), - LEX_WORD( "->" ) AS_TOKEN( ALIASOP ), - LEX_WORD( "*=" ) AS_TOKEN( MULTEQ ), - LEX_WORD( "**" ) AS_TOKEN( POWER + DONT_REDUCE ), - LEX_WORD( "/=" ) AS_TOKEN( DIVEQ ), - LEX_WORD( "^=" ) AS_TOKEN( EXPEQ ), - LEX_WORD( "%=" ) AS_TOKEN( MODEQ ) - }; - -/* Intermediate KeyWords when ambigious. */ -#define DO_WHILE 701 -#define DO_WHILE_WITH 702 - -/* KeyWords are grouped based on the next token they require. */ -#define WANTS_VAR 703 /* Wants Variable (including Macros): DO, FOR, PRIVATE, PUBLIC */ -#define WANTS_ID 704 /* Wants Identifier: ANNOUNCE, EXTERN, FIELD, FUNCTION, LOCAL, MEMVAR, PARAMETERS, PROCEDURE, STATIC */ -#define WANTS_EOL 705 /* Wants EOL: ELSE, END, ENDCASE, ENDDO, ENDIF, EXIT, LOOP, NEXT, OTHERWISE, RECOVER */ -#define WANTS_EXP 706 /* Wants Expression: BREAK, CASE, ELSEIF, IF, RETURN, WHILE */ -#define REJECT_OP 707 - -#define HB_WANTS_VAR LEX_CUSTOM_ACTION - 512 -#define HB_WANTS_ID LEX_CUSTOM_ACTION - 1024 -#define HB_WANTS_EOL LEX_CUSTOM_ACTION - 1536 -#define HB_WANTS_EXP LEX_CUSTOM_ACTION - 2048 - -/* When 2 identifiers are correct syntax like in class declaration, we have to temporarily store the 2nd identifier. */ -#define HB_ID_ON_HOLD LEX_CUSTOM_ACTION - 7 - -#define HB_MACRO_ERR LEX_CUSTOM_ACTION - 8 - -#define HB_INIT_PROC LEX_CUSTOM_ACTION - 9 -#define HB_INIT_FUNC LEX_CUSTOM_ACTION - 10 -#define HB_EXIT_PROC LEX_CUSTOM_ACTION - 11 -#define HB_EXIT_FUNC LEX_CUSTOM_ACTION - 12 -#define HB_STATIC_PROC LEX_CUSTOM_ACTION - 13 -#define HB_STATIC_FUNC LEX_CUSTOM_ACTION - 14 - -#define HB_DO_CASE_ID LEX_CUSTOM_ACTION - 15 - -#define HB_DO_WHILE_ID LEX_CUSTOM_ACTION - 16 -#define HB_DO_WHILE_WITH LEX_CUSTOM_ACTION - 17 - -#define _WITH_ID_CR LEX_CUSTOM_ACTION - 18 -#define _WITH_ID_SEMI LEX_CUSTOM_ACTION - 19 - -#define HB_IN LEX_CUSTOM_ACTION - 20 -#define HB_STEP LEX_CUSTOM_ACTION - 21 -#define HB_TO LEX_CUSTOM_ACTION - 22 -#define HB_WITH LEX_CUSTOM_ACTION - 23 - -/* When reservered words are used as Identifier. */ -#define HB_IDENTIFIER LEX_CUSTOM_ACTION - 24 - -#define HB_INLINE LEX_CUSTOM_ACTION - 25 - -#define USE_KEYWORDS - -/* Key Words. */ -LANGUAGE_KEY_WORDS_ARE { - LEX_WORD( "ANNOUNCE" ) AS_TOKEN( HB_WANTS_ID - ANNOUNCE ), - LEX_WORD( "BEGIN{WS}SEQUENCE" ) AS_TOKEN( BEGINSEQ ), - LEX_WORD( "BREAK" ) AS_TOKEN( HB_WANTS_EXP - BREAK ), - LEX_WORD( "CASE" ) AS_TOKEN( HB_WANTS_EXP - CASE ), - LEX_WORD( "DECLARE" ) AS_TOKEN( DECLARE ), - LEX_WORD( "DO" ) AS_TOKEN( HB_WANTS_VAR - DO ), - LEX_WORD( "DO{WS}CASE" ) AS_TOKEN( DOCASE ), - LEX_WORD( "DO{WS}WHILE" ) AS_TOKEN( DO_WHILE ), - LEX_WORD( "DO{WS}WHILE{WS}WITH" ) AS_TOKEN( DO_WHILE_WITH ), - LEX_WORD( "ELSE" ) AS_TOKEN( HB_WANTS_EOL - ELSE ), - LEX_WORD( "ELSEIF" ) AS_TOKEN( HB_WANTS_EXP - ELSEIF ), - LEX_WORD( "END" ) AS_TOKEN( HB_WANTS_EOL - END ), - LEX_WORD( "ENDCASE" ) AS_TOKEN( HB_WANTS_EOL - ENDCASE ), - LEX_WORD( "ENDDO" ) AS_TOKEN( HB_WANTS_EOL - ENDDO ), - LEX_WORD( "ENDIF" ) AS_TOKEN( HB_WANTS_EOL - ENDIF ), - LEX_WORD( "EXIT" ) AS_TOKEN( HB_WANTS_EOL - EXIT ), - LEX_WORD( "EXIT{WS}FUNCTION" ) AS_TOKEN( HB_EXIT_FUNC ), - LEX_WORD( "EXIT{WS}PROCEDURE" ) AS_TOKEN( HB_EXIT_PROC ), - LEX_WORD( "EXTERNAL" ) AS_TOKEN( HB_WANTS_ID - EXTERN ), - LEX_WORD( "FIELD" ) AS_TOKEN( HB_WANTS_ID - FIELD ), - LEX_WORD( "FOR" ) AS_TOKEN( HB_WANTS_VAR - FOR ), - LEX_WORD( "FUNCTION" ) AS_TOKEN( HB_WANTS_ID - FUNCTION ), - LEX_WORD( "IF" ) AS_TOKEN( HB_WANTS_EXP - IF ), - LEX_WORD( "INIT{WS}FUNCTION" ) AS_TOKEN( HB_INIT_FUNC ), - LEX_WORD( "INIT{WS}PROCEDURE" ) AS_TOKEN( HB_INIT_PROC ), - LEX_WORD( "LOCAL" ) AS_TOKEN( HB_WANTS_ID - LOCAL ), - LEX_WORD( "LOOP" ) AS_TOKEN( HB_WANTS_EOL - LOOP ), - LEX_WORD( "MEMVAR" ) AS_TOKEN( HB_WANTS_ID - MEMVAR ), - LEX_WORD( "NEXT" ) AS_TOKEN( HB_WANTS_EOL - NEXT ), - LEX_WORD( "OTHERWISE" ) AS_TOKEN( HB_WANTS_EOL - OTHERWISE ), - LEX_WORD( "PARAMETERS" ) AS_TOKEN( HB_WANTS_ID - PARAMETERS ), - LEX_WORD( "PRIVATE" ) AS_TOKEN( HB_WANTS_VAR - PRIVATE ), - LEX_WORD( "PROCEDURE" ) AS_TOKEN( HB_WANTS_ID - PROCEDURE ), - LEX_WORD( "PUBLIC" ) AS_TOKEN( HB_WANTS_VAR - PUBLIC ), - LEX_WORD( "RECOVER" ) AS_TOKEN( HB_WANTS_EOL - RECOVER ), - LEX_WORD( "RECOVER{WS}USING" ) AS_TOKEN( RECOVERUSING ), - LEX_WORD( "RETURN" ) AS_TOKEN( HB_WANTS_EXP - RETURN ), - LEX_WORD( "STATIC" ) AS_TOKEN( HB_WANTS_ID - STATIC ), - LEX_WORD( "STATIC{WS}FUNCTION" ) AS_TOKEN( HB_STATIC_FUNC ), - LEX_WORD( "STATIC{WS}PROCEDURE" ) AS_TOKEN( HB_STATIC_PROC ), - LEX_WORD( "WHILE" ) AS_TOKEN( HB_WANTS_EXP - WHILE ), - LEX_WORD( "_HB_CLASS" ) AS_TOKEN( DECLARE_CLASS ), - LEX_WORD( "_HB_MEMBER" ) AS_TOKEN( DECLARE_MEMBER ), - LEX_WORD( "_PROCREQ_" ) AS_TOKEN( PROCREQ ) - }; - -/* Intermediate Words when ambigious. */ -#define QSELF 801 -#define _LINE_ 802 - -/* Words. */ -LANGUAGE_WORDS_ARE { - LEX_WORD( ".F." ) AS_TOKEN( FALSEVALUE + DONT_REDUCE ), - LEX_WORD( ".N." ) AS_TOKEN( FALSEVALUE + DONT_REDUCE ), - LEX_WORD( ".T." ) AS_TOKEN( TRUEVALUE + DONT_REDUCE ), - LEX_WORD( ".Y." ) AS_TOKEN( TRUEVALUE + DONT_REDUCE ), - - LEX_WORD( "AS{WS}ANYTYPE" ) AS_TOKEN( AS_VARIANT + DONT_REDUCE ), - LEX_WORD( "AS{WS}ARRAY" ) AS_TOKEN( AS_ARRAY + DONT_REDUCE ), - LEX_WORD( "AS{WS}ARRAY{WS}OF{WS}ANYTYPE" ) AS_TOKEN( AS_ARRAY + DONT_REDUCE ), - LEX_WORD( "AS{WS}ARRAY{WS}OF{WS}ARRAY" ) AS_TOKEN( AS_ARRAY_ARRAY + DONT_REDUCE ), - LEX_WORD( "AS{WS}ARRAY{WS}OF{WS}CHARACTER" ) AS_TOKEN( AS_CHARACTER_ARRAY + DONT_REDUCE ), - LEX_WORD( "AS{WS}ARRAY{WS}OF{WS}CLASS" ) AS_TOKEN( AS_CLASS_ARRAY + DONT_REDUCE ), - LEX_WORD( "AS{WS}ARRAY{WS}OF{WS}CODEBLOCK" ) AS_TOKEN( AS_BLOCK_ARRAY + DONT_REDUCE ), - LEX_WORD( "AS{WS}ARRAY{WS}OF{WS}DATE" ) AS_TOKEN( AS_DATE_ARRAY + DONT_REDUCE ), - LEX_WORD( "AS{WS}ARRAY{WS}OF{WS}LOGICAL" ) AS_TOKEN( AS_LOGICAL_ARRAY + DONT_REDUCE ), - LEX_WORD( "AS{WS}ARRAY{WS}OF{WS}NUMERIC" ) AS_TOKEN( AS_NUMERIC_ARRAY + DONT_REDUCE ), - LEX_WORD( "AS{WS}ARRAY{WS}OF{WS}OBJECT" ) AS_TOKEN( AS_OBJECT_ARRAY + DONT_REDUCE ), - LEX_WORD( "AS{WS}ARRAY{WS}OF{WS}STRING" ) AS_TOKEN( AS_CHARACTER_ARRAY + DONT_REDUCE ), - LEX_WORD( "AS{WS}ARRAY{WS}OF{WS}USUAL" ) AS_TOKEN( AS_CHARACTER_ARRAY + DONT_REDUCE ), - LEX_WORD( "AS{WS}CHARACTER" ) AS_TOKEN( AS_CHARACTER + DONT_REDUCE ), - LEX_WORD( "AS{WS}CLASS" ) AS_TOKEN( AS_CLASS + DONT_REDUCE ), - LEX_WORD( "AS{WS}CODEBLOCK" ) AS_TOKEN( AS_BLOCK + DONT_REDUCE ), - LEX_WORD( "AS{WS}DATE" ) AS_TOKEN( AS_DATE + DONT_REDUCE ), - LEX_WORD( "AS{WS}LOGICAL" ) AS_TOKEN( AS_LOGICAL + DONT_REDUCE ), - LEX_WORD( "AS{WS}NUMERIC" ) AS_TOKEN( AS_NUMERIC + DONT_REDUCE ), - LEX_WORD( "AS{WS}OBJECT" ) AS_TOKEN( AS_OBJECT + DONT_REDUCE ), - LEX_WORD( "AS{WS}STRING" ) AS_TOKEN( AS_CHARACTER + DONT_REDUCE ), - LEX_WORD( "AS{WS}USUAL" ) AS_TOKEN( AS_CHARACTER + DONT_REDUCE ), - - LEX_WORD( "FIELD" ) AS_TOKEN( FIELD ), - LEX_WORD( "HB_INLINE" ) AS_TOKEN( HB_INLINE ), - LEX_WORD( "IF" ) AS_TOKEN( IIF ), - LEX_WORD( "IIF" ) AS_TOKEN( IIF ), - LEX_WORD( "IN" ) AS_TOKEN( HB_IN ), - LEX_WORD( "LINE" ) AS_TOKEN( _LINE_ ), - LEX_WORD( "NIL" ) AS_TOKEN( NIL + DONT_REDUCE ), - LEX_WORD( "OPTIONAL" ) AS_TOKEN( OPTIONAL ), - LEX_WORD( "QSELF" ) AS_TOKEN( QSELF ), - /* LEX_WORD( "SELF" ) AS_TOKEN( SELF ), */ - LEX_WORD( "STEP" ) AS_TOKEN( HB_STEP ), - LEX_WORD( "TO" ) AS_TOKEN( HB_TO ), - LEX_WORD( "WITH" ) AS_TOKEN( HB_WITH ), - LEX_WORD( "_FIELD" ) AS_TOKEN( FIELD ), - LEX_WORD( "_GET_" ) AS_TOKEN( GET ) - }; - -/* Intermediate Reductions when still ambigious or need further reductions. */ -#define _ID_ARRAY 901 -#define _ID_COMMA 902 -#define _ID_CR 903 -#define _ID_SEMI 904 -#define _ID_ASSIGN 905 -#define _WHL_ID_CR 906 -#define _WHL_ID_SEMI 907 -#define _QOUT_LIT 908 - -/* When 2 identifiers are correct syntax like in class declaration, we have to temporarily store the 2nd identifier. */ -#define _ID_ON_HOLD 913 - -LANGUAGE_RULES_ARE { - /* Wants any Var. */ - IF_SEQUENCE_IS( WANTS_VAR , IDENTIFIER , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( WANTS_VAR , MACROVAR , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( WANTS_VAR , MACROTEXT , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( WANTS_VAR , '&' , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( WANTS_VAR , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - /* Wants Identifier. */ - IF_SEQUENCE_IS( WANTS_ID , IDENTIFIER , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( WANTS_ID , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - /* Wants EOL */ - IF_SEQUENCE_IS( WANTS_EOL , '\n' , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( WANTS_EOL , ';' , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( WANTS_EOL , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - /* Wants Expression ( DOESN'T WANT OPERATORS ) - At BOL, if followed by operator (other than logicals .t., .f., !) than Identifier else COMMAND. */ - IF_SEQUENCE_IS( REJECT_OP , INC , '\n' , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , INC , ';' , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , DEC , '\n' , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , DEC , ';' , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , INASSIGN , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , ALIASOP , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , PLUSEQ , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , MINUSEQ , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , MULTEQ , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , DIVEQ , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , EXPEQ , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , MODEQ , 0 , 0 ) PASS_THROUGH(), - /* IF_SEQUENCE_IS( REJECT_OP , '(' , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , '[' , 0 , 0 ) PASS_THROUGH(), DONT uncomment!!!*/ - IF_SEQUENCE_IS( REJECT_OP , '=' , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , ':' , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( REJECT_OP , 0 , 0 , 0 ) REDUCE_TO( WANTS_EXP + DONT_REDUCE , 0 ), - - IF_SEQUENCE_IS( REJECT_OP , OPTIONAL , 0 , 0 ) REDUCE_TO( WANTS_EXP + DONT_REDUCE , HB_IDENTIFIER ), - IF_SEQUENCE_IS( REJECT_OP , WANTS_ID , 0 , 0 ) REDUCE_TO( WANTS_EXP + DONT_REDUCE , HB_IDENTIFIER ), - IF_SEQUENCE_IS( REJECT_OP , WANTS_EXP , 0 , 0 ) REDUCE_TO( WANTS_EXP + DONT_REDUCE , HB_IDENTIFIER ), - IF_SEQUENCE_IS( REJECT_OP , WANTS_VAR , 0 , 0 ) REDUCE_TO( WANTS_EXP + DONT_REDUCE , HB_IDENTIFIER ), - - - /* Complex */ - - IF_SEQUENCE_IS( DOCASE , '\n' , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( DOCASE , ';' , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( DOCASE , 0 , 0 , 0 ) REDUCE_TO( HB_DO_CASE_ID , 0 ), - - IF_SEQUENCE_IS( DO_WHILE_WITH, '\n' , 0 , 0 ) REDUCE_TO( WHILE + DONT_REDUCE, _WITH_ID_CR ), - IF_SEQUENCE_IS( DO_WHILE_WITH, ';' , 0 , 0 ) REDUCE_TO( WHILE + DONT_REDUCE, _WITH_ID_SEMI), - IF_SEQUENCE_IS( DO_WHILE_WITH, 0 , 0 , 0 ) REDUCE_TO( HB_DO_WHILE_WITH , 0 ), - - IF_SEQUENCE_IS( DO_WHILE , '\n' , 0 , 0 ) REDUCE_TO( HB_DO_WHILE_ID , '\n' + DONT_REDUCE ), - IF_SEQUENCE_IS( DO_WHILE , ';' , 0 , 0 ) REDUCE_TO( HB_DO_WHILE_ID , ';' + DONT_REDUCE ), - IF_SEQUENCE_IS( DO_WHILE , 0 , 0 , 0 ) REDUCE_TO( WHILE + DONT_REDUCE, 0 ), - - - /* DECLARE as PRIVATE. */ - IF_SEQUENCE_IS( DECLARE , IDENTIFIER , '[' , 0 ) REDUCE_TO( PRIVATE + DONT_REDUCE , _ID_ARRAY ), - IF_SEQUENCE_IS( DECLARE , IDENTIFIER , ',' , 0 ) REDUCE_TO( PRIVATE + DONT_REDUCE , _ID_COMMA ), - IF_SEQUENCE_IS( DECLARE , IDENTIFIER , '\n' , 0 ) REDUCE_TO( PRIVATE + DONT_REDUCE , _ID_CR ), - IF_SEQUENCE_IS( DECLARE , IDENTIFIER , ';' , 0 ) REDUCE_TO( PRIVATE + DONT_REDUCE , _ID_SEMI ), - IF_SEQUENCE_IS( DECLARE , IDENTIFIER ,INASSIGN, 0 ) REDUCE_TO( PRIVATE + DONT_REDUCE , _ID_ASSIGN ), - IF_SEQUENCE_IS( DECLARE , MACROVAR , 0 , 0 ) REDUCE_TO( PRIVATE + DONT_REDUCE , MACROVAR ), - IF_SEQUENCE_IS( DECLARE , MACROTEXT , 0 , 0 ) REDUCE_TO( PRIVATE + DONT_REDUCE , MACROTEXT ), - - /* Any other DECLARE IDENTIFIER, must be Strong Type DECLARE. */ - IF_SEQUENCE_IS( DECLARE , IDENTIFIER , 0 , 0 ) PASS_THROUGH(), - - IF_SEQUENCE_IS( _ID_ON_HOLD , 0 , 0 , 0 ) REDUCE_TO( HB_ID_ON_HOLD , 0 ), - - /* Any other DECLARE must be Identifier. */ - IF_SEQUENCE_IS( DECLARE , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - /* Expnasions from DECLARE ...*/ - IF_SEQUENCE_IS( _ID_ARRAY , 0 , 0 , 0 ) REDUCE_TO( IDENTIFIER + DONT_REDUCE , '[' + DONT_REDUCE ), - IF_SEQUENCE_IS( _ID_COMMA , 0 , 0 , 0 ) REDUCE_TO( IDENTIFIER + DONT_REDUCE , ',' + DONT_REDUCE ), - IF_SEQUENCE_IS( _ID_CR , 0 , 0 , 0 ) REDUCE_TO( IDENTIFIER + DONT_REDUCE , '\n' + DONT_REDUCE ), - IF_SEQUENCE_IS( _ID_SEMI , 0 , 0 , 0 ) REDUCE_TO( IDENTIFIER + DONT_REDUCE , ';' + DONT_REDUCE ), - IF_SEQUENCE_IS( _ID_ASSIGN , 0 , 0 , 0 ) REDUCE_TO( IDENTIFIER + DONT_REDUCE , INASSIGN + DONT_REDUCE ), - - - /* This FIELD is NOT at BOL wants only ->. */ - IF_SEQUENCE_IS( FIELD , ALIASOP , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( FIELD , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - - /* IF_SEQUENCE_IS( SELF , ':' , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( SELF , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), */ - - IF_SEQUENCE_IS( QSELF , '(' , ')' , 0 ) REDUCE_TO( SELF + DONT_REDUCE, 0 ), - IF_SEQUENCE_IS( QSELF , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - IF_SEQUENCE_IS( IIF , '(' , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( IIF , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - IF_SEQUENCE_IS( OPTIONAL , IDENTIFIER , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( OPTIONAL , '@' , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( OPTIONAL , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - IF_SEQUENCE_IS( PROCREQ , '(' , 0 , 0 ) REDUCE_TO( PROCREQ + DONT_REDUCE, 0 ), - IF_SEQUENCE_IS( PROCREQ , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - IF_SEQUENCE_IS( GET , '(' , 0 , 0 ) REDUCE_TO( GET + DONT_REDUCE , 0 ), - IF_SEQUENCE_IS( GET , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - IF_SEQUENCE_IS( NE1 , _LINE_ , 0 , 0 ) REDUCE_TO( LINE + DONT_REDUCE, 0 ), - IF_SEQUENCE_IS( _LINE_ , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - IF_SEQUENCE_IS( '&' , '\'' , 0 , 0 ) REDUCE_TO( HB_MACRO_ERR , 0 ), - IF_SEQUENCE_IS( '&' , '"' , 0 , 0 ) REDUCE_TO( HB_MACRO_ERR , 0 ), - IF_SEQUENCE_IS( '&' , '[' , 0 , 0 ) REDUCE_TO( HB_MACRO_ERR , 0 ), - - IF_SEQUENCE_IS( _QOUT_LIT , 0 , 0 , 0 ) REDUCE_TO( HB_RET_QOUT_LIT , 0 ) - }; - -/* ------------------------------------------------- End of Language Definitions. ------------------------------------------------ */ - -/* SimpLex Macros. */ - -#undef LEX_CASE - #define LEX_CASE(x) ( ( ( iRet = (x) ) > 96 && iRet < 123 ) ? iRet - 32 : iRet ) - -/* Commented 2001-08-29 - Not really needed! -#undef NEW_LINE_ACTION - #define NEW_LINE_ACTION() \ - while( iTexts ) \ - { \ - DEBUG_INFO( printf( "Releasing short term Text: %i = %s At: %i\n", iTexts, aTexts[iTexts - 1], aTexts[iTexts - 1] ) ); \ - iTexts--; \ - hb_xfree( aTexts[iTexts] ); \ - } -*/ - -#undef INTERCEPT_ACTION - #define INTERCEPT_ACTION(x) x = hb_comp_SLX_InterceptAction( x, (char*) sToken ) - -#undef ELEMENT_TOKEN - #define ELEMENT_TOKEN(x,y) hb_comp_SLX_ElementToken(x,y) - -#undef YY_INPUT /* to implement our own YY_INPUT function to manage PRGs without \n at the end */ - extern FILE * yyin; /* currently yacc parsed file */ - int yy_lex_input( char *, int ); - #define YY_INPUT( buf, result, max_size ) result = yy_lex_input( buf, max_size ); - -#undef CUSTOM_ACTION - #define CUSTOM_ACTION(x) x = hb_comp_SLX_CustomAction( x, aiHold, &iHold, &bIgnoreWords, iLastToken, (char*) sToken, s_szBuffer ) - -#undef STREAM_EXCEPTION - #define STREAM_EXCEPTION( sPair, cChar ) \ - if( sTerm[1] == ']' && iCloseSquare ) \ - { \ - szBuffer -= ( ( strlen( sPair ) - iCloseSquare ) + 1 ); \ - sPair[ iCloseSquare - 1 ] = '\0'; \ - aiHold[ iHold++ ] = HB_LIT_ACT; \ - } \ - else \ - { \ - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_STRING_TERMINATOR, sPair, NULL ); \ - aiHold[ iHold++ ] = '\n'; \ - yylval.string = hb_compIdentifierNew( sPair, TRUE ); \ - aiHold[ iHold++ ] = LITERAL + DONT_REDUCE ; \ - } \ - -#undef STREAM_APPEND - #define STREAM_APPEND(x) \ - if( iPairLen == 0 && sStart[0] == '[' && sStart[1] ) { sPair[ iPairLen++ ] = sStart[1]; } \ - if( x == ']' && iCloseSquare == 0 ) { iCloseSquare = iPairLen + 1; } sPair[ iPairLen++ ] = x; - -#undef STREAM_OPEN - #define STREAM_OPEN( sStarter ) \ - { \ - extern BOOL hb_ppInsideTextBlock; \ - \ - iCloseSquare = 0; \ - \ - if( sStarter[0] == 'Q' ) \ - bTmp = hb_ppInsideTextBlock; \ - else \ - bTmp = TRUE; \ - } \ - if( bTmp ) - -#undef IF_BELONG_LEFT - #define IF_BELONG_LEFT(chr) if( iLastToken == IDENTIFIER || iLastToken == SELF || iLastToken == ']' || iLastToken == MACROVAR || iLastToken == MACROTEXT || iLastToken == ')' || iLastToken == '}' || iLastToken == WANTS_EOL || iLastToken == WANTS_ID || iLastToken == WANTS_VAR || iLastToken == DECLARE || iLastToken == FIELD || /*iLastToken == SELF ||*/ iLastToken == QSELF || iLastToken == IIF || iLastToken == PROCREQ ) - -/* Support Functions. */ -static int hb_comp_SLX_InterceptAction( int iRet, char *sToken ) -{ - extern char *yytext; - extern int yyleng; - - if( iRet < 256 ) - { - yytext[0] = iRet; - yytext[1] = '\0'; - yyleng = 1; - } - else if( iRet < 512 ) - { - if( iRet == IDENTIFIER ) - { - if( iIdentifier > 0 ) - { - iIdentifier--; - } - } - else if( yylval.string == NULL ) - { - yytext = sToken; - yyleng = strlen( yytext ); - } - } - else - { - yytext = sToken; - yyleng = strlen( yytext ); - - if( iRet == WANTS_EXP ) - { iRet = iWantsEXP; } - else if( iRet == WANTS_EOL ) - { iRet = iWantsEOL; } - else if( iRet == WANTS_ID ) - { iRet = iWantsID; } - else if( iRet == WANTS_VAR ) - { iRet = iWantsVAR; } - else if( iRet == REJECT_OP ) - { yylval.string = hb_compIdentifierNew( (char*) sToken, TRUE ); iRet = IDENTIFIER; } - else - { printf( "Error SLX0001 Missing handler for '%i' line: %i\n", iRet, hb_comp_iLine - 1 ); hb_comp_iErrorCount++; } - } - - #ifdef SHOW_LEX_TOKENS - if( iRet == IDENTIFIER ) - printf( " IDENTIFIER = \"%s\"\n", yylval.string ); - else if( iRet == LITERAL ) - printf( " LITERAL = \"%s\"\n", yylval.string ); - else if( iRet == MACROVAR ) - printf( " MACROVAR = \"%s\"\n", yylval.string ); - else if( iRet == MACROTEXT ) - printf( " MACROTEXT = \"%s\"\n", yylval.string ); - else if( iRet == NUM_INTEGER ) - printf( " INTEGER = %i\n", yylval.valInteger.iNumber ); - else if( iRet == NUM_LONG ) - printf( " INTEGER = %il\n", yylval.valLong.lNumber ); - else if( iRet == NUM_DOUBLE ) - printf( " DOUBLE = %f\n", yylval.valDouble.dNumber ); - else if( iRet < 256 ) - { - if( iRet == '\n' || iRet == ';' ) - printf( "***NEW LINE %i\n", hb_comp_iLine - 1 ); - else if( iRet == -1 ) - printf( "!!!\n" ); - else - printf( " DELIMITER = \"%c\"\n", iRet ); - } - else - printf( " TOKEN = %i\n", iRet ); - #endif - - return iRet; -} - -static int hb_comp_SLX_ElementToken( char* szToken, unsigned int iTokenLen ) -{ - extern char *yytext; - extern int yyleng; - - char* tmpPtr; - int iRet; - - yytext = szToken; - yyleng = (int) iTokenLen; - - if( ( *yytext > 64 && *yytext < 91 ) || *yytext == '&' || *yytext == '_' ) - { - /* Macro. */ - if( ( tmpPtr = strrchr( yytext, '&' ) ) != NULL ) /* Right Search. */ - { - /* Is '&' the first char? - Since its was right search that would be the only '&'. */ - if( tmpPtr == yytext ) - { - /* Maybe just the Macro Operator. */ - if( yyleng == 1 ) - { - iRet = '&'; - } - /* No '.' so Simple Macro. */ - else if( ( tmpPtr = strchr( yytext, '.' ) ) == NULL ) /* Left Search. */ - { - /* Remove the '&'. */ - yytext++; - yyleng--; - - yylval.string = hb_compIdentifierNew( yytext, TRUE ); - iRet = MACROVAR; - } - else if( tmpPtr == yytext + yyleng - 1 ) - { - /* The only '.' is last char, so Simple Macro. */ - - /* Remove the '&' and the '.' */ - yytext++; - yyleng -= 2; - yytext[yyleng] = '\0'; - - yylval.string = hb_compIdentifierNew( yytext, TRUE ); - iRet = MACROVAR; - } - else - { - /* - yytext = hb_compIdentifierNew( yytext, TRUE ); - */ - yylval.string = hb_strdup( yytext ); - iRet = MACROTEXT; - } - } - else - { - /* - yytext = hb_compIdentifierNew( yytext, TRUE ); - */ - yylval.string = hb_strdup( yytext ); - iRet = MACROTEXT; - } - } - else - { - DEBUG_INFO( printf( "Element \"%s\" is IDENTIFIER\n", yytext ) ); - - if( yyleng > HB_SYMBOL_NAME_LEN ) - { - yytext[ HB_SYMBOL_NAME_LEN ] = '\0'; - yyleng = HB_SYMBOL_NAME_LEN; - } - - if( iIdentifier ) - { - DEBUG_INFO( printf( "*** iDentifier = %i - Holding %s\n", iIdentifier, yytext ) ); - sIdOnHold = hb_compIdentifierNew( yytext, TRUE ); - iRet = _ID_ON_HOLD; - } - else - { - iIdentifier++; - DEBUG_INFO( printf( "Primary Identifier %s Increased to: %i\n", yytext, iIdentifier ) ); - yylval.string = hb_compIdentifierNew( yytext, TRUE ); - iRet = IDENTIFIER; - } - } - } - else - { - /* ConverNumber */ - - HB_LONG lNumber; - double dNumber; - int iDec, iWidth; - - yylval.string = (char*) hb_xgrab( TOKEN_SIZE ); - yylval.string[0] = 0; - - iRet = hb_comp_SLX_Str2Num( yytext, &lNumber, &dNumber, &iDec, &iWidth ); - - if( !isdigit( yytext[0] ) && !( yytext[0] == '.' && isdigit( yytext[1] ) ) ) - { - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, yytext, NULL ); - return yytext[0]; - } - else if ( iRet == NUM_DOUBLE ) - { - yylval.valDouble.dNumber = dNumber; - yylval.valDouble.bDec = iDec; - yylval.valDouble.bWidth = iWidth; - yylval.valDouble.szValue = yytext; - } - else if( HB_LIM_INT16( lNumber ) ) - { - yylval.valInteger.iNumber = ( int ) lNumber; - yylval.valInteger.szValue = yytext; - iRet = NUM_INTEGER; - } - else - { - yylval.valLong.lNumber = lNumber; - yylval.valLong.szValue = yytext; - } - iRet += DONT_REDUCE; - } - - DEBUG_INFO( printf( "Element \"%s\" is %i\n", szToken, iRet ) ); - return iRet; -} - -static int hb_comp_SLX_Str2Num( char* szNum, HB_LONG * plVal, double * pdVal, int * piDec, int * piWidth ) -{ - BOOL fDbl; - - fDbl = hb_compStrToNum( szNum, strlen( szNum ), plVal, pdVal, piDec, piWidth ); - return fDbl ? NUM_DOUBLE : NUM_LONG; -} - -static int hb_comp_SLX_CustomAction( int x, int aiHold[], int *ptr_iHold, BOOL *ptr_bIgnoreWords, int iLastToken, char *sToken, char *s_szBuffer ) -{ - extern BOOL hb_pp_bInline; - - DEBUG_INFO( printf( "Custom Action for %i\n", x ) ); - - if( x < HB_WANTS_EXP ) - { - *ptr_bIgnoreWords = FALSE; - iWantsEXP = (-x) + (HB_WANTS_EXP) ; - return REJECT_OP; - } - else if( x < HB_WANTS_EOL ) - { - iWantsEOL = (-x) + (HB_WANTS_EOL) ; - return WANTS_EOL; - } - else if( x < HB_WANTS_ID ) - { - iWantsID = (-x) + (HB_WANTS_ID) ; - return WANTS_ID; - } - else if( x < HB_WANTS_VAR ) - { - iWantsVAR = (-x) + (HB_WANTS_VAR) ; - return WANTS_VAR; - } - - switch ( x ) - { - case HB_IDENTIFIER : - yylval.string = hb_compIdentifierNew( (char*) sToken, TRUE ); - iIdentifier++; - DEBUG_INFO( printf( "Primary Identifier %s Increased to: %i\n", (char*) sToken, iIdentifier ) ); - return IDENTIFIER + DONT_REDUCE; - - case HB_SELF : - aiHold[ (*ptr_iHold)++ ] = ':' + DONT_REDUCE ; - yylval.string = hb_compIdentifierNew( "SELF", TRUE ); - iIdentifier++; - DEBUG_INFO( printf( "HB_SELF, Primary Identifier %s Increased to: %i\n", "SELF", iIdentifier ) ); - return IDENTIFIER; - - case HB_CHK_BLOCK : - if( s_sLastBlock == NULL ) - { - char *pTmp = (char *) s_szBuffer; - - /* Skip White Space. */ - while( *pTmp && ( *pTmp == ' ' || *pTmp == '\t' ) ) - { - pTmp++; - } - - if( *pTmp == '|' ) - { - unsigned int iBrackets = 1; - char cTmp; - BOOL bMacro = FALSE; - - pTmp++; - while( *pTmp ) - { - if( *pTmp == '}' ) - { - iBrackets--; - if( iBrackets == 0 ) - { - break; - } - } - else if( *pTmp == '{' ) - { - iBrackets++; - } - else if( *pTmp == '&' ) - { - bMacro = TRUE; - } - - pTmp++; - } - - if( bMacro ) - { - pTmp++; - cTmp = *pTmp; - *pTmp = '\0'; - - s_sLastBlock = hb_compIdentifierNew( s_szBuffer - 1, TRUE ); - - *pTmp = cTmp; - } - } - } - return '{' + DONT_REDUCE; - - case HB_LIT_ACT : - yylval.string = hb_compIdentifierNew( sPair, TRUE ); - return LITERAL + DONT_REDUCE ; - - case HB_INIT_PROC : - aiHold[ (*ptr_iHold)++ ] = PROCEDURE + DONT_REDUCE; - return INIT + DONT_REDUCE; - - case HB_INIT_FUNC : - aiHold[ (*ptr_iHold)++ ] = FUNCTION + DONT_REDUCE; - return INIT + DONT_REDUCE; - - case HB_EXIT_PROC : - aiHold[ (*ptr_iHold)++ ] = PROCEDURE + DONT_REDUCE; - return EXIT + DONT_REDUCE; - - case HB_EXIT_FUNC : - aiHold[ (*ptr_iHold)++ ] = FUNCTION + DONT_REDUCE; - return EXIT + DONT_REDUCE; - - case HB_STATIC_PROC : - aiHold[ (*ptr_iHold)++ ] = PROCEDURE + DONT_REDUCE; - return STATIC + DONT_REDUCE; - - case HB_STATIC_FUNC : - aiHold[ (*ptr_iHold)++ ] = FUNCTION + DONT_REDUCE; - return STATIC + DONT_REDUCE; - - case HB_IN : - *ptr_bIgnoreWords = FALSE; - if( iLastToken == IDENTIFIER ) - { return IN + DONT_REDUCE; } - else - { - yylval.string = hb_compIdentifierNew( "IN", TRUE ); - iIdentifier++; - DEBUG_INFO( printf( "HB_IN, Primary Identifier %s Increased to: %i\n", "IN", iIdentifier ) ); - return IDENTIFIER; - } - - case HB_STEP : - *ptr_bIgnoreWords = FALSE; - if( iLastToken == NUM_INTEGER || iLastToken == NUM_LONG || iLastToken == NUM_DOUBLE || iLastToken == IDENTIFIER || iLastToken == MACROVAR || iLastToken == MACROTEXT || iLastToken == ')' || iLastToken == ']' ) - { return STEP + DONT_REDUCE; } - else - { - yylval.string = hb_compIdentifierNew( "STEP", TRUE ); - iIdentifier++; - DEBUG_INFO( printf( "HB_STEP, Primary Identifier %s Increased to: %i\n", "STEP", iIdentifier ) ); - return IDENTIFIER; - } - - case HB_TO : - *ptr_bIgnoreWords = FALSE; - if( iLastToken == NUM_INTEGER || iLastToken == NUM_LONG || iLastToken == NUM_DOUBLE || iLastToken == IDENTIFIER || iLastToken == MACROVAR || iLastToken == MACROTEXT || iLastToken == ')' || iLastToken == ']' ) - { return TO + DONT_REDUCE; } - else - { - yylval.string = hb_compIdentifierNew( "TO", TRUE ); - iIdentifier++; - DEBUG_INFO( printf( "HB_TO, Primary Identifier %s Increased to: %i\n", "IN", iIdentifier ) ); - return IDENTIFIER; - } - - case HB_WITH : - *ptr_bIgnoreWords = FALSE; - if( iLastToken == IDENTIFIER || iLastToken == MACROVAR || iLastToken == MACROTEXT || iLastToken == ')' ) - { return WITH + DONT_REDUCE; } - else - { - yylval.string = hb_compIdentifierNew( "WITH", TRUE ); - iIdentifier++; - DEBUG_INFO( printf( "HB_WITH, Primary Identifier %s Increased to: %i\n", "WITH", iIdentifier ) ); - return IDENTIFIER; - } - - case _WITH_ID_CR : - aiHold[ (*ptr_iHold)++ ] = '\n' + DONT_REDUCE; - yylval.string = hb_compIdentifierNew( "WITH", TRUE ); - iIdentifier++; - DEBUG_INFO( printf( "_WITH_ID_CR, Primary Identifier %s Increased to: %i\n", "WITH", iIdentifier ) ); - return IDENTIFIER + DONT_REDUCE; - - case _WITH_ID_SEMI : - aiHold[ (*ptr_iHold)++ ] = ';' + DONT_REDUCE; - yylval.string = hb_compIdentifierNew( "WITH", TRUE ); - iIdentifier++; - DEBUG_INFO( printf( "_WITH_ID_SEMI, Primary Identifier %s Increased to: %i\n", "WITH", iIdentifier ) ); - return IDENTIFIER + DONT_REDUCE; - - case HB_NESTED_LIT : - { - int iPairLen = strlen( sPair ); - - sPair[ iPairLen ] = sTerm[0]; - sPair[ iPairLen + 1 ] = '\0'; - yylval.string = hb_compIdentifierNew( sPair, TRUE ); - return LITERAL + DONT_REDUCE ; - } - - case HB_QOUT_ACT : - iIdentifier++; - DEBUG_INFO( printf( "HB_QOUT_ACT, Primary Identifier %s Increased to: %i\n", "QOUT", iIdentifier ) ); - yylval.string = hb_compIdentifierNew( "QOUT", TRUE ); - aiHold[ (*ptr_iHold)++ ] = _QOUT_LIT; - aiHold[ (*ptr_iHold)++ ] = '(' + DONT_REDUCE; - return IDENTIFIER + DONT_REDUCE; - - case HB_RET_QOUT_LIT : - yylval.string = hb_compIdentifierNew( sPair, TRUE ); - aiHold[ (*ptr_iHold)++ ] = '\n' + DONT_REDUCE; - aiHold[ (*ptr_iHold)++ ] = ')' + DONT_REDUCE; - return LITERAL + DONT_REDUCE ; - - case HB_DO_WHILE_ID : - iIdentifier++; - DEBUG_INFO( printf( "HB_DO_WHILE_ID, Primary Identifier %s Increased to: %i\n", "WHILE", iIdentifier ) ); - yylval.string = hb_compIdentifierNew( "WHILE", TRUE ); - aiHold[ (*ptr_iHold)++ ] = IDENTIFIER + DONT_REDUCE; - return DO + DONT_REDUCE; - - case HB_DO_WHILE_WITH : - aiHold[ (*ptr_iHold)++ ] = WITH + DONT_REDUCE; - yylval.string = hb_compIdentifierNew( "WHILE", TRUE ); - iIdentifier++; - DEBUG_INFO( printf( "HB_DO_WHILE_WITH, Primary Identifier %s Increased to: %i\n", "WHILE", iIdentifier ) ); - aiHold[ (*ptr_iHold)++ ] = IDENTIFIER + DONT_REDUCE; - return DO + DONT_REDUCE; - - case HB_DO_CASE_ID : - yylval.string = hb_compIdentifierNew( "CASE", TRUE ); - iIdentifier++; - DEBUG_INFO( printf( "HB_DO_CASE_ID, Primary Identifier %s Increased to: %i\n", "CASE", iIdentifier ) ); - aiHold[ (*ptr_iHold)++ ] = IDENTIFIER + DONT_REDUCE; - return DO + DONT_REDUCE; - - case HB_MACRO_ERR : - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, "&", NULL ); - return 0; - - case HB_ID_ON_HOLD : - yylval.string = sIdOnHold; - iIdentifier++; - DEBUG_INFO( printf( "RELEASED ID_ON_HOLD: %s - Increased to: %i\n", sIdOnHold, iIdentifier ) ); - return IDENTIFIER; - - case HB_INLINE : - - /* NOTE: hb_compiLineINLINE is being RESET in ppcomp.c - hb_pp_Internal() */ - - if( hb_comp_iLineINLINE ) - { - hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_TOOMANY_INLINE, "on the same line", NULL ); - iIdentifier++; - return IDENTIFIER + DONT_REDUCE; - } - else - { - #define INLINE_NORMAL 0 - #define INLINE_SINGLE_QUOT 1 - #define INLINE_DOUBLE_QUOT 2 - #define INLINE_COMMENT 3 - - char sBuffer[ YY_BUF_SIZE ], *pBuffer, sInlineSym[] = "HB_INLINE_0", cMode = INLINE_NORMAL; - int iSize, iBraces = 0; - PINLINE pInline; - - hb_comp_iLineINLINE = hb_comp_iLine; - hb_pp_bInline = TRUE; - - sInlineSym[10] = hb_comp_cInlineID++; - - switch( sInlineSym[10] ) - { - case '9' + 1 : - sInlineSym[10] = 'A'; - break; - - case 'Z' + 1 : - hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_TOOMANY_INLINE, NULL, NULL ); - break; - } - - pInline = hb_compInlineAdd( hb_compIdentifierNew( sInlineSym, TRUE ) ); - - DigestInline : - - YY_INPUT( (char*) sBuffer, iSize, YY_BUF_SIZE ); - if( iSize == 0 ) - { - hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_INVALID_INLINE, hb_comp_functions.pLast->szName, NULL ); - hb_pp_bInline = FALSE; - return '\n' + DONT_REDUCE; - } - pBuffer = (char*) sBuffer; - - while( *pBuffer ) - { - switch( cMode ) - { - case INLINE_NORMAL : - if( *pBuffer == '{' ) - { - iBraces++; - } - else if( *pBuffer == '}' && iBraces > 1 ) - { - iBraces--; - } - else if( *pBuffer == '}' ) - { - hb_pp_bInline = FALSE; - break; - } - else if( *pBuffer == '\'' ) - { - cMode = INLINE_SINGLE_QUOT; - } - else if( *pBuffer == '"' ) - { - cMode = INLINE_DOUBLE_QUOT; - } - else if( *pBuffer == '/' && *(pBuffer+1) == '/' ) - { - goto SaveInline; - } - else if( *pBuffer == '/' && *(pBuffer+1) == '*' ) - { - pBuffer++; - cMode = INLINE_COMMENT; - } - break; - - case INLINE_SINGLE_QUOT : - if( *pBuffer == '\\' ) - { - pBuffer++; - } - else if( *pBuffer == '\'' ) - { - cMode = INLINE_NORMAL; - } - break; - - case INLINE_DOUBLE_QUOT : - if( *pBuffer == '\\' ) - { - pBuffer++; - } - else if( *pBuffer == '"' ) - { - cMode = INLINE_NORMAL; - } - break; - - case INLINE_COMMENT : - if( *pBuffer == '*' && *(pBuffer+1) == '/' ) - { - pBuffer++; - cMode = INLINE_NORMAL; - } - break; - } - - pBuffer++; - } - - SaveInline : - - if( pInline->pCode == NULL ) - { - pInline->pCode = (unsigned char *) hb_xgrab( ( iSize = strlen( (char*) sBuffer ) ) + 1 ); - strcpy( (char *) pInline->pCode, (char*) sBuffer ); - } - else - { - pInline->pCode = (unsigned char *) hb_xrealloc( pInline->pCode, pInline->lPCodeSize + ( iSize = strlen( (char*) sBuffer ) ) + 1 ); - strcpy( (char *) (pInline->pCode + pInline->lPCodeSize), (char*) sBuffer ); - } - pInline->lPCodeSize += iSize; - - if( hb_pp_bInline ) - { - goto DigestInline; - } - else - { - if( hb_comp_iLanguage != LANG_C && hb_comp_iLanguage != LANG_OBJ_MODULE ) - { - hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_REQUIRES_C, NULL, NULL ); - hb_xfree( ( void * ) pInline->pCode ); - hb_xfree( ( void * ) pInline->szFileName ); - hb_xfree( ( void * ) pInline ); /* NOTE: szName will be released by hb_compSymbolKill() */ - } - - hb_comp_iLinePRG = hb_comp_iLine; - hb_comp_iLine = hb_comp_iLineINLINE; - - yylval.string = hb_compIdentifierNew( sInlineSym, TRUE ); - iIdentifier++; - DEBUG_INFO( printf( "INLINE, Primary Identifier %s Increased to: %i\n", "INLINE", iIdentifier ) ); - return IDENTIFIER + DONT_REDUCE; - } - } - - default: - printf( "WARNING! No Handler for Custom Action %i\n", x ); - } - - return x; -} - -int yy_lex_input( char *buffer, int iBufferSize ) -{ - HB_SYMBOL_UNUSED( iBufferSize ); - - if( ( hb_comp_iLine % 100 ) == 0 && hb_comp_bQuiet == FALSE ) - { - printf( "\r%i", hb_comp_iLine ); - fflush( stdout ); - } - - return hb_pp_Internal( buffer ); -} - -char * hb_comp_SLX_LastBlock( BOOL bReset ) -{ - if( bReset && s_sLastBlock ) - { - /* - hb_xfree( s_sLastBlock ); - */ - s_sLastBlock = NULL; - } - - return s_sLastBlock; -} diff --git a/harbour/source/compiler/harbour.sly b/harbour/source/compiler/harbour.sly deleted file mode 100644 index 0430873511..0000000000 --- a/harbour/source/compiler/harbour.sly +++ /dev/null @@ -1,2336 +0,0 @@ -%{ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Compiler YACC rules and actions - * - * Copyright 1999 Antonio Linares - * www - http://www.harbour-project.org - * - * 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 of the License, 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 program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit - * their web site at http://www.gnu.org/). - * - */ - -/* TODO list - * 1) Change the pcode generated by ::cVar from Self:cVar to QSELF():cVar - * The major problem to solve is how to support QSELF() inside a codeblock. - * 2) Support this syntax: nPtr := @Hello() - */ - -#include "hbcomp.h" -#undef alloca -#define alloca hb_xgrab -#undef malloc -#define malloc hb_xgrab -#undef free -#define free hb_xfree - -/* Compile using: bison -d -v harbour.y */ - -extern FILE *yyin; /* currently yacc parsed file */ -extern int hb_comp_iLine; /* currently parsed file line number */ -extern char *yytext; - -#ifdef __cplusplus -typedef struct yy_buffer_state *YY_BUFFER_STATE; -extern YY_BUFFER_STATE yy_create_buffer( FILE *, int ); /* yacc functions to manage multiple files */ -extern void yy_switch_to_buffer( YY_BUFFER_STATE ); /* yacc functions to manage multiple files */ -extern void yy_delete_buffer( YY_BUFFER_STATE ); /* yacc functions to manage multiple files */ -#else -extern void * yy_create_buffer( FILE *, int ); /* yacc functions to manage multiple files */ -extern void yy_switch_to_buffer( void * ); /* yacc functions to manage multiple files */ -extern void yy_delete_buffer( void * ); /* yacc functions to manage multiple files */ -#endif - -/* lex & yacc related prototypes */ -#if !defined(__GNUC__) && !defined(__IBMCPP__) - #if 0 - /* This makes BCC 551 fail with Bison 1.30, even with the - supplied harbour.simple file, which makes Bison 1.30 blow. - [vszakats] */ - void __yy_memcpy ( char*, const char*, unsigned int ); /* to satisfy Borland compiler */ - #endif -#endif -extern int yyparse( void ); /* main yacc parsing function */ -extern void yyerror( char * ); /* parsing error management function */ -extern int yylex( void ); /* main lex token function, called by yyparse() */ -#ifdef __cplusplus -extern "C" int yywrap( void ); -#else -extern int yywrap( void ); /* manages the EOF of current processed file */ -#endif - -static void hb_compLoopStart( void ); -static void hb_compLoopEnd( void ); -static void hb_compLoopLoop( void ); -static void hb_compLoopExit( void ); -static void hb_compLoopHere( void ); - -static void * hb_compElseIfGen( void * pFirstElseIf, ULONG ulOffset ); /* generates a support structure for elseifs pcode fixups */ -static void hb_compElseIfFix( void * pIfElseIfs ); /* implements the ElseIfs pcode fixups */ - -static void hb_compRTVariableAdd( HB_EXPR_PTR, BOOL ); -static void hb_compRTVariableGen( char * ); - -static void hb_compVariableDim( char *, HB_EXPR_PTR ); - -#ifdef HARBOUR_YYDEBUG - #define YYDEBUG 1 /* Parser debug information support */ -#endif - -typedef struct __ELSEIF -{ - ULONG ulOffset; - struct __ELSEIF * pNext; -} _ELSEIF, * PELSEIF; /* support structure for else if pcode fixups */ - -typedef struct _LOOPEXIT -{ - ULONG ulOffset; - int iLine; - USHORT wSeqCounter; - struct _LOOPEXIT * pLoopList; - struct _LOOPEXIT * pExitList; - struct _LOOPEXIT * pNext; -} LOOPEXIT, * PTR_LOOPEXIT; /* support structure for EXIT and LOOP statements */ - -typedef struct HB_RTVAR_ -{ - HB_EXPR_PTR pVar; - BOOL bPopValue; - struct HB_RTVAR_ *pNext; - struct HB_RTVAR_ *pPrev; -} HB_RTVAR, *HB_RTVAR_PTR; /* support structure for PUBLIC and PRIVATE statements */ - -USHORT hb_comp_wSeqCounter = 0; -USHORT hb_comp_wForCounter = 0; -USHORT hb_comp_wIfCounter = 0; -USHORT hb_comp_wWhileCounter = 0; -USHORT hb_comp_wCaseCounter = 0; - -char * hb_comp_buffer; /* yacc input buffer */ - -static PTR_LOOPEXIT hb_comp_pLoops = NULL; -static HB_RTVAR_PTR hb_comp_rtvars = NULL; - -static BOOL bTrancuateBaseArray = FALSE; -static HB_EXPR_PTR pGetArgList = NULL, pBaseArrayName = NULL, pGetVarArray; - -static BOOL s_bBlock = FALSE, s_bBlockMacro = FALSE, s_bBlockDeclared = FALSE, s_bSetGet; -static HB_EXPR_PTR pBlockSimple; - -extern int hb_compLocalGetPos( char * szVarName ); /* returns the order + 1 of a local variable */ -extern int hb_compStaticGetPos( char *, PFUNCTION ); /* return if passed name is a static variable */ -extern int hb_compFieldGetPos( char *, PFUNCTION ); /* return if passed name is a field variable */ -extern int hb_compMemvarGetPos( char *, PFUNCTION ); /* return if passed name is a memvar variable */ - -extern char * hb_comp_SLX_LastBlock( BOOL bReset ); - -char * hb_comp_szAnnounce = NULL; /* ANNOUNCEd procedure */ - -static void hb_compDebugStart( void ) { }; - -%} - -%union /* special structure used by lex and yacc to share info */ -{ - char * string; /* to hold a string returned by lex */ - int iNumber; /* to hold a temporary integer number */ - long lNumber; /* to hold a temporary long number */ - struct - { - int iNumber; /* to hold a number returned by lex */ - char * szValue; - } valInteger; - struct - { - long lNumber; /* to hold a long number returned by lex */ - char * szValue; - } valLong; - struct - { - double dNumber; /* to hold a double number returned by lex */ - /* NOTE: Intentionally using "unsigned char" instead of "BYTE" */ - unsigned char bWidth; /* to hold the width of the value */ - unsigned char bDec; /* to hold the number of decimal points in the value */ - char * szValue; - } valDouble; - HB_EXPR_PTR asExpr; - void * pVoid; /* to hold any memory structure we may need */ -}; - -%token FUNCTION PROCEDURE IDENTIFIER RETURN NIL NUM_DOUBLE INASSIGN NUM_INTEGER NUM_LONG -%token LOCAL STATIC IIF IF ELSE ELSEIF END ENDIF LITERAL TRUEVALUE FALSEVALUE -%token ANNOUNCE EXTERN INIT EXIT AND OR NOT PUBLIC EQ NE1 NE2 -%token INC DEC ALIASOP DOCASE CASE OTHERWISE ENDCASE ENDDO MEMVAR -%token WHILE LOOP END FOR NEXT TO STEP LE GE FIELD IN PARAMETERS -%token PLUSEQ MINUSEQ MULTEQ DIVEQ POWER EXPEQ MODEQ -%token PRIVATE BEGINSEQ BREAK RECOVER RECOVERUSING DO WITH SELF LINE -%token MACROVAR MACROTEXT -%token AS_ARRAY AS_BLOCK AS_CHARACTER AS_CLASS AS_DATE AS_LOGICAL AS_NUMERIC AS_OBJECT AS_VARIANT DECLARE OPTIONAL DECLARE_CLASS DECLARE_MEMBER -%token AS_ARRAY_ARRAY AS_BLOCK_ARRAY AS_CHARACTER_ARRAY AS_CLASS_ARRAY AS_DATE_ARRAY AS_LOGICAL_ARRAY AS_NUMERIC_ARRAY AS_OBJECT_ARRAY -%token PROCREQ GET - -/*the lowest precedence*/ -/*postincrement and postdecrement*/ -%left POST -/*assigment - from right to left*/ -%right INASSIGN -%right PLUSEQ MINUSEQ -%right MULTEQ DIVEQ MODEQ -%right EXPEQ -/*logical operators*/ -%right OR -%right AND -%right NOT -/*relational operators*/ -%right '=' '<' '>' EQ NE1 NE2 LE GE '$' -/*mathematical operators*/ -%right '+' '-' -%right '*' '/' '%' -%right POWER -%right UNARY -/*preincrement and predecrement*/ -%right PRE -/*special operators*/ -%right ALIASOP '&' '@' -%right '\n' ';' ',' -/*the highest precedence*/ - -%type IdentName IDENTIFIER LITERAL SendId MACROVAR MACROTEXT CompTimeStr -%type NUM_DOUBLE -%type NUM_INTEGER -%type NUM_LONG -%type FunScope -%type Params ParamList -%type IfBegin VarList ExtVarList -%type FieldList -%type WhileBegin -%type IfElseIf Cases -%type Argument ArgList ElemList BlockExpList BlockVarList BlockNoVar -%type DoName DoProc DoArgument DoArgList -%type PareExpList1 PareExpList2 PareExpList3 PareExpListN -%type ExpList ExpList1 ExpList2 ExpList3 -%type NumValue NumAlias -%type NilValue NilAlias -%type LiteralValue LiteralAlias -%type CodeBlock CodeBlockAlias -%type Logical LogicalAlias -%type SelfValue SelfAlias -%type Array ArrayAlias -%type ArrayAt ArrayAtAlias -%type Variable VarAlias -%type MacroVar MacroVarAlias -%type MacroExpr MacroExprAlias -%type AliasId AliasVar AliasExpr -%type VariableAt VariableAtAlias -%type FunCall FunCallAlias -%type ObjectData ObjectDataAlias -%type ObjectMethod ObjectMethodAlias -%type IfInline IfInlineAlias -%type PareExpList PareExpListAlias -%type Expression SimpleExpression LValue -%type EmptyExpression -%type ExprAssign ExprOperEq ExprPreOp ExprPostOp -%type ExprEqual ExprMath ExprBool ExprRelation ExprUnary -%type ExprPlusEq ExprMinusEq ExprMultEq ExprDivEq ExprModEq ExprExpEq -%type ArrayIndex IndexList -%type DimIndex DimList -%type FieldAlias FieldVarAlias -%type PostOp -%type Get GetVar GetA GetVarArray GetArgList - -%% - -Main : { hb_compLinePush(); } Source { } - | /* empty file */ - ; - -Source : Crlf - | VarDefs - | FieldsDef - | MemvarDef - | Declaration - | Function - | Statement - | Line - | ProcReq - | error Crlf { yyclearin; yyerrok; } - | Source Crlf - | Source VarDefs - | Source FieldsDef - | Source MemvarDef - | Source Declaration - | Source Function - | Source Statement - | Source Line - | Source ProcReq - | Source error Crlf { yyclearin; yyerrok; } - ; - -Line : LINE NUM_INTEGER LITERAL Crlf - | LINE NUM_INTEGER LITERAL '@' LITERAL Crlf /* Xbase++ style */ - ; - -ProcReq : PROCREQ CompTimeStr ')' Crlf {} - ; - -CompTimeStr: LITERAL { hb_compAutoOpenAdd( $1 ); } - | LITERAL '+' LITERAL { char szFileName[ _POSIX_PATH_MAX ]; sprintf( szFileName, "%s%s", $1, $3 ); hb_compAutoOpenAdd( szFileName ); } - ; - -Function : FunScope FUNCTION IdentName { hb_comp_cVarType = ' '; hb_compFunctionAdd( $3, ( HB_SYMBOLSCOPE ) $1, 0 ); } Params Crlf {} - | FunScope PROCEDURE IdentName { hb_comp_cVarType = ' '; hb_compFunctionAdd( $3, ( HB_SYMBOLSCOPE ) $1, FUN_PROCEDURE ); } Params Crlf {} - ; - -FunScope : { $$ = HB_FS_PUBLIC; } - | STATIC { $$ = HB_FS_STATIC; } - | INIT { $$ = HB_FS_INIT; } - | EXIT { $$ = HB_FS_EXIT; } - ; - -Params : { $$ = 0; } - | '(' ')' { $$ = 0; } - | '(' { hb_comp_iVarScope = VS_PARAMETER; } ParamList ')' { $$ = $3; } - ; - -AsType : /* not specified */ { hb_comp_cVarType = ' '; } - | StrongType - ; - -StrongType : AS_NUMERIC { hb_comp_cVarType = 'N'; } - | AS_CHARACTER { hb_comp_cVarType = 'C'; } - | AS_DATE { hb_comp_cVarType = 'D'; } - | AS_LOGICAL { hb_comp_cVarType = 'L'; } - | AS_BLOCK { hb_comp_cVarType = 'B'; } - | AS_OBJECT { hb_comp_cVarType = 'O'; } - | AS_CLASS IdentName { hb_comp_cVarType = 'S'; hb_comp_szFromClass = $2 } - | AS_VARIANT { hb_comp_cVarType = ' '; } - | AsArray - ; - -AsArray : AS_ARRAY { hb_comp_cVarType = 'A'; } - | AS_NUMERIC_ARRAY { hb_comp_cVarType = 'n'; } - | AS_CHARACTER_ARRAY { hb_comp_cVarType = 'c'; } - | AS_DATE_ARRAY { hb_comp_cVarType = 'd'; } - | AS_LOGICAL_ARRAY { hb_comp_cVarType = 'l'; } - | AS_ARRAY_ARRAY { hb_comp_cVarType = 'a'; } - | AS_BLOCK_ARRAY { hb_comp_cVarType = 'b'; } - | AS_OBJECT_ARRAY { hb_comp_cVarType = 'o'; } - | AS_CLASS_ARRAY IdentName { hb_comp_cVarType = 's'; hb_comp_szFromClass = $2 } - ; - -ParamList : IdentName AsType { hb_compVariableAdd( $1, hb_comp_cVarType ); $$ = 1; } - | ParamList ',' IdentName AsType { hb_compVariableAdd( $3, hb_comp_cVarType ); $$++; } - ; - -/* NOTE: This allows the use of Expression as a statement. - * The Expression is validated later in reduction phase of - * hb_compExprGenStatement(). With this solution we don't have to - * stop compilation if invalid syntax will be used. - */ -Statement : ExecFlow { hb_comp_bDontGenLineNum = TRUE; } CrlfStmnt { } - | IfInline CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | FunCall CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | AliasExpr CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ObjectMethod CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | MacroVar CrlfStmnt { if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_XBASE ) ) - hb_compExprDelete( hb_compExprGenStatement( $1 ) ); - else - hb_compExprDelete( hb_compErrorSyntax( $1 ) ); - } - | MacroExpr CrlfStmnt { if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_XBASE ) ) - hb_compExprDelete( hb_compExprGenStatement( $1 ) ); - else - hb_compExprDelete( hb_compErrorSyntax( $1 ) ); - } - | PareExpList CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ExprPreOp CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ExprPostOp CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ExprOperEq CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ExprEqual CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | ExprAssign CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | DoProc CrlfStmnt { hb_compExprDelete( hb_compExprGenStatement( $1 ) ); } - | BREAK CrlfStmnt { hb_compGenBreak(); hb_compGenPCode2( HB_P_DOSHORT, 0, ( BOOL ) 1 ); - hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } - | BREAK { hb_compLinePushIfInside(); } Expression Crlf { hb_compGenBreak(); hb_compExprDelete( hb_compExprGenPush( $3 ) ); - hb_compGenPCode2( HB_P_DOSHORT, 1, ( BOOL ) 1 ); - hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; - } - | RETURN CrlfStmnt { - if( hb_comp_wSeqCounter ) - { - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_EXIT_IN_SEQUENCE, "RETURN", NULL ); - } - hb_compGenPCode1( HB_P_ENDPROC ); - if( (hb_comp_functions.pLast->bFlags & FUN_PROCEDURE) == 0 ) - { /* return from a function without a return value */ - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NO_RETURN_VALUE, NULL, NULL ); - } - hb_comp_functions.pLast->bFlags |= FUN_WITH_RETURN; - hb_comp_bDontGenLineNum = TRUE; - hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; - } - | RETURN { hb_compLinePushIfInside(); hb_comp_cVarType = ' '; } Expression Crlf { - - hb_comp_cCastType = hb_comp_cVarType; - hb_comp_cVarType = ' '; - - if( hb_comp_wSeqCounter ) - { - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_EXIT_IN_SEQUENCE, "RETURN", NULL ); - } - hb_compExprGenPush( $3 ); /* TODO: check if return value agree with declared value */ - hb_compGenPCode2( HB_P_RETVALUE, HB_P_ENDPROC, ( BOOL ) 1 ); - if( hb_comp_functions.pLast->bFlags & FUN_PROCEDURE ) - { /* procedure returns a value */ - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PROC_RETURN_VALUE, NULL, NULL ); - } - hb_comp_functions.pLast->bFlags |= FUN_WITH_RETURN; - hb_comp_bDontGenLineNum = TRUE; - hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; - } - | PUBLIC { hb_compLinePushIfInside(); hb_comp_iVarScope = VS_PUBLIC; } - ExtVarList - { hb_compRTVariableGen( "__MVPUBLIC" ); hb_comp_cVarType = ' '; hb_comp_iVarScope = VS_NONE; } CrlfStmnt - | PRIVATE { hb_compLinePushIfInside(); hb_comp_iVarScope = VS_PRIVATE; } - ExtVarList - { hb_compRTVariableGen( "__MVPRIVATE" ); hb_comp_cVarType = ' '; hb_comp_iVarScope = VS_NONE; } CrlfStmnt - - | EXIT { hb_comp_bDontGenLineNum = TRUE; hb_compLoopExit(); } CrlfStmnt { hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } - | LOOP { hb_comp_bDontGenLineNum = TRUE; hb_compLoopLoop(); } CrlfStmnt { hb_comp_functions.pLast->bFlags |= FUN_BREAK_CODE; } - | EXTERN ExtList Crlf - | ANNOUNCE IdentName { - if( hb_comp_szAnnounce == NULL ) - { - /* check for reserved name - * NOTE: Clipper doesn't check for it - */ - char * szFunction = hb_compReservedName( $2 ); - if( szFunction ) - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_FUNC_RESERVED, szFunction, $2 ); - hb_comp_szAnnounce = $2; - } - else - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_DUPL_ANNOUNCE, $2, NULL ); - } Crlf - - ; - -CrlfStmnt : { hb_compLinePushIfInside(); } Crlf - ; - -LineStat : Crlf { $$ = 0; hb_comp_bDontGenLineNum = TRUE; } - | Statement { $$ = 1; } - | Declaration { $$ = 1; } - | Line { $$ = 1; } - ; - -Statements : LineStat { $$ = $1; } - | Statements LineStat { $$ += $2; } - ; - -ExtList : IdentName { hb_compExternAdd( $1 ); } - | ExtList ',' IdentName { hb_compExternAdd( $3 ); } - ; - -IdentName : IDENTIFIER { $$ = $1; } - ; - -/* Numeric values - */ -NumValue : NUM_DOUBLE { $$ = hb_compExprNewDouble( $1.dNumber, $1.bWidth, $1.bDec ); } - | NUM_INTEGER { $$ = hb_compExprNewLong( $1.iNumber ); } - | NUM_LONG { $$ = hb_compExprNewLong( $1.lNumber ); } - ; - -NumAlias : NUM_INTEGER ALIASOP { $$ = hb_compExprNewLong( $1.iNumber ); } - | NUM_LONG ALIASOP { $$ = hb_compExprNewLong( $1.lNumber ); } - | NUM_DOUBLE ALIASOP { $$ = hb_compErrorAlias( hb_compExprNewDouble( $1.dNumber, $1.bWidth, $1.bDec ) ); } - ; - -/* NIL value - */ -NilValue : NIL { $$ = hb_compExprNewNil(); } -; - -NilAlias : NilValue ALIASOP { $$ = $1; } -; - -/* Literal string value - */ -LiteralValue : LITERAL { $$ = hb_compExprNewString( $1 ); - if( bTrancuateBaseArray && pBaseArrayName == NULL ) - { char *pCopy = hb_strdup( $1 ), *pTmp = strchr( pCopy, '[' ); - if( pTmp ) - { - pCopy[ pTmp - pCopy ] = '\0'; - pBaseArrayName = hb_compExprNewString( pCopy ); - } - bTrancuateBaseArray = FALSE; - } - } - ; - -LiteralAlias : LiteralValue ALIASOP { $$ = $1; } -; - -/* Codeblock value - */ -CodeBlockAlias : CodeBlock ALIASOP { $$ = $1; } -; - -/* Logical value - */ -Logical : TRUEVALUE { $$ = hb_compExprNewLogical( TRUE ); } - | FALSEVALUE { $$ = hb_compExprNewLogical( FALSE ); } - ; - -LogicalAlias : Logical ALIASOP { $$ = $1; } -; - -/* SELF value and expressions - */ -SelfValue : SELF { $$ = hb_compExprNewSelf(); } -; - -SelfAlias : SelfValue ALIASOP { $$ = $1; } -; - -/* Literal array - */ -Array : '{' ElemList '}' { $$ = hb_compExprNewArray( $2 ); } - ; - -ArrayAlias : Array ALIASOP { $$ = $1; } -; - -/* Literal array access - */ -ArrayAt : Array ArrayIndex { $$ = $2; } -; - -ArrayAtAlias : ArrayAt ALIASOP { $$ = $1; } -; - -/* Variables - */ -Variable : IdentName { - $$ = hb_compExprNewVar( $1 ); - if( s_bBlock ) - { - s_bBlockDeclared = ( s_bBlockDeclared || hb_compLocalGetPos( $1 ) || hb_compStaticGetPos( $1, hb_comp_functions.pLast ) || ( hb_comp_bStartProc == FALSE && hb_compStaticGetPos( $1, hb_comp_functions.pFirst ) ) ); - } - } -; - -VarAlias : IdentName ALIASOP { $$ = hb_compExprNewAlias( $1 ); } -; - -/* Macro variables - */ -MacroVar : MACROVAR { $$ = hb_compExprNewMacro( NULL, '&', $1 ); - if( s_bBlock ) - { - s_bBlockDeclared = ( s_bBlockDeclared || hb_compLocalGetPos( $1 ) || hb_compStaticGetPos( $1, hb_comp_functions.pLast ) || ( hb_comp_bStartProc == FALSE && hb_compStaticGetPos( $1, hb_comp_functions.pFirst ) ) ); - s_bBlockMacro = TRUE; - } - } - | MACROTEXT { $$ = hb_compExprNewMacro( NULL, 0, $1 ); } - ; - -MacroVarAlias : MacroVar ALIASOP { $$ = $1; } -; - -/* Macro expressions - */ -MacroExpr : '&' PareExpList { $$ = hb_compExprNewMacro( $2, 0, NULL ); } -; - -MacroExprAlias : MacroExpr ALIASOP { $$ = $1; } -; - -/* Aliased variables - */ -/* special case: _FIELD-> and FIELD-> can be nested - */ -FieldAlias : FIELD ALIASOP { $$ = hb_compExprNewAlias( "FIELD" ); } - | FIELD ALIASOP FieldAlias { $$ = $3; } - ; - -/* ignore _FIELD-> or FIELD-> if a real alias is specified - */ -FieldVarAlias : FieldAlias VarAlias { hb_compExprDelete( $1 ); $$ = $2; } - | FieldAlias NumAlias { hb_compExprDelete( $1 ); $$ = $2; } - | FieldAlias PareExpListAlias { hb_compExprDelete( $1 ); $$ = $2; } - | FieldAlias MacroVarAlias { hb_compExprDelete( $1 ); $$ = $2; } - | FieldAlias MacroExprAlias { hb_compExprDelete( $1 ); $$ = $2; } - | FieldAlias NilAlias { hb_compExprDelete( $1 ); $$ = hb_compErrorAlias( $2 ); } - | FieldAlias LiteralAlias { hb_compExprDelete( $1 ); $$ = hb_compErrorAlias( $2 ); } - | FieldAlias LogicalAlias { hb_compExprDelete( $1 ); $$ = hb_compErrorAlias( $2 ); } - | FieldAlias CodeBlockAlias { hb_compExprDelete( $1 ); $$ = hb_compErrorAlias( $2 ); } - | FieldAlias SelfAlias { hb_compExprDelete( $1 ); $$ = hb_compErrorAlias( $2 ); } - | FieldAlias ArrayAlias { hb_compExprDelete( $1 ); $$ = hb_compErrorAlias( $2 ); } - | FieldAlias ArrayAtAlias { hb_compExprDelete( $1 ); $$ = hb_compErrorAlias( $2 ); } - | FieldAlias IfInlineAlias { hb_compExprDelete( $1 ); $$ = hb_compErrorAlias( $2 ); } - ; - -AliasId : IdentName { $$ = hb_compExprNewVar( $1 ); } - | MacroVar { $$ = $1; } - | MacroExpr { $$ = $1; } - ; - -AliasVar : NumAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2 ); } - | MacroVarAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2 ); } - | MacroExprAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2 ); } - | PareExpListAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2 ); } - | NilAlias AliasId { $$ = hb_compErrorAlias( $1 ); } - | LiteralAlias AliasId { $$ = hb_compErrorAlias( $1 ); } - | LogicalAlias AliasId { $$ = hb_compErrorAlias( $1 ); } - | CodeBlockAlias AliasId { $$ = hb_compErrorAlias( $1 ); } - | SelfAlias AliasId { $$ = hb_compErrorAlias( $1 ); } - | ArrayAlias AliasId { $$ = hb_compErrorAlias( $1 ); } - | ArrayAtAlias AliasId { $$ = hb_compErrorAlias( $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ - | VariableAtAlias AliasId { $$ = hb_compErrorAlias( $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ - | IfInlineAlias AliasId { $$ = hb_compErrorAlias( $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ - | FunCallAlias AliasId { $$ = hb_compErrorAlias( $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ - | ObjectDataAlias AliasId { $$ = hb_compErrorAlias( $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ - | ObjectMethodAlias AliasId { $$ = hb_compErrorAlias( $1 ); } /* QUESTION: Clipper reports error here - we can handle this */ - | VarAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2 ); } - | FieldAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2 ); } - | FieldVarAlias AliasId { $$ = hb_compExprNewAliasVar( $1, $2 ); } - ; - -/* Aliased expressions - */ -/* NOTE: In the case: - * alias->( Expression ) - * alias always selects a workarea at runtime - */ -AliasExpr : NumAlias PareExpList { $$ = hb_compExprNewAliasExpr( $1, $2 ); } - | VarAlias PareExpList { $$ = hb_compExprNewAliasExpr( $1, $2 ); } - | MacroVarAlias PareExpList { $$ = hb_compExprNewAliasExpr( $1, $2 ); } - | MacroExprAlias PareExpList { $$ = hb_compExprNewAliasExpr( $1, $2 ); } - | PareExpListAlias PareExpList { $$ = hb_compExprNewAliasExpr( $1, $2 ); } - | FieldAlias PareExpList { $$ = hb_compErrorAlias( $2 ); } /* QUESTION: Clipper reports error here - we can handle it */ - ; - -/* Array expressions access - */ -VariableAt : NilValue ArrayIndex { $$ = $2; } - | LiteralValue ArrayIndex { $$ = $2; } - | CodeBlock ArrayIndex { $$ = $2; } - | Logical ArrayIndex { $$ = $2; } - | SelfValue ArrayIndex { $$ = $2; } - | Variable ArrayIndex { $$ = $2; } - | AliasVar ArrayIndex { $$ = $2; } - | AliasExpr ArrayIndex { $$ = $2; } - | MacroVar ArrayIndex { $$ = $2; } - | MacroExpr ArrayIndex { $$ = $2; } - | ObjectData ArrayIndex { $$ = $2; } - | ObjectMethod ArrayIndex { $$ = $2; } - | FunCall ArrayIndex { $$ = $2; } - | IfInline ArrayIndex { $$ = $2; } - | PareExpList ArrayIndex { $$ = $2; } - ; - -VariableAtAlias : VariableAt ALIASOP { $$ = $1; } -; - -/* Function call - */ -FunCall : IdentName '(' ArgList ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( $1 ), $3 ); } - | MacroVar '(' ArgList ')' { $$ = hb_compExprNewFunCall( $1, $3 ); } - | MacroExpr '(' ArgList ')' { $$ = hb_compExprNewFunCall( $1, $3 ); } - | Get { $$ = $1 } - | GetA { $$ = $1 } - ; - -ArgList : Argument { $$ = hb_compExprNewArgList( $1 ); } - | ArgList ',' Argument { $$ = hb_compExprAddListExpr( $1, $3 ); } - ; - -Argument : EmptyExpression { $$ = $1; } - | '@' IdentName { $$ = hb_compExprNewVarRef( $2 ); } - | '@' IdentName '(' DummyArgList ')' { $$ = hb_compExprNewFunRef( $2 ); } - ; - -DummyArgList : DummyArgument {} - | DummyArgList ',' DummyArgument {} - ; - -DummyArgument : EmptyExpression {} - | '@' IdentName {} - | '@' IdentName '(' DummyArgList ')' {} - ; - -FunCallAlias : FunCall ALIASOP { $$ = $1; } -; - -/* Object's instance variable - */ -SendId : IdentName { $$ = $1; } - | MacroVar { $$ = "&"; hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_INVALID_SEND, "&", NULL); } - ; - -ObjectData : NumValue ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | NilValue ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | LiteralValue ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | CodeBlock ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | Logical ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | SelfValue ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | Array ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | ArrayAt ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | Variable ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | AliasVar ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | AliasExpr ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | MacroVar ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | MacroExpr ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | FunCall ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | IfInline ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | PareExpList ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | VariableAt ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | ObjectMethod ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - | ObjectData ':' SendId { $$ = hb_compExprNewSend( $1, $3 ); } - ; - -ObjectDataAlias : ObjectData ALIASOP { $$ = $1; } -; - -/* Object's method - */ -ObjectMethod : ObjectData '(' ArgList ')' { $$ = hb_compExprNewMethodCall( $1, $3 ); } - ; - -ObjectMethodAlias : ObjectMethod ALIASOP { $$ = $1; } -; - -/* NOTE: We have to distinguish IdentName here because it is repeated - * in DoArgument (a part of DO WITH .. statement) - * where it generates different action. - */ -SimpleExpression : - NumValue - | NilValue { $$ = $1; } - | LiteralValue { $$ = $1; } - | CodeBlock { $$ = $1; } - | Logical { $$ = $1; } - | SelfValue { $$ = $1; } - | SelfValue {hb_comp_cVarType = ' '} StrongType { $$ = $1; } - | Array { $$ = $1; } - | ArrayAt { $$ = $1; } - | AliasVar { $$ = $1; } - | MacroVar { $$ = $1; } - | MacroExpr { $$ = $1; } - | VariableAt { $$ = $1; } - | FunCall { $$ = $1; } - | FunCall {hb_comp_cVarType = ' '} StrongType { $$ = $1; } - | IfInline { $$ = $1; } - | ObjectData { $$ = $1; } - | ObjectData {hb_comp_cVarType = ' '} StrongType { $$ = $1; } - | ObjectMethod { $$ = $1; } - | ObjectMethod {hb_comp_cVarType = ' '} StrongType { $$ = $1; } - | AliasExpr { $$ = $1; } - | ExprAssign { $$ = $1; } - | ExprOperEq { $$ = $1; } - | ExprPostOp { $$ = $1; } - | ExprPreOp { $$ = $1; } - | ExprUnary { $$ = $1; } - | ExprMath { $$ = $1; } - | ExprBool { $$ = $1; } - | ExprRelation { $$ = $1; } - ; - -Expression : Variable { $$ = $1; } - | SimpleExpression { $$ = $1; } - | PareExpList { $$ = $1; } - | Variable { hb_comp_cVarType = ' ';} StrongType { $$ = $1; } - | PareExpList { hb_comp_cVarType = ' ';} StrongType { $$ = $1; } - ; - -EmptyExpression: /* nothing => nil */ { $$ = hb_compExprNewEmpty(); } - | Expression - ; - -LValue : IdentName { $$ = hb_compExprNewVar( $1 ); } - | AliasVar - | MacroVar - | MacroExpr - | ObjectData - | VariableAt - | PareExpList { $$ = hb_compExprListStrip( $1, NULL ); } - ; - -/* NOTE: PostOp can be used in one context only - it uses $0 rule - * (the rule that stands before PostOp) - */ -PostOp : INC { $$ = hb_compExprNewPostInc( $0 ); } - | DEC { $$ = hb_compExprNewPostDec( $0 ); } - ; - -/* NOTE: The rule: Expression Operator Expression - * that can be used standalone as a statement have to be written - * using all possible left values to resolve shift/reduce conflicts - */ -ExprPostOp : NumValue PostOp %prec POST { $$ = $2; } - | NilValue PostOp %prec POST { $$ = $2; } - | LiteralValue PostOp %prec POST { $$ = $2; } - | CodeBlock PostOp %prec POST { $$ = $2; } - | Logical PostOp %prec POST { $$ = $2; } - | SelfValue PostOp %prec POST { $$ = $2; } - | Array PostOp %prec POST { $$ = $2; } - | ArrayAt PostOp %prec POST { $$ = $2; } - | Variable PostOp %prec POST { $$ = $2; } - | MacroVar PostOp %prec POST { $$ = $2; } - | MacroExpr PostOp %prec POST { $$ = $2; } - | AliasVar PostOp %prec POST { $$ = $2; } - | AliasExpr PostOp %prec POST { $$ = $2; } - | VariableAt PostOp %prec POST { $$ = $2; } - | PareExpList PostOp %prec POST { $$ = $2; } - | IfInline PostOp %prec POST { $$ = $2; } - | FunCall PostOp %prec POST { $$ = $2; } - | ObjectData PostOp %prec POST { $$ = $2; } - | ObjectMethod PostOp %prec POST { $$ = $2; } - ; - -ExprPreOp : INC Expression %prec PRE { $$ = hb_compExprNewPreInc( $2 ); } - | DEC Expression %prec PRE { $$ = hb_compExprNewPreDec( $2 ); } - ; - -ExprUnary : NOT Expression { $$ = hb_compExprNewNot( $2 ); } - | '-' Expression %prec UNARY { $$ = hb_compExprNewNegate( $2 ); } - | '+' Expression %prec UNARY { $$ = $2; } - ; -/* -ExprAssign : Expression INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } -; -*/ - -ExprAssign : NumValue INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | NilValue INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | LiteralValue INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | CodeBlock INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | Logical INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | SelfValue INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | Array INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | ArrayAt INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | Variable INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); hb_comp_cCastType = hb_comp_cVarType; hb_comp_cVarType = ' ';} - | MacroVar INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | MacroExpr INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | AliasVar INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | AliasExpr INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | VariableAt INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); hb_comp_cCastType = hb_comp_cVarType; hb_comp_cVarType = ' ';} - | PareExpList INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | IfInline INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | FunCall INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - | ObjectData INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); hb_comp_cCastType = hb_comp_cVarType; hb_comp_cVarType = ' ';} - | ObjectMethod INASSIGN Expression { $$ = hb_compExprAssign( $1, $3 ); } - ; - -ExprEqual : NumValue '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | NilValue '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | LiteralValue '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | CodeBlock '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | Logical '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | SelfValue '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | Array '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | ArrayAt '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | Variable '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | MacroVar '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | MacroExpr '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | AliasVar '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | AliasExpr '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | VariableAt '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | PareExpList '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | IfInline '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | FunCall '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | ObjectData '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - | ObjectMethod '=' Expression %prec INASSIGN { $$ = hb_compExprAssign( $1, $3 ); } - ; - -ExprPlusEq : NumValue PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | NilValue PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | LiteralValue PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | CodeBlock PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | Logical PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | SelfValue PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | Array PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | ArrayAt PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | Variable PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | MacroVar PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | MacroExpr PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | AliasVar PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | AliasExpr PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | VariableAt PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | PareExpList PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | IfInline PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | FunCall PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | ObjectData PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - | ObjectMethod PLUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlusEq( $1 ), $3 ); } - ; - -ExprMinusEq : NumValue MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | NilValue MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | LiteralValue MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | CodeBlock MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | Logical MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | SelfValue MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | Array MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | ArrayAt MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | Variable MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | MacroVar MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | MacroExpr MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | AliasVar MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | AliasExpr MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | VariableAt MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | PareExpList MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | IfInline MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | FunCall MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | ObjectData MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - | ObjectMethod MINUSEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinusEq( $1 ), $3 ); } - ; - -ExprMultEq : NumValue MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | NilValue MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | LiteralValue MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | CodeBlock MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | Logical MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | SelfValue MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | Array MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | ArrayAt MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | Variable MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | MacroVar MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | MacroExpr MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | AliasVar MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | AliasExpr MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | VariableAt MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | PareExpList MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | IfInline MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | FunCall MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | ObjectData MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - | ObjectMethod MULTEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewMultEq( $1 ), $3 ); } - ; - -ExprDivEq : NumValue DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | NilValue DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | LiteralValue DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | CodeBlock DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | Logical DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | SelfValue DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | Array DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | ArrayAt DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | Variable DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | MacroVar DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | MacroExpr DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | AliasVar DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | AliasExpr DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | VariableAt DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | PareExpList DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | IfInline DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | FunCall DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | ObjectData DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - | ObjectMethod DIVEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewDivEq( $1 ), $3 ); } - ; - -ExprModEq : NumValue MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | NilValue MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | LiteralValue MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | CodeBlock MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | Logical MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | SelfValue MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | Array MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | ArrayAt MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | Variable MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | MacroVar MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | MacroExpr MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | AliasVar MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | AliasExpr MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | VariableAt MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | PareExpList MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | IfInline MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | FunCall MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | ObjectData MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - | ObjectMethod MODEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewModEq( $1 ), $3 ); } - ; - -ExprExpEq : NumValue EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | NilValue EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | LiteralValue EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | CodeBlock EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | Logical EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | SelfValue EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | Array EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | ArrayAt EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | Variable EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | MacroVar EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | MacroExpr EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | AliasVar EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | AliasExpr EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | VariableAt EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | PareExpList EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | IfInline EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | FunCall EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | ObjectData EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - | ObjectMethod EXPEQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewExpEq( $1 ), $3 ); } - ; - -ExprOperEq : ExprPlusEq { $$ = $1; } - | ExprMinusEq { $$ = $1; } - | ExprMultEq { $$ = $1; } - | ExprDivEq { $$ = $1; } - | ExprModEq { $$ = $1; } - | ExprExpEq { $$ = $1; } - ; - -ExprMath : Expression '+' Expression { $$ = hb_compExprSetOperand( hb_compExprNewPlus( $1 ), $3 ); } - | Expression '-' Expression { $$ = hb_compExprSetOperand( hb_compExprNewMinus( $1 ), $3 ); } - | Expression '*' Expression { $$ = hb_compExprSetOperand( hb_compExprNewMult( $1 ), $3 ); } - | Expression '/' Expression { $$ = hb_compExprSetOperand( hb_compExprNewDiv( $1 ), $3 ); } - | Expression '%' Expression { $$ = hb_compExprSetOperand( hb_compExprNewMod( $1 ), $3 ); } - | Expression POWER Expression { $$ = hb_compExprSetOperand( hb_compExprNewPower( $1 ), $3 ); } - ; - -ExprBool : Expression AND Expression { $$ = hb_compExprSetOperand( hb_compExprNewAnd( $1 ), $3 ); } - | Expression OR Expression { $$ = hb_compExprSetOperand( hb_compExprNewOr( $1 ), $3 ); } - ; - -ExprRelation: Expression EQ Expression { $$ = hb_compExprSetOperand( hb_compExprNewEQ( $1 ), $3 ); } - | Expression '<' Expression { $$ = hb_compExprSetOperand( hb_compExprNewLT( $1 ), $3 ); } - | Expression '>' Expression { $$ = hb_compExprSetOperand( hb_compExprNewGT( $1 ), $3 ); } - | Expression LE Expression { $$ = hb_compExprSetOperand( hb_compExprNewLE( $1 ), $3 ); } - | Expression GE Expression { $$ = hb_compExprSetOperand( hb_compExprNewGE( $1 ), $3 ); } - | Expression NE1 Expression { $$ = hb_compExprSetOperand( hb_compExprNewNE( $1 ), $3 ); } - | Expression NE2 Expression { $$ = hb_compExprSetOperand( hb_compExprNewNE( $1 ), $3 ); } - | Expression '$' Expression { $$ = hb_compExprSetOperand( hb_compExprNewIN( $1 ), $3 ); } - | Expression '=' Expression { $$ = hb_compExprSetOperand( hb_compExprNewEqual( $1 ), $3 ); } - ; - -ArrayIndex : IndexList ']' { $$ = $1; } - ; - -/* NOTE: $0 represents the expression before ArrayIndex - * Don't use ArrayIndex in other context than as an array index! - */ -IndexList : '[' Expression { $$ = hb_compExprNewArrayAt( $0, $2 ); } - | IndexList ',' Expression { $$ = hb_compExprNewArrayAt( $1, $3 ); } - | IndexList ']' '[' Expression { $$ = hb_compExprNewArrayAt( $1, $4 ); } - ; - -ElemList : Argument { $$ = hb_compExprNewList( $1 ); } - | ElemList ',' Argument { $$ = hb_compExprAddListExpr( $1, $3 ); } - ; - -Get : _Get_ GetVar ',' - { - if( s_bSetGet ) - { - HB_EXPR_PTR pSetGetBlock, pGetVar = $2, pIsNil, pIfList, pIIF; - - pIsNil = hb_compExprSetOperand( hb_compExprNewEQ( hb_compExprNewVar( "_1" ) ), hb_compExprNewNil() ); - - pIfList = hb_compExprNewList( pIsNil ); - pIfList = hb_compExprAddListExpr( pIfList, pGetVar ); - pIfList = hb_compExprAddListExpr( pIfList, hb_compExprAssign( pGetVar, hb_compExprNewVar( "_1" ) ) ); - - pIIF = hb_compExprNewIIF( pIfList ); - - pSetGetBlock = hb_compExprNewCodeBlock(NULL,0,0); - pSetGetBlock = hb_compExprCBVarAdd( pSetGetBlock, "_1", ' ' ); - - hb_compExprAddCodeblockExpr( pSetGetBlock, pIIF ); - - pGetArgList = hb_compExprNewArgList( pSetGetBlock ); - } - else - { - pGetArgList = hb_compExprNewArgList( hb_compExprNewNil() ); - } - } - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $5 ) ; /* Var Name */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $8 ) ; /* Picture */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $11 ); /* ValidBlock */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $14 ); /* WhenBlock */ } - GetAExt ')' - { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; } - - | _Get_ MACROVAR ',' { pGetArgList = hb_compExprNewArgList( hb_compExprNewNil() ); } - EmptyExpression { hb_compExprAddListExpr( pGetArgList, hb_compExprNewVar( $2 ) ) ; /* Var Name */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $8 ) ; /* Picture */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $11 ); /* ValidBlock */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $14 ); /* WhenBlock */ } - GetAExt ')' - { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; } - - | _Get_ MACROTEXT ',' { pGetArgList = hb_compExprNewArgList( hb_compExprNewNil() ); } - EmptyExpression { hb_compExprAddListExpr( pGetArgList, hb_compExprNewString( $2 ) ) ; /* Var Name */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $8 ) ; /* Picture */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $11 ); /* ValidBlock */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $14 ); /* WhenBlock */ } - GetAExt ')' - { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; } - - | _Get_ MacroExpr ',' { pGetArgList = hb_compExprNewArgList( hb_compExprNewNil() ); } - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $5 ) ; /* Var Name */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $8 ) ; /* Picture */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $11 ); /* ValidBlock */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $14 ); /* WhenBlock */ } - GetAExt ')' - { - /* TODO: Clipper allways error, but we can handle simple macros or macros with no declared symbols!!! */ - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_GET_COMPLEX_MACRO, NULL, NULL ); - $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GET"), pGetArgList ); pGetArgList = NULL; - } - ; - -GetVar : Variable - { - s_bSetGet = ( hb_compLocalGetPos( $1->value.asSymbol ) || - hb_compStaticGetPos( $1->value.asSymbol, hb_comp_functions.pLast ) || - ( hb_comp_bStartProc == FALSE && hb_compStaticGetPos( $1->value.asSymbol, hb_comp_functions.pFirst ) ) || - hb_compMemvarGetPos( $1->value.asSymbol, hb_comp_functions.pLast ) || - hb_compFieldGetPos( $1->value.asSymbol, hb_comp_functions.pLast ) ); - $$ = $1; - } - | AliasVar { s_bSetGet = TRUE; $$ = $1; } - | ObjectData { s_bSetGet = TRUE; $$ = $1; } - ; - -GetArgList : Argument { $$ = hb_compExprAddListExpr( pGetArgList, $1 ); } - | GetArgList ',' Argument { $$ = hb_compExprAddListExpr( pGetArgList, $3 ); } - ; - -_Get_ : GET { pBaseArrayName = NULL; } - ; - -GetA : _Get_ GetVarArray { pGetArgList = hb_compExprNewArgList( $2 ); bTrancuateBaseArray = TRUE; } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, ( pBaseArrayName ? pBaseArrayName : $5 ) ); bTrancuateBaseArray = FALSE; pBaseArrayName = NULL; /* Var Name */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $8 ) ; /* Picture */ } ',' - EmptyExpression { hb_compExprAddListExpr( pGetArgList, $11 ); /* ValidBlock */ } ',' - EmptyExpression { - HB_EXPR_PTR pArrayVar, pIndex; - - hb_compExprAddListExpr( pGetArgList, $14 ); /* WhenBlock */ - - // We need to scan the pGetVarArray backwards and build a list of the Index Expressions. - pArrayVar = HB_EXPR_USE( pGetVarArray->value.asList.pExprList, HB_EA_REDUCE ); - pIndex = HB_EXPR_USE( pGetVarArray->value.asList.pIndex, HB_EA_REDUCE ); - pIndex->pNext = NULL; - - while( pArrayVar->ExprType == HB_ET_ARRAYAT ) - { - pArrayVar->value.asList.pIndex->pNext = pIndex; - pIndex = pArrayVar->value.asList.pIndex; - pArrayVar = pArrayVar->value.asList.pExprList; - } - - pIndex = hb_compExprNewList( pIndex ); - - hb_compExprAddListExpr( pGetArgList, hb_compExprNewArray( pIndex ) ); /* Array with Index Expressions as 6th parameter */ - } - GetAExt ')' { $$ = hb_compExprNewFunCall( hb_compExprNewFunName( "__GETA"), pGetArgList ); pGetArgList = NULL; } - ; - -GetVarArray : Variable ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddCodeblockExpr( hb_compExprNewCodeBlock(NULL,0,0), $1 ); } - | ObjectData ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddCodeblockExpr( hb_compExprNewCodeBlock(NULL,0,0), $1 ); } - | AliasVar ArrayIndex { pGetVarArray = $2; $$ = hb_compExprAddCodeblockExpr( hb_compExprNewCodeBlock(NULL,0,0), $1 ); } - | MacroVar ArrayIndex { - pGetVarArray = $2; $$ = hb_compExprNewNil(); - - if( $1->value.asMacro.cMacroOp ) - { - pBaseArrayName = hb_compExprNewVar( $1->value.asMacro.szMacro ); - } - else - { - pBaseArrayName = hb_compExprNewString( $1->value.asMacro.szMacro ); - } - } - | MacroExpr ArrayIndex { $$ = hb_compExprNewNil(); - /* TODO: Clipper allways error, but we can handle simple macros or macros with no declared symbols!!! */ - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_GET_COMPLEX_MACRO, NULL, NULL ); - } - ; - -GetAExt : { /* Nothing*/ } - | ',' GetArgList - ; - -CodeBlock : '{' '|' { s_bBlock = TRUE; $$ = hb_compExprNewCodeBlock(NULL,0,0) } BlockNoVar '|' BlockExpList '}' - { - if( s_bBlockMacro ) - { - if( pBlockSimple && pBlockSimple->ExprType == HB_ET_MACRO && pBlockSimple->value.asMacro.SubType == HB_ET_MACRO_VAR ) - { - HB_EXPR_PTR pMacroVar, pBlockString; - - pMacroVar = hb_compExprNewVar( pBlockSimple->value.asMacro.szMacro ); - pBlockString = hb_compExprNewString( "{||" ); - pBlockString = hb_compExprSetOperand( hb_compExprNewPlus( pBlockString ), pMacroVar ); - pBlockString = hb_compExprSetOperand( hb_compExprNewPlus( pBlockString ), hb_compExprNewString( "}" ) ); - $$ = hb_compExprNewMacro( pBlockString, 0, NULL ); - } - else if( s_bBlockDeclared ) - { - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BLOCK, NULL, NULL ); - $$ = $3; - } - else - { - $$ = hb_compExprNewMacro( hb_compExprNewString( hb_comp_SLX_LastBlock( FALSE ) ), 0, NULL ); - } - } - else - { - $$ = $3; - } - hb_comp_SLX_LastBlock( TRUE ); - s_bBlock = FALSE; s_bBlockMacro = FALSE; s_bBlockDeclared = FALSE; - } - - | '{' '|' { s_bBlock = TRUE; $$ = hb_compExprNewCodeBlock(NULL,0,0); } BlockVarList '|' BlockExpList '}' - { - if( s_bBlockMacro ) - { - if( pBlockSimple && pBlockSimple->ExprType == HB_ET_MACRO && pBlockSimple->value.asMacro.SubType == HB_ET_MACRO_VAR ) - { - HB_EXPR_PTR pMacroVar, pBlockString; - - pMacroVar = hb_compExprNewVar( pBlockSimple->value.asMacro.szMacro ); - pBlockString = hb_compExprNewString( "{||" ); - pBlockString = hb_compExprSetOperand( hb_compExprNewPlus( pBlockString ), pMacroVar ); - pBlockString = hb_compExprSetOperand( hb_compExprNewPlus( pBlockString ), hb_compExprNewString( "}" ) ); - $$ = hb_compExprNewMacro( pBlockString, 0, NULL ); - } - else if( s_bBlockDeclared ) - { - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_BLOCK, NULL, NULL ); - $$ = $3; - } - else - { - $$ = hb_compExprNewMacro( hb_compExprNewString( hb_comp_SLX_LastBlock( FALSE ) ), 0, NULL ); - } - } - else - { - $$ = $3; - } - hb_comp_SLX_LastBlock( TRUE ); - s_bBlock = FALSE; s_bBlockMacro = FALSE; s_bBlockDeclared = FALSE; - } - ; - -/* NOTE: This uses $-2 then don't use BlockExpList in other context - */ -BlockExpList : Expression { pBlockSimple = $1; $$ = hb_compExprAddCodeblockExpr( $-2, $1 ); } - | BlockExpList ',' Expression { pBlockSimple = NULL; $$ = hb_compExprAddCodeblockExpr( $-2, $3 ); } - ; - -/* NOTE: This is really not needed however it allows the use of $-2 item - * in BlockExpList to refer the same rule defined in Codeblock - */ -BlockNoVar : /* empty list */ { $$ = NULL; } -; - -BlockVarList : IdentName AsType { hb_comp_iVarScope = VS_LOCAL; $$ = hb_compExprCBVarAdd( $0, $1, hb_comp_cVarType ); hb_comp_cVarType = ' '; } - | BlockVarList ',' IdentName AsType { hb_comp_iVarScope = VS_LOCAL; $$ = hb_compExprCBVarAdd( $0, $3, hb_comp_cVarType ); hb_comp_cVarType = ' '; } - ; - -/* There is a conflict between the use of IF( Expr1, Expr2, Expr3 ) - * and parenthesized expression ( Expr1, Expr2, Expr3 ) - * To solve this conflict we have to split the definitions into more - * atomic ones. - * Also the generation of pcodes have to be delayed and moved to the - * end of whole parenthesized expression. - */ -PareExpList1: ExpList1 ')' { $$ = $1; } - ; - -PareExpList2: ExpList2 ')' { $$ = $1; } - ; - -PareExpList3: ExpList3 ')' { $$ = $1; } - ; - -PareExpListN: ExpList ')' { $$ = $1; } - ; - -PareExpList : PareExpList1 { $$ = $1; } - | PareExpList2 { $$ = $1; } - | PareExpList3 { $$ = $1; } - | PareExpListN { $$ = $1; } - ; - -PareExpListAlias : PareExpList ALIASOP { $$ = $1; } -; - -ExpList1 : '(' EmptyExpression { $$ = hb_compExprNewList( $2 ); } -; - -ExpList2 : ExpList1 ',' EmptyExpression { $$ = hb_compExprAddListExpr( $1, $3 ); } -; - -ExpList3 : ExpList2 ',' EmptyExpression { $$ = hb_compExprAddListExpr( $1, $3 ); } -; - -ExpList : ExpList3 ',' EmptyExpression { $$ = hb_compExprAddListExpr( $1, $3 ); } - | ExpList ',' EmptyExpression { $$ = hb_compExprAddListExpr( $1, $3 ); } - ; - -IfInline : IIF PareExpList3 { $$ = hb_compExprNewIIF( $2 ); } - | IF ExpList1 ',' EmptyExpression ',' - { $$ = hb_compExprAddListExpr( $2, $4 ); } - EmptyExpression ')' - { $$ = hb_compExprNewIIF( hb_compExprAddListExpr( $6, $7 ) ); } - ; - -IfInlineAlias : IfInline ALIASOP { $$ = $1; } -; - -VarDefs : LOCAL { hb_comp_iVarScope = VS_LOCAL; hb_compLinePush(); } VarList Crlf { hb_comp_cVarType = ' '; } - | STATIC { hb_comp_iVarScope = VS_STATIC; hb_compLinePush(); } VarList Crlf { hb_comp_cVarType = ' '; } - | PARAMETERS { if( hb_comp_functions.pLast->bFlags & FUN_USES_LOCAL_PARAMS ) - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_PARAMETERS_NOT_ALLOWED, NULL, NULL ); - else - hb_comp_functions.pLast->wParamNum=0; hb_comp_iVarScope = ( VS_PRIVATE | VS_PARAMETER ); } - MemvarList Crlf { hb_comp_iVarScope = VS_NONE; } - ; - -VarList : VarDef { $$ = 1; } - | VarList ',' VarDef { $$++; } - ; - -ExtVarList : ExtVarDef { $$ = 1; } - | ExtVarList ',' ExtVarDef { $$++; } - ; - -/* NOTE: if STATIC or LOCAL variables are declared and initialized then we can - * assign a value immediately - however for PRIVATE and PUBLIC variables - * initialization have to be delayed because we have to create these variables - * first. - */ -ExtVarDef : VarDef - | MacroVar AsType - { hb_compRTVariableAdd( hb_compExprNewRTVar( NULL, $1 ), FALSE ); } - | MacroVar AsType INASSIGN Expression - { hb_compExprDelete( hb_compExprGenPush( $4 ) ); - hb_compRTVariableAdd( hb_compExprNewRTVar( NULL, $1 ), TRUE ); - } - | MacroVar DimList - { - USHORT uCount = (USHORT) hb_compExprListLen( $2 ); - hb_compExprDelete( hb_compExprGenPush( $2 ) ); - hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), ( BOOL ) 1 ); - hb_compRTVariableAdd( hb_compExprNewRTVar( NULL, $1 ), TRUE ); - } - | MacroVar DimList AsArray - { - USHORT uCount = (USHORT) hb_compExprListLen( $2 ); - hb_compExprDelete( hb_compExprGenPush( $2 ) ); - hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), ( BOOL ) 1 ); - hb_compRTVariableAdd( hb_compExprNewRTVar( NULL, $1 ), TRUE ); - } - ; - -VarDef : IdentName AsType { hb_compVariableAdd( $1, hb_comp_cVarType ); } - { - if( hb_comp_iVarScope == VS_STATIC ) - { - hb_compStaticDefStart(); /* switch to statics pcode buffer */ - hb_compStaticDefEnd(); - } - else if( hb_comp_iVarScope == VS_PUBLIC || hb_comp_iVarScope == VS_PRIVATE ) - { - hb_compRTVariableAdd( hb_compExprNewRTVar( $1, NULL ), FALSE ); - } - } - - | IdentName AsType { $$ = hb_comp_iVarScope; - hb_compVariableAdd( $1, hb_comp_cVarType ); - } - INASSIGN {hb_comp_cVarType = ' ';} Expression - { - hb_comp_cCastType = hb_comp_cVarType; - hb_comp_cVarType = ' '; - - hb_comp_iVarScope = $3; - if( hb_comp_iVarScope == VS_STATIC ) - { - hb_compStaticDefStart(); /* switch to statics pcode buffer */ - hb_compExprDelete( hb_compExprGenStatement( hb_compExprAssignStatic( hb_compExprNewVar( $1 ), $6 ) ) ); - hb_compStaticDefEnd(); - } - else if( hb_comp_iVarScope == VS_PUBLIC || hb_comp_iVarScope == VS_PRIVATE ) - { - hb_compExprDelete( hb_compExprGenPush( $6 ) ); - hb_compRTVariableAdd( hb_compExprNewRTVar( $1, NULL ), TRUE ); - } - else - { - hb_compExprDelete( hb_compExprGenStatement( hb_compExprAssign( hb_compExprNewVar( $1 ), $6 ) ) ); - } - hb_comp_iVarScope = $3; - } - - | IdentName DimList { hb_compVariableDim( $1, $2 ); } - | IdentName DimList AsArray { hb_compVariableDim( $1, $2 ); } - ; - -/* NOTE: DimList and DimIndex is the same as ArrayIndex and IndexList - * however we are using quite different actions here - */ -DimList : DimIndex ']' { $$ = $1; } - ; - -DimIndex : '[' Expression { $$ = hb_compExprNewArgList( $2 ); } - | DimIndex ',' Expression { $$ = hb_compExprAddListExpr( $1, $3 ); } - | DimIndex ']' '[' Expression { $$ = hb_compExprAddListExpr( $1, $4 ); } - ; - - -FieldsDef : FIELD { hb_comp_iVarScope = VS_FIELD; } FieldList Crlf { hb_comp_cVarType = ' '; } - ; - -FieldList : IdentName AsType { $$=hb_compFieldsCount(); hb_compVariableAdd( $1, hb_comp_cVarType ); } - | FieldList ',' IdentName AsType { hb_compVariableAdd( $3, hb_comp_cVarType ); } - | FieldList IN IdentName { hb_compFieldSetAlias( $3, $1 ); } - ; - -MemvarDef : MEMVAR { hb_comp_iVarScope = VS_MEMVAR; } MemvarList Crlf { hb_comp_cVarType = ' '; } - ; - -MemvarList : IdentName AsType { hb_compVariableAdd( $1, hb_comp_cVarType ); } - | MemvarList ',' IdentName AsType { hb_compVariableAdd( $3, hb_comp_cVarType ); } - ; - -Declaration: DECLARE IdentName '(' { hb_compDeclaredAdd( $2 ); hb_comp_szDeclaredFun = $2; } DecList ')' AsType Crlf - { - if( hb_comp_pLastDeclared ) - { - hb_comp_pLastDeclared->cType = hb_comp_cVarType; - - if ( toupper( hb_comp_cVarType ) == 'S' ) - { - hb_comp_pLastDeclared->pClass = hb_compClassFind( hb_comp_szFromClass ); - if( ! hb_comp_pLastDeclared->pClass ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szFromClass, hb_comp_pLastDeclared->szName ); - hb_comp_pLastDeclared->cType = ( isupper( ( int ) hb_comp_cVarType ) ? 'O' : 'o' ); - } - - /* Resetting */ - hb_comp_szFromClass = NULL; - } - } - hb_comp_szDeclaredFun = NULL; - hb_comp_cVarType = ' '; - hb_comp_iVarScope = VS_NONE; - } - | DECLARE IdentName { hb_comp_pLastClass = hb_compClassAdd( $2 ); } ClassInfo Crlf { hb_comp_iVarScope = VS_NONE; } - | DECLARE_CLASS IdentName Crlf { hb_comp_pLastClass = hb_compClassAdd( $2 ); hb_comp_iVarScope = VS_NONE; } - | DECLARE_MEMBER DecMethod Crlf { hb_comp_iVarScope = VS_NONE; } - | DECLARE_MEMBER '{' AsType { hb_comp_cDataListType = hb_comp_cVarType; } DecDataList '}' Crlf { hb_comp_cDataListType = 0; hb_comp_iVarScope = VS_NONE; } - ; - -DecDataList: DecData - | DecDataList ',' DecData - ; - -ClassInfo : DecMethod - | ClassInfo DecMethod - | DecData - | ClassInfo DecData - ; - -DecMethod : IdentName '(' { hb_comp_pLastMethod = hb_compMethodAdd( hb_comp_pLastClass, $1 ); } DecList ')' AsType - { - if( hb_comp_pLastMethod ) - { - hb_comp_pLastMethod->cType = hb_comp_cVarType; - if ( toupper( hb_comp_cVarType ) == 'S' ) - { - hb_comp_pLastMethod->pClass = hb_compClassFind( hb_comp_szFromClass ); - if( ! hb_comp_pLastMethod->pClass ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szFromClass, hb_comp_pLastMethod->szName ); - hb_comp_pLastMethod->cType = ( isupper( ( int ) hb_comp_cVarType ) ? 'O' : 'o' ); - } - - hb_comp_szFromClass = NULL; - } - } - hb_comp_pLastMethod = NULL; - hb_comp_cVarType = ' '; - } - ; - -DecData : IdentName { hb_comp_pLastMethod = hb_compMethodAdd( hb_comp_pLastClass, $1 ); } AsType - { - if( hb_comp_pLastMethod ) - { - PCOMCLASS pClass; - char * szSetData = ( char * ) hb_xgrab( strlen( $1 ) + 2 ); - - /* List Type overrides if exists. */ - if( hb_comp_cDataListType ) hb_comp_cVarType = hb_comp_cDataListType; - - hb_comp_pLastMethod->cType = hb_comp_cVarType; - if ( toupper( hb_comp_cVarType ) == 'S' ) - { - pClass = hb_compClassFind( hb_comp_szFromClass ); - hb_comp_pLastMethod->pClass = pClass; - if( ! hb_comp_pLastMethod->pClass ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szFromClass, hb_comp_pLastMethod->szName ); - hb_comp_pLastMethod->cType = ( isupper( ( int ) hb_comp_cVarType ) ? 'O' :'o' ); - } - } - else - pClass = NULL; - - sprintf( szSetData, "_%s", $1 ); - - hb_comp_pLastMethod = hb_compMethodAdd( hb_comp_pLastClass, szSetData ); - hb_comp_pLastMethod->cType = hb_comp_cVarType; - hb_comp_pLastMethod->iParamCount = 1; - - hb_comp_pLastMethod->cParamTypes = ( BYTE * ) hb_xgrab( 1 ); - hb_comp_pLastMethod->cParamTypes[0] = hb_comp_cVarType; - - hb_comp_pLastMethod->pParamClasses = ( PCOMCLASS * ) hb_xgrab( sizeof( COMCLASS ) ); - hb_comp_pLastMethod->pParamClasses[0] = pClass; - - if ( toupper( hb_comp_cVarType ) == 'S' ) - { - hb_comp_pLastMethod->pClass = pClass; - hb_comp_szFromClass = NULL; - } - } - - hb_comp_pLastMethod = NULL; - hb_comp_cVarType = ' '; - } - ; - -DecList : /* Nothing */ {} - | FormalList - | OptList - | FormalList ',' OptList - ; - -FormalList : IdentName AsType { hb_compDeclaredParameterAdd( $1, hb_comp_cVarType ); } - | '@' IdentName AsType { hb_compDeclaredParameterAdd( $2, hb_comp_cVarType + VT_OFFSET_BYREF ); } - | '@' IdentName '(' DummyArgList ')' { hb_compDeclaredParameterAdd( $2, 'F' ); } - | FormalList ',' IdentName AsType { hb_compDeclaredParameterAdd( $3, hb_comp_cVarType ); } - | FormalList ',' '@' IdentName AsType { hb_compDeclaredParameterAdd( $4, hb_comp_cVarType + VT_OFFSET_BYREF ); } - | FormalList ',' '@' IdentName '(' DummyArgList ')' { hb_compDeclaredParameterAdd( $4, 'F' ); } - ; - -OptList : OPTIONAL IdentName AsType { hb_compDeclaredParameterAdd( $2, hb_comp_cVarType + VT_OFFSET_OPTIONAL ); } - | OPTIONAL '@' IdentName AsType { hb_compDeclaredParameterAdd( $3, hb_comp_cVarType + VT_OFFSET_OPTIONAL + VT_OFFSET_BYREF ); } - | OPTIONAL '@' IdentName '(' DummyArgList ')' { hb_compDeclaredParameterAdd( $3, hb_comp_cVarType + VT_OFFSET_OPTIONAL + VT_OFFSET_BYREF ); } - | OptList ',' OPTIONAL IdentName AsType { hb_compDeclaredParameterAdd( $4, hb_comp_cVarType + VT_OFFSET_OPTIONAL ); } - | OptList ',' OPTIONAL '@' IdentName AsType { hb_compDeclaredParameterAdd( $5, hb_comp_cVarType + VT_OFFSET_OPTIONAL + VT_OFFSET_BYREF ); } - | OptList ',' OPTIONAL '@' IdentName '(' DummyArgList ')' { hb_compDeclaredParameterAdd( $5, hb_comp_cVarType + VT_OFFSET_OPTIONAL + VT_OFFSET_BYREF ); } - ; - -ExecFlow : IfEndif - | DoCase - | DoWhile - | ForNext - | BeginSeq - ; - -IfEndif : IfBegin EndIf { hb_compGenJumpHere( $1 ); } - | IfBegin IfElse EndIf { hb_compGenJumpHere( $1 ); } - | IfBegin IfElseIf EndIf { hb_compGenJumpHere( $1 ); hb_compElseIfFix( $2 ); } - | IfBegin IfElseIf IfElse EndIf { hb_compGenJumpHere( $1 ); hb_compElseIfFix( $2 ); } - ; - -EmptyStatements : LineStat { $$ = $1; } - | EmptyStatements LineStat { $$ += $2; } - ; - -EmptyStats : /* empty */ { $$ = 0; } - | EmptyStatements { $$ = $1; } - ; - -IfBegin : IF SimpleExpression { ++hb_comp_wIfCounter; hb_compLinePush(); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2 ) ); $$ = hb_compGenJumpFalse( 0 ); } - EmptyStats - { $$ = hb_compGenJump( 0 ); hb_compGenJumpHere( $5 ); } - - | IF Variable { ++hb_comp_wIfCounter; hb_compLinePush(); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2 ) ); $$ = hb_compGenJumpFalse( 0 ); } - EmptyStats - { $$ = hb_compGenJump( 0 ); hb_compGenJumpHere( $5 ); } - - | IF PareExpList1 { ++hb_comp_wIfCounter; hb_compLinePush(); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2 ) ); $$ = hb_compGenJumpFalse( 0 ); } - EmptyStats - { $$ = hb_compGenJump( 0 ); hb_compGenJumpHere( $5 ); } - - | IF PareExpList2 { ++hb_comp_wIfCounter; hb_compLinePush(); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2 ) ); $$ = hb_compGenJumpFalse( 0 ); } - EmptyStats - { $$ = hb_compGenJump( 0 ); hb_compGenJumpHere( $5 ); } - - | IF PareExpListN { ++hb_comp_wIfCounter; hb_compLinePush(); } Crlf { hb_compExprDelete( hb_compExprGenPush( $2 ) ); $$ = hb_compGenJumpFalse( 0 ); } - EmptyStats - { $$ = hb_compGenJump( 0 ); hb_compGenJumpHere( $5 ); } - ; - -IfElse : ELSE Crlf { hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; } - EmptyStats - ; - -IfElseIf : ELSEIF { hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; hb_compLinePush(); } Expression Crlf - { hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; - hb_compExprDelete( hb_compExprGenPush( $3 ) ); - $$ = hb_compGenJumpFalse( 0 ); - } - EmptyStats - { $$ = hb_compElseIfGen( NULL, hb_compGenJump( 0 ) ); - hb_compGenJumpHere( $5 ); - } - - | IfElseIf ELSEIF { hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; hb_compLinePush(); } Expression Crlf - { hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; - hb_compExprDelete( hb_compExprGenPush( $4 ) ); - $$ = hb_compGenJumpFalse( 0 ); - } - EmptyStats - { $$ = hb_compElseIfGen( $1, hb_compGenJump( 0 ) ); - hb_compGenJumpHere( $6 ); - } - ; - -EndIf : ENDIF { --hb_comp_wIfCounter; hb_comp_functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); } - | END { --hb_comp_wIfCounter; hb_comp_functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); } - ; - -DoCase : DoCaseBegin - Cases - EndCase { hb_compElseIfFix( $2 ); } - - | DoCaseBegin - Otherwise - EndCase - - | DoCaseBegin - EndCase - - | DoCaseBegin - Cases - Otherwise - EndCase { hb_compElseIfFix( $2 ); } - ; - -EndCase : ENDCASE - { --hb_comp_wCaseCounter; - hb_comp_functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); - } - | END - { --hb_comp_wCaseCounter; - hb_comp_functions.pLast->bFlags &= ~ ( FUN_WITH_RETURN | FUN_BREAK_CODE ); - } - ; - -DoCaseStart : DOCASE { ++hb_comp_wCaseCounter; } Crlf - ; - -DoCaseBegin : DoCaseStart { } - | DoCaseStart Statements { - if( $2 > 0 ) - { - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_MAYHEM_IN_CASE, NULL, NULL ); - } - } - ; - -Cases : CASE { hb_compLinePush(); } Expression Crlf - { - hb_compExprDelete( hb_compExprGenPush( $3 ) ); - $$ = hb_compGenJumpFalse( 0 ); - } - EmptyStats - { - hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; - $$ = hb_compElseIfGen( 0, hb_compGenJump( 0 ) ); - hb_compGenJumpHere( $5 ); - } - - | Cases CASE { hb_compLinePush(); } Expression Crlf - { - hb_compExprDelete( hb_compExprGenPush( $4 ) ); - $$ = hb_compGenJumpFalse( 0 ); - } - EmptyStats - { - hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; - $$ = hb_compElseIfGen( $1, hb_compGenJump( 0 ) ); - hb_compGenJumpHere( $6 ); - } - ; - -Otherwise : OTHERWISE Crlf { hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; } - EmptyStats - | Otherwise OTHERWISE { hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_MAYHEM_IN_CASE, NULL, NULL ); } Crlf - EmptyStats - ; - -DoWhile : WhileBegin Expression Crlf - { - hb_compExprDelete( hb_compExprGenPush( $2 ) ); - $$ = hb_compGenJumpFalse( 0 ); - } - EmptyStats - { - hb_compLoopHere(); - hb_compGenJump( $1 - hb_comp_functions.pLast->lPCodePos ); - } - EndWhile - { - hb_compGenJumpHere( $4 ); --hb_comp_wWhileCounter; - hb_compLoopEnd(); - hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; - } - ; - -WhileBegin : WHILE { $$ = hb_comp_functions.pLast->lPCodePos; hb_compLinePushIfInside(); ++hb_comp_wWhileCounter; hb_compLoopStart(); } - ; - -EndWhile : END { hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; } - | ENDDO { hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; } - ; - -ForNext : FOR LValue ForAssign Expression /* 1 2 3 4 */ - { - hb_compLinePush(); - hb_compDebugStart(); - ++hb_comp_wForCounter; /* 5 */ - $$ = hb_compExprGenStatement( hb_compExprAssign( $2, $4 ) ); - } - TO Expression StepExpr /* 6 7 8 */ - { - hb_compLoopStart(); - $$ = hb_comp_functions.pLast->lPCodePos; /* 9 */ - hb_compExprGenPush( $2 ); /* counter */ - hb_compExprGenPush( $7 ); /* end */ - if( $8 ) - hb_compExprGenPush( $8 ); /* step */ - } - Crlf /* 10 */ - { - if( $8 ) - hb_compGenPCode1( HB_P_FORTEST ); - else - hb_compGenPCode1( HB_P_LESSEQUAL ); - $$ = hb_compGenJumpFalse( 0 ); /* 11 */ - } - ForStatements /* 12 */ - { - short iStep, iLocal; - - hb_compLoopHere(); - - if( $8 ) - { - if( $8->ExprType == HB_ET_NUMERIC && $8->value.asNum.NumType == HB_ET_LONG && - $8->value.asNum.lVal >= -32768 && $8->value.asNum.lVal <= 32767 ) - { - iStep = ( short ) $8->value.asNum.lVal; - } - else - { - iStep = 0; - } - } - else - { - iStep = 1; - } - - if( iStep && ( iLocal = hb_compLocalGetPos( $2->value.asSymbol ) ) > 0 && iLocal < 256 ) - { - hb_compGenPCode4( HB_P_LOCALNEARADDINT, ( BYTE ) iLocal, HB_LOBYTE( iStep ), HB_HIBYTE( iStep ), ( BOOL ) 0 ); - } - else if( $8 ) - { - hb_compExprClear( hb_compExprGenStatement( hb_compExprSetOperand( hb_compExprNewPlusEq( $2 ), $8 ) ) ); - } - else - { - hb_compExprClear( hb_compExprGenStatement( hb_compExprNewPreInc( $2 ) ) ); - } - - hb_compGenJump( $9 - hb_comp_functions.pLast->lPCodePos ); - hb_compGenJumpHere( $11 ); - hb_compLoopEnd(); - hb_compExprDelete( $7 ); - hb_compExprDelete( $5 ); /* deletes $5, $2, $4 */ - if( $8 ) - hb_compExprDelete( $8 ); - hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; - } - ; - -ForAssign : '=' - | INASSIGN - ; - -StepExpr : /* default step expression */ { $$ = NULL; } - | STEP Expression { $$ = hb_compExprReduce( $2 ); } - ; - -ForStatements : EmptyStats NEXT { hb_compLinePush(); --hb_comp_wForCounter; } - | EmptyStats NEXT IdentName { hb_compLinePush(); --hb_comp_wForCounter; } - | EmptyStats END { hb_compLinePush(); --hb_comp_wForCounter; } - | EmptyStats END IdentName { hb_compLinePush(); --hb_comp_wForCounter; } - ; - -BeginSeq : BEGINSEQ { ++hb_comp_wSeqCounter; $$ = hb_compSequenceBegin(); } Crlf - EmptyStats - { - /* Set jump address for HB_P_SEQBEGIN opcode - this address - * will be used in BREAK code if there is no RECOVER clause - */ - hb_compGenJumpHere( $2 ); - $$ = hb_compSequenceEnd(); - } - RecoverSeq - { - /* Replace END address with RECOVER address in - * HB_P_SEQBEGIN opcode if there is RECOVER clause - */ - if( $6 ) - hb_compGenJumpThere( $2, $6 ); - } - END - { - /* Fix END address - * There is no line number after HB_P_SEQEND in case no - * RECOVER clause is used - */ - hb_compGenJumpThere( $5, hb_comp_functions.pLast->lPCodePos ); - if( !$6 ) /* only if there is no RECOVER clause */ - --hb_comp_wSeqCounter; /* RECOVER is also considered as end of sequence */ - /* hb_compSequenceFinish( $2, $4 ); */ - hb_comp_functions.pLast->bFlags &= ~ FUN_WITH_RETURN; - } - ; - -RecoverSeq : /* no recover */ { $$ = 0; } - | RecoverEmpty Crlf { $$ = $1; } EmptyStats - | RecoverUsing Crlf { $$ = $1; } EmptyStats - ; - -RecoverEmpty : RECOVER - { - hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; - $$ = hb_comp_functions.pLast->lPCodePos; - --hb_comp_wSeqCounter; - hb_compLinePush(); - hb_compGenPCode2( HB_P_SEQRECOVER, HB_P_POP, ( BOOL ) 0 ); - } - ; - -RecoverUsing : RECOVERUSING IdentName - { - hb_comp_functions.pLast->bFlags &= ~ FUN_BREAK_CODE; - $$ = hb_comp_functions.pLast->lPCodePos; - --hb_comp_wSeqCounter; - hb_compLinePush(); - hb_compGenPCode1( HB_P_SEQRECOVER ); - hb_compGenPopVar( $2 ); - } - ; - -/* NOTE: In Clipper all variables used in DO .. WITH are passed by reference - * however if they are part of an expression then they are passed by value - * for example: - * DO .. WITH ++variable - * will pass the value of variable not a reference - */ -DoName : IdentName { $$ = hb_compExprNewFunName( $1 ); hb_compAutoOpenAdd( $1 ); } - | MacroVar { $$ = $1; } - | MacroExpr { $$ = $1; } - ; - -DoProc : DO DoName - { $$ = hb_compExprNewFunCall( $2, NULL ); } - | DO DoName WITH DoArgList - { $$ = hb_compExprNewFunCall( $2, $4 ); } - | WHILE WITH DoArgList - { hb_compAutoOpenAdd( "WHILE" ); $$ = hb_compExprNewFunCall( hb_compExprNewFunName( hb_compIdentifierNew("WHILE", TRUE) ), $3 ); } - ; - -DoArgList : ',' { $$ = hb_compExprAddListExpr( hb_compExprNewArgList( hb_compExprNewNil() ), hb_compExprNewNil() ); } - | ',' DoArgument { $$ = hb_compExprAddListExpr( hb_compExprNewArgList( hb_compExprNewNil() ), $2 ); } - | DoArgument { $$ = hb_compExprNewArgList( $1 ); } - | DoArgList ',' { $$ = hb_compExprAddListExpr( $1, hb_compExprNewNil() ); } - | DoArgList ',' DoArgument { $$ = hb_compExprAddListExpr( $1, $3 ); } - ; - -DoArgument : IdentName { $$ = hb_compExprNewVarRef( $1 ); } - | '@' IdentName '(' DummyArgList ')' { $$ = hb_compExprNewFunRef( $2 ); } - | SimpleExpression { $$ = $1; } - | PareExpList { $$ = $1; } - ; - -Crlf : '\n' { hb_comp_bError = FALSE; } - | ';' { hb_comp_bDontGenLineNum = TRUE; } - ; - -%% - -/* - ** ------------------------------------------------------------------------ ** - */ - -#if 0 -int hb_compYACCMain( char * szName ) -{ - /* Generate the starting procedure frame */ - if( hb_comp_bStartProc ) - hb_compFunctionAdd( hb_strupr( hb_strdup( szName ) ), HB_FS_PUBLIC, FUN_PROCEDURE ); - else - /* Don't pass the name of module if the code for starting procedure - * will be not generated. The name cannot be placed as first symbol - * because this symbol can be used as function call or memvar's name. - */ - hb_compFunctionAdd( hb_strupr( hb_strdup( "" ) ), HB_FS_PUBLIC, FUN_PROCEDURE ); - - yyparse(); - - /* fix all previous function returns offsets */ - hb_compFinalizeFunction(); - - hb_compExternGen(); /* generates EXTERN symbols names */ - - if( hb_comp_pInitFunc ) - { - PCOMSYMBOL pSym; - - /* Fix the number of static variables */ - hb_comp_pInitFunc->pCode[ 3 ] = HB_LOBYTE( hb_comp_iStaticCnt ); - hb_comp_pInitFunc->pCode[ 4 ] = HB_HIBYTE( hb_comp_iStaticCnt ); - hb_comp_pInitFunc->iStaticsBase = hb_comp_iStaticCnt; - - pSym = hb_compSymbolAdd( hb_comp_pInitFunc->szName, NULL ); - pSym->cScope |= hb_comp_pInitFunc->cScope; - hb_comp_functions.pLast->pNext = hb_comp_pInitFunc; - hb_comp_functions.pLast = hb_comp_pInitFunc; - hb_compGenPCode1( HB_P_ENDPROC ); - ++hb_comp_functions.iCount; - } - - if( hb_comp_szAnnounce ) - hb_compAnnounce( hb_comp_szAnnounce ); - - /* Close processed file (it is opened in hb_compInclude() function ) - */ - fclose( yyin ); - - while( hb_comp_files.pLast ) - { - PFILE pFile = hb_comp_files.pLast; - if( pFile->pBuffer ) - hb_xfree( (void *) pFile->pBuffer ); - hb_xfree( (void *) pFile->szFileName ); - hb_comp_files.pLast = pFile->pPrev; - hb_xfree( pFile ); - } - hb_comp_files.pLast = NULL; - - return 0; -} -#endif - -/* ------------------------------------------------------------------------ */ - -void yyerror( char * s ) -{ - if( yytext[ 0 ] == '\n' ) - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_YACC, s, "" ); - else - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_YACC, s, yytext ); -} - - -BOOL hb_compInclude( char * szFileName, HB_PATHNAMES * pSearch ) -{ - PFILE pFile; - - yyin = fopen( szFileName, "r" ); - if( ! yyin ) - { - if( pSearch ) - { - PHB_FNAME pFileName = hb_fsFNameSplit( szFileName ); - - while( pSearch && !yyin ) - { - char szFName[ _POSIX_PATH_MAX ]; /* filename to parse */ - - pFileName->szPath = pSearch->szPath; - hb_fsFNameMerge( szFName, pFileName ); - yyin = fopen( szFName, "r" ); - if( ! yyin ) - { - pSearch = pSearch->pNext; - if( ! pSearch ) - return FALSE; - } - } - - hb_xfree( ( void * ) pFileName ); - } - else - return FALSE; - } - - pFile = ( PFILE ) hb_xgrab( sizeof( _FILE ) ); - pFile->handle = yyin; - pFile->pBuffer = hb_xgrab( HB_PP_BUFF_SIZE ); - pFile->iBuffer = pFile->lenBuffer = 10; - pFile->szFileName = szFileName; - pFile->iLine = 0; - pFile->pPrev = hb_comp_files.pLast; - - hb_comp_files.pLast = pFile; - -#ifdef __cplusplus - yy_switch_to_buffer( ( YY_BUFFER_STATE ) ( hb_comp_buffer = ( char * ) yy_create_buffer( yyin, 8192 * 2 ) ) ); -#else - yy_switch_to_buffer( hb_comp_buffer = yy_create_buffer( yyin, 8192 * 2 ) ); -#endif - hb_comp_files.iFiles++; - - return TRUE; -} - -int yywrap( void ) /* handles the EOF of the currently processed file */ -{ - if( hb_comp_files.iFiles == 1 ) - { - hb_xfree( hb_comp_files.pLast->pBuffer ); - hb_comp_files.pLast->pBuffer = NULL; - return 1; /* we have reached the main EOF */ - } - - return 0; -} - -/* ************************************************************************* */ - -/* - * This function stores the position in pcode buffer where the FOR/WHILE - * loop starts. It will be used to fix any LOOP/EXIT statements - */ -static void hb_compLoopStart( void ) -{ - PTR_LOOPEXIT pLoop = ( PTR_LOOPEXIT ) hb_xgrab( sizeof( LOOPEXIT ) ); - - if( hb_comp_pLoops ) - { - PTR_LOOPEXIT pLast = hb_comp_pLoops; - - while( pLast->pNext ) - pLast = pLast->pNext; - pLast->pNext = pLoop; - } - else - hb_comp_pLoops = pLoop; - - pLoop->pNext = NULL; - pLoop->pExitList = NULL; - pLoop->pLoopList = NULL; - pLoop->ulOffset = hb_comp_functions.pLast->lPCodePos; /* store the start position */ - pLoop->iLine = hb_comp_iLine; - pLoop->wSeqCounter = hb_comp_wSeqCounter; /* store current SEQUENCE counter */ -} - -/* - * Stores the position of LOOP statement to fix it later at the end of loop - */ -static void hb_compLoopLoop( void ) -{ - if( ! hb_comp_pLoops ) - { - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_UNMATCHED_EXIT, "LOOP", NULL ); - } - else - { - PTR_LOOPEXIT pLast, pLoop; - - pLoop = ( PTR_LOOPEXIT ) hb_xgrab( sizeof( LOOPEXIT ) ); - - pLoop->pLoopList = NULL; - pLoop->ulOffset = hb_comp_functions.pLast->lPCodePos; /* store the position to fix */ - - pLast = hb_comp_pLoops; - while( pLast->pNext ) - pLast = pLast->pNext; - - if( pLast->wSeqCounter != hb_comp_wSeqCounter ) - { - /* Attempt to LOOP from BEGIN/END sequence - * Current SEQUENCE counter is different then at the beginning of loop - * Notice that LOOP is allowed in RECOVER code. - */ - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_EXIT_IN_SEQUENCE, "LOOP", NULL ); - } - else - { - while( pLast->pLoopList ) - pLast = pLast->pLoopList; - - pLast->pLoopList = pLoop; - - hb_compGenJump( 0 ); - } - } -} - -/* - * Stores the position of EXIT statement to fix it later at the end of loop - */ -static void hb_compLoopExit( void ) -{ - if( ! hb_comp_pLoops ) - { - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_UNMATCHED_EXIT, "EXIT", NULL ); - } - else - { - PTR_LOOPEXIT pLast, pLoop; - - pLoop = ( PTR_LOOPEXIT ) hb_xgrab( sizeof( LOOPEXIT ) ); - - pLoop->pExitList = NULL; - pLoop->ulOffset = hb_comp_functions.pLast->lPCodePos; /* store the position to fix */ - - pLast = hb_comp_pLoops; - while( pLast->pNext ) - pLast = pLast->pNext; - - if( pLast->wSeqCounter != hb_comp_wSeqCounter ) - { - /* Attempt to LOOP from BEGIN/END sequence - * Current SEQUENCE counter is different then at the beginning of loop - * Notice that LOOP is allowed in RECOVER code. - */ - hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_EXIT_IN_SEQUENCE, "EXIT", NULL ); - } - else - { - while( pLast->pExitList ) - pLast = pLast->pExitList; - - pLast->pExitList = pLoop; - - hb_compGenJump( 0 ); - } - } -} - -/* - * Fixes the LOOP statement - */ -static void hb_compLoopHere( void ) -{ - PTR_LOOPEXIT pLoop = hb_comp_pLoops, pFree; - - if( pLoop ) - { - while( pLoop->pNext ) - pLoop = pLoop->pNext; - - pLoop = pLoop->pLoopList; - while( pLoop ) - { - hb_compGenJumpHere( pLoop->ulOffset + 1 ); - pFree = pLoop; - pLoop = pLoop->pLoopList; - hb_xfree( ( void * ) pFree ); - } - } -} - -/* - * Fixes the EXIT statements and releases memory allocated for current loop - */ -static void hb_compLoopEnd( void ) -{ - PTR_LOOPEXIT pExit, pLoop = hb_comp_pLoops, pLast = hb_comp_pLoops, pFree; - - if( pLoop ) - { - while( pLoop->pNext ) - { - pLast = pLoop; - pLoop = pLoop->pNext; - } - - pExit = pLoop->pExitList; - while( pExit ) - { - hb_compGenJumpHere( pExit->ulOffset + 1 ); - pFree = pExit; - pExit = pExit->pExitList; - hb_xfree( ( void * ) pFree ); - } - - pLast->pNext = NULL; - if( pLoop == hb_comp_pLoops ) - hb_comp_pLoops = NULL; - hb_xfree( ( void * ) pLoop ); - } -} - -static void * hb_compElseIfGen( void * pFirst, ULONG ulOffset ) -{ - PELSEIF pElseIf = ( PELSEIF ) hb_xgrab( sizeof( _ELSEIF ) ), pLast; - - pElseIf->ulOffset = ulOffset; - pElseIf->pNext = 0; - - if( ! pFirst ) - pFirst = pElseIf; - else - { - pLast = ( PELSEIF ) pFirst; - while( pLast->pNext ) - pLast = pLast->pNext; - pLast->pNext = pElseIf; - } - return pFirst; -} - - -static void hb_compElseIfFix( void * pFixElseIfs ) -{ - PELSEIF pFix = ( PELSEIF ) pFixElseIfs; - - while( pFix ) - { - hb_compGenJumpHere( pFix->ulOffset ); - pFix = pFix->pNext; - } -} - -static void hb_compRTVariableAdd( HB_EXPR_PTR pVar, BOOL bPopInitValue ) -{ - HB_RTVAR_PTR pRTvar = ( HB_RTVAR_PTR ) hb_xgrab( sizeof( HB_RTVAR ) ); - - pRTvar->pVar = pVar; - pRTvar->bPopValue = bPopInitValue; - pRTvar->pNext = NULL; - pRTvar->pPrev = NULL; - - if( hb_comp_rtvars ) - { - HB_RTVAR_PTR pLast = hb_comp_rtvars; - while( pLast->pNext ) - pLast = pLast->pNext; - pLast->pNext = pRTvar; - pRTvar->pPrev = pLast; - } - else - hb_comp_rtvars = pRTvar; -} - -static void hb_compRTVariableGen( char * szCreateFun ) -{ - USHORT usCount = 0; - HB_RTVAR_PTR pVar = hb_comp_rtvars; - HB_RTVAR_PTR pDel; - - /* generate the function call frame */ - hb_compGenPushSymbol( hb_strdup( szCreateFun ), TRUE, FALSE ); - hb_compGenPushNil(); - - /* push variable names to create */ - while( pVar->pNext ) - { - hb_compExprGenPush( pVar->pVar ); - pVar = pVar->pNext; - ++usCount; - } - hb_compExprGenPush( pVar->pVar ); - ++usCount; - - /* call function that will create either PUBLIC or PRIVATE variables */ - if( usCount > 255 ) - hb_compGenPCode3( HB_P_DO, HB_LOBYTE( usCount ), HB_HIBYTE( usCount ), ( BOOL ) 1 ); - else - hb_compGenPCode2( HB_P_DOSHORT, ( BYTE ) usCount, ( BOOL ) 1 ); - - /* pop initial values */ - while( pVar ) - { - if( pVar->bPopValue ) - hb_compExprDelete( hb_compExprGenPop( pVar->pVar ) ); - else - hb_compExprDelete( pVar->pVar ); - pDel = pVar; - pVar = pVar->pPrev; - hb_xfree( pDel ); - } - hb_comp_rtvars = NULL; -} - -static void hb_compVariableDim( char * szName, HB_EXPR_PTR pInitValue ) -{ - if( hb_comp_iVarScope == VS_PUBLIC || hb_comp_iVarScope == VS_PRIVATE ) - { - USHORT uCount = (USHORT) hb_compExprListLen( pInitValue ); - hb_compVariableAdd( szName, 'A' ); - hb_compExprDelete( hb_compExprGenPush( pInitValue ) ); - hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), ( BOOL ) 1 ); - hb_compRTVariableAdd( hb_compExprNewRTVar( szName, NULL ), TRUE ); - } - else if( hb_comp_iVarScope == VS_STATIC ) - { - USHORT uCount = (USHORT) hb_compExprListLen( pInitValue ); - HB_EXPR_PTR pVar = hb_compExprNewVar( szName ); - HB_EXPR_PTR pAssign; - - /* create a static variable */ - hb_compVariableAdd( szName, 'A' ); - hb_compStaticDefStart(); /* switch to statics pcode buffer */ - /* create an array */ - hb_compExprGenPush( pInitValue ); - hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), ( BOOL ) 1 ); - /* check if valid initializers were used but don't generate any code */ - pAssign = hb_compExprAssignStatic( pVar, pInitValue ); - /* now pop an array */ - hb_compExprGenPop( pVar ); - /* delete all used expressions */ - hb_compExprDelete( pAssign ); - hb_compStaticDefEnd(); - } - else - { - USHORT uCount = (USHORT) hb_compExprListLen( pInitValue ); - - hb_compVariableAdd( szName, 'A' ); - hb_compExprDelete( hb_compExprGenPush( pInitValue ) ); - hb_compGenPCode3( HB_P_ARRAYDIM, HB_LOBYTE( uCount ), HB_HIBYTE( uCount ), ( BOOL ) 1 ); - hb_compExprDelete( hb_compExprGenPop( hb_compExprNewVar( szName ) ) ); - } -} - diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 85bce93af2..b2b82a6ece 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -316,7 +316,7 @@ ProcReq : PROCREQ CompTimeStr ')' Crlf { HB_COMP_PARAM->functions.pLast->bFla ; CompTimeStr: LITERAL { hb_compAutoOpenAdd( HB_COMP_PARAM, $1 ); } - | LITERAL '+' LITERAL { char szFileName[ _POSIX_PATH_MAX ]; sprintf( szFileName, "%s%s", $1, $3 ); hb_compAutoOpenAdd( HB_COMP_PARAM, szFileName ); } + | LITERAL '+' LITERAL { char szFileName[ _POSIX_PATH_MAX + 1 ]; hb_strncat( hb_strncpy( szFileName, $1, _POSIX_PATH_MAX ), $3, _POSIX_PATH_MAX ); hb_compAutoOpenAdd( HB_COMP_PARAM, hb_compIdentifierNew( HB_COMP_PARAM, szFileName, TRUE ) ); } ; Function : FunScope FUNCTION IdentName { HB_COMP_PARAM->cVarType = ' '; hb_compFunctionAdd( HB_COMP_PARAM, $3, ( HB_SYMBOLSCOPE ) $1, 0 ); } Crlf {} diff --git a/harbour/source/compiler/hbgenerr.c b/harbour/source/compiler/hbgenerr.c index 974e3a2321..c7328aca33 100644 --- a/harbour/source/compiler/hbgenerr.c +++ b/harbour/source/compiler/hbgenerr.c @@ -91,7 +91,8 @@ char * hb_comp_szErrors[] = "Memory buffer overflow", "Memory corruption detected", "Implicit send operator with no WITH OBJECT in sight", - "Input buffer overflow" + "Input buffer overflow", + "Unsupported output language option" }; /* Table with parse warnings */ @@ -135,38 +136,36 @@ char * hb_comp_szWarnings[] = void hb_compGenError( HB_COMP_DECL, char * szErrors[], char cPrefix, int iError, const char * szError1, const char * szError2 ) { - int iLine = hb_pp_line( HB_COMP_PARAM->pLex->pPP ); - char * szFile = hb_pp_fileName( HB_COMP_PARAM->pLex->pPP ); - - if( cPrefix != 'F' && HB_COMP_PARAM->fError ) - return; - - if( szFile ) - fprintf( hb_comp_errFile, "\r%s(%i) ", szFile, iLine ); - - fprintf( hb_comp_errFile, "Error %c%04i ", cPrefix, iError ); - fprintf( hb_comp_errFile, szErrors[ iError - 1 ], szError1, szError2 ); - fprintf( hb_comp_errFile, "\n" ); - - HB_COMP_PARAM->iErrorCount++; - HB_COMP_PARAM->fError = TRUE; - - /* fatal error - exit immediately */ - if( cPrefix == 'F' ) + if( !HB_COMP_PARAM->fExit && ( cPrefix == 'F' || !HB_COMP_PARAM->fError ) ) { - hb_compMainExit(); - exit( EXIT_FAILURE ); + char * szFile = hb_pp_fileName( HB_COMP_PARAM->pLex->pPP ); + int iLine = hb_pp_line( HB_COMP_PARAM->pLex->pPP ); + + if( szFile ) + fprintf( hb_comp_errFile, "\r%s(%i) ", szFile, iLine ); + + fprintf( hb_comp_errFile, "Error %c%04i ", cPrefix, iError ); + fprintf( hb_comp_errFile, szErrors[ iError - 1 ], szError1, szError2 ); + fprintf( hb_comp_errFile, "\n" ); + + HB_COMP_PARAM->iErrorCount++; + HB_COMP_PARAM->fError = TRUE; + + /* fatal error - exit immediately */ + if( cPrefix == 'F' ) + HB_COMP_PARAM->fExit = TRUE; } } void hb_compGenWarning( HB_COMP_DECL, char * szWarnings[], char cPrefix, int iWarning, const char * szWarning1, const char * szWarning2) { char * szText = szWarnings[ iWarning - 1 ]; - int iLine = hb_pp_line( HB_COMP_PARAM->pLex->pPP ); - if( ( szText[ 0 ] - '0' ) <= HB_COMP_PARAM->iWarnings ) + if( !HB_COMP_PARAM->fExit && ( szText[ 0 ] - '0' <= HB_COMP_PARAM->iWarnings ) ) { char * szFile = hb_pp_fileName( HB_COMP_PARAM->pLex->pPP ); + int iLine = hb_pp_line( HB_COMP_PARAM->pLex->pPP ); + if( szFile ) fprintf( hb_comp_errFile, "\r%s(%i) ", szFile, iLine ); diff --git a/harbour/source/compiler/hbslex.c b/harbour/source/compiler/hbslex.c deleted file mode 100644 index 6ac54fab2a..0000000000 --- a/harbour/source/compiler/hbslex.c +++ /dev/null @@ -1,20 +0,0 @@ -/* - * $Id$ - */ - -#include "hbcomp.h" -#include "harboury.h" -#include "hbsetup.h" -#include "hberrors.h" -#include "hbdefs.h" - -#define MAX_STREAM 2048 /* Max length of in-line LITERAL */ -#define MAX_STREAM_STARTER 7 /* "QOUT([" */ -#define MAX_STREAM_TERMINATOR 4 /* "])\n" */ -#define MAX_STREAM_EXCLUSIONS 2 - -#define TOKEN_SIZE HB_SYMBOL_NAME_LEN + 1 - -#define SLX_RULES "harbour.slx" - -#include "simplex.c" diff --git a/harbour/source/compiler/hbstrong.c b/harbour/source/compiler/hbstrong.c deleted file mode 100644 index bfe3a5d84a..0000000000 --- a/harbour/source/compiler/hbstrong.c +++ /dev/null @@ -1,2896 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Compiler PCode generation functions - * - * Copyright 1999 {list of individual authors and e-mail addresses} - * www - http://www.harbour-project.org - * - * 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 of the License, or - * (at your option) any later version, with one exception: - * - * 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 program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit - * their web site at http://www.gnu.org/). - * - */ - -/* - * The following parts are Copyright of the individual authors. - * www - http://www.harbour-project.org - * - * Copyright 2000 RonPinkas - * hb_compStrongType() - * - * See doc/license.txt for licensing terms. - * - */ - -#include "hbcomp.h" - -#if defined(HB_COMP_STRONG_TYPES) - -static PVAR hb_compPrivateFind( char * szPrivateName ) -{ - PFUNCTION pFunc = hb_comp_functions.pLast; - PVAR pPrivate = NULL; - - if( pFunc ) - pPrivate = pFunc->pPrivates; - - while ( pPrivate ) - { - if( ! strcmp( pPrivate->szName, szPrivateName ) ) - return pPrivate; - else - pPrivate = pPrivate->pNext; - - } - return NULL; -} - -void hb_compStrongType( int iSize ) -{ - PFUNCTION pFunc = hb_comp_functions.pLast, pTmp; - PVAR pVar = NULL; - PCOMSYMBOL pSym = NULL; - PCOMDECLARED pDeclared; - ULONG ulPos = pFunc->lPCodePos - iSize; - SHORT wVar = 0; - BYTE szType0[64], szType1[64], szType2[64], cType, cSubType0 = 0, cSubType1 = 0, cSubType2 = 0; - BYTE bLast1, bLast2; - static int s_aiPreCondStack[ 16 ], s_iCondIndex = 0; - - /* - printf( "\nProcessing: %i Stack: %i\n", pFunc->pCode[ ulPos ], pFunc->iStackSize ); - */ - - /* Make sure we have enough stack space. */ - if( ! pFunc->pStack ) - { - pFunc->pStack = ( BYTE * ) hb_xgrab( pFunc->iStackSize += 16 ); - } - else if( pFunc->iStackSize - pFunc->iStackIndex < 4 ) - { - pFunc->pStack = ( BYTE * ) hb_xrealloc( pFunc->pStack, pFunc->iStackSize += 16 ); - } - - /* TODO: Split under conitions for the different matching possible iSize. */ - - /* TODO: Subject to Operator Overloading! */ - - switch ( pFunc->pCode[ ulPos ] ) - { - /*-----------------4/26/00 0:16AM------------------- - * Push values on stack. - * --------------------------------------------------*/ - - case HB_P_SWAPALIAS : - /* TODO check affect on stack. */ - break; - - case HB_P_RETVALUE : - if( pFunc->iStackIndex < 1 ) - break; - - pFunc->iStackIndex--; - - pSym = hb_compSymbolFind( pFunc->szName, NULL, HB_SYM_FUNCNAME ); - - if( pSym && pSym->szName ) - { - char cType1, cType2; - - pDeclared = hb_compDeclaredFind( pSym->szName ); - - if( pDeclared ) - { - if( hb_comp_cCastType == ' ' ) - { - /* No casting - do nothing. */ - } - else if( toupper( hb_comp_cCastType ) == 'S' ) - { - PCOMCLASS pClass = hb_compClassFind( hb_comp_szFromClass ); - - if( pClass ) - { - if( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses ) - { - pFunc->pStackClasses[ pFunc->iStackClasses - 1 ] = pClass; - } - else - { - pFunc->pStackClasses[ pFunc->iStackClasses++ ] = pClass; - } - pFunc->pStack[ pFunc->iStackIndex ] = hb_comp_cCastType; - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szFromClass, pDeclared->szName ); - pFunc->pStack[ pFunc->iStackIndex ] = ( isupper( ( int ) hb_comp_cCastType ) ? 'O' : 'o' ); - } - - hb_comp_cCastType = ' '; - } - else - { - pFunc->pStack[ pFunc->iStackIndex ] = hb_comp_cCastType; - hb_comp_cCastType = ' '; - } - - /* Variant as SubType. */ - if( ( pFunc->pStack[ pFunc->iStackIndex ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType1 = ( pFunc->pStack[ pFunc->iStackIndex ] -= VT_OFFSET_VARIANT ); - cType1 = 'X'; - } - else - { - cType1 = pFunc->pStack[ pFunc->iStackIndex ]; - } - - if( cSubType1 ) - { - if( cSubType1 == 'S' && pFunc->iStackClasses ) - sprintf( ( char * ) szType1, "AnyType.SubType[%s]", pFunc->pStackClasses[ --pFunc->iStackClasses ]->szName ); - else if( cSubType1 == 's' && pFunc->iStackClasses ) - sprintf( ( char * ) szType1, "AnyType.SubType[ARRAY OF %s]", pFunc->pStackClasses[ --pFunc->iStackClasses ]->szName ); - else if( cSubType1 == '-' ) - strcpy( ( char * ) szType1, "AnyType.SubType[NIL]" ); - else - sprintf( ( char * ) szType1, "AnyType.SubType[%c]", cSubType1 ); - } - else - { - if( cType1 == 'S' && pFunc->iStackClasses ) - sprintf( ( char * ) szType1, "%s", pFunc->pStackClasses[ --pFunc->iStackClasses ]->szName ); - else if( cType1 == 's' && pFunc->iStackClasses ) - sprintf( ( char * ) szType1, "ARRAY OF %s", pFunc->pStackClasses[ --pFunc->iStackClasses ]->szName ); - else if( cType1 == '-' ) - strcpy( ( char * ) szType1, "NIL" ); - else - sprintf( ( char * ) szType1, "%c", cType1 ); - } - - cType2 = pDeclared->cType; - if( cType2 == 'S' ) - sprintf( ( char * ) szType2, "%s", pDeclared->pClass->szName ); - else if( cType2 == 's' ) - sprintf( ( char * ) szType2, "ARRAY OF %s", pDeclared->pClass->szName ); - else if( cType2 == '-' ) - sprintf( ( char * ) szType2, "NIL" ); - else - sprintf( ( char * ) szType2, "%c", cType2 ); - - if( pDeclared->cType != ' ' && pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_RETURN_SUSPECT, ( char * ) szType1, ( char * ) szType2 ); - else if( pDeclared->cType == 'S' && pFunc->pStack[ pFunc->iStackIndex ] == 'O' ) - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_RETURN_SUSPECT, ( char * ) szType1, ( char * ) szType2 ); - else if( pDeclared->cType == 's' && pFunc->pStack[ pFunc->iStackIndex ] == 'o' ) - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_RETURN_SUSPECT, ( char * ) szType1, ( char * ) szType2 ); - else if( pDeclared->cType != ' ' && pDeclared->cType != pFunc->pStack[ pFunc->iStackIndex ] ) - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_RETURN_TYPE, ( char * ) szType1, ( char * ) szType2 ); - } - } - break; - - case HB_P_DO : - case HB_P_FUNCTION : - wVar = HB_PCODE_MKSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ); - /* DON't put break; Has to fall through */ - case HB_P_DOSHORT : - case HB_P_FUNCTIONSHORT : - if( wVar == 0 ) - wVar = pFunc->pCode[ ulPos + 1 ]; - - if( pFunc->iStackIndex < ( wVar + 2 ) ) - { - /* - printf( "\nNeeded %i values, found %i!\n", wVar + 1, pFunc->iStackIndex - 1 ); - */ - pFunc->iStackIndex = 1; - pFunc->pStack[ 0 ] = ' '; - break; - } - - if( pFunc->iStackFunctions > 0 && pFunc->pStackFunctions[ --pFunc->iStackFunctions ] ) - { - int hb_comp_iParamCount, iParamCount, iOptionals = 0; - BYTE * hb_comp_cParamTypes; - - hb_comp_cParamTypes = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->cParamTypes; - hb_comp_iParamCount = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->iParamCount; - - iParamCount = hb_comp_iParamCount; - /* First, find how many optionals. */ - while ( --iParamCount >= 0 ) - { - if( hb_comp_cParamTypes[ iParamCount ] == ( ' ' + VT_OFFSET_OPTIONAL ) || hb_comp_cParamTypes[ iParamCount ] >= ( 'A' + VT_OFFSET_OPTIONAL ) ) - iOptionals++; - else - break; - } - - /* - printf( "\nOptionals: %i\n", iOptionals ); - printf( "\nExec Function: %s, wVar: %i Parameters: %i Optionals: %i\n", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, wVar, hb_comp_iParamCount, iOptionals ); - */ - - /* Now, check the types. */ - if( wVar >= ( hb_comp_iParamCount - iOptionals ) && wVar <= hb_comp_iParamCount ) - { - BYTE iParamBase = pFunc->iStackIndex - wVar, cFormalType, cParamType; - int iOffset = wVar; - - while ( --iOffset >= 0 ) - { - BOOL bByRef = FALSE; - - cParamType = pFunc->pStack[ iParamBase + iOffset ]; - if( ( cParamType == '-' + VT_OFFSET_VARIANT ) || cParamType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cParamType -= VT_OFFSET_VARIANT; - } - - cFormalType = hb_comp_cParamTypes[ iOffset ]; - - if( cFormalType == ( ' ' + VT_OFFSET_OPTIONAL ) || cFormalType >= ( 'A' + VT_OFFSET_OPTIONAL ) ) - { - cFormalType -= VT_OFFSET_OPTIONAL; - } - - if( cFormalType == ' ' + VT_OFFSET_BYREF || cFormalType >= ( 'A' + VT_OFFSET_BYREF ) ) - { - bByRef = TRUE; - cFormalType -= VT_OFFSET_BYREF; - } - - /* --- */ - - if( cFormalType == ' ' && ! bByRef ) - { - /* Declared is Variant, accept anything. */ - } - else if( cFormalType == 'S' && cParamType == 'S' && pFunc->iStackClasses ) - { - PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; - PCOMCLASS hb_comp_pParamClass = pFunc->pStackClasses[ --pFunc->iStackClasses ]; - - if( hb_comp_pFormalClass != hb_comp_pParamClass ) - { - sprintf( ( char * ) szType1, "%s %i", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, iOffset + 1 ); - sprintf( ( char * ) szType2, "%s", hb_comp_pFormalClass->szName ); - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 ); - } - } - else if( cFormalType == 's' && cParamType == 's' && pFunc->iStackClasses ) - { - PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; - PCOMCLASS hb_comp_pParamClass = pFunc->pStackClasses[ --pFunc->iStackClasses ]; - - if( hb_comp_pFormalClass != hb_comp_pParamClass ) - { - sprintf( ( char * ) szType1, "%s %i", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, iOffset + 1 ); - sprintf( ( char * ) szType2, "ARRAY OF %s", hb_comp_pFormalClass->szName ); - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 ); - } - } - else if( cFormalType != cParamType ) - { - if( cFormalType == 'S' ) - { - PCOMCLASS hb_comp_pParamClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; - sprintf( ( char * ) szType2, "%s", hb_comp_pParamClass->szName ); - } - else if( cFormalType == 's' ) - { - PCOMCLASS hb_comp_pParamClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; - sprintf( ( char * ) szType2, "ARRAY OF %s", hb_comp_pParamClass->szName ); - } - else - { - /* Cleanup. */ - if( toupper( cParamType ) == 'S' && pFunc->iStackClasses ) - { - --pFunc->iStackClasses; - } - - if( bByRef ) - { - sprintf( ( char * ) szType2, "@%c", cFormalType ); - } - else if( islower( cFormalType ) ) - { - sprintf( ( char * ) szType2, "ARRAY OF %c", toupper( cFormalType ) ); - } - else - { - sprintf( ( char * ) szType2, "%c", cFormalType ); - } - } - - sprintf( ( char * ) szType1, "%s #%i", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, iOffset + 1 ); - - if( cParamType == ' ' || cParamType == '-' || cParamType == 'U' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_SUSPECT, ( char * ) szType1, ( char * ) szType2 ); - } - else if( bByRef && ( cParamType == ( ' ' + VT_OFFSET_BYREF ) || cParamType >= ( 'A' + VT_OFFSET_BYREF ) ) ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_SUSPECT, ( char * ) szType1, ( char * ) szType2 ); - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 ); - } - } - } - } - else - { - sprintf( ( char * ) szType1, "%s got %i", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, wVar ); - - if( iOptionals ) - { - sprintf( ( char * ) szType2, "%i-%i", hb_comp_iParamCount - iOptionals, hb_comp_iParamCount ); - } - else - { - sprintf( ( char * ) szType2, "%i", hb_comp_iParamCount - iOptionals ); - } - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_COUNT, ( char * ) szType1, ( char * ) szType2 ); - } - } - else - { - /* - printf( "\nExec Non Declared Function - Stack: %i Functions: %i\n", pFunc->iStackIndex, pFunc->iStackFunctions ); - */ - } - - #if 0 - { - int i; - for ( i = 0; i < pFunc->iStackIndex; i++ ) - { - printf( "\nStack: %i Type: %c", i, pFunc->pStack[ i ] ); - } - } - printf( "\Removing %i parameters\n", wVar ); - - #endif - - /* Removing all the parameters. Return type already pushed just prior to parameters */ - pFunc->iStackIndex -= wVar; - - /* Removing the NIL */ - pFunc->iStackIndex--; - - if( pFunc->pCode[ ulPos ] == HB_P_DO || pFunc->pCode[ ulPos ] == HB_P_DOSHORT ) - { - /* No return value. */ - pFunc->iStackIndex--; - /* - printf( "\nNo Type for Procedure. - Stack: %i\n", pFunc->iStackIndex ); - */ - } - else - { - #if 0 - /* Declared result already on stack. */ - cType = pFunc->pStack[ pFunc->iStackIndex - 1 ]; - if( ( cType == '-' + VT_OFFSET_VARIANT ) || cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cType -= VT_OFFSET_VARIANT; - } - printf( "\nType of Function \'%c\' - Stack: %i\n", cType, pFunc->iStackIndex ); - #endif - } - break; - - case HB_P_MESSAGE : - if( pFunc->iStackIndex < 1 ) - break; - - cSubType1 = pFunc->pStack[ pFunc->iStackIndex - 1 ]; - - if( ( cSubType1 == '-' + VT_OFFSET_VARIANT ) || cSubType1 >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType1 -= VT_OFFSET_VARIANT; - if( cSubType1 == 'S' ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[Object]" ); - } - else if( cSubType1 == 's' ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[ARRAY OF Object]" ); - } - else if( islower( cSubType1 ) ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[ARRAY OF %c]", cSubType1 ); - } - else if( cSubType1 == '-' ) - { - strcpy( ( char * ) szType1, "AnyType.SubType[NIL]" ); - } - else - { - sprintf( ( char * ) szType1, "AnyType.SubType[%c]", cSubType1 ); - } - } - else - { - sprintf( ( char * ) szType1, "%c", cSubType1 ); - } - - if( cSubType1 == 'O' ) - ;/* The Object is not declared. */ - else if( cSubType1 == 'S' ) - { - pSym = hb_compSymbolGetPos( HB_PCODE_MKUSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ) ); - - if( pSym && pSym->szName && pFunc->iStackClasses && pFunc->pStackClasses[ pFunc->iStackClasses - 1 ] ) - { - if( pFunc->iStackFunctions < 8 ) - { - pFunc->pStackFunctions[ pFunc->iStackFunctions++ ] = hb_compMethodFind( pFunc->pStackClasses[ pFunc->iStackClasses - 1 ], pSym->szName ); - - /*printf( "\nMethod: %s of Class: %s Parameters: %i\n", pSym->szName, pFunc->pStackClasses[ pFunc->iStackClasses - 1 ]->szName, pFunc->pStackFunctions[ pFunc->iStackFunctions - 1 ]->iParamCount );*/ - - if( pFunc->pStackFunctions[ pFunc->iStackFunctions - 1 ] == NULL ) - { - if( pSym->szName[0] == '_' ) - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_MESSAGE_NOT_FOUND, &( pSym->szName[1] ), pFunc->pStackClasses[ pFunc->iStackClasses - 1 ]->szName ); - else - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_MESSAGE_NOT_FOUND, pSym->szName, pFunc->pStackClasses[ pFunc->iStackClasses - 1 ]->szName ); - } - } - } - else /* The method is not declared. */ - { - if( pFunc->iStackFunctions < 8 ) - { - pFunc->pStackFunctions[ pFunc->iStackFunctions++ ] = NULL; - } - } - } - else if( cSubType1 == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "O", NULL ); - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, ( char * ) szType1, "O" ); - } - - /* Result will be pushed by HB_P_SEND*/ - break; - - /* Also handled by HB_P_MESSAGE. */ - case HB_P_SEND : - wVar = HB_PCODE_MKSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ); - - /* Fall Through - don't add break !!! */ - - case HB_P_SENDSHORT : - if( wVar == 0 ) - wVar = ( SHORT ) pFunc->pCode[ ulPos + 1 ]; - - if( pFunc->iStackIndex < ( wVar + 1 ) ) - break; - - cType = pFunc->pStack[ pFunc->iStackIndex - ( wVar + 1 ) ]; - if( ( cType == '-' + VT_OFFSET_VARIANT ) || cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cType -= VT_OFFSET_VARIANT; - } - - if( cType == 'S' && pFunc->iStackFunctions > 0 && pFunc->pStackFunctions[ pFunc->iStackFunctions - 1 ] ) - { - int hb_comp_iParamCount, iParamCount, iOptionals = 0; - BYTE * hb_comp_cParamTypes; - - hb_comp_cParamTypes = pFunc->pStackFunctions[ --pFunc->iStackFunctions ]->cParamTypes; - hb_comp_iParamCount = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->iParamCount; - - iParamCount = hb_comp_iParamCount; - - /* - printf( "\nExec Method: %s of Class: %s Parameters: %i\n", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, pFunc->pStackClasses[ pFunc->iStackClasses - 1 ]->szName, pFunc->pStackFunctions[ pFunc->iStackFunctions ]->iParamCount ); - */ - - /* First, find how many optionals. */ - while ( --iParamCount >= 0 ) - { - if( hb_comp_cParamTypes[ iParamCount ] == ( ' ' + VT_OFFSET_OPTIONAL ) || hb_comp_cParamTypes[ iParamCount ] >= ( 'A' + VT_OFFSET_OPTIONAL ) ) - iOptionals++; - else - break; - } - - /*printf( "\nOptionals: %i\n", iOptionals );*/ - - /*printf( "Method: %s, wVar: %i Parameters: %i Optionals: %i\n", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, wVar, hb_comp_iParamCount, iOptionals );*/ - - /* Now, check the types. */ - if( wVar >= ( hb_comp_iParamCount - iOptionals ) && wVar <= hb_comp_iParamCount ) - { - BYTE iParamBase = pFunc->iStackIndex - wVar, cFormalType; - int iOffset = wVar; - - while ( --iOffset >= 0 ) - { - cFormalType = hb_comp_cParamTypes[ iOffset ]; - - /*printf( "\nFormal # %i Type: %c\n", iOffset, cFormalType );*/ - - if( cFormalType == ( ' ' + VT_OFFSET_OPTIONAL ) || cFormalType >= ( 'A' + VT_OFFSET_OPTIONAL ) ) - cFormalType -= VT_OFFSET_OPTIONAL; - - if( cFormalType == ' ' + VT_OFFSET_BYREF ) - cFormalType = '@'; - - if( cFormalType == ' ' ) - ; /* Formal is Variant, accept anything. */ - else if( pFunc->pStack[ iParamBase + iOffset ] == '-' ) - ; /* Parameter is NIL, always accepted. */ - else if( cFormalType == '@' && pFunc->pStack[ iParamBase + iOffset ] >= ( 'A' + VT_OFFSET_BYREF ) ) - ; /* Formal is ANY REFERENCE, and Parameter is SOME REFERENCE. */ - else if( cFormalType == pFunc->pStack[ iParamBase + iOffset ] - VT_OFFSET_VARIANT ) - ; /* Prameter is VARIANT.SubType of same as Formal. */ - else if( cFormalType == 'S' && pFunc->pStack[ iParamBase + iOffset ] == 'S' && pFunc->iStackClasses ) - { - PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; - PCOMCLASS hb_comp_pParamClass = pFunc->pStackClasses[ --pFunc->iStackClasses ]; - - if( hb_comp_pFormalClass != hb_comp_pParamClass ) - { - sprintf( ( char * ) szType1, "%i", iOffset + 1 ); - sprintf( ( char * ) szType2, "%s", hb_comp_pFormalClass->szName ); - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 ); - } - } - else if( cFormalType == 's' && pFunc->pStack[ iParamBase + iOffset ] == 's' && pFunc->iStackClasses ) - { - PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; - PCOMCLASS hb_comp_pParamClass = pFunc->pStackClasses[ --pFunc->iStackClasses ]; - - if( hb_comp_pFormalClass != hb_comp_pParamClass ) - { - sprintf( ( char * ) szType1, "%i", iOffset + 1 ); - sprintf( ( char * ) szType2, "ARRAY OF %s", hb_comp_pFormalClass->szName ); - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 ); - } - } - else if( islower( cFormalType ) && pFunc->pStack[ iParamBase + iOffset ] == 'A' ) - { - if( cFormalType == 'S' ) - { - PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; - sprintf( ( char * ) szType2, "%s", hb_comp_pFormalClass->szName ); - } - else if( cFormalType == 's' ) - { - PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; - sprintf( ( char * ) szType2, "ARRAY OF %s", hb_comp_pFormalClass->szName ); - } - else - { - if( cFormalType == ( '-' + VT_OFFSET_BYREF ) || cFormalType >= ( 'A' + VT_OFFSET_BYREF ) ) - sprintf( ( char * ) szType2, "@%c", cFormalType - VT_OFFSET_BYREF ); - else if( islower( cFormalType ) ) - sprintf( ( char * ) szType2, "ARRAY OF %c", toupper( cFormalType ) ); - else - sprintf( ( char * ) szType2, "%c", cFormalType ); - } - - if( pFunc->pStack[ iParamBase + iOffset ] == 'S' ) - { - PCOMCLASS hb_comp_pParamClass = pFunc->pStackClasses[ --pFunc->iStackClasses ]; - sprintf( ( char * ) szType1, "(%i) %s", iOffset + 1, hb_comp_pParamClass->szName ); - } - else if( pFunc->pStack[ iParamBase + iOffset ] == 's' ) - { - PCOMCLASS hb_comp_pParamClass = pFunc->pStackClasses[ --pFunc->iStackClasses ]; - sprintf( ( char * ) szType1, "(%i) ARRAY OF %s", iOffset + 1, hb_comp_pParamClass->szName ); - } - else - { - if( pFunc->pStack[ iParamBase + iOffset ] == ( '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ iParamBase + iOffset ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - sprintf( ( char * ) szType1, "(%i) AnyType.SubType[%c]", iOffset + 1, pFunc->pStack[ iParamBase + iOffset ] - VT_OFFSET_VARIANT ); - else if( islower( pFunc->pStack[ iParamBase + iOffset ] ) ) - sprintf( ( char * ) szType1, "(%i) ARRAY OF %c", iOffset + 1, toupper( pFunc->pStack[ iParamBase + iOffset ] ) ); - else - sprintf( ( char * ) szType1, "(%i) %c", iOffset + 1, pFunc->pStack[ iParamBase + iOffset ] ); - } - - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_SUSPECT, ( char * ) szType1, ( char * ) szType2 ); - } - else if( cFormalType != pFunc->pStack[ iParamBase + iOffset ] ) - { - if( cFormalType == 'S' ) - { - PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; - sprintf( ( char * ) szType2, "%s", hb_comp_pFormalClass->szName ); - } - else if( cFormalType == 's' ) - { - PCOMCLASS hb_comp_pFormalClass = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pParamClasses[ iOffset ]; - sprintf( ( char * ) szType2, "ARRAY OF %s", hb_comp_pFormalClass->szName ); - } - else - { - if( cFormalType == ( '-' + VT_OFFSET_BYREF ) || cFormalType >= ( 'A' + VT_OFFSET_BYREF ) ) - sprintf( ( char * ) szType2, "@%c", cFormalType - VT_OFFSET_BYREF ); - else if( islower( cFormalType ) ) - sprintf( ( char * ) szType2, "ARRAY OF %c", toupper( cFormalType ) ); - else - sprintf( ( char * ) szType2, "%c", cFormalType ); - } - - if( pFunc->pStack[ iParamBase + iOffset ] == 'S' ) - { - PCOMCLASS hb_comp_pParamClass = pFunc->pStackClasses[ --pFunc->iStackClasses ]; - sprintf( ( char * ) szType1, "(%i) %s", iOffset + 1, hb_comp_pParamClass->szName ); - } - else if( pFunc->pStack[ iParamBase + iOffset ] == 's' ) - { - PCOMCLASS hb_comp_pParamClass = pFunc->pStackClasses[ --pFunc->iStackClasses ]; - sprintf( ( char * ) szType1, "(%i) ARRAY OF %s", iOffset + 1, hb_comp_pParamClass->szName ); - } - else - { - if( pFunc->pStack[ iParamBase + iOffset ] == ( '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ iParamBase + iOffset ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - sprintf( ( char * ) szType1, "(%i) AnyType.SubType[%c]", iOffset + 1, pFunc->pStack[ iParamBase + iOffset ] - VT_OFFSET_VARIANT ); - else if( islower( pFunc->pStack[ iParamBase + iOffset ] ) ) - sprintf( ( char * ) szType1, "(%i) ARRAY OF %c", iOffset + 1, toupper( pFunc->pStack[ iParamBase + iOffset ] ) ); - else - sprintf( ( char * ) szType1, "(%i) %c", iOffset + 1, pFunc->pStack[ iParamBase + iOffset ] ); - } - - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_TYPE, ( char * ) szType1, ( char * ) szType2 ); - } - } - } - else - { - /*printf( "Method: %s, wVar: %i Parameters: %i Optionals: %i\n", pFunc->pStackFunctions[ pFunc->iStackFunctions ]->szName, wVar, hb_comp_iParamCount, iOptionals );*/ - sprintf( ( char * ) szType1, "%i", wVar ); - sprintf( ( char * ) szType2, "%i", hb_comp_iParamCount - iOptionals ); - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_PARAM_COUNT, ( char * ) szType1, ( char * ) szType2 ); - } - } - else if( pFunc->iStackFunctions ) - { - --pFunc->iStackFunctions; - } - - /* Removing all the parameters.*/ - pFunc->iStackIndex -= wVar; - - if( cType == 'S' && pFunc->pStackFunctions[ pFunc->iStackFunctions ] ) - { - pFunc->pStack[ pFunc->iStackIndex - 1 ] = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->cType; - - /* - printf( "\nDeclared Method!!! Stack: %i Type: %c\n", pFunc->iStackIndex, pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - */ - - if( toupper( pFunc->pStack[ pFunc->iStackIndex - 1 ] ) == 'S' && pFunc->iStackClasses < 8 ) - { - /* - printf( "\nNested CLASS!!! Stack: %i Type: %c Class: %s\n", pFunc->iStackIndex, pFunc->pStack[ pFunc->iStackIndex - 1 ], pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pClass->szName ); - */ - pFunc->pStackClasses[ pFunc->iStackClasses++ ] = pFunc->pStackFunctions[ pFunc->iStackFunctions ]->pClass; - } - } - else - { - pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' '; - } - - break; - - case HB_P_DEC : - case HB_P_INC : - if( ( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex - 1 ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType1 = ( pFunc->pStack[ pFunc->iStackIndex - 1 ] -= VT_OFFSET_VARIANT ); - } - - if( cSubType1 && cSubType1 == '-' ) - { - strcpy( ( char * ) szType1, "AnyType.SubType[NIL]" ); - } - else if( cSubType1 ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[%c]", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' ) - { - strcpy( ( char * ) szType1, "NIL" ); - } - else - { - sprintf( ( char * ) szType1, "%c", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - } - - if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == 'N' ) - { - /* Ok. */ - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "N", NULL ); - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, ( char * ) szType1, "N" ); - } - break; - - case HB_P_JUMPNEAR : - case HB_P_JUMP : - case HB_P_JUMPFAR : - /* Restoring Stack depth. */ - if( s_iCondIndex ) - { - pFunc->iStackIndex = s_aiPreCondStack[ --s_iCondIndex ]; - } - /* - printf( "\nAfter Cond: %i\n", pFunc->iStackIndex ); - */ - break; - - case HB_P_JUMPFALSENEAR : - case HB_P_JUMPFALSE : - case HB_P_JUMPFALSEFAR : - case HB_P_JUMPTRUENEAR : - case HB_P_JUMPTRUE : - case HB_P_JUMPTRUEFAR : - if( pFunc->iStackIndex < 1 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - pFunc->iStackIndex--; - - /* - printf( "\nBefore Cond: %i\n", pFunc->iStackIndex ); - */ - - /* Saving Stack depth befor Jump. */ - /* TODO: Remove Hard coded limitation. */ - if( s_iCondIndex < 16 ) - { - s_aiPreCondStack[ s_iCondIndex++ ] = pFunc->iStackIndex; - } - - if( ( pFunc->pStack[ pFunc->iStackIndex ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType1 = ( pFunc->pStack[ pFunc->iStackIndex ] -= VT_OFFSET_VARIANT ); - } - - if( cSubType1 && cSubType1 == '-' ) - { - strcpy( ( char * ) szType1, "AnyType.SubType[NIL]" ); - } - else if( cSubType1 ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[%c]", pFunc->pStack[ pFunc->iStackIndex ] ); - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == '-' ) - { - strcpy( ( char * ) szType1, "NIL" ); - } - else - { - sprintf( ( char * ) szType1, "%c", pFunc->pStack[ pFunc->iStackIndex ] ); - } - - if( pFunc->pStack[ pFunc->iStackIndex ] == 'L' ) - { - /* Ok. */ - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "L", NULL ); - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, ( char * ) szType1, "L" ); - } - break; - - case HB_P_INSTRING : - if( pFunc->iStackIndex < 2 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - pFunc->iStackIndex--; - - if( ( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex - 1 ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType1 = ( pFunc->pStack[ pFunc->iStackIndex - 1 ] -= VT_OFFSET_VARIANT ); - } - - if( ( pFunc->pStack[ pFunc->iStackIndex ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType2 = ( pFunc->pStack[ pFunc->iStackIndex ] -= VT_OFFSET_VARIANT ); - } - - if( cSubType1 && cSubType1 == '-' ) - { - strcpy( ( char * ) szType1, "AnyType.SubType[NIL]" ); - } - else if( cSubType1 ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[%c]", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' ) - { - strcpy( ( char * ) szType1, "NIL"); - } - else - { - sprintf( ( char * ) szType1, "%c", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - } - - if( cSubType2 && cSubType2 == '-' ) - { - strcpy( ( char * ) szType2, "AnyType.SubType[NIL]" ); - } - else if( cSubType2 ) - { - sprintf( ( char * ) szType2, "AnyType.SubType[%c]", pFunc->pStack[ pFunc->iStackIndex ] ); - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == '-' ) - { - strcpy( ( char * ) szType2, "NIL" ); - } - else - { - sprintf( ( char * ) szType2, "%c", pFunc->pStack[ pFunc->iStackIndex ] ); - } - - if( pFunc->pStack[ pFunc->iStackIndex ] == ' ' && pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) - { - /* Ok. */ - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == 'C' && pFunc->pStack[ pFunc->iStackIndex - 1 ] == 'C' ) - { - /* Override the last item with the new result type */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'L'; - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "C", NULL ); - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] != 'C' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, ( char * ) szType1, "C" ); - - /* Override the last item with the new result type */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'U'; - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "C", NULL ); - - /* Override the last item with the new result type */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' '; - } - else if( pFunc->pStack[ pFunc->iStackIndex ] != 'C' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, ( char * ) szType2, "C" ); - - /* Override the last item with the new result type */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'U'; - } - - break; - - /* May be subject to Operator Overloading - don't restrict to Numeric! */ - case HB_P_DIVIDE : - case HB_P_PLUS : - case HB_P_MINUS : - case HB_P_NEGATE : - case HB_P_MULT : - case HB_P_POWER : - if( pFunc->iStackIndex < 2 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - pFunc->iStackIndex--; - - /*printf( "\nTop: %c Bottom: %c Typ-SubType: %c Bottom->SubType: %c\n", pFunc->pStack[ pFunc->iStackIndex], pFunc->pStack[ pFunc->iStackIndex - 1 ], pFunc->pStack[ pFunc->iStackIndex] - 100, pFunc->pStack[ pFunc->iStackIndex - 1 ] - 100 );*/ - - if( ( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex - 1 ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType1 = pFunc->pStack[ pFunc->iStackIndex - 1 ] - VT_OFFSET_VARIANT; - } - - if( ( pFunc->pStack[ pFunc->iStackIndex ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType2 = pFunc->pStack[ pFunc->iStackIndex ] - VT_OFFSET_VARIANT; - } - - if( cSubType1 && cSubType1 == '-' ) - { - strcpy( ( char * ) szType1, "AnyType.SubType[NIL]" ); - } - else if( cSubType1 ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[%c]", cSubType1 ); - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' ) - { - strcpy( ( char * ) szType1, "NIL"); - } - else - { - sprintf( ( char * ) szType1, "%c", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - } - - if( cSubType2 && cSubType2 == '-' ) - { - strcpy( ( char * ) szType2, "AnyType.SubType[NIL]" ); - } - else if( cSubType2 ) - { - sprintf( ( char * ) szType2, "AnyType.SubType[%c]", cSubType2 ); - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == '-' ) - { - strcpy( ( char * ) szType2, "NIL" ); - } - else - { - sprintf( ( char * ) szType2, "%c", pFunc->pStack[ pFunc->iStackIndex ] ); - } - - if( ! cSubType1 ) - { - cSubType1 = pFunc->pStack[ pFunc->iStackIndex - 1 ]; - } - - if( ! cSubType2 ) - { - cSubType2 = pFunc->pStack[ pFunc->iStackIndex ]; - } - - if( cSubType1 == ' ' && cSubType2 == ' ' ) - { - /* Override the last item with the new result type which is already there */ - } - else if( cSubType1 == 'N' && cSubType2 == 'N' ) - { - /* Override the last item with the new result type wich is already there */ - } - else if( ( pFunc->pCode[ ulPos ] == HB_P_PLUS || pFunc->pCode[ ulPos ] == HB_P_MINUS ) && - cSubType1 == cSubType2 ) - { - /* Override the last item with the new result type wich is already there */ - } - else if( cSubType1 == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, ( char * ) szType1, ( char * ) szType2 ); - - /* Override the last item with the new result type. */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = cSubType2; - } - else if( cSubType2 == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, ( char * ) szType2, ( char * ) szType1 ); - - /* Override the last item with the new result type. */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = cSubType1; - } - else if( cSubType1 == '-' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, (char *) szType1, ( char * ) szType2 ); - - /* Override the last item with the new result type. */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'U'; - } - else if( cSubType2 == '-' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, (char *) szType2, ( char * ) szType1 ); - - /* Override the last item with the new result type. */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'U'; - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERANDS_INCOMPATIBLE, ( char * ) szType1, ( char * ) szType2 ); - - /* Override the last item with the new result type */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'U'; - } - break; - - case HB_P_FORTEST : - - if( pFunc->iStackIndex < 3 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - pFunc->iStackIndex--; - - /* --- */ - - if( ( pFunc->pStack[ pFunc->iStackIndex - 2 ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex - 2 ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType0 = pFunc->pStack[ pFunc->iStackIndex - 2 ] - VT_OFFSET_VARIANT; - } - - if( ( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex - 1 ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType1 = pFunc->pStack[ pFunc->iStackIndex - 1 ] - VT_OFFSET_VARIANT; - } - - if( ( pFunc->pStack[ pFunc->iStackIndex ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType2 = pFunc->pStack[ pFunc->iStackIndex ] - VT_OFFSET_VARIANT; - } - - /* --- */ - - if( cSubType0 && cSubType0 == '-' ) - { - strcpy( ( char * ) szType0, "AnyType.SubType[NIL]" ); - } - else if( cSubType0 ) - { - sprintf( ( char * ) szType0, "AnyType.SubType[%c]", cSubType0 ); - } - else if( pFunc->pStack[ pFunc->iStackIndex - 2 ] == '-' ) - { - strcpy( ( char * ) szType0, "NIL"); - } - else - { - sprintf( ( char * ) szType0, "%c", pFunc->pStack[ pFunc->iStackIndex - 2 ] ); - } - - /* --- */ - - if( cSubType1 && cSubType1 == '-' ) - { - strcpy( ( char * ) szType1, "AnyType.SubType[NIL]" ); - } - else if( cSubType1 ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[%c]", cSubType1 ); - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' ) - { - strcpy( ( char * ) szType1, "NIL"); - } - else - { - sprintf( ( char * ) szType1, "%c", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - } - - /* --- */ - - if( cSubType2 && cSubType2 == '-' ) - { - strcpy( ( char * ) szType2, "AnyType.SubType[NIL]" ); - } - else if( cSubType2 ) - { - sprintf( ( char * ) szType2, "AnyType.SubType[%c]", cSubType2 ); - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == '-' ) - { - strcpy( ( char * ) szType2, "NIL" ); - } - else - { - sprintf( ( char * ) szType2, "%c", pFunc->pStack[ pFunc->iStackIndex ] ); - } - - /* --- */ - - if( ! cSubType0 ) - { - cSubType0 = pFunc->pStack[ pFunc->iStackIndex - 2 ]; - } - - if( ! cSubType1 ) - { - cSubType1 = pFunc->pStack[ pFunc->iStackIndex - 1 ]; - } - - if( ! cSubType2 ) - { - cSubType2 = pFunc->pStack[ pFunc->iStackIndex ]; - } - - /* --- */ - - if( cSubType0 == 'N' ) - { - /* Ok. */ - } - else if ( cSubType0 == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "UnKnown", "N" ); - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, ( char * ) szType0, "N" ); - } - - /* --- */ - - if( cSubType1 == 'N' ) - { - /* Ok. */ - } - else if ( cSubType1 == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "UnKnown", "N" ); - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, ( char * ) szType1, "N" ); - } - - /* --- */ - - if( cSubType2 == 'N' ) - { - /* Ok. */ - } - else if ( cSubType2 == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "UnKnown", "N" ); - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, ( char * ) szType2, "N" ); - } - - /* Remove Step. */ - pFunc->iStackIndex--; - - /* Override the last item with Logical */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'L'; - - break; - - case HB_P_GREATER : - case HB_P_GREATEREQUAL : - case HB_P_LESSEQUAL : - case HB_P_LESS : - if( pFunc->iStackIndex < 2 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - pFunc->iStackIndex--; - - if( ( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex - 1 ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType1 = ( pFunc->pStack[ pFunc->iStackIndex - 1 ] -= VT_OFFSET_VARIANT ); - } - - if( ( pFunc->pStack[ pFunc->iStackIndex ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType2 = ( pFunc->pStack[ pFunc->iStackIndex ] -= VT_OFFSET_VARIANT ); - } - - if( cSubType1 && cSubType1 == '-' ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[NIL]" ); - } - else if( cSubType1 ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[%c]", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' ) - { - strcpy( ( char * ) szType1, "NIL" ); - } - else - { - sprintf( ( char * ) szType1, "%c", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - } - - if( cSubType2 && cSubType2 == '-' ) - { - strcpy( ( char * ) szType2, "AnyType.SubType[NIL]" ); - } - else if( cSubType2 ) - { - sprintf( ( char * ) szType2, "AnyType.SubType[%c]", pFunc->pStack[ pFunc->iStackIndex ] ); - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == '-' ) - { - strcpy( ( char * ) szType2, "NIL" ); - } - else - { - sprintf( ( char * ) szType2, "%c", pFunc->pStack[ pFunc->iStackIndex ] ); - } - - if( pFunc->pStack[ pFunc->iStackIndex ] == '-' || pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERANDS_INCOMPATIBLE, ( char * ) szType1, ( char * ) szType2 ); - - /* Override the last item with the new result type wich is already there */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'U'; - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == ' ' && pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) - { - /* Override the last item with the new result type which is already there */ - ; - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == pFunc->pStack[ pFunc->iStackIndex - 1 ] ) - { - /* Override the last item with the new result type */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'L'; - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, ( char * ) szType1, NULL ); - - /* Override the last item with the new result type wich is already there */ - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, ( char * ) szType2, NULL ); - - /* Override the last item with the new result type */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' '; - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERANDS_INCOMPATIBLE, ( char * ) szType1, ( char * ) szType2 ); - - /* Override the last item with the new result type */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'U'; - } - - break; - - case HB_P_EQUAL : - case HB_P_EXACTLYEQUAL : - case HB_P_NOTEQUAL : - if( pFunc->iStackIndex < 2 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - pFunc->iStackIndex--; - - if( ( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex - 1 ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType1 = ( pFunc->pStack[ pFunc->iStackIndex - 1 ] -= VT_OFFSET_VARIANT ); - } - if( cSubType1 && cSubType1 == '-' ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[NIL]" ); - } - else if( cSubType1 ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[%c]", cSubType1 ); - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' ) - { - strcpy( ( char * ) szType1, "NIL"); - } - else - { - sprintf( ( char * ) szType1, "%c", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - } - - /*---*/ - - if( ( pFunc->pStack[ pFunc->iStackIndex ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType2 = ( pFunc->pStack[ pFunc->iStackIndex ] -= VT_OFFSET_VARIANT ); - } - if( cSubType2 && cSubType2 == '-' ) - { - strcpy( ( char * ) szType2, "AnyType.SubType[NIL]" ); - } - else if( cSubType2 ) - { - sprintf( ( char * ) szType2, "AnyType.SubType[%c]", cSubType2 ); - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == '-' ) - { - strcpy( ( char * ) szType2, "NIL" ); - } - else - { - sprintf( ( char * ) szType2, "%c", pFunc->pStack[ pFunc->iStackIndex ] ); - } - - /*---*/ - - if( ! cSubType1 ) - { - cSubType1 = pFunc->pStack[ pFunc->iStackIndex - 1 ]; - } - - if( ! cSubType2 ) - { - cSubType2 = pFunc->pStack[ pFunc->iStackIndex ]; - } - - if( cSubType1 == '-' || cSubType2 == '-' ) - { - /* Override the last item with the new result type */ - } - else if( cSubType1 == cSubType2 ) - { - /* Override the last item with the new result type */ - } - else if( cSubType1 == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, ( char * ) szType2, NULL ); - /* Override the last item with the new result type wich is already there */ - } - else if( cSubType2 == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, ( char * ) szType1, NULL ); - /* Override the last item with the new result type */ - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERANDS_INCOMPATIBLE, ( char * ) szType1, ( char * ) szType2 ); - /* Override the last item with the new result type */ - } - - /* Override the last item with the new result type */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'L'; - - break; - - case HB_P_NOT : - if( pFunc->iStackIndex < 1 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - if( ( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex - 1 ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType1 = ( pFunc->pStack[ pFunc->iStackIndex - 1 ] -= VT_OFFSET_VARIANT ); - } - - if( cSubType1 && cSubType1 == '-' ) - { - strcpy( ( char * ) szType1, "AnyType.SubType[NIL]" ); - } - else if( cSubType1 ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[%c]", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' ) - { - strcpy( ( char * ) szType1, "NIL" ); - } - else - { - sprintf( ( char * ) szType1, "%c", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - } - - if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "L", NULL ); - - /* Override the last item with the new result type which is already there */ - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] != 'L' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, ( char * ) szType1, "L" ); - - /* Override the last item with the new result type */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'U'; - } - - break; - - case HB_P_AND : - case HB_P_OR : - if( pFunc->iStackIndex < 2 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - pFunc->iStackIndex--; - - if( ( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex - 1 ] >= 'A' + VT_OFFSET_VARIANT ) - { - cSubType1 = ( pFunc->pStack[ pFunc->iStackIndex - 1 ] -= VT_OFFSET_VARIANT ); - } - - if( ( pFunc->pStack[ pFunc->iStackIndex ] == '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cSubType2 = ( pFunc->pStack[ pFunc->iStackIndex ] -= VT_OFFSET_VARIANT ); - } - - if( cSubType1 && cSubType1 == '-' ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[NIL]" ); - } - else if( cSubType1 ) - { - sprintf( ( char * ) szType1, "AnyType.SubType[%c]", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == '-' ) - { - strcpy( ( char * ) szType1, "NIL"); - } - else - { - sprintf( ( char * ) szType1, "%c", pFunc->pStack[ pFunc->iStackIndex - 1 ] ); - } - - if( cSubType2 && cSubType2 == '-' ) - { - strcpy( ( char * ) szType2, "AnyType.SubType[NIL]" ); - } - else if( cSubType2 ) - { - sprintf( ( char * ) szType2, "AnyType.SubType[%c]", pFunc->pStack[ pFunc->iStackIndex ] ); - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == '-' ) - { - strcpy( ( char * ) szType2, "NIL" ); - } - else - { - sprintf( ( char * ) szType2, "%c", pFunc->pStack[ pFunc->iStackIndex ] ); - } - - if( ( pFunc->pStack[ pFunc->iStackIndex ] == ' ' && pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) || - ( pFunc->pStack[ pFunc->iStackIndex ] == 'L' && pFunc->pStack[ pFunc->iStackIndex - 1 ] == 'L' ) ) - { - /* Override the last item with the new result type which is already there */ - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "L", NULL ); - - /* Override the last item with the new result type which is already there */ - } - else if( pFunc->pStack[ pFunc->iStackIndex - 1 ] != 'L' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, ( char * ) szType1, "L" ); - - /* Override the last item with the new result type */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'U'; - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "L", NULL ); - - /* Override the last item with the new result type which is already there */ - } - - else if( pFunc->pStack[ pFunc->iStackIndex ] != 'L' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_TYPE, ( char * ) szType2, "L" ); - - /* Override the last item with the new result type */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'U'; - } - - break; - - case HB_P_DUPLICATE : - if( pFunc->iStackIndex < 1 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - bLast1 = pFunc->pStack[ pFunc->iStackIndex - 1 ]; - pFunc->pStack[ pFunc->iStackIndex++ ] = bLast1; - break; - - case HB_P_DUPLTWO : - if( pFunc->iStackIndex < 2 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - bLast1 = pFunc->pStack[ pFunc->iStackIndex - 2 ]; - bLast2 = pFunc->pStack[ pFunc->iStackIndex - 1 ]; - pFunc->pStack[ pFunc->iStackIndex++ ] = bLast1; - pFunc->pStack[ pFunc->iStackIndex++ ] = bLast2; - break; - - /* Explicit Types. */ - - /* Objects */ - case HB_P_PUSHSELF : - pFunc->pStack[ pFunc->iStackIndex++ ] = 'O'; - - /* Todo find Self's Class. */ - break; - - #if 0 - /* Blcoks */ - case HB_P_PUSHBLOCKSHORT : - case HB_P_PUSHBLOCK : - break; - #endif - - case HB_P_ENDBLOCK : - /* Override the last value of the block left on the stack. */ - /* The last value was actualy generated on the pBlock stack, not in parrent. */ - pFunc->pStack[ pFunc->iStackIndex++ ] = 'B'; - break; - - /* Undefined */ - case HB_P_PUSHNIL : - pFunc->pStack[ pFunc->iStackIndex++ ] = '-'; - break; - - /* Logicals */ - case HB_P_TRUE : - case HB_P_FALSE : - pFunc->pStack[ pFunc->iStackIndex++ ] = 'L'; - break; - - /* Numerics */ - case HB_P_PUSHDOUBLE : - case HB_P_PUSHLONGLONG : - case HB_P_PUSHLONG : - case HB_P_PUSHINT : - case HB_P_PUSHBYTE : - case HB_P_ZERO : - case HB_P_ONE : - pFunc->pStack[ pFunc->iStackIndex++ ] = 'N'; - break; - - /* Charcters */ - case HB_P_PUSHSTRSHORT : - case HB_P_PUSHSTR : - pFunc->pStack[ pFunc->iStackIndex++ ] = 'C'; - break; - - case HB_P_PUSHSYMNEAR : - case HB_P_PUSHSYM : - case HB_P_MPUSHSYM : - /* In Private or Public statement can't be a declared function */ - if( ( hb_comp_iVarScope == VS_PRIVATE || hb_comp_iVarScope == VS_PUBLIC ) ) - { - pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; - } - else - { - if( pFunc->pCode[ ulPos ] == HB_P_PUSHSYMNEAR ) - { - pSym = hb_compSymbolGetPos( pFunc->pCode[ ulPos + 1 ] ); - } - else - { - pSym = hb_compSymbolGetPos( HB_PCODE_MKUSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ) ); - } - - /*printf( "\nSymbol: %s\n", pSym->szName );*/ - - if( pSym && pSym->szName ) - { - pDeclared = hb_compDeclaredFind( pSym->szName ); - - if( pDeclared ) - { - pFunc->pStack[ pFunc->iStackIndex++ ] = pDeclared->cType; - - if( toupper( pDeclared->cType ) == 'S' && pFunc->iStackClasses < 8 ) - { - pFunc->pStackClasses[ pFunc->iStackClasses++ ] = pDeclared->pClass; - } - } - else - { - pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; - } - - /* Storing, will be checked by HB_P_FUNCTION, OK to store NULL */ - /* TODO don't use hard coded size */ - if( pFunc->iStackFunctions < 8 ) - { - pFunc->pStackFunctions[ pFunc->iStackFunctions++ ] = pDeclared; - } - - /* QUESTION: Add other "safe" functions, or remove adaptive type checking support for memvars? */ - if( strcmp( pSym->szName, "QOUT" ) == 1 ) - { - /*printf( "\nRestting privates affected by: %s\n", pSym->szName );*/ - - /* All Private Variants Subtype will be unknown after function call. */ - pVar = pFunc->pMemvars; - while ( pVar ) - { - if( pVar->cType == ( '-' + VT_OFFSET_VARIANT ) || pVar->cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - pVar->cType = ' '; - } - - pVar = pVar->pNext; - } - } - - /* - printf( "\nPushed: %s() Type: %c Stack: %i\n", pSym->szName, pFunc->pStack[ pFunc->iStackIndex - 1], pFunc->iStackIndex - 1 ); - */ - } - else - { - /* Storing, will be checked by FUNCTION, OK to store NULL */ - /* TODO don't use hard coded size */ - if( pFunc->iStackFunctions < 8 ) - { - pFunc->pStackFunctions[ pFunc->iStackFunctions++ ] = NULL; - } - - pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; - } - } - break; - - case HB_P_FUNCPTR : - /* Previous symbol pushed no longer used as function call. */ - pFunc->pStackFunctions[ --pFunc->iStackFunctions ] = NULL; - pFunc->pStack[ pFunc->iStackIndex - 1 ] = 'F'; - break; - - case HB_P_PUSHLOCALNEAR : - case HB_P_PUSHLOCALREF : - case HB_P_PUSHLOCAL : - if( pFunc->pCode[ ulPos ] == HB_P_PUSHLOCALNEAR ) - { - wVar = ( signed char ) pFunc->pCode[ ulPos + 1 ]; - } - else - { - wVar = HB_PCODE_MKSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ); - } - - /* we are accesing variables within a codeblock */ - if( wVar < 0 ) - { - /* Finding the Function owning the block. */ - pTmp = pFunc->pOwner; - - /* Might be a nested block. */ - while ( pTmp->pOwner ) - { - pTmp = pTmp->pOwner; - } - - pVar = pFunc->pStatics; - while( ++wVar < 0 && pVar ) - { - pVar = pVar->pNext; - } - - if ( pVar ) - { - wVar = hb_compVariableGetPos( pTmp->pLocals, pVar->szName ); - pVar = hb_compVariableFind( pTmp->pLocals, wVar ); - } - } - else - { - pVar = hb_compVariableFind( pFunc->pLocals, wVar ); - } - - if( pVar ) - { - if( pFunc->pCode[ ulPos ] == HB_P_PUSHLOCALREF ) - { - pVar->iUsed |= VU_INITIALIZED; - } - else if( ! ( pVar->iUsed & VU_INITIALIZED ) ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_INITIALIZED, pVar->szName, NULL ); - } - - /* - printf( "\nUsed: %s\n", pVar->szName ); - */ - - /* Mark as used */ - pVar->iUsed |= VU_USED; - - if( pVar->cType == ( '-' + VT_OFFSET_VARIANT ) || pVar->cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cType = pVar->cType - VT_OFFSET_VARIANT; - } - else - { - cType = pVar->cType; - } - - if( toupper( cType ) == 'S' && pFunc->iStackClasses < 8 ) - { - /* Object of declared class */ - pFunc->pStackClasses[ pFunc->iStackClasses++ ] = pVar->pClass; - } - - if( pFunc->pCode[ ulPos ] == HB_P_PUSHLOCALREF ) - pFunc->pStack[ pFunc->iStackIndex++ ] = pVar->cType + VT_OFFSET_BYREF; - else - pFunc->pStack[ pFunc->iStackIndex++ ] = pVar->cType; - } - else - { - /* - printf( "\nCould not find Local %i in: $s\n", wVar, pFunc->szName ); - */ - - if( pFunc->pCode[ ulPos ] == HB_P_PUSHLOCALREF ) - pFunc->pStack[ pFunc->iStackIndex++ ] = '@'; - else - pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; - } - break; - - case HB_P_PUSHSTATICREF : - case HB_P_PUSHSTATIC : - pTmp = hb_comp_functions.pFirst; - wVar = HB_PCODE_MKSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ); - - while( pTmp->pNext && pTmp->pNext->iStaticsBase < wVar ) - { - pTmp = pTmp->pNext; - } - - pVar = hb_compVariableFind( pTmp->pStatics, wVar - pTmp->iStaticsBase ); - - /* Will be pushed shortly. */ - pFunc->iStackIndex++; - - if( pVar ) - { - /*printf( "\nStatic: %s Type: %c Function: %s Found in: %s\n", pVar->szName, pVar->cType, pFunc->szName, pTmp->szName );*/ - - /* Only if "private" static, since global static may be intialized elsewhere. */ - /* May have been initialized in previous execution of the function. - if( pTmp == pFunc ) - if( ! ( pVar->iUsed & VU_INITIALIZED ) ) - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_INITIALIZED, pVar->szName, NULL ); - */ - - /* Mark as used */ - pVar->iUsed |= VU_USED; - - if( pVar->cType == ( '-' + VT_OFFSET_VARIANT ) || pVar->cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cType = pVar->cType - VT_OFFSET_VARIANT; - } - else - { - cType = pVar->cType; - } - - if( toupper( cType ) == 'S' && pFunc->iStackClasses < 8 ) - { - /* Object of declared class */ - pFunc->pStackClasses[ pFunc->iStackClasses++ ] = pVar->pClass; - } - - if( pFunc->pCode[ ulPos ] == HB_P_PUSHSTATICREF ) - { - pFunc->pStack[ pFunc->iStackIndex - 1 ] = pVar->cType + VT_OFFSET_BYREF; - } - else - { - pFunc->pStack[ pFunc->iStackIndex - 1 ] = pVar->cType; - } - } - else - { - if( pFunc->pCode[ ulPos ] == HB_P_PUSHSTATICREF ) - { - pFunc->pStack[ pFunc->iStackIndex - 1 ] = '@'; - } - else - { - pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' '; - } - } - break; - - case HB_P_PUSHVARIABLE : - /* Type can not be detrmined at compile time. */ - pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; - break; - - case HB_P_PUSHALIASEDVAR : - /* TODO check what is aliased var. */ - pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; - break; - - case HB_P_PUSHALIASEDFIELDNEAR : - pSym = hb_compSymbolGetPos( pFunc->pCode[ ulPos + 1 ] ); - /* Fall through - don't add break */ - - case HB_P_PUSHALIASEDFIELD : - case HB_P_PUSHFIELD : - if( ! pSym ) - pSym = hb_compSymbolGetPos( HB_PCODE_MKUSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ) ); - - if( pSym && pSym->szName && pFunc->pFields ) - { - wVar = hb_compVariableGetPos( pFunc->pFields, pSym->szName ); - if( wVar ) - pVar = hb_compVariableFind( pFunc->pFields, wVar ); - } - - /* Fall through - don't add break */ - - case HB_P_PUSHMEMVARREF : - case HB_P_PUSHMEMVAR : - if( ! pSym ) - pSym = hb_compSymbolGetPos( HB_PCODE_MKUSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ) ); - - if( pSym ) - { - if( pFunc->pCode[ ulPos ] == HB_P_PUSHMEMVAR && pSym->szName ) - { - if( pFunc->pMemvars ) - { - wVar = hb_compVariableGetPos( pFunc->pMemvars, pSym->szName ); - } - - if( wVar ) - { - pVar = hb_compVariableFind( pFunc->pMemvars, wVar ); - } - - if( ! pVar ) - { - pVar = hb_compPrivateFind( pSym->szName ); - } - - if( ( ! pVar ) && hb_comp_functions.pFirst->pMemvars ) - { - wVar = hb_compVariableGetPos( hb_comp_functions.pFirst->pMemvars, pSym->szName ); - if( wVar ) - { - pVar = hb_compVariableFind( hb_comp_functions.pFirst->pMemvars, wVar ); - /* May have been initialized in any other function - can't check. */ - pVar->iUsed |= VU_INITIALIZED; - } - } - } - - if( pVar ) - { - cType = pVar->cType; - - /*printf( "\nPushed: %s Type: %c SubType: %c\n", pVar->szName, pVar->cType, pVar->cType - 100 );*/ - - if( pFunc->pCode[ ulPos ] == HB_P_PUSHMEMVARREF ) - { - pVar->iUsed |= VU_INITIALIZED; - } - else if( ! ( pVar->iUsed & VU_INITIALIZED ) ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_INITIALIZED, pVar->szName, NULL ); - } - - if( cType == ( '-' + VT_OFFSET_VARIANT ) || cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cType -= VT_OFFSET_VARIANT; - } - - /* Mark as used */ - pVar->iUsed |= VU_USED; - - if( pFunc->pCode[ ulPos ] == HB_P_PUSHMEMVARREF ) - { - pFunc->pStack[ pFunc->iStackIndex - 1 ] = pVar->cType + VT_OFFSET_BYREF; - } - else if( toupper( cType ) == 'S' && pFunc->iStackClasses < 8 ) - { - /* Object of declared class */ - pFunc->pStackClasses[ pFunc->iStackClasses++ ] = pVar->pClass; - pFunc->pStack[ pFunc->iStackIndex++ ] = pVar->cType; - } - else - { - pFunc->pStack[ pFunc->iStackIndex - 1 ] = pVar->cType; - } - } - else - { - cType = pSym->cType; - - /*printf( "\nPushed Symbol: %s Type: %c SubType: %c\n", pSym->szName, pSym->cType, pSym->cType - 100 );*/ - - if( cType == ( '-' + VT_OFFSET_VARIANT ) || cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cType -= VT_OFFSET_VARIANT; - } - - if( pFunc->pCode[ ulPos ] == HB_P_PUSHMEMVARREF ) - { - pFunc->pStack[ pFunc->iStackIndex - 1 ] = pSym->cType + VT_OFFSET_BYREF; - } - else if( toupper( cType ) == 'S' && pFunc->iStackClasses < 8 ) - { - /* Object of declared class */ - pFunc->pStackClasses[ pFunc->iStackClasses++ ] = pSym->pClass; - pFunc->pStack[ pFunc->iStackIndex++ ] = pSym->cType; - } - else - pFunc->pStack[ pFunc->iStackIndex - 1 ] = pSym->cType; - } - } - else - if( pFunc->pCode[ ulPos ] == HB_P_PUSHMEMVARREF ) - pFunc->pStack[ pFunc->iStackIndex++ ] = '@'; - else - pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; - - break; - - /* Arrays. */ - - case HB_P_ARRAYDIM : - wVar = HB_PCODE_MKSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ); - - if( pFunc->iStackIndex < wVar ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - /* Removing the dimensions sizes. */ - pFunc->iStackIndex -= wVar; - - /* Push type array of NILs (empty array). */ - pFunc->pStack[ pFunc->iStackIndex++ ] = '-' + 100; - - /*printf( "\nPushed array at: %i\n", pFunc->iStackIndex - 1 );*/ - break; - - case HB_P_ARRAYGEN : - wVar = HB_PCODE_MKSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ); - - /* TODO Error Message after finalizing all possible pcodes. */ - if( pFunc->iStackIndex < wVar ) - { - pFunc->iStackIndex = 1; - pFunc->pStack[ 0 ] = 'A'; - break; - } - - /* Pop the Elements. */ - pFunc->iStackIndex -= wVar; - - /* Push the array. */ - pFunc->pStack[ pFunc->iStackIndex++ ] = 'A'; - break; - - case HB_P_ARRAYPUSH : - if( pFunc->iStackIndex < 1 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - /* Poping the Array Index. */ - pFunc->iStackIndex--; - - cType = pFunc->pStack[ pFunc->iStackIndex - 1 ]; - - /*printf( "\n Base Type: %c\n", cType );*/ - - if( cType == ( '-' + VT_OFFSET_VARIANT ) || cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cType -= VT_OFFSET_VARIANT; - } - - if( cType == ' ' ) - { - /* Type unknown. */ - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "A", NULL ); - pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' '; - } - else if( cType == 'A' ) - { - /* Variant Array Element - Type unknown. */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' '; - } - else if( cType == 'a' ) - { - /* Variant Array Element - Type unknown. */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' '; - } - else if( islower( cType ) ) - { - /* Now we have the declared array element on the stack.*/ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = toupper( cType ); - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_ARRAY, NULL, NULL ); - } - break; - - case HB_P_ARRAYPOP : - if( pFunc->iStackIndex < 3 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - /* Poping the Array Index. */ - pFunc->iStackIndex--; - - { - BYTE cElementType = pFunc->pStack[ pFunc->iStackIndex - 2 ]; - - cType = pFunc->pStack[ pFunc->iStackIndex - 1 ]; - - if( cType == ( '-' + VT_OFFSET_VARIANT ) || cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cType -= VT_OFFSET_VARIANT; - } - - if( cElementType == ( '-' + VT_OFFSET_VARIANT ) || cElementType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cElementType -= VT_OFFSET_VARIANT; - } - - if( cType == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_OPERAND_SUSPECT, "A", NULL ); - } - else if( cType == 'A' ) - { - /* Array of variant can hold any value. */ - } - else if( cType == 'a' ) - { - /* Array of variant can hold any value. */ - } - else if( islower( cType ) && cElementType == ' ' ) - { - /* Array Of explicit type. */ - char szType[2]; - - sprintf( ( char * ) szType, "%c", toupper( cType ) ); - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT, ( char * ) szType, NULL ); - } - else if( islower( cType ) && toupper( cType ) != cElementType && cElementType != '-' ) - { - /* Array Of explicit type. */ - char szType[2]; - - sprintf( ( char * ) szType, "%c", toupper( cType ) ); - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_TYPE, ( char * ) szType, NULL ); - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_NOT_ARRAY, NULL, NULL ); - } - } - - /* Poping the Assigned Value. */ - pFunc->iStackIndex--; - - break; - - /* Macros type unknown */ - case HB_P_MPUSHALIASEDFIELD : - case HB_P_MPUSHALIASEDVAR : - case HB_P_MPUSHFIELD : - case HB_P_MPUSHMEMVAR : - case HB_P_MPUSHMEMVARREF : - case HB_P_MPUSHVARIABLE : - case HB_P_MACROPUSHALIASED : - case HB_P_MACROPUSH : - if( pFunc->iStackIndex < 1 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - /* Replace the value of the macro expression with unknown result of expanded macro. */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' '; - break; - - case HB_P_MACROSYMBOL : - if( pFunc->iStackIndex < 1 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - /* Replace Macro Variable Symbol Name type with unknown type of expanded macro Function Call */ - pFunc->pStack[ pFunc->iStackIndex - 1 ] = ' '; - break; - - case HB_P_MACROTEXT : - /* Stack already has type C. */ - /*pFunc->pStack[ pFunc->iStackIndex ] = 'C';*/ - break; - - /*-----------------4/26/00 0:15AM------------------- - * Begin POP Check and Remove from Stack. - * --------------------------------------------------*/ - - case HB_P_POP : - case HB_P_POPALIAS : - pFunc->iStackIndex--; - break; - - case HB_P_POPVARIABLE : - /* Ambigious Variable, will be determined only in Run Time! */ - pFunc->iStackIndex--; - - if( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses ) - --pFunc->iStackClasses; - - break; - - case HB_P_POPALIASEDVAR : - /* Ambigious Variable, will be determined only in Run Time! */ - pFunc->iStackIndex--; - - if( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses ) - --pFunc->iStackClasses; - - break; - - case HB_P_POPALIASEDFIELDNEAR : - if( pFunc->pCode[ ulPos ] == HB_P_POPALIASEDFIELDNEAR ) - { - wVar = ( SHORT ) pFunc->pCode[ ulPos + 1 ]; - pSym = hb_compSymbolGetPos( wVar ); - } - - /* Fall through, don't put break!!!*/ - - case HB_P_POPALIASEDFIELD : - case HB_P_POPFIELD : - if( pFunc->pCode[ ulPos ] == HB_P_POPFIELD || pFunc->pCode[ ulPos ] == HB_P_POPALIASEDFIELD ) - { - wVar = HB_PCODE_MKSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ); - pSym = hb_compSymbolGetPos( wVar ); - } - - /*printf( "\nField: %s Pos: %i", pSym->szName, wVar );*/ - - /* For fall through as well */ - if( pSym && pSym->szName && pFunc->pFields ) - { - wVar = hb_compVariableGetPos( pFunc->pFields, pSym->szName ); - if( wVar ) - pVar = hb_compVariableFind( pFunc->pFields, wVar ); - } - - if( ( ( ! wVar ) || ( ! pVar ) ) && pSym && pSym->szName && hb_comp_functions.pFirst->pFields ) - { - wVar = hb_compVariableGetPos( hb_comp_functions.pFirst->pFields, pSym->szName ); - pVar = hb_compVariableFind( hb_comp_functions.pFirst->pFields, wVar ); - } - - /* Fall through, don't put break!!!*/ - - case HB_P_POPMEMVAR : - if( pFunc->iStackIndex < 1 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - pFunc->iStackIndex--; - - if( pFunc->pCode[ ulPos ] == HB_P_POPMEMVAR ) - wVar = HB_PCODE_MKSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ); - - if( ! pSym ) - pSym = hb_compSymbolGetPos( wVar ); - - /* - if( pFunc->pMemvars ) - printf( "\nSymbol: %s #%li Function: %s which HAS memvars\n", pSym->szName, wVar, pFunc->szName ); - - if( pFunc->pPrivates ) - printf( "\nSymbol: %s #%li Function: %s which HAS privates\n", pSym->szName, wVar, pFunc->szName ); - */ - - if( pSym ) - { - if( pFunc->pCode[ ulPos ] == HB_P_POPMEMVAR && pSym->szName ) - { - if( pFunc->pMemvars ) - wVar = hb_compVariableGetPos( pFunc->pMemvars, pSym->szName ); - - if( wVar ) - pVar = hb_compVariableFind( pFunc->pMemvars, wVar ); - - if( ! pVar ) - pVar = hb_compPrivateFind( pSym->szName ); - - if( ( ! pVar ) && hb_comp_functions.pFirst->pMemvars ) - { - wVar = hb_compVariableGetPos( hb_comp_functions.pFirst->pMemvars, pSym->szName ); - if( wVar ) - pVar = hb_compVariableFind( hb_comp_functions.pFirst->pMemvars, wVar ); - } - } - - if( pVar ) - { - pVar->iUsed |= VU_INITIALIZED; - - /*printf( "\nSymbol: %s Variable: %s Type: %c #%i Function: %s\n", pSym->szName, pVar->szName, pVar->cType, wVar, pFunc->szName );*/ - - /* Allow any type into a Variant, and record the subtype */ - if( pVar->cType == ' ' || pVar->cType == ( '-' + VT_OFFSET_VARIANT ) || pVar->cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - if( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - pVar->cType = ' '; - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == ( '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - pVar->cType = pFunc->pStack[ pFunc->iStackIndex ]; - } - else - { - pVar->cType = pFunc->pStack[ pFunc->iStackIndex ] + VT_OFFSET_VARIANT; - } - - /* Will need the Class Handle. */ - cType = pVar->cType; - if( cType == ( '-' + VT_OFFSET_VARIANT ) || cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cType -= VT_OFFSET_VARIANT; - } - - if( toupper( cType ) == 'S' && pFunc->iStackClasses ) - { - pVar->pClass = pFunc->pStackClasses[ pFunc->iStackClasses - 1 ]; - } - else - { - pVar->pClass = NULL; - } - - /* - printf( "\nSymbol: %s Variable: %s Assigned Type: \'%c\' SubType: %c #%i Stack: %i\n", pSym->szName, pVar->szName, pVar->cType, pVar->cType - 100, wVar, pFunc->iStackIndex ); - */ - } - else - { - char szType[2]; - if( pVar->cType == 'S' ) - sprintf( ( char * ) szType, "%s", pVar->pClass->szName ); - else if( pVar->cType == 's' ) - sprintf( ( char * ) szType, "ARRAY OF %s", pVar->pClass->szName ); - else if( islower( pVar->cType ) ) - sprintf( ( char * ) szType, "ARRAY OF %c", toupper( pVar->cType ) ); - else - sprintf( ( char * ) szType, "%c", pVar->cType ); - - /*printf( "Variable: %s Type: \'%c\' SubType: %c Comparing: %c Recorded: %s\n", pSym->szName, pVar->cType, pVar->cType - 100, pFunc->pStack[ pFunc->iStackIndex ], ( char * ) szType );*/ - - if( hb_comp_cCastType == ' ' ) - ; /* No casting - do nothing. */ - else if( toupper( hb_comp_cCastType ) == 'S' ) - { - PCOMCLASS pClass = hb_compClassFind( hb_comp_szFromClass ); - - if( pClass ) - { - if( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses ) - { - pFunc->pStackClasses[ pFunc->iStackClasses - 1 ] = pClass; - } - else - { - pFunc->pStackClasses[ pFunc->iStackClasses++ ] = pClass; - } - pFunc->pStack[ pFunc->iStackIndex ] = hb_comp_cCastType; - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szFromClass, pVar->szName ); - pFunc->pStack[ pFunc->iStackIndex ] = ( isupper( ( int ) hb_comp_cCastType ) ? 'O' : 'o' ); - } - - hb_comp_cCastType = ' '; - } - else - { - pFunc->pStack[ pFunc->iStackIndex ] = hb_comp_cCastType; - hb_comp_cCastType = ' '; - } - - if( pFunc->pStack[ pFunc->iStackIndex ] == ( '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - pFunc->pStack[ pFunc->iStackIndex ] -= VT_OFFSET_VARIANT; - } - - if( pFunc->pStack[ pFunc->iStackIndex ] == '-' ) - { - /* NIL allowed into all types */ - } - else if( pVar->cType == 'a' && islower( pFunc->pStack[ pFunc->iStackIndex ] ) ) - { - /* Array Of ANYTYPE may accept any Array */ - } - else if( islower( pVar->cType ) && pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT, ( char * ) szType, NULL ); - } - else if( islower( pVar->cType ) && pFunc->pStack[ pFunc->iStackIndex ] == 'A' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT, ( char * ) szType, NULL ); - } - else if( islower( pVar->cType ) && pVar->cType != pFunc->pStack[ pFunc->iStackIndex ] ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_TYPE, ( char * ) szType, NULL ); - } - else if( pVar->cType != ' ' && pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_SUSPECT, pVar->szName, ( char * ) szType ); - } - else if( pVar->cType == 'S' && pFunc->pStack[ pFunc->iStackIndex ] == 'O' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_SUSPECT, pVar->szName, ( char * ) szType ); - } - else if( pVar->cType == 's' && pFunc->pStack[ pFunc->iStackIndex ] == 'o' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT, pVar->szName, ( char * ) szType ); - } - else if( pVar->cType == 'S' && pFunc->pStack[ pFunc->iStackIndex ] == 'S' ) - { - if( pFunc->iStackClasses && pVar->pClass == pFunc->pStackClasses[ pFunc->iStackClasses - 1 ] ) - { - /* Same class */ - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_TYPE, pVar->szName, ( char * ) szType ); - } - } - else if( pVar->cType == 's' && pFunc->pStack[ pFunc->iStackIndex ] == 's' ) - { - if( pFunc->iStackClasses && pVar->pClass == pFunc->pStackClasses[ pFunc->iStackClasses - 1 ] ) - { - /* Same class */ - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_TYPE, pVar->szName, ( char * ) szType ); - } - } - else if( isupper( pVar->cType ) && pVar->cType != pFunc->pStack[ pFunc->iStackIndex ] ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_TYPE, pVar->szName, ( char * ) szType ); - } - } - } - else - { - /* Allow any type into a Variant, and record the subtype */ - if( pSym->cType == ' ' || pSym->cType == ( '-' + VT_OFFSET_VARIANT ) || pSym->cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - if( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - pSym->cType = ' '; - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == ( '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - pSym->cType = pFunc->pStack[ pFunc->iStackIndex ]; - } - else - { - pSym->cType = pFunc->pStack[ pFunc->iStackIndex ] + VT_OFFSET_VARIANT; - } - - /* Will need the Class Handle. */ - if( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses ) - { - pSym->pClass = pFunc->pStackClasses[ pFunc->iStackClasses - 1 ]; - } - } - else - { - char szType[2]; - - if( pSym->cType == 'S' ) - { - sprintf( ( char * ) szType, "%s", pSym->pClass->szName ); - } - else if( pSym->cType == 's' ) - { - sprintf( ( char * ) szType, "ARRAY OF %s", pSym->pClass->szName ); - } - else if( islower( pSym->cType ) ) - { - sprintf( ( char * ) szType, "ARRAY OF %c", toupper( pSym->cType ) ); - } - else - { - sprintf( ( char * ) szType, "%c", pSym->cType ); - } - - if( pFunc->pStack[ pFunc->iStackIndex ] == ( '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - pFunc->pStack[ pFunc->iStackIndex ] -= VT_OFFSET_VARIANT; - } - - if( pFunc->pStack[ pFunc->iStackIndex ] == '-' ) - { - /* NIL allowed into all types */ - } - else if( pSym->cType == 'a' && islower( pFunc->pStack[ pFunc->iStackIndex ] ) ) - { - /* Array Of ANYTYPE may accept any Array */ - } - else if( islower( pSym->cType ) && pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT, ( char * ) szType, NULL ); - } - else if( islower( pSym->cType ) && pFunc->pStack[ pFunc->iStackIndex ] == 'A' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT, ( char * ) szType, NULL ); - } - else if( islower( pSym->cType ) && pSym->cType != pFunc->pStack[ pFunc->iStackIndex ] ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_TYPE, ( char * ) szType, NULL ); - } - else if( pSym->cType != ' ' && pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_SUSPECT, pSym->szName, ( char * ) szType ); - } - else if( pSym->cType == 'S' && pFunc->pStack[ pFunc->iStackIndex ] == 'O' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_SUSPECT, pSym->szName, ( char * ) szType ); - } - else if( pSym->cType == 's' && pFunc->pStack[ pFunc->iStackIndex ] == 'o' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT, pSym->szName, ( char * ) szType ); - } - else if( pSym->cType == 'S' && pFunc->pStack[ pFunc->iStackIndex ] == 'S' ) - { - if( pFunc->iStackClasses && pSym->pClass == pFunc->pStackClasses[ pFunc->iStackClasses - 1 ] ) - { - /* Same class */ - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_TYPE, pSym->szName, ( char * ) szType ); - } - } - else if( pSym->cType == 's' && pFunc->pStack[ pFunc->iStackIndex ] == 's' ) - { - if( pFunc->iStackClasses && pSym->pClass == pFunc->pStackClasses[ pFunc->iStackClasses - 1 ] ) - ; /* Same class */ - else - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_TYPE, pSym->szName, ( char * ) szType ); - } - else if( isupper( pSym->cType ) && pSym->cType != pFunc->pStack[ pFunc->iStackIndex ] ) - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_TYPE, pSym->szName, ( char * ) szType ); - } - } - } - - /* Resetting */ - if( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses ) - --pFunc->iStackClasses; - - break; - - case HB_P_POPLOCALNEAR : - case HB_P_POPLOCAL : - /* TODO Error Message after finalizing all possible pcodes. */ - if( pFunc->iStackIndex < 1 ) - { - fprintf( hb_comp_errFile, "Oops - Stack: %i\n", pFunc->iStackIndex ); - break; - } - - pFunc->iStackIndex--; - - if( pFunc->pCode[ ulPos ] == HB_P_POPLOCAL ) - { - wVar = HB_PCODE_MKSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ); - } - else - { - wVar = ( SHORT ) pFunc->pCode[ ulPos + 1 ]; - } - - /* we are accesing variables within a codeblock */ - if( wVar < 0 ) - { - /* Finding the Function owning the block. */ - pTmp = pFunc->pOwner; - - /* Might be a nested block. */ - while ( pTmp->pOwner ) - { - pTmp = pTmp->pOwner; - } - - pVar = pFunc->pStatics; - while( ++wVar < 0 && pVar ) - { - pVar = pVar->pNext; - } - - if ( pVar ) - { - wVar = hb_compVariableGetPos( pTmp->pLocals, pVar->szName ); - pVar = hb_compVariableFind( pTmp->pLocals, wVar ); - } - } - else - { - pVar = hb_compVariableFind( pFunc->pLocals, wVar ); - } - - if( pVar ) - { - pVar->iUsed |= VU_INITIALIZED; - - /* Allow any type into a Variant, and record the subtype */ - if( pVar->cType == ' ' || pVar->cType == ( '-' + VT_OFFSET_VARIANT ) || pVar->cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - if( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - pVar->cType = ' '; - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == ( '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - pVar->cType = pFunc->pStack[ pFunc->iStackIndex ]; - } - else - { - pVar->cType = pFunc->pStack[ pFunc->iStackIndex ] + VT_OFFSET_VARIANT; - } - - cType = pVar->cType; - if( cType == ( '-' + VT_OFFSET_VARIANT ) || cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cType -= VT_OFFSET_VARIANT; - } - - if( toupper( cType ) == 'S' && pFunc->iStackClasses ) - { - pVar->pClass = pFunc->pStackClasses[ pFunc->iStackClasses - 1 ]; - } - else - { - pVar->pClass = NULL; - } - } - else - { - char szType[2]; - - if( pVar->cType == 'S' ) - sprintf( ( char * ) szType, "%s", pVar->pClass->szName ); - else if( pVar->cType == 's' ) - sprintf( ( char * ) szType, "ARRAY OF %s", pVar->pClass->szName ); - else if( islower( pVar->cType ) ) - sprintf( ( char * ) szType, "ARRAY OF %c", toupper( pVar->cType ) ); - else - sprintf( ( char * ) szType, "%c", pVar->cType ); - - if( hb_comp_cCastType == ' ' ) - ; /* No casting - do nothing. */ - else if( toupper( hb_comp_cCastType ) == 'S' ) - { - PCOMCLASS pClass = hb_compClassFind( hb_comp_szFromClass ); - - if( pClass ) - { - if( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses ) - { - pFunc->pStackClasses[ pFunc->iStackClasses - 1 ] = pClass; - } - else - { - pFunc->pStackClasses[ pFunc->iStackClasses++ ] = pClass; - } - pFunc->pStack[ pFunc->iStackIndex ] = hb_comp_cCastType; - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szFromClass, pVar->szName ); - pFunc->pStack[ pFunc->iStackIndex ] = ( isupper( ( int ) hb_comp_cCastType ) ? 'O' : 'o' ); - } - - hb_comp_cCastType = ' '; - } - else - { - pFunc->pStack[ pFunc->iStackIndex ] = hb_comp_cCastType; - hb_comp_cCastType = ' '; - } - - if( pFunc->pStack[ pFunc->iStackIndex ] == ( '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - pFunc->pStack[ pFunc->iStackIndex ] -= VT_OFFSET_VARIANT; - } - - if( pFunc->pStack[ pFunc->iStackIndex ] == '-' ) - { - /* NIL allowed into all types */ - } - else if( pVar->cType == 'a' && islower( pFunc->pStack[ pFunc->iStackIndex ] ) ) - { - /* Array Of ANYTYPE may accept any Array */ - } - else if( islower( pVar->cType ) && pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT, ( char * ) szType, NULL ); - } - else if( islower( pVar->cType ) && pFunc->pStack[ pFunc->iStackIndex ] == 'A' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT, ( char * ) szType, NULL ); - } - else if( islower( pVar->cType ) && pVar->cType != pFunc->pStack[ pFunc->iStackIndex ] ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_TYPE, ( char * ) szType, NULL ); - } - else if( pVar->cType != ' ' && pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_SUSPECT, pVar->szName, ( char * ) szType ); - } - else if( pVar->cType == 'S' && pFunc->pStack[ pFunc->iStackIndex ] == 'O' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_SUSPECT, pVar->szName, ( char * ) szType ); - } - else if( pVar->cType == 's' && pFunc->pStack[ pFunc->iStackIndex ] == 'o' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT, pVar->szName, ( char * ) szType ); - } - else if( pVar->cType == 'S' && pFunc->pStack[ pFunc->iStackIndex ] == 'S' ) - { - if( pFunc->iStackClasses && pVar->pClass == pFunc->pStackClasses[ pFunc->iStackClasses - 1 ] ) - { - /* Same class */ - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_TYPE, pVar->szName, ( char * ) szType ); - } - } - else if( pVar->cType == 's' && pFunc->pStack[ pFunc->iStackIndex ] == 's' ) - { - if( pFunc->iStackClasses && pVar->pClass == pFunc->pStackClasses[ pFunc->iStackClasses - 1 ] ) - ; /* Same class */ - else - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_TYPE, pVar->szName, ( char * ) szType ); - } - else if( isupper( pVar->cType ) && pVar->cType != pFunc->pStack[ pFunc->iStackIndex ] ) - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_TYPE, pVar->szName, ( char * ) szType ); - } - } - - /* Resetting */ - if( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses ) - --pFunc->iStackClasses; - - break; - - case HB_P_POPSTATIC : - if( pFunc->iStackIndex < 1 ) - /* TODO Error Message after finalizing all possible pcodes. */ - break; - - pFunc->iStackIndex--; - - pTmp = hb_comp_functions.pFirst; - wVar = HB_PCODE_MKSHORT( &( pFunc->pCode[ ulPos + 1 ] ) ); - - while( pTmp->pNext && pTmp->pNext->iStaticsBase < wVar ) - pTmp = pTmp->pNext; - - pVar = hb_compVariableFind( pTmp->pStatics, wVar - pTmp->iStaticsBase ); - - if( pVar ) - { - pVar->iUsed |= VU_INITIALIZED; - - /* Allow any type into a Variant, and record the subtype */ - if( pVar->cType == ' ' || pVar->cType == ( '-' + VT_OFFSET_VARIANT ) || pVar->cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - if( pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - pVar->cType = ' '; - } - else if( pFunc->pStack[ pFunc->iStackIndex ] == ( '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - pVar->cType = pFunc->pStack[ pFunc->iStackIndex ]; - } - else - { - pVar->cType = pFunc->pStack[ pFunc->iStackIndex ] + VT_OFFSET_VARIANT; - } - - cType = pVar->cType; - if( cType == ( '-' + VT_OFFSET_VARIANT ) || cType >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - cType -= VT_OFFSET_VARIANT; - } - if( toupper( cType ) == 'S' && pFunc->iStackClasses ) - { - pVar->pClass = pFunc->pStackClasses[ pFunc->iStackClasses - 1 ]; - } - else - { - pVar->pClass = NULL; - } - - /* - printf( "\nStack: %c Asc: %i, Var: %c Asc: %i\n", pFunc->pStack[ pFunc->iStackIndex ], pFunc->pStack[ pFunc->iStackIndex ], pVar->cType, pVar->cType ); - */ - } - else - { - char szType[2]; - if( pVar->cType == 'S' ) - sprintf( ( char * ) szType, "%s", pVar->pClass->szName ); - else if( pVar->cType == 's' ) - sprintf( ( char * ) szType, "ARRAY OF %s", pVar->pClass->szName ); - else if( islower( pVar->cType ) ) - sprintf( ( char * ) szType, "ARRAY OF %c", toupper( pVar->cType ) ); - else - sprintf( ( char * ) szType, "%c", pVar->cType ); - - if( hb_comp_cCastType == ' ' ) - ; /* No casting - do nothing. */ - else if( toupper( hb_comp_cCastType ) == 'S' ) - { - PCOMCLASS pClass = hb_compClassFind( hb_comp_szFromClass ); - - if( pClass ) - { - if( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses ) - { - pFunc->pStackClasses[ pFunc->iStackClasses - 1 ] = pClass; - } - else - { - pFunc->pStackClasses[ pFunc->iStackClasses++ ] = pClass; - } - pFunc->pStack[ pFunc->iStackIndex ] = hb_comp_cCastType; - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szFromClass, pVar->szName ); - pFunc->pStack[ pFunc->iStackIndex ] = ( isupper( ( int ) hb_comp_cCastType ) ? 'O' : 'o' ); - } - - hb_comp_cCastType = ' '; - } - else - { - pFunc->pStack[ pFunc->iStackIndex ] = hb_comp_cCastType; - hb_comp_cCastType = ' '; - } - - if( pFunc->pStack[ pFunc->iStackIndex ] == ( '-' + VT_OFFSET_VARIANT ) || pFunc->pStack[ pFunc->iStackIndex ] >= ( 'A' + VT_OFFSET_VARIANT ) ) - { - pFunc->pStack[ pFunc->iStackIndex ] -= VT_OFFSET_VARIANT; - } - - if( pFunc->pStack[ pFunc->iStackIndex ] == '-' ) - { - /* NIL allowed into all types */ - } - else if( pVar->cType == 'a' && islower( pFunc->pStack[ pFunc->iStackIndex ] ) ) - { - /* Array Of ANYTYPE may accept any Array */ - } - else if( islower( pVar->cType ) && pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT, ( char * ) szType, NULL ); - } - else if( islower( pVar->cType ) && pFunc->pStack[ pFunc->iStackIndex ] == 'A' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT, ( char * ) szType, NULL ); - } - else if( islower( pVar->cType ) && pVar->cType != pFunc->pStack[ pFunc->iStackIndex ] ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_TYPE, ( char * ) szType, NULL ); - } - else if( pVar->cType != ' ' && pFunc->pStack[ pFunc->iStackIndex ] == ' ' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_SUSPECT, pVar->szName, ( char * ) szType ); - } - else if( pVar->cType == 'S' && pFunc->pStack[ pFunc->iStackIndex ] == 'O' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_SUSPECT, pVar->szName, ( char * ) szType ); - } - else if( pVar->cType == 's' && pFunc->pStack[ pFunc->iStackIndex ] == 'o' ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_SUSPECT, pVar->szName, ( char * ) szType ); - } - else if( pVar->cType == 'S' && pFunc->pStack[ pFunc->iStackIndex ] == 'S' ) - { - if( pFunc->iStackClasses && pVar->pClass == pFunc->pStackClasses[ pFunc->iStackClasses - 1 ] ) - { - /* Same class */ - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_TYPE, pVar->szName, ( char * ) szType ); - } - } - else if( pVar->cType == 's' && pFunc->pStack[ pFunc->iStackIndex ] == 's' ) - { - if( pFunc->iStackClasses && pVar->pClass == pFunc->pStackClasses[ pFunc->iStackClasses - 1 ] ) - { - /* Same class */ - } - else - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ARRAY_ASSIGN_TYPE, pVar->szName, ( char * ) szType ); - } - } - else if( isupper( pVar->cType ) && pVar->cType != pFunc->pStack[ pFunc->iStackIndex ] ) - { - hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_ASSIGN_TYPE, pVar->szName, ( char * ) szType ); - } - } - } - - /* Resetting */ - if( toupper( pFunc->pStack[ pFunc->iStackIndex ] ) == 'S' && pFunc->iStackClasses ) - { - --pFunc->iStackClasses; - } - break; - - /* Macros Undefined Types */ - - case HB_P_MPOPALIASEDFIELD : - case HB_P_MPOPALIASEDVAR : - case HB_P_MPOPFIELD : - case HB_P_MPOPMEMVAR : - case HB_P_MACROPOP : - case HB_P_MACROPOPALIASED : - pFunc->iStackIndex--; - break; - - case HB_P_SEQRECOVER : - /* TODO: find type of BREAK() */ - pFunc->pStack[ pFunc->iStackIndex++ ] = ' '; - break; - } - - /* TODO Error or trace messages when completed. */ - if( pFunc->iStackIndex < 0 ) - { - fprintf( hb_comp_errFile, "\nStrongType Stack underflow!\n" ); - pFunc->iStackIndex = 0; - } -} -#endif /* ifdefined(HB_COMP_STRONG_TYPES) */ - diff --git a/harbour/source/compiler/hbusage.c b/harbour/source/compiler/hbusage.c index edbae59d50..c57f997600 100644 --- a/harbour/source/compiler/hbusage.c +++ b/harbour/source/compiler/hbusage.c @@ -189,7 +189,9 @@ void hb_compPrintCredits( void ) */ void hb_compPrintLogo( void ) { - printf( "Harbour Compiler Alpha build %d.%d (%s)\n", - HB_VER_MINOR, HB_VER_REVISION, HB_VER_LEX ); + char * szVer = hb_verHarbour(); + + printf( "%s\n", szVer ); printf( "Copyright 1999-2006, http://www.harbour-project.org/\n" ); + hb_xfree( szVer ); } diff --git a/harbour/source/compiler/simplex.c b/harbour/source/compiler/simplex.c deleted file mode 100644 index 683efd6911..0000000000 --- a/harbour/source/compiler/simplex.c +++ /dev/null @@ -1,1581 +0,0 @@ -/* - * $Id$ - */ - -/* - * Copyright 2000 Ron Pinkas - * www - http://www.Profit-Master.com - * - * 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 (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include -#include -#include -#include - -/* NOT overidable (yet). */ -#define MAX_MATCH 4 - -#ifndef TOKEN_SIZE - #define TOKEN_SIZE 64 -#endif - -/* Language Definitions Readability. */ -#define SELF_CONTAINED_WORDS_ARE static LEX_WORD aSelfs[] = -#define LANGUAGE_KEY_WORDS_ARE static LEX_WORD aKeys[] = -#define LANGUAGE_WORDS_ARE static LEX_WORD aWords[] = -#define LANGUAGE_RULES_ARE static int aiRules[][ MAX_MATCH + 2 ] = -#define ACCEPT_TOKEN_AND_DROP_DELIMITER_IF_ONE_OF_THESE(x) static char *szOmmit = x -#define ACCEPT_TOKEN_AND_RETURN_DELIMITERS static LEX_DELIMITER aDelimiters[] = -#define DELIMITER_BELONGS_TO_TOKEN_IF_ONE_OF_THESE(x) static char *szAppend = x -#define START_NEW_LINE_IF_ONE_OF_THESE(x) static char *szNewLine = x -#define IF_SEQUENCE_IS(a, b, c, d) {a, b, c, d -#define REDUCE_TO(x, y) ,x, y } -#define PASS_THROUGH() ,0, 0 } -#define LEX_DELIMITER(x) {x -#define LEX_WORD(x) {x -#define AS_TOKEN(x) ,x } - -/* Streams ("Pairs"). */ -#define DEFINE_STREAM_AS_ONE_OF_THESE LEX_PAIR aPairs[] = -#define START_WITH(x) { x, -#define END_WITH(x) x, -#define STOP_IF_ONE_OF_THESE(x) x, -#define TEST_LEFT(x) x, -#define AS_PAIR_TOKEN(x) x } -#define STREAM_EXCEPTION( sPair, chrPair) \ - if( chrPair ) \ - { \ - printf( "Exception: %c for stream at: \"%s\"\n", chrPair, sPair ); \ - } \ - else \ - { \ - printf( "Exception: for stream at: \"%s\"\n", chrPair, sPair ); \ - } \ - -/* Pairs. */ -#ifndef MAX_STREAM - #define MAX_STREAM 2048 -#endif -#ifndef MAX_STREAM_STARTER - #define MAX_STREAM_STARTER 2 -#endif -#ifndef MAX_STREAM_TERMINATOR - #define MAX_STREAM_TERMINATOR 2 -#endif -#ifndef MAX_STREAM_EXCLUSIONS - #define MAX_STREAM_EXCLUSIONS 2 -#endif - -static char sPair[ MAX_STREAM ]; -static char * sStart, * sTerm; -static char * sExclude; -static BOOL bTestLeft; -static int iPairToken = 0; - -/* Self Contained Words. */ -static char sSelf[ TOKEN_SIZE ]; - -typedef struct _LEX_DELIMITER -{ - char cDelimiter; - int iToken; -} LEX_DELIMITER; /* support structure for KEYS and WORDS. */ - -typedef struct _LEX_WORD -{ - char sWord[ TOKEN_SIZE ]; - int iToken; -} LEX_WORD; /* support structure for KEYS and WORDS. */ - -typedef struct _LEX_PAIR -{ - char sStart[MAX_STREAM_STARTER]; - char sTerm[MAX_STREAM_TERMINATOR]; - char sExclude[MAX_STREAM_EXCLUSIONS]; - BOOL bTestLeft; - int iToken; -} LEX_PAIR; /* support structure for Streams (Pairs). */ - -#ifdef __cplusplus - typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -/* Above are NOT overidable !!! Need to precede the Language Definitions. */ - -/* --------------------------------------------------------------------------------- */ - -/* Overidables. */ -#define LEX_CUSTOM_ACTION -65 -#define DONT_REDUCE 1024 -#define YY_BUF_SIZE 16384 -#define MAX_RULES 1024 - -#define YY_INPUT( a, b, c ) - -/* Optional User Macros. */ -#define LEX_USER_SETUP() -#define INIT_ACTION() -#define INTERCEPT_ACTION(x) -#define CUSTOM_ACTION(x) -#define NEW_LINE_ACTION() -#define ELEMENT_TOKEN(x,y) -1 -#define DEBUG_INFO(x) -#define LEX_CASE(x) -#define STREAM_OPEN(x) -#define STREAM_APPEND(x) sPair[ iPairLen++ ] = x - -#include SLX_RULES - -/* Declarations. */ - -FILE *yyin; /* currently yacc parsed file */ - -extern void yyerror( char * ); /* parsing error management function */ - -#ifdef __cplusplus - extern "C" int yywrap( void ); -#else - extern int yywrap( void ); /* manages the EOF of current processed file */ -#endif - -/* Use prototypes in function declarations. */ -#define YY_USE_PROTOS - -#ifdef YY_USE_PROTOS - #define YY_PROTO(proto) proto -#else - #define YY_PROTO(proto) () -#endif - -/* ---------------------------------------------------------------------------------------------- */ - -#define LEX_RULE_SIZE ( sizeof( (int) iRet ) * ( MAX_MATCH + 2 ) ) -#define LEX_WORD_SIZE ( sizeof( LEX_WORD ) ) -#define LEX_PAIR_SIZE ( sizeof( LEX_PAIR ) ) -#define LEX_DELIMITER_SIZE ( sizeof( LEX_DELIMITER ) ) - -/* Using statics when we could use locals to eliminate Allocations and Deallocations each time yylex is called and returns. */ - -/* Look ahead Tokens. */ -static int iHold = 0; -static int aiHold[4]; - -/* Pre-Checked Tokens. */ -static int iReturn = 0; -static int aiReturn[4]; - -/* yylex */ -static char * tmpPtr; -static char sToken[TOKEN_SIZE]; -static unsigned int iLen = 0; -static char chr, cPrev = 0; -static unsigned int iLastToken = 0; -static char szLexBuffer[ YY_BUF_SIZE ]; -static char * s_szBuffer; -static unsigned int iSize = 0; -static int iRet; -static BOOL bTmp, bIgnoreWords = FALSE, bRecursive = FALSE; - -/* Lex emulation */ -char * yytext = (char *) sToken; -int yyleng; - -/* NewLine Support. */ -static BOOL bNewLine = TRUE, bStart = TRUE; - -#ifdef USE_KEYWORDS - static unsigned int iKeys = (int) ( sizeof( aKeys ) / LEX_WORD_SIZE ); -#endif - -static unsigned int iWords = (int) ( sizeof( aWords ) / LEX_WORD_SIZE ); -static unsigned int iSelfs = (int) ( sizeof( aSelfs ) / LEX_WORD_SIZE ); -static unsigned int iPairs = (int) ( sizeof( aPairs ) / LEX_PAIR_SIZE ); -static unsigned int iDelimiters = (int) ( sizeof( aDelimiters ) / LEX_DELIMITER_SIZE ); -static unsigned int iRules = (int) ( sizeof( aiRules ) / LEX_RULE_SIZE ); - -typedef struct _TREE_NODE -{ - int iMin; - int iMax; -} TREE_NODE; /* support structure for Streams (Pairs). */ - -/* Indexing System. */ -static TREE_NODE aPairNodes[256], aSelfNodes[256], aKeyNodes[256], aWordNodes[256], aRuleNodes[MAX_RULES]; -static char acOmmit[256], acNewLine[256]; -static int acReturn[256]; - -static int Reduce( int iToken ); -int SimpLex_GetNextToken( void ); -int SimpLex_CheckToken( void ); -void SimpLex_CheckWords( void ); - -/* Indexing System. */ -static void GenTrees( void ); -static int rulecmp( const void * pLeft, const void * pRight ); - -/* --------------------------------------------------------------------------------- */ - -/* MACROS. */ - -/* Readability Macros. */ -#define LEX_RULE_SIZE ( sizeof( (int) iRet ) * ( MAX_MATCH + 2 ) ) -#define LEX_WORD_SIZE ( sizeof( LEX_WORD ) ) -#define LEX_PAIR_SIZE ( sizeof( LEX_PAIR ) ) -#define IF_TOKEN_READY() if( iReturn ) -#define IF_TOKEN_ON_HOLD() if( iHold ) -#define RESET_LEX() { iLen = 0; iHold = 0; iReturn = 0; bNewLine = TRUE; bStart = TRUE; } -#define FORCE_REDUCE() Reduce( 0 ) - -#define HOLD_TOKEN(x) PUSH_TOKEN(x) - -#define IF_BEGIN_PAIR(chr) \ - if( aPairNodes[(int)chr].iMin == -1 ) \ - { \ - bTmp = FALSE; \ - } \ - else \ - { \ - register unsigned int i = aPairNodes[(int)chr].iMin, iMax = aPairNodes[(int)chr].iMax + 1, iStartLen; \ - register unsigned char chrStart; \ - unsigned int iLastPair = 0, iLastLen = 0; \ - \ - DEBUG_INFO( printf( "Checking %i Streams for %c At: >%s<\n", iPairs, chr, szBuffer - 1 ) ); \ - \ - while( i < iMax ) \ - { \ - iStartLen = 1; \ - \ - chrStart = LEX_CASE( *szBuffer ); \ - \ - while( aPairs[i].sStart[iStartLen] ) \ - { \ - if( chrStart != aPairs[i].sStart[iStartLen] ) \ - { \ - break; \ - } \ - \ - iStartLen++; \ - \ - chrStart = LEX_CASE( *( szBuffer + iStartLen - 1 ) ); \ - } \ - \ - /* Match */ \ - if( aPairs[i].sStart[iStartLen] == '\0' ) \ - { \ - if( iStartLen > iLastLen ) \ - { \ - iLastPair = i + 1; \ - iLastLen = iStartLen; \ - } \ - } \ - i++; \ - } \ - \ - bTmp = FALSE; \ - \ - if( iLastPair ) \ - { \ - iLastPair--; \ - STREAM_OPEN( aPairs[iLastPair].sStart )\ - { \ - bTmp = TRUE; \ - \ - /* Last charcter read. */\ - if( iStartLen > 1 ) chr = chrStart; \ - \ - /* Moving to next postion after the Stream Start position. */ \ - szBuffer += ( iLastLen - 1 ); \ - \ - sStart = (char *) aPairs[iLastPair].sStart; \ - sTerm = (char *) aPairs[iLastPair].sTerm; \ - sExclude = (char *) aPairs[iLastPair].sExclude; \ - bTestLeft = aPairs[iLastPair].bTestLeft; \ - iPairToken = aPairs[iLastPair].iToken; \ - \ - DEBUG_INFO( printf( "Looking for Stream Terminator: >%s< Exclusions >%s<\n", sTerm, sExclude ) ); \ - } \ - } \ - } \ - /* Begin New Pair. */ \ - if( bTmp ) - -#define CHECK_SELF_CONTAINED(chr) \ - if( aSelfNodes[(int)chr].iMin != -1 ) \ - { \ - register unsigned int i = aSelfNodes[(int)chr].iMin, iMax = aSelfNodes[(int)chr].iMax + 1, iSelfLen; \ - register unsigned char chrSelf; \ - \ - DEBUG_INFO( printf( "Checking %i Selfs for %c At: >%s<\n", iSelfs, chr, szBuffer - 1 ) ); \ - \ - while( i < iMax ) \ - { \ - sSelf[0] = chr; \ - iSelfLen = 1; \ - chrSelf = LEX_CASE( *szBuffer ); \ - \ - while( aSelfs[i].sWord[iSelfLen] ) \ - { \ - if( aSelfs[i].sWord[iSelfLen] == chrSelf ) \ - { \ - sSelf[ iSelfLen ] = chrSelf; \ - } \ - else \ - { \ - break; \ - } \ - \ - iSelfLen++; \ - \ - chrSelf = LEX_CASE( *( szBuffer + iSelfLen - 1 ) ); \ - } \ - \ - /* Match */ \ - if( aSelfs[i].sWord[iSelfLen] == '\0' ) \ - { \ - /* Moving to next postion after the Self Contained Word. */ \ - szBuffer += ( iSelfLen - 1 ); \ - s_szBuffer = szBuffer; \ - \ - sSelf[ iSelfLen ] = '\0'; \ - iRet = aSelfs[i].iToken; \ - \ - if( iLen ) \ - { \ - DEBUG_INFO( printf( "Holding Self >%s<\n", sSelf ) ); \ - \ - HOLD_TOKEN( iRet ); \ - \ - /* Terminate current token and check it. */ \ - sToken[ iLen ] = '\0'; \ - \ - /* Last charcter read. */\ - chr = chrSelf;\ - \ - return SimpLex_CheckToken(); \ - } \ - else \ - { \ - DEBUG_INFO( printf( "Reducing Self >%s<\n", sSelf ) ); \ - bIgnoreWords = FALSE;\ - \ - if( bNewLine )\ - {\ - bNewLine = FALSE;\ - NEW_LINE_ACTION();\ - }\ - \ - /* Last charcter read. */\ - if( iSelfLen > 1 ) chr = chrSelf;\ - \ - return iRet; \ - } \ - } \ - \ - i++; \ - } \ - } - -#define IF_ABORT_PAIR(chrPair) \ - tmpPtr = sExclude; \ - while ( *tmpPtr && chrPair != *tmpPtr ) \ - { \ - tmpPtr++; \ - } \ - \ - /* Exception. */ \ - if( *tmpPtr ) - -#define IF_APPEND_DELIMITER(chr) \ - /* Delimiter to Append? */ \ - tmpPtr = (char*) szAppend; \ - while ( *tmpPtr && chr != *tmpPtr ) tmpPtr++; \ - \ - /* Delimiter to Append found. */ \ - if( *tmpPtr ) - -#ifndef IF_BELONG_LEFT - #define IF_BELONG_LEFT(chr) \ - /* Give precedence to associate rules */ \ - DEBUG_INFO( printf( "Checking Left for: '%c' cPrev: '%c'\n", chr, cPrev ) ); \ - \ - if( 0 ) -#endif - -#define RETURN_READY_TOKEN() \ - \ - iReturn--; \ - iRet = aiReturn[iReturn]; \ - \ - DEBUG_INFO( printf( "Returning Ready: %i\n", iRet ) ); \ - \ - INTERCEPT_ACTION(iRet); \ - return iRet; \ - -#define RELEASE_TOKEN() \ - \ - /* Last in First Out. */ \ - iHold--; \ - iRet = aiHold[iHold]; \ - \ - DEBUG_INFO( printf( "Released %i Now Holding %i Tokens: %i %i %i %i\n", iRet, iHold, aiHold[0], aiHold[1], aiHold[2], aiHold[3] ) ); \ - bIgnoreWords = FALSE;\ - \ - if( iRet < 256 ) \ - { \ - if( acNewLine[iRet] ) bNewLine = TRUE; \ - } \ - \ - DEBUG_INFO( printf( "Reducing Held: %i Pos: %i\n", iRet, iHold ) ); \ - LEX_RETURN( Reduce( iRet ) ); - -#define LEX_RETURN(x) \ - \ - iRet = x;\ - \ - if( iRet < LEX_CUSTOM_ACTION ) \ - { \ - iRet = CUSTOM_ACTION(iRet); \ - } \ - \ - if( iRet ) \ - { \ - DEBUG_INFO( printf( "Returning: %i\n", iRet ) ); \ - \ - INTERCEPT_ACTION(iRet); \ - \ - return iRet; \ - } \ - else \ - { \ - goto Start; \ - } - -#define PUSH_TOKEN( iPushToken )\ -{\ - aiHold[ iHold++ ] = iPushToken;\ - DEBUG_INFO( printf("Now Holding %i Tokens: %i %i %i %i\n", iHold, aiHold[0], aiHold[1], aiHold[2], aiHold[3] ) ); \ -} - -#ifndef YY_DECL - #define YY_DECL int yylex YY_PROTO(( void )) -#endif - -YY_DECL -{ - - LEX_USER_SETUP(); - - Start : - IF_TOKEN_READY() - { - RETURN_READY_TOKEN(); - } - - IF_TOKEN_ON_HOLD() - { - RELEASE_TOKEN(); - } - - if( iSize == 0 ) - { - if( bStart ) - { - bStart = FALSE; - GenTrees(); - INIT_ACTION(); - } - - YY_INPUT( (char*) szLexBuffer, iSize, YY_BUF_SIZE ); - - if( iSize ) - { - s_szBuffer = (char*) szLexBuffer; - DEBUG_INFO( printf( "New Buffer: >%s<\n", szLexBuffer ) ); - } - else - { - RESET_LEX(); - DEBUG_INFO( printf( "Returning: \n" ) ); - return -1; \ - } - } - - LEX_RETURN( Reduce( SimpLex_GetNextToken() ) ) -} - -int SimpLex_GetNextToken( void ) -{ - register char * szBuffer = s_szBuffer; - - iLen = 0; - - while ( 1 ) - { - if ( iSize && *szBuffer ) - { - if( iPairToken ) - { - goto ProcessStream; - } - - cPrev = chr; - - /* Get next character. */ - iSize--; - chr = (*szBuffer++); - - /* Not using LEX_CASE() yet (white space)!!! */ - - if( acOmmit[(int)chr] ) - { - while( acOmmit[(int)(*szBuffer)] ) - { - iSize--; szBuffer++; - } - - if ( iLen ) - { - /* Terminate current token and check it. */ - sToken[ iLen ] = '\0'; - - s_szBuffer = szBuffer; - - DEBUG_INFO( printf( "Token: \"%s\" Ommited: \'%c\'\n", sToken, chr ) ); - return SimpLex_CheckToken(); - } - else - { - continue; - } - } - - chr = LEX_CASE(chr); - - CHECK_SELF_CONTAINED(chr); - - /* New Pair ? */ - IF_BEGIN_PAIR( chr ) - { - if( iLen ) - { - DEBUG_INFO( printf( "Holding Stream Mode: '%c' Buffer = >%s<\n", chr, szBuffer ) ); - - /* Terminate and Check Token to the left. */ - sToken[ iLen ] = '\0'; - - s_szBuffer = szBuffer; - - DEBUG_INFO( printf( "Token: \"%s\" before New Pair at: \'%c\'\n", sToken, chr ) ); - return SimpLex_CheckToken(); - } - - ProcessStream : - - bIgnoreWords = FALSE; - - if( bTestLeft ) - { - IF_BELONG_LEFT( chr ) - { - /* Resetting. */ - iPairToken = 0; - - s_szBuffer = szBuffer; - - DEBUG_INFO( printf( "Reducing Left '%c'\n", chr ) ); - return (int) chr ; - } - } - - { register int iPairLen = 0; - register char chrPair; - - /* Look for the terminator. */ - while ( *szBuffer ) - { - /* Next Character. */ - chrPair = *szBuffer++ ; - - /* Terminator ? */ - if( chrPair == sTerm[0] ) - { - register int iTermLen = 1; - - if( sTerm[1] ) - { - register char chrTerm = *szBuffer; /* Not using LEX_CASE() here !!! */ - - while( sTerm[iTermLen] ) - { - if( chrTerm != sTerm[iTermLen] ) - { - /* Last charcter read. */ - chr = chrTerm; - break; - } - - iTermLen++; - - chrTerm = *( szBuffer + iTermLen - 1 ); /* Not using LEX_CASE() here !!! */ - } - } - - /* Match */ \ - if( sTerm[iTermLen] == '\0' ) \ - { \ - /* Moving to next postion after the Stream Terminator. */ \ - szBuffer += ( iTermLen - 1 ); \ - - sPair[ iPairLen ] = '\0'; - - if( bNewLine ) - { - bNewLine = FALSE; - NEW_LINE_ACTION(); - } - - iRet = iPairToken; - - /* Resetting. */ - iPairToken = 0; - - s_szBuffer = szBuffer; - - DEBUG_INFO( printf( "Returning Pair = >%s<\n", sPair ) ); - return iRet; - } - } - - /* Check if exception. */ - IF_ABORT_PAIR( chrPair ) - { - sPair[ iPairLen ] = '\0'; - - /* Resetting. */ - iPairToken = 0; - - /* Last charcter read. */ - chr = chrPair; - - STREAM_EXCEPTION( sPair, chrPair ); - - s_szBuffer = szBuffer; - - return iPairToken; - } - else - { - STREAM_APPEND( chrPair ); - } - } - } - - /* Resetting. */ - iPairToken = 0; - - /* EOF */ - STREAM_EXCEPTION( sPair, NULL ); - - s_szBuffer = szBuffer; - - return iPairToken; - } - /* End Pairs. */ - - /* NewLine ? */ - if( acNewLine[(int)chr] ) - { - while( acNewLine[(int)(*szBuffer)] ) - { - iSize--; szBuffer++; - } - s_szBuffer = szBuffer; - - if( iLen ) - { - /* Will return NewLine on next call. */ - HOLD_TOKEN( chr ); - - /* Terminate current token and check it. */ - sToken[ iLen ] = '\0'; - - DEBUG_INFO( printf( "Token: \"%s\" at Holding: \'%c\'\n", sToken, chr ) ); - return SimpLex_CheckToken(); - } - else - { - DEBUG_INFO( printf( "Reducing NewLine '%c'\n", chr ) ); - bIgnoreWords = FALSE; - bNewLine = TRUE; - return (int) chr; - } - } - - #ifdef USE_BELONGS - IF_APPEND_DELIMITER( chr ) - { - /* Append and Terminate current token and check it. */ - sToken[ iLen++ ] = chr; - sToken[ iLen ] = '\0'; - - s_szBuffer = szBuffer; - - DEBUG_INFO( printf( "Token: \"%s\" Appended: \'%c\'\n", sToken, chr ) ); - return SimpLex_CheckToken(); - } - #endif - - if( acReturn[(int)chr] ) - { - s_szBuffer = szBuffer; - - if( iLen ) - { - /* Will be returned on next cycle. */ - - HOLD_TOKEN( acReturn[(int)chr] ); - - /* Terminate current token and check it. */ - sToken[ iLen ] = '\0'; - - DEBUG_INFO( printf( "Token: \"%s\" Holding: \'%c\' As: %i \n", sToken, chr, iRet ) ); - return SimpLex_CheckToken(); - } - else - { - bIgnoreWords = FALSE; - - if( bNewLine ) - { - bNewLine = FALSE; - NEW_LINE_ACTION(); - } - - DEBUG_INFO( printf( "Reducing Delimiter: '%c' As: %i\n", chr, acReturn[(int)chr] ) ); - return acReturn[(int)chr]; - } - } - - /* Acumulate and scan next Charcter. */ - sToken[ iLen++ ] = chr; - - continue; - } - else - { - YY_INPUT( (char*) szLexBuffer, iSize, YY_BUF_SIZE ); - - if( iSize ) - { - szBuffer = (char*) szLexBuffer; - continue; - } - else - { - - if( iLen ) - { - /* */ - HOLD_TOKEN( -1 ); - - /* Terminate current token and check it. */ - sToken[ iLen ] = '\0'; - - s_szBuffer = szBuffer; - - DEBUG_INFO( printf( "Token: \"%s\" at: \'\'\n", sToken ) ); - return SimpLex_CheckToken(); - } - else - { - s_szBuffer = szBuffer; - DEBUG_INFO( printf( "Returning: \n", iRet ) ); \ - return -1; \ - } - } - } - } -} - -int SimpLex_CheckToken( void ) -{ - if( bRecursive ) - { - return 0; - } - else - { - bRecursive = TRUE; - } - - if( bNewLine ) - { - bIgnoreWords = FALSE; - - NEW_LINE_ACTION(); - - #ifdef USE_KEYWORDS - SimpLex_CheckWords(); - if( iRet ) - { - bRecursive = FALSE; - /* bIgnoreWords and bNewLine were handled by SimpLex_CheckWords(). */ - return iRet; - } - #endif - } - - if( bIgnoreWords ) - { - DEBUG_INFO( printf( "Skiped Words for Word: %s\n", (char*) sToken ) ); - bIgnoreWords = FALSE; - } - else - { - SimpLex_CheckWords(); - if( iRet ) - { - bRecursive = FALSE; - return iRet; - } - } - - DEBUG_INFO( printf( "Reducing Element: \"%s\"\n", (char*) sToken ) ); - - iRet = ELEMENT_TOKEN( (char*)sToken, iLen ); - - bRecursive = FALSE; - return iRet; -} - -int Reduce( int iToken ) -{ - BeginReduce : - - if( iToken < LEX_CUSTOM_ACTION ) - { - iToken = CUSTOM_ACTION( iToken ); \ - } - - if( iToken > DONT_REDUCE ) - { - iLastToken = ( iToken - DONT_REDUCE ); - DEBUG_INFO( printf( "Returning Dont Reduce %i\n", iLastToken ) ); - return iLastToken; - } - else if( iToken <= 0 || iToken >= MAX_RULES ) - { - DEBUG_INFO( printf( "Passing through (out of range): %i\n", iToken ) ); - return iToken; - } - - iLastToken = iToken; - - /* No Rules for this token. */ - if( aRuleNodes[ iToken ].iMin == -1 ) - { - DEBUG_INFO( printf( "Passing through: %i\n", iToken ) ); - return iToken; - } - else - { - register unsigned int i = (unsigned int)(aRuleNodes[ iToken ].iMin), iMax = (unsigned int)(aRuleNodes[ iToken ].iMax); - register unsigned int iTentative = 0, iMatched = 1; - - DEBUG_INFO( printf( "Scaning Prospects %i-%i at Pos: 0 for Token: %i\n", i, iMax -1, iToken ) ); - - { - FoundProspect : - - DEBUG_INFO( printf( "Prospect of %i Tokens - Testing Token: %i\n", iMatched, iToken ) ); - - if( iMatched == MAX_MATCH || aiRules[i][iMatched] == 0 ) - { - DEBUG_INFO( printf( "Saving Tentative %i - Found match of %i Tokens at Token: %i\n", i, iMatched, iToken ) ); - iTentative = i; - } - else - { - DEBUG_INFO( printf( "Partial Match - Get next Token after Token: %i\n", iToken ) ); - - if( iHold ) - { - iHold--; - iToken = aiHold[ iHold ]; - bIgnoreWords = FALSE; - if( iToken < 256 ) - { - if( acNewLine[iToken] ) bNewLine = TRUE; - } - } - else - { - iToken = SimpLex_GetNextToken(); - } - - if( iToken < LEX_CUSTOM_ACTION ) - { - iToken = CUSTOM_ACTION( iToken ); \ - } - - if( iToken > DONT_REDUCE ) - { - DEBUG_INFO( printf( "Reduce Forced for Token: %i\n", iToken - DONT_REDUCE ) ); - aiHold[iHold++] = iToken; - goto AfterScanRules; - } - else - { - iLastToken = iToken; - } - - if( aiRules[i][iMatched] == iToken ) - { - /* Continue... Still a prospect. */ - DEBUG_INFO( printf( "Accepted Token: %i - Continue with this Rule...\n", iToken ) ); - iMatched++; - goto FoundProspect; - } - else if( aiRules[i][iMatched] > iToken ) - { - DEBUG_INFO( printf( "Rejected Token: %i - Giving up...\n", iToken ) ); - aiHold[iHold++] = iToken; - goto AfterScanRules; - } - else - { - DEBUG_INFO( printf( "Rejected Token: %i - Continue with next Rule...\n", iToken ) ); - aiHold[iHold++] = iToken; - } - } - - if( i < iMax ) - { - register unsigned int j = 1; - - DEBUG_INFO( printf( "Checking if next rule is extension of last Rule\n" ) ); - - while( j < iMatched ) - { - if( aiRules[i][j] != aiRules[i+1][j] ) - { - break; - } - j++; - } - if( j < iMatched ) - { - DEBUG_INFO( printf( "Rejected Rule - Not an extension of previous - Giving up...\n" ) ); - } - else - { - DEBUG_INFO( printf( "Accepted Next Rule...\n" ) ); - i++; - goto FoundProspect; - } - } - else - { - DEBUG_INFO( printf( "No More prospects...\n" ) ); - } - } - - AfterScanRules : - - if( iTentative ) - { - DEBUG_INFO( printf( "Processing Tentative: %i\n", iTentative ) ); - - while( iMatched > 1 && aiRules[i][iMatched - 1] && aiRules[iTentative][iMatched - 1] == 0 ) - { - DEBUG_INFO( printf( "Reclaimed Token: %i\n", aiRules[i][iMatched - 1] ) ); - aiHold[iHold++] = aiRules[i][iMatched - 1]; - iMatched--; - } - - if( aiRules[iTentative][MAX_MATCH] ) - { - DEBUG_INFO( printf( "Reducing Rule: %i Found %i Tokens\n", iTentative, iMatched ) ); - - if( aiRules[iTentative][MAX_MATCH + 1] ) - { - DEBUG_INFO( printf( "Pushing Reduction: %i\n", aiRules[iTentative][MAX_MATCH + 1] ) ); - aiHold[iHold++] = aiRules[iTentative][MAX_MATCH + 1]; - } - - DEBUG_INFO( printf( "Recycling Reduction: %i\n", aiRules[iTentative][MAX_MATCH] ) ); - iToken = aiRules[iTentative][MAX_MATCH]; - goto BeginReduce; - } - else - { - DEBUG_INFO( printf( "Passing Through %i Tokens\n", iMatched ) ); - while( iMatched > 1 ) - { - iMatched--; - DEBUG_INFO( printf( "Stacking Return: %i\n", aiRules[iTentative][iMatched] ) ); - aiReturn[iReturn++] = aiRules[iTentative][iMatched]; - } - DEBUG_INFO( printf( "Returning: %i\n", aiRules[iTentative][0] ) ); - return aiRules[iTentative][0]; - } - } - else - { - while( iMatched > 1 ) - { - iMatched--; - DEBUG_INFO( printf( "Pushing: %i\n", aiRules[i][iMatched] ) ); - aiHold[iHold++] = aiRules[i][iMatched]; - } - - DEBUG_INFO( printf( "Returning Shifted Left: %i\n", aiRules[i][0] ) ); - return aiRules[i][0]; - } - } -} - -void SimpLex_CheckWords( void ) -{ - int iTentative = -1, iCompare; - unsigned int i, iMax, iLenMatched, iBaseSize, iKeyLen; - char *pNextSpacer, *sKeys2Match = NULL, *szBaseBuffer = s_szBuffer, cSpacer = chr; - LEX_WORD *aCheck; - - #ifdef DEBUG_LEX - char sKeyDesc[] = "Key", sWordDesc[] = "Word", *sDesc; - #endif - #ifdef LEX_ABBREVIATE - unsigned int iLen2Match; - #endif - - #ifdef USE_KEYWORDS - if( bNewLine ) - { - i = aKeyNodes[ (int)(sToken[0]) ].iMin; - iMax = aKeyNodes[ (int)(sToken[0]) ].iMax + 1; - aCheck = (LEX_WORD*) ( &(aKeys[0]) ); - #ifdef DEBUG_LEX - sDesc = (char*) sKeyDesc; - #endif - } - else - #endif - { - i = aWordNodes[ (int)(sToken[0]) ].iMin; - iMax = aWordNodes[ (int)(sToken[0]) ].iMax + 1; - aCheck = (LEX_WORD*) ( &( aWords[0] ) ); - #ifdef DEBUG_LEX - sDesc = (char*) sWordDesc; - #endif - } - - bNewLine = FALSE; - - DEBUG_INFO( printf( "Pre-Scaning %ss for Token: %s at Positions: %i-%i\n", sDesc, (char*) sToken, i, iMax -1 ) ); - - while( i < iMax ) - { - if( sToken[1] < aCheck[i].sWord[1] ) - { - DEBUG_INFO( printf( "Gave-Up! Token [%s] < Pattern [%s]\n", sToken, aCheck[i].sWord ) ); - iRet = 0; - return; - } - else if( sToken[1] > aCheck[i].sWord[1] ) - { - DEBUG_INFO( printf( "Skip... %s [%s] < [%s]\n", sDesc, aCheck[i].sWord, sToken ) ); - i++; - DEBUG_INFO( printf( "Continue with larger: [%s]\n", aCheck[i].sWord ) ); - continue; - } - else - { - break; - } - } - - while( i < iMax ) - { - if( sKeys2Match ) - { - pNextSpacer = strstr( sKeys2Match, "{WS}" ); - } - else - { - sKeys2Match = aCheck[ i ].sWord; - pNextSpacer = strstr( sKeys2Match, "{WS}" ); - } - - if( sToken[0] < sKeys2Match[0] ) - { - DEBUG_INFO( printf( "Gave-Up! Token [%s] < Pattern [%s]\n", sToken, sKeys2Match ) ); - break; - } - else if( sToken[0] > sKeys2Match[0] ) - { - DEBUG_INFO( printf( "Skip... %s [%s] < [%s]\n", sDesc, sKeys2Match, sToken ) ); - i++; - if( ( iLenMatched = ( sKeys2Match - aCheck[i - 1].sWord ) ) == 0 ) - { - sKeys2Match = NULL; - DEBUG_INFO( printf( "Continue with larger: [%s]\n", aCheck[i].sWord ) ); - continue; - } - - /* Is there a next potential Pattern. */ - if( i < iMax && strncmp( aCheck[i - 1].sWord, aCheck[i].sWord, iLenMatched ) == 0 ) - { - /* Same relative position, in the next Pattern. */ - sKeys2Match = aCheck[i].sWord + iLenMatched; - DEBUG_INFO( printf( "Continue with larger: [%s] at: [%s]\n", aCheck[i].sWord, sKeys2Match ) ); - continue; - } - else - { - DEBUG_INFO( printf( "Gave-Up! %i !< %i or Pattern [%s] not compatible with last match\n", i, iMax, aCheck[i].sWord ) ); - break; - } - } - - if( pNextSpacer ) - { - /* Token not followed by white space - can't match this [or any latter] pattern! */ - if( ! acOmmit[(int)cSpacer] ) - { - DEBUG_INFO( printf( "Skip... Pattern [%s] requires {WS}, cSpacer: %c\n", sKeys2Match, cSpacer ) ); - - i++; - if( ( iLenMatched = ( sKeys2Match - aCheck[i - 1].sWord ) ) == 0 ) - { - sKeys2Match = NULL; - DEBUG_INFO( printf( "Continue with: [%s]\n", aCheck[i].sWord ) ); - continue; - } - - /* Is there a next potential Pattern. */ - if( i < iMax && strncmp( aCheck[i - 1].sWord, aCheck[i].sWord, iLenMatched ) == 0 ) - { - /* Same relative position, in the next Pattern. */ - sKeys2Match = aCheck[i].sWord + iLenMatched; - DEBUG_INFO( printf( "Continue with: [%s] at: [%s]\n", aCheck[i].sWord, sKeys2Match ) ); - continue; - } - else - { - DEBUG_INFO( printf( "Gave-Up! %i !< %i or Pattern [%s] not compatible with last match\n", i, iMax, aCheck[i].sWord ) ); - break; - } - } - - iKeyLen = pNextSpacer - sKeys2Match; - } - else - { - iKeyLen = strlen( sKeys2Match ); - } - - #ifdef LEX_ABBREVIATE - iLen2Match = iLen; - if( iLen2Match < LEX_ABBREVIATE && iLen2Match < iKeyLen ) - { - iLen2Match = ( LEX_ABBREVIATE < iKeyLen ) ? LEX_ABBREVIATE : iKeyLen ; - } - - if( iLen2Match > iKeyLen && i < iMax - 1 ) - { - DEBUG_INFO( printf( "Trying Next... length mismatch - iKeyLen: %i iLen2Match: %i comparing: [%s] with: [%s]\n", iKeyLen, iLen2Match, sToken, sKeys2Match ) ); - i++; - - if( ( iLenMatched = ( sKeys2Match - aCheck[i - 1].sWord ) ) == 0 ) - { - sKeys2Match = NULL; - DEBUG_INFO( printf( "Continue with: [%s]\n", aCheck[i].sWord ) ); - continue; - } - - /* Is there a next potential Pattern. */ - if( i < iMax && strncmp( aCheck[i - 1].sWord, aCheck[i].sWord, iLenMatched ) == 0 ) - { - /* Same relative position, in the next Pattern. */ - sKeys2Match = aCheck[i].sWord + iLenMatched; - DEBUG_INFO( printf( "Continue with: [%s] at: [%s]\n", aCheck[i].sWord, sKeys2Match ) ); - continue; - } - else - { - DEBUG_INFO( printf( "Gave-Up! %i !< %i or Pattern [%s] not compatible with last match\n", i, iMax, aCheck[i].sWord ) ); - break; - } - } - - DEBUG_INFO( printf( "iKeyLen: %i iLen2Match: %i comparing: [%s] with: [%s]\n", iKeyLen, iLen2Match, sToken, sKeys2Match ) ); - - iCompare = strncmp( (char*) sToken, sKeys2Match, iLen2Match ); - #else - iCompare = strcmp( (char*) sToken, sKeys2Match ); - #endif - - if( iCompare == 0 ) /* Match found */ - { - if( pNextSpacer == NULL ) /* Full Match! */ - { - DEBUG_INFO( printf( "Saving Tentative %s [%s] == [%s]\n", sDesc, sToken, sKeys2Match ) ); - - iTentative = i; - iLenMatched = strlen( aCheck[i].sWord ); - - /* Saving this pointer of the input stream, we might have to get here again. */ - szBaseBuffer = s_szBuffer; iBaseSize = iSize; - DEBUG_INFO( printf( "Saved Buffer Postion: %i at: [%s]\n", iBaseSize, szBaseBuffer ) ); - - /* No White Space after last Token! */ - if( iHold || iPairToken ) - { - DEBUG_INFO( printf( "No White space after [%s] Holding: %i\n", sToken, aiHold[0] ) ); - break; - } - - IsExtendedMatch : - i++; - - /* Is there a next potential Pattern, that is an extended version of the current Pattern. */ - if( i < iMax && strncmp( aCheck[i - 1].sWord, aCheck[i].sWord, iLenMatched ) == 0 ) - { - if( strlen( aCheck[i].sWord ) > ( iLenMatched + 4 ) && ( pNextSpacer = strstr( aCheck[i].sWord + iLenMatched, "{WS}" ) ) != NULL ) - { - /* Same relative position, in the next Pattern. */ - sKeys2Match = pNextSpacer + 4; - DEBUG_INFO( printf( "Continue with: [%s] at: [%s]\n", aCheck[i].sWord, sKeys2Match ) ); - } - else - { - DEBUG_INFO( printf( "Skip... - Not Extended: [%s]\n", aCheck[i].sWord ) ); - goto IsExtendedMatch; - } - } - else - { - DEBUG_INFO( printf( "Gave-Up! %i !< %i or Pattern [%s] not extension of Pattern [%s]\n", i, iMax, aCheck[i].sWord, aCheck[iTentative].sWord ) ); - break; - } - } - else - { - sKeys2Match = pNextSpacer + 4; - DEBUG_INFO( printf( "Partial %s Match! [%s] == [%s] - Looking for: [%s]\n", sDesc, sToken, aCheck[i].sWord, sKeys2Match ) ); - - /* Saving this pointer of the input stream, we might have to get here again. */ - szBaseBuffer = s_szBuffer; iBaseSize = iSize; - DEBUG_INFO( printf( "Saved Buffer Postion: %i at: [%s]\n", iBaseSize, szBaseBuffer ) ); - } - - /* i may have been increased above - don't want to read next token if it won't get used! */ - if( i < iMax ) - { - bRecursive = TRUE; - cSpacer = chr; - - DEBUG_INFO( printf( "Getting next Token...\n" ) ); - SimpLex_GetNextToken(); - continue; - } - } - else if( iCompare > 0 ) - { - DEBUG_INFO( printf( "Trying Next %s Pattern... [%s] > [%s]\n", sDesc, sToken, sKeys2Match ) ); - i++; - - if( ( iLenMatched = ( sKeys2Match - aCheck[i - 1].sWord ) ) == 0 ) - { - sKeys2Match = NULL; - DEBUG_INFO( printf( "Continue with: [%s]\n", aCheck[i].sWord ) ); - continue; - } - - /* Is there a next potential Pattern. */ - if( i < iMax && strncmp( aCheck[i - 1].sWord, aCheck[i].sWord, iLenMatched ) == 0 ) - { - /* Same relative position, in the next Pattern. */ - sKeys2Match = aCheck[i].sWord + iLenMatched; - DEBUG_INFO( printf( "Continue with: [%s] at: [%s]\n", aCheck[i].sWord, sKeys2Match ) ); - continue; - } - else - { - DEBUG_INFO( printf( "Gave-Up! %i !< %i or Pattern [%s] not compatible with previous match.\n", i, iMax, aCheck[i].sWord ) ); - break; - } - } - else - { - DEBUG_INFO( printf( "Gave-Up! [%s] < [%s]\n", sToken, sKeys2Match ) ); - break; - } - } - - if( s_szBuffer != szBaseBuffer ) - { - s_szBuffer = szBaseBuffer; iSize = iBaseSize; iHold = 0; iReturn = 0; iPairToken = 0; - DEBUG_INFO( printf( "Partial Match - Restored position: %i at: [%s]\n", iSize, s_szBuffer ) ); - } - - if( iTentative > -1 ) - { - DEBUG_INFO( printf( "Reducing %s Pattern: %i [%s]\n", sDesc, iTentative, aCheck[iTentative].sWord ) ); - - bIgnoreWords = TRUE; - - iRet = aCheck[ iTentative ].iToken; - if( iRet < LEX_CUSTOM_ACTION ) - { - iRet = CUSTOM_ACTION( iRet ); - } - } - else - { - iRet = 0; - } -} - -#ifdef __cplusplus - YY_BUFFER_STATE yy_create_buffer( FILE * pFile, int iBufSize ) -#else - void * yy_create_buffer( FILE * pFile, int iBufSize ) -#endif -{ - /* Avoid warning of unused symbols. */ - (void) pFile; - (void) iBufSize; - - iSize = 0; - - #ifdef __cplusplus - return (YY_BUFFER_STATE) szLexBuffer; - #else - return (void*) szLexBuffer; - #endif -} - -#ifdef __cplusplus - void yy_switch_to_buffer( YY_BUFFER_STATE pBuffer ) -#else - void yy_switch_to_buffer( void * pBuffer ) -#endif -{ - /* Avoid warning of unused symbols. */ - (void) pBuffer; - FORCE_REDUCE(); - iSize = 0; -} - -#ifdef __cplusplus - void yy_delete_buffer( YY_BUFFER_STATE pBuffer ) -#else - void yy_delete_buffer( void * pBuffer ) -#endif -{ - /* Avoid warning of unused symbols. */ - (void) pBuffer; - FORCE_REDUCE(); - iSize = 0; -} - -void * yy_bytes_buffer( char * pBuffer, int iBufSize ) -{ - s_szBuffer = pBuffer; - iSize = iBufSize; - - if( bStart ) - { - bStart = FALSE; - GenTrees(); - INIT_ACTION(); - } - - return s_szBuffer; -} - -static void GenTrees( void ) -{ - register unsigned int i; - register unsigned int iIndex; - - i = 0; - while( i < 256 ) - { - acOmmit[i] = 0; - acNewLine[i] = 0; - acReturn[i] = 0; - aPairNodes[i].iMin = -1; - aPairNodes[i].iMax = -1; - aSelfNodes[i].iMin = -1; - aSelfNodes[i].iMax = -1; - aKeyNodes[i].iMin = -1; - aKeyNodes[i].iMax = -1; - aWordNodes[i].iMin = -1; - aWordNodes[i].iMax = -1; - aRuleNodes[i].iMin = -1; - aRuleNodes[i].iMax = -1; - i++; - } - - while( i < MAX_RULES ) - { - aRuleNodes[i].iMin = -1; - aRuleNodes[i].iMax = -1; - i++; - } - - i = 0; - while ( szOmmit[i] ) - { - acOmmit[ (int)(szOmmit[i]) ] = 1; - i++; - } - - i = 0; - while ( szNewLine[i] ) - { - acNewLine[ (int)(szNewLine[i]) ] = 1; - i++; - } - - i = 0; - while ( i < iDelimiters ) - { - acReturn[ (int)(aDelimiters[i].cDelimiter) ] = aDelimiters[i].iToken; - i++; - } - - i = 0; - while ( i < iPairs ) - { - iIndex = aPairs[i].sStart[0]; - if( aPairNodes[ iIndex ].iMin == -1 ) - { - aPairNodes[ iIndex ].iMin = i; - } - aPairNodes[ iIndex ].iMax = i; - i++; - } - - i = 0; - while ( i < iSelfs ) - { - iIndex = aSelfs[i].sWord[0]; - if( aSelfNodes[ iIndex ].iMin == -1 ) - { - aSelfNodes[ iIndex ].iMin = i; - } - aSelfNodes[ iIndex ].iMax = i; - i++; - } - - #ifdef USE_KEYWORDS - i = 0; - while ( i < iKeys ) - { - iIndex = aKeys[i].sWord[0]; - if( aKeyNodes[ iIndex ].iMin == -1 ) - { - aKeyNodes[ iIndex ].iMin = i; - } - aKeyNodes[ iIndex ].iMax = i; - i++; - } - #endif - - i = 0; - while ( i < iWords ) - { - iIndex = aWords[i].sWord[0]; - if( aWordNodes[ iIndex ].iMin == -1 ) - { - aWordNodes[ iIndex ].iMin = i; - } - aWordNodes[ iIndex ].iMax = i; - i++; - } - - /* Reduce logic excpects the Rules to be sorted. */ - qsort( ( void * ) aiRules, iRules, LEX_RULE_SIZE, rulecmp ); - - i = 0; - while ( i < iRules ) - { - iIndex = (unsigned int) aiRules[i][0]; - if( iIndex > 1023 ) - { - printf( "ERROR! Primary Token: %i out of range.\n", (int) iIndex ); - exit( EXIT_FAILURE ); - } - if( aRuleNodes[ iIndex ].iMin == -1 ) - { - aRuleNodes[ iIndex ].iMin = i; - } - aRuleNodes[ iIndex ].iMax = i; - i++; - } -} - -static int rulecmp( const void * pLeft, const void * pRight ) -{ - int *iLeftRule = (int*)( pLeft ); - int *iRightRule = (int*)( pRight ); - register unsigned int i = 0; - - while( iLeftRule[i] == iRightRule[i] ) - { - i++; - } - - if( iLeftRule[i] < iRightRule[i] ) - { - return -1; - } - else - { - return 1; - } -} diff --git a/harbour/source/macro/Makefile b/harbour/source/macro/Makefile index a925dfa7e2..e6c9cb9077 100644 --- a/harbour/source/macro/Makefile +++ b/harbour/source/macro/Makefile @@ -4,22 +4,6 @@ ROOT = ../../ -YACC_FLAGS = -p hb_macro - -YACC_SOURCE=macro.y - -YACC_HEADERS=\ - hbmacro.h \ - hbsetup.h \ - hbpcode.h \ - hbdefs.h \ - -ifeq ($(HB_LEX),SIMPLEX) - -C_EXTRA=macroslx.c - -else - #NOTE: You can pass additional parameters that control the speed/size # ratio of generated flex scanner. These parameters are: # -Cf - fastest/biggest @@ -29,20 +13,23 @@ else # -Ce # -Cem - slowest/smallest # see Flex documentation for full set of switches -LEX_FLAGS = -Phb_macro -C - +#LEX_FLAGS = -Phb_macro -C #LEX_SOURCE=macro.l +#LEX_HEADERS=\ +# hbsetup.h \ +# hberrors.h \ +# hbdefs.h \ +# hbmacro.h \ -LEX_HEADERS=\ - hbsetup.h \ - hberrors.h \ - hbdefs.h \ +YACC_FLAGS = -p hb_macro +YACC_SOURCE=macro.y +YACC_HEADERS=\ hbmacro.h \ - -endif + hbsetup.h \ + hbpcode.h \ + hbdefs.h \ C_SOURCES=\ - $(C_EXTRA) \ macroa.c \ macrob.c \ macroc.c \ diff --git a/harbour/source/macro/macro.slx b/harbour/source/macro/macro.slx deleted file mode 100644 index f3d23d50d3..0000000000 --- a/harbour/source/macro/macro.slx +++ /dev/null @@ -1,389 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Compiler MACRO SimpLex rules - * - * Copyright 2000 Ron Pinkas - * www - http://www.harbour-project.org - * - * 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 (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -//#define SHOW_LEX_TOKENS -//#define DEBUG_LEX - -#ifdef DEBUG_LEX - #undef DEBUG_INFO - #define DEBUG_INFO(x) x -#endif - -#undef LEX_ABBREVIATE - #define LEX_ABBREVIATE 4 - -#undef YY_BUF_SIZE - #define YY_BUF_SIZE 1 /* Not needed because using the pMacro->String as input buffer. */ - -/* declaration of yylex function - * NOTE: yylval_ptr is passed automaticaly by bison if %pure_parser is used -*/ -#undef YY_DECL - #define YY_DECL int yylex( YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro ) - -#define YYLEX_PARAM pMacro - -#undef YY_INPUT - #define YY_INPUT( buf, result, max_size ) result = 0; - -#undef STREAM_EXCEPTION - #define STREAM_EXCEPTION( sPair, cChar ) \ - hb_macroError( EG_SYNTAX, YYLEX_PARAM ); - -#undef IF_BELONG_LEFT - #define IF_BELONG_LEFT(chr) if( iLastToken == IDENTIFIER || iLastToken == ']' || iLastToken == MACROVAR || iLastToken == MACROTEXT || iLastToken == ')' || iLastToken == '}' || iLastToken == FIELD || /*iLastToken == SELF ||*/ iLastToken == QSELF || iLastToken == IIF ) - -static HB_MACRO_PTR pMacro; -static YYSTYPE *pYYLVAL; - -static int hb_macro_SLX_CustomAction( int x, int aiHold[], int *ptr_iHold, char *sToken ); -static int hb_macro_SLX_ElementToken( char* szToken, unsigned int iTokenLen ); -static int hb_comp_SLX_Str2Num( char* szNum, HB_LONG * lVal, double * dVal, int * iDec, int * iWidth ); - -void * yy_bytes_buffer( char * pBuffer, int iBufSize ); - -/* ----------------------------------------------------- Language Definitions. ---------------------------------------------------- */ - -/* Delimiters. */ -ACCEPT_TOKEN_AND_DROP_DELIMITER_IF_ONE_OF_THESE( " \t" ); - -ACCEPT_TOKEN_AND_RETURN_DELIMITERS { - LEX_DELIMITER( ',' ) AS_TOKEN( ',' + DONT_REDUCE ), - LEX_DELIMITER( '(' ) AS_TOKEN( '(' ), - LEX_DELIMITER( ')' ) AS_TOKEN( ')' ), - LEX_DELIMITER( '[' ) AS_TOKEN( '[' ), - LEX_DELIMITER( ']' ) AS_TOKEN( ']' + DONT_REDUCE ), - LEX_DELIMITER( '}' ) AS_TOKEN( '}' + DONT_REDUCE ), - LEX_DELIMITER( ':' ) AS_TOKEN( ':' ), - LEX_DELIMITER( '=' ) AS_TOKEN( '=' + DONT_REDUCE ), - LEX_DELIMITER( '#' ) AS_TOKEN( NE1 + DONT_REDUCE ), - LEX_DELIMITER( '@' ) AS_TOKEN( '@' + DONT_REDUCE ), - LEX_DELIMITER( '<' ) AS_TOKEN( '<' + DONT_REDUCE ), - LEX_DELIMITER( '>' ) AS_TOKEN( '>' + DONT_REDUCE ), - LEX_DELIMITER( '!' ) AS_TOKEN( NOT + DONT_REDUCE ), - LEX_DELIMITER( '{' ) AS_TOKEN( '{' + DONT_REDUCE ), - LEX_DELIMITER( '|' ) AS_TOKEN( '|' + DONT_REDUCE ), - LEX_DELIMITER( '^' ) AS_TOKEN( POWER + DONT_REDUCE ), - LEX_DELIMITER( '%' ) AS_TOKEN( '%' + DONT_REDUCE ), - LEX_DELIMITER( '*' ) AS_TOKEN( '*' + DONT_REDUCE ), - LEX_DELIMITER( '/' ) AS_TOKEN( '/' + DONT_REDUCE ), - LEX_DELIMITER( '+' ) AS_TOKEN( '+' + DONT_REDUCE ), - LEX_DELIMITER( '-' ) AS_TOKEN( '-' + DONT_REDUCE ), - LEX_DELIMITER( '$' ) AS_TOKEN( '$' + DONT_REDUCE ) - }; - -/* Intermediate Token, needs CustomAction. */ -#define HB_LIT_ACT LEX_CUSTOM_ACTION - 1 - -/* Stream Pairs. */ -DEFINE_STREAM_AS_ONE_OF_THESE { - START_WITH("\"") END_WITH("\"" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_LIT_ACT), - START_WITH("'") END_WITH("'") STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_LIT_ACT), - START_WITH("[") END_WITH("]" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(TRUE ) AS_PAIR_TOKEN(HB_LIT_ACT) - }; - -START_NEW_LINE_IF_ONE_OF_THESE( "\n;" ); - -#define HB_SELF LEX_CUSTOM_ACTION - 2 - -SELF_CONTAINED_WORDS_ARE { - LEX_WORD( ".AND." ) AS_TOKEN( AND + DONT_REDUCE ), - LEX_WORD( ".NOT." ) AS_TOKEN( NOT + DONT_REDUCE ), - LEX_WORD( ".OR." ) AS_TOKEN( OR + DONT_REDUCE ), - LEX_WORD( ":=" ) AS_TOKEN( INASSIGN + DONT_REDUCE ), - LEX_WORD( "::" ) AS_TOKEN( HB_SELF ), - LEX_WORD( "==" ) AS_TOKEN( EQ + DONT_REDUCE ), - LEX_WORD( "<>" ) AS_TOKEN( NE2 + DONT_REDUCE ), - LEX_WORD( "<=" ) AS_TOKEN( LE + DONT_REDUCE ), - LEX_WORD( ">=" ) AS_TOKEN( GE + DONT_REDUCE ), - LEX_WORD( "!=" ) AS_TOKEN( NE2 + DONT_REDUCE ), - LEX_WORD( "++" ) AS_TOKEN( INC + DONT_REDUCE ), - LEX_WORD( "+=" ) AS_TOKEN( PLUSEQ + DONT_REDUCE ), - LEX_WORD( "--" ) AS_TOKEN( DEC + DONT_REDUCE ), - LEX_WORD( "-=" ) AS_TOKEN( MINUSEQ + DONT_REDUCE ), - LEX_WORD( "->" ) AS_TOKEN( ALIASOP ), - LEX_WORD( "*=" ) AS_TOKEN( MULTEQ + DONT_REDUCE ), - LEX_WORD( "**" ) AS_TOKEN( POWER + DONT_REDUCE ), - LEX_WORD( "/=" ) AS_TOKEN( DIVEQ + DONT_REDUCE ), - LEX_WORD( "^=" ) AS_TOKEN( EXPEQ + DONT_REDUCE ), - LEX_WORD( "%=" ) AS_TOKEN( MODEQ + DONT_REDUCE ) - }; - -/* Intermediate Words when ambigious. */ -#define QSELF 802 - -/* Words. */ -LANGUAGE_WORDS_ARE { - LEX_WORD( ".F." ) AS_TOKEN( FALSEVALUE + DONT_REDUCE ), - LEX_WORD( ".N." ) AS_TOKEN( FALSEVALUE + DONT_REDUCE ), - LEX_WORD( ".T." ) AS_TOKEN( TRUEVALUE + DONT_REDUCE ), - LEX_WORD( ".Y." ) AS_TOKEN( TRUEVALUE + DONT_REDUCE ), - LEX_WORD( "FIELD" ) AS_TOKEN( FIELD ), - LEX_WORD( "IF" ) AS_TOKEN( IIF ), - LEX_WORD( "IIF" ) AS_TOKEN( IIF ), - LEX_WORD( "NIL" ) AS_TOKEN( NIL + DONT_REDUCE ), - LEX_WORD( "QSELF" ) AS_TOKEN( QSELF ), - /* LEX_WORD( "SELF" ) AS_TOKEN( SELF ), */ - LEX_WORD( "_FIELD" ) AS_TOKEN( FIELD ) - }; - -/* When reservered words are used as Identifier. */ -#define HB_IDENTIFIER LEX_CUSTOM_ACTION - 3 -#define HB_MACRO_ERR LEX_CUSTOM_ACTION - 4 - -LANGUAGE_RULES_ARE { - /* This _FIELD_ is NOT at BOL wants only ->. */ - IF_SEQUENCE_IS( FIELD , ALIASOP , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( FIELD , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - /* IF_SEQUENCE_IS( SELF , ':' , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( SELF , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), */ - - IF_SEQUENCE_IS( QSELF , '(' , ')' , 0 ) REDUCE_TO( SELF + DONT_REDUCE, 0 ), - IF_SEQUENCE_IS( QSELF , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - IF_SEQUENCE_IS( IIF , '(' , 0 , 0 ) PASS_THROUGH(), - IF_SEQUENCE_IS( IIF , 0 , 0 , 0 ) REDUCE_TO( HB_IDENTIFIER , 0 ), - - IF_SEQUENCE_IS( '&' , '\'' , 0 , 0 ) REDUCE_TO( HB_MACRO_ERR , 0 ), - IF_SEQUENCE_IS( '&' , '"' , 0 , 0 ) REDUCE_TO( HB_MACRO_ERR , 0 ), - IF_SEQUENCE_IS( '&' , '[' , 0 , 0 ) REDUCE_TO( HB_MACRO_ERR , 0 ) - }; - -/* ------------------------------------------------- End of Language Definitions. ------------------------------------------------ */ - -#undef LEX_CASE - #define LEX_CASE(x) ( ( ( iRet = (x) ) > 96 && iRet < 123 ) ? iRet - 32 : iRet ) - -#ifdef SHOW_LEX_TOKENS - #undef INTERCEPT_ACTION - #define INTERCEPT_ACTION(x) \ - if( x == IDENTIFIER ) \ - printf( " IDENTIFIER = \"%s\"\n", pYYLVAL->string ); \ - else if( x == LITERAL ) \ - printf( " LITERAL = \"%s\"\n", pYYLVAL->string ); \ - else if( x == MACROVAR ) \ - printf( " MACROVAR = \"%s\"\n", pYYLVAL->string ); \ - else if( x == MACROTEXT ) \ - printf( " MACROTEXT = \"%s\"\n", pYYLVAL->string ); \ - else if( x == NUM_LONG ) \ - printf( " INTEGER = %il\n", pYYLVAL->valLong.lNumber ); \ - else if( x == NUM_DOUBLE ) \ - printf( " DOUBLE = %f\n", pYYLVAL->valDouble.dNumber ); \ - else if( x < 256 ) \ - if( x == '\n' || x == ';' ) \ - printf( " NEW LINE %i\n", hb_comp_iLine - 1 ); \ - else \ - printf( " DELIMITER = \"%c\"\n", x ); \ - else \ - printf( " TOKEN = %i\n", x ); -#endif - -#undef ELEMENT_TOKEN - #define ELEMENT_TOKEN(x,y) hb_macro_SLX_ElementToken(x,y) - -#undef CUSTOM_ACTION - #define CUSTOM_ACTION(x) x = hb_macro_SLX_CustomAction( x, aiHold, &iHold, (char*) sToken ) - -#undef LEX_USER_SETUP - #define LEX_USER_SETUP() if( pYYLVAL == NULL ) pYYLVAL = yylval_ptr; - -static int hb_macro_SLX_ElementToken( char* szToken, unsigned int iTokenLen ) -{ - extern char *yytext; - extern int yyleng; - - char *tmpPtr; - int iRet; - - yytext = szToken; - yyleng = iTokenLen; - - if( ( *yytext > 64 && *yytext < 91 ) || *yytext == '&' || *yytext == '_' ) - { - /* Macro. */ - if( ( tmpPtr = strrchr( yytext, '&' ) ) != NULL ) /* Right Search. */ - { - /* Is '&' the first char? - Since its was right search that would be the only '&'. */ - if( tmpPtr == yytext ) - { - /* Maybe just the Macro Operator. */ - if( yyleng == 1 ) - { - iRet = '&'; - } - /* No '.' so Simple Macro. */ - else if( ( tmpPtr = strchr( yytext, '.' ) ) == NULL ) /* Left Search. */ - { - /* Remove the '&'. */ - yytext++; - yyleng--; - - pYYLVAL->string = hb_strdup( yytext ); - iRet = MACROVAR; - } - else if( tmpPtr == yytext + yyleng - 1 ) - { - /* The only '.' is last char, so Simple Macro. */ - - /* Remove the '&' and the '.' */ - yytext++; - yyleng -= 2; - yytext[yyleng] = '\0'; - - pYYLVAL->string = hb_strdup( yytext ); - iRet = MACROVAR; - } - else - { - yytext = hb_strdup( yytext ); - pYYLVAL->string = yytext; - iRet = MACROTEXT; - } - } - else - { - yytext = hb_strdup( yytext ); - pYYLVAL->string = yytext; - iRet = MACROTEXT; - } - } - else - { - if( yyleng > (int) YYLEX_PARAM->uiNameLen ) - { - yytext[ YYLEX_PARAM->uiNameLen ] = '\0'; - yyleng = YYLEX_PARAM->uiNameLen; - } - - pYYLVAL->string = hb_strdup( yytext ); - iRet = IDENTIFIER; - } - } - else - { - /* ConverNumber */ - - HB_LONG lNumber; - double dNumber; - int iDec, iWidth; - - iRet = hb_comp_SLX_Str2Num( yytext, &lNumber, &dNumber, &iDec, &iWidth ); - - if ( iRet == NUM_DOUBLE ) - { - pYYLVAL->valDouble.dNumber = dNumber; - pYYLVAL->valDouble.bDec = iDec; - pYYLVAL->valDouble.bWidth = iWidth; - pYYLVAL->valDouble.szValue = yytext; - } - else - { - pYYLVAL->valLong.lNumber = lNumber; - pYYLVAL->valLong.szValue = yytext; - } - } - - DEBUG_INFO( printf( "Element \"%s\" is %i\n", sToken, iRet ) ); - return iRet + DONT_REDUCE; -} - -static int hb_comp_SLX_Str2Num( char* szNum, HB_LONG * plVal, double * pdVal, int * piDec, int * piWidth ) -{ - BOOL fDbl; - - fDbl = hb_compStrToNum( szNum, strlen( szNum ), plVal, pdVal, piDec, piWidth ); - return fDbl ? NUM_DOUBLE : NUM_LONG; -} - -int hb_macro_SLX_CustomAction( int x, int aiHold[], int *ptr_iHold, char *sToken ) -{ - switch ( x ) - { - case HB_LIT_ACT : - pYYLVAL->string = hb_strdup( sPair ); - return LITERAL + DONT_REDUCE ; - - case HB_IDENTIFIER : - pYYLVAL->string = hb_strdup( sToken ); - return IDENTIFIER + DONT_REDUCE; - - case HB_SELF : - aiHold[ (*ptr_iHold)++ ] = ':' + DONT_REDUCE ; - pYYLVAL->string = hb_strdup( "SELF" ); - return IDENTIFIER + DONT_REDUCE ; - - case HB_MACRO_ERR : - hb_macroError( EG_SYNTAX, YYLEX_PARAM ); - return 0; - - default: - printf( "ERROR! [MACRO.SLX] - No Handler for Custom Action %i\n", x ); - return 0; - } -} - -void * hb_compFlexNew( HB_MACRO_PTR pNewMacro ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_compFlexNew(%s, %i)", pNewMacro->string, pNewMacro->length)); - - pYYLVAL = NULL; - pMacro = pNewMacro; - - DEBUG_INFO( printf( "*** New Macro: %s\n", pMacro->string ) ); - return yy_bytes_buffer( pMacro->string, pMacro->length ); -} - -void hb_compFlexDelete( void * pBuffer ) -{ - HB_SYMBOL_UNUSED( pBuffer ); -} diff --git a/harbour/source/macro/macroslx.c b/harbour/source/macro/macroslx.c deleted file mode 100644 index 763a195066..0000000000 --- a/harbour/source/macro/macroslx.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * MACRO Compiler SimpLex rules main (host) file. - * - * Copyright 2000 Ron Pinkas - * www - http://www.harbour-project.org - * - * 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 (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#define HB_MACRO_SUPPORT - -#define yylex hb_complex - -#include -#include -#include -#include - -#include "hbmacro.h" -#include "hbcomp.h" - -#include "macroy.h" -#include "hbsetup.h" /* main configuration file */ -#include "hberrors.h" -#include "hbdefs.h" - -#define MAX_STREAM 2048 /* Max length of in-line LITERAL */ -#define MAX_STREAM_STARTER 2 -#define MAX_STREAM_TERMINATOR 2 -#define MAX_STREAM_EXCLUSIONS 2 - -#define TOKEN_SIZE HB_SYMBOL_NAME_LEN + 1 - -/* NOTE: 02/08/2000 - maurilio.longo@libero.it, under OS/2 GCC I need to use relative paths in include command */ -/* this is relative to position of simplex.c in harbour source tree */ -#define SLX_RULES "../macro/macro.slx" - -/* this is relative to position of macroslx.c in harbour source tree */ -#include "../compiler/simplex.c" diff --git a/harbour/source/pp/ppcore.c b/harbour/source/pp/ppcore.c index 5131445a1e..64cdd9a1ae 100644 --- a/harbour/source/pp/ppcore.c +++ b/harbour/source/pp/ppcore.c @@ -951,8 +951,11 @@ static void hb_pp_getLine( PHB_PP_STATE pState ) ++ul; while( ++ul < ulLen && pBuffer[ ul ] != '"' ) { - if( pBuffer[ ul ] == '\\' && ulLen - ul > 1 ) - ++ul; + if( pBuffer[ ul ] == '\\' ) + { + if( ++ul == ulLen ) + break; + } } ulStrip = ul - 2; hb_strRemEscSeq( pBuffer + 2, &ulStrip ); @@ -1230,8 +1233,8 @@ static int hb_pp_tokenStr( PHB_PP_TOKEN pToken, PHB_MEM_BUFFER pBuffer, { int iLines = 0, iSpace = fSpaces ? pToken->spaces : 0; - /* This is workaround for stringify token list and later decoding by - FLEX/SIMPLEX which breaks Clipper compatible code */ + /* This is workaround for stringify token list and later decoding by FLEX + which breaks Clipper compatible code */ if( iSpace == 0 && fQuote && ltype && ltype >= HB_PP_TOKEN_ASSIGN && HB_PP_TOKEN_TYPE( pToken->type ) >= HB_PP_TOKEN_ASSIGN ) @@ -1251,14 +1254,23 @@ static int hb_pp_tokenStr( PHB_PP_TOKEN pToken, PHB_MEM_BUFFER pBuffer, for( i = 0; iq && i < pToken->len; ++i ) { - if( pToken->value[ i ] == '"' ) - iq &= ~1; - else if( pToken->value[ i ] == '\'' ) - iq &= ~2; - else if( pToken->value[ i ] == ']' ) - iq &= ~4; - else if( pToken->value[ i ] == '\n' ) - iq = 0; + switch( pToken->value[ i ] ) + { + case '"': + iq &= ~1; + break; + case '\'': + iq &= ~2; + break; + case ']': + iq &= ~4; + break; + case '\n': + case '\r': + case '\0': + iq = 0; + break; + } } if( iq == 0 && fQuote ) { @@ -1286,6 +1298,9 @@ static int hb_pp_tokenStr( PHB_PP_TOKEN pToken, PHB_MEM_BUFFER pBuffer, case '\b': iq = ch = 'b'; break; + case '\0': + iq = ch = '0'; + break; case '"': case '\\': iq = 1; diff --git a/harbour/utils/hbpp/hbppcomp.c b/harbour/utils/hbpp/hbppcomp.c index 5541db57c8..70c8346548 100644 --- a/harbour/utils/hbpp/hbppcomp.c +++ b/harbour/utils/hbpp/hbppcomp.c @@ -311,9 +311,7 @@ int hb_pp_Internal_( FILE * handl_o, char * sOut ) if( hb_comp_iLineINLINE && hb_pp_StreamBlock == 0 ) { hb_comp_iLine = hb_comp_iLinePRG + ( hb_comp_iLine - hb_comp_iLineINLINE ); - #ifndef SIMPLEX - hb_comp_iLine++; - #endif + hb_comp_iLine++; hb_comp_iLineINLINE = 0; }