2006-11-24 19:10 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/config/bsd/gcc.cf
  * harbour/config/darwin/gcc.cf
  * harbour/config/dos/djgpp.cf
  * harbour/config/dos/owatcom.cf
  * harbour/config/hpux/gcc.cf
  * harbour/config/linux/gcc.cf
  * harbour/config/linux/owatcom.cf
  * harbour/config/os2/gcc.cf
  * harbour/config/sunos/gcc.cf
  * harbour/config/w32/bcc32.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
  * harbour/include/hbexprb.c
  * harbour/include/hbver.h
  * harbour/source/common/hbstr.c
  * harbour/source/common/hbver.c
  * harbour/source/compiler/Makefile
  * harbour/source/compiler/cmdcheck.c
  * harbour/source/compiler/complex.c
  * harbour/source/compiler/gencli.c
  * harbour/source/compiler/genjava.c
  * harbour/source/compiler/genobj32.c
  * harbour/source/compiler/harbour.c
  - harbour/source/compiler/harbour.simple
  - harbour/source/compiler/harbour.slx
  - harbour/source/compiler/harbour.sly
  * harbour/source/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<hex> and \<oct> 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 someone will try to use strings with embedded
      0 now then they will be cut but nothing worser should happen.
This commit is contained in:
Przemyslaw Czerpak
2006-11-24 18:10:07 +00:00
parent 841d16a4b8
commit e6a3baea64
42 changed files with 692 additions and 9982 deletions

View File

@@ -8,6 +8,67 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2006-02-08 20:23 UTC+0100 Antonio Linares <alinares@fivetechsoft.com>
* 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 <alinares@fivetechsoft.com>
* 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<hex> and \<oct> 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.

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 =

View File

@@ -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

View File

@@ -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

View File

@@ -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:= ,

View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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[] );

View File

@@ -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 )

View File

@@ -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

View File

@@ -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, <pExpr>, <pExpr>:=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

View File

@@ -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
*/

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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:<id>" 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:<id>" 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" );

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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" );

View File

@@ -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 );

View File

@@ -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;
}

View File

@@ -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 <alloca.h>
#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 <malloc.h>
#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 <malloc.h> */
#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;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -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 {}

View File

@@ -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 );

View File

@@ -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"

File diff suppressed because it is too large Load Diff

View File

@@ -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 );
}

File diff suppressed because it is too large Load Diff

View File

@@ -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 \

View File

@@ -1,389 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Compiler MACRO SimpLex rules
*
* Copyright 2000 Ron Pinkas <ronpinkas@profit-master.com>
* 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 );
}

View File

@@ -1,82 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* MACRO Compiler SimpLex rules main (host) file.
*
* Copyright 2000 Ron Pinkas <ronpinkas@profit-master.com>
* 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 <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#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"

View File

@@ -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;

View File

@@ -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;
}