From 4a4e7b593b4b9462546437f51f8ecba57d273277 Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Fri, 8 Sep 2000 11:00:40 +0000 Subject: [PATCH] 2000-09-08 03:50 UTC+0800 Ron Pinkas * config/dos/djgpp.cf + Added support for $(C_USER) and $(L_USER) /* Could someone please verify, that this is the correct way. */ * source/compiler/simplex.c + Added: #define SUSPEND_WORDS 8192, and minor support logic. * source/compiler/harbour.slx ! Removed 14 #defines, and 14 cases from hb_lex_CustomAction(), by taking advantage of SUSPEND_WORDS. * source/macro/macro.slx - Removed 1 unused variable. --- harbour/ChangeLog | 13 +++ harbour/config/dos/djgpp.cf | 4 +- harbour/source/compiler/harbour.slx | 162 ++++++---------------------- harbour/source/compiler/simplex.c | 50 +++++---- harbour/source/macro/macro.slx | 4 +- 5 files changed, 80 insertions(+), 153 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f3c1d46678..163c3485d1 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,16 @@ +2000-09-08 03:50 UTC+0800 Ron Pinkas + * config/dos/djgpp.cf + + Added support for $(C_USER) and $(L_USER) /* Could someone please verify, that this is the correct way. */ + + * source/compiler/simplex.c + + Added: #define SUSPEND_WORDS 8192, and minor support logic. + + * source/compiler/harbour.slx + ! Removed 14 #defines, and 14 cases from hb_lex_CustomAction(), by taking advantage of SUSPEND_WORDS. + + * source/macro/macro.slx + - Removed 1 unused variable. + 2000-09-07 00:10 UTC+0800 Ron Pinkas * include/hbcomp.h * source/compiler/harbour.c diff --git a/harbour/config/dos/djgpp.cf b/harbour/config/dos/djgpp.cf index 669c2c5f04..29440f336b 100644 --- a/harbour/config/dos/djgpp.cf +++ b/harbour/config/dos/djgpp.cf @@ -13,7 +13,7 @@ CC = gcc CC_IN = -c CC_OUT = -o CPPFLAGS = -I. -I$(HB_INC_COMPILE) -CFLAGS = -Wall +CFLAGS = -Wall $(C_USER) LD = gcc LD_OUT = -o @@ -62,7 +62,7 @@ echo. $(file) >> __link__.tmp endef define link_exe_file -echo. $(LDFLAGS) $(LD_OUT)$@ > __link__.tmp +echo. $(LDFLAGS) $(L_USER) $(LD_OUT)$@ > __link__.tmp $(foreach file, $^, $(link_file)) $(foreach file, $(LINKPATHS), $(link_file)) $(foreach file, $(LINKLIBS), $(link_file)) diff --git a/harbour/source/compiler/harbour.slx b/harbour/source/compiler/harbour.slx index 2bb91a5037..1ca94c1897 100644 --- a/harbour/source/compiler/harbour.slx +++ b/harbour/source/compiler/harbour.slx @@ -114,10 +114,10 @@ DELIMITER_BELONGS_TO_TOKEN_IF_ONE_OF_THESE( "" ); /* Custom Action can be requested by setting reduction to LEX_CUSTOM_ACTION or lower. */ /* Intermediate Token needed to be expanded. */ -#define HB_LIT_ACT -1000 -#define HB_NESTED_LIT -1001 -#define HB_QOUT_ACT -1002 -#define HB_RET_QOUT_LIT -1003 +#define HB_LIT_ACT -1001 +#define HB_NESTED_LIT -1002 +#define HB_QOUT_ACT -1003 +#define HB_RET_QOUT_LIT -1004 /* Stream Pairs. */ DEFINE_STREAM_AS_ONE_OF_THESE { @@ -165,38 +165,22 @@ SELF_CONTAINED_WORDS_ARE { #define FIELD_ 1005 #define PRIVATE_ 1006 -/* Custom Actions - Suspend reserved words after these (waiting for Identifier). */ -#define HB_FUNCTION -1004 -#define HB_PROCEDURE -1005 -#define HB_EXTERN -1006 -#define HB_DECLARE -1007 -#define HB_PUBLIC -1008 -#define HB_PRIVATE -1009 -#define HB_LOCAL -1010 -#define HB_MEMVAR -1011 -#define HB_FIELD -1012 -#define HB_PARAM -1013 -#define HB_FOR -1014 -#define HB_OPTIONAL -1015 -#define HB_CLASS -1016 -#define HB_MEMBER -1017 - /* When 2 identifiers are correct syntax like in class declaration, we have to temporarily store the 2nd identifier. */ -#define HB_ID_ON_HOLD -1018 +#define HB_ID_ON_HOLD -1005 -#define HB_MACRO_ERR -1019 +#define HB_MACRO_ERR -1006 -#define HB_CHK_NEXT -1020 -#define HB_CHK_EXIT -1021 -#define HB_CHK_LOOP -1022 -#define HB_CHK_IN -1023 +#define HB_CHK_NEXT -1007 +#define HB_CHK_EXIT -1008 +#define HB_CHK_LOOP -1009 +#define HB_CHK_IN -1010 -#define HB_INIT_PROC -1024 -#define HB_EXIT_PROC -1025 -#define HB_INIT_FUNC -1026 -#define HB_EXIT_FUNC -1027 +#define HB_INIT_PROC -1011 +#define HB_EXIT_PROC -1012 +#define HB_INIT_FUNC -1013 +#define HB_EXIT_FUNC -1014 -#define HB_RET_FUNID -1029 +#define HB_RET_FUNID -1015 /* Key Words. */ LANGUAGE_KEY_WORDS_ARE { @@ -204,7 +188,7 @@ LANGUAGE_KEY_WORDS_ARE { LEX_WORD( "BEGIN" ) AS_TOKEN( BEGIN_ ), LEX_WORD( "BREAK" ) AS_TOKEN( BREAK ), LEX_WORD( "CASE" ) AS_TOKEN( CASE ), - LEX_WORD( "DECLARE" ) AS_TOKEN( HB_DECLARE ), + LEX_WORD( "DECLARE" ) AS_TOKEN( DECLARE + SUSPEND_WORDS ), LEX_WORD( "DO" ) AS_TOKEN( DO ), LEX_WORD( "ELSE" ) AS_TOKEN( ELSE ), LEX_WORD( "ELSEIF" ) AS_TOKEN( ELSEIF ), @@ -213,28 +197,28 @@ LANGUAGE_KEY_WORDS_ARE { LEX_WORD( "ENDDO" ) AS_TOKEN( ENDDO ), LEX_WORD( "ENDIF" ) AS_TOKEN( ENDIF ), LEX_WORD( "EXIT" ) AS_TOKEN( EXIT_ ), - LEX_WORD( "EXTERNAL" ) AS_TOKEN( HB_EXTERN ), - LEX_WORD( "FIELD" ) AS_TOKEN( HB_FIELD ), - LEX_WORD( "FOR" ) AS_TOKEN( HB_FOR ), - LEX_WORD( "FUNCTION" ) AS_TOKEN( HB_FUNCTION ), + LEX_WORD( "EXTERNAL" ) AS_TOKEN( EXTERN + SUSPEND_WORDS ), + LEX_WORD( "FIELD" ) AS_TOKEN( FIELD_ + SUSPEND_WORDS ), + LEX_WORD( "FOR" ) AS_TOKEN( FOR + SUSPEND_WORDS ), + LEX_WORD( "FUNCTION" ) AS_TOKEN( FUNCTION + SUSPEND_WORDS ), LEX_WORD( "IF" ) AS_TOKEN( IF ), LEX_WORD( "INIT" ) AS_TOKEN( INIT ), - LEX_WORD( "LOCAL" ) AS_TOKEN( HB_LOCAL ), + LEX_WORD( "LOCAL" ) AS_TOKEN( LOCAL + SUSPEND_WORDS ), LEX_WORD( "LOOP" ) AS_TOKEN( LOOP ), - LEX_WORD( "MEMVAR" ) AS_TOKEN( HB_MEMVAR ), + LEX_WORD( "MEMVAR" ) AS_TOKEN( MEMVAR + SUSPEND_WORDS ), LEX_WORD( "NEXT" ) AS_TOKEN( NEXT ), LEX_WORD( "OTHERWISE" ) AS_TOKEN( OTHERWISE ), - LEX_WORD( "PARAMETERS" ) AS_TOKEN( HB_PARAM ), - LEX_WORD( "PRIVATE" ) AS_TOKEN( HB_PRIVATE ), - LEX_WORD( "PROCEDURE" ) AS_TOKEN( HB_PROCEDURE ), - LEX_WORD( "PUBLIC" ) AS_TOKEN( HB_PUBLIC ), + LEX_WORD( "PARAMETERS" ) AS_TOKEN( PARAMETERS + SUSPEND_WORDS ), + LEX_WORD( "PRIVATE" ) AS_TOKEN( PRIVATE + SUSPEND_WORDS ), + LEX_WORD( "PROCEDURE" ) AS_TOKEN( PROCEDURE + SUSPEND_WORDS ), + LEX_WORD( "PUBLIC" ) AS_TOKEN( PUBLIC + SUSPEND_WORDS ), LEX_WORD( "RECOVER" ) AS_TOKEN( RECOVER ), LEX_WORD( "RETURN" ) AS_TOKEN( RETURN ), LEX_WORD( "STATIC" ) AS_TOKEN( STATIC ), LEX_WORD( "WHILE" ) AS_TOKEN( WHILE ), LEX_WORD( "_PROCREQ_" ) AS_TOKEN( PROCREQ_ ), - LEX_WORD( "_HB_CLASS" ) AS_TOKEN( HB_CLASS ), - LEX_WORD( "_HB_MEMBER" ) AS_TOKEN( HB_MEMBER ) + LEX_WORD( "_HB_CLASS" ) AS_TOKEN( DECLARE_CLASS + SUSPEND_WORDS ), + LEX_WORD( "_HB_MEMBER" ) AS_TOKEN( DECLARE_MEMBER + SUSPEND_WORDS ) }; /* Intermediate Words when ambigious. */ @@ -285,7 +269,7 @@ LANGUAGE_WORDS_ARE { LEX_WORD( "NUMERIC" ) AS_TOKEN( _NUMERIC_ ), LEX_WORD( "OBJECT" ) AS_TOKEN( _OBJECT_ ), LEX_WORD( "OF" ) AS_TOKEN( _OF_ ), - LEX_WORD( "OPTIONAL" ) AS_TOKEN( HB_OPTIONAL ), + LEX_WORD( "OPTIONAL" ) AS_TOKEN( OPTIONAL + SUSPEND_WORDS ), LEX_WORD( "PROCEDURE" ) AS_TOKEN( _PROC_ ), LEX_WORD( "QSELF" ) AS_TOKEN( QSELF ), LEX_WORD( "SELF" ) AS_TOKEN( _SELF_ ), @@ -992,7 +976,7 @@ LANGUAGE_RULES_ARE { } #undef CUSTOM_ACTION - #define CUSTOM_ACTION(x) x = hb_lex_CustomAction(x, iWordLen, aiHold, &iHold, &bIgnoreWords, iLastToken, aiReturn, &iReturn ) + #define CUSTOM_ACTION(x) x = hb_lex_CustomAction(x, aiHold, &iHold, iLastToken, aiReturn, &iReturn ) #undef INIT_ACTION #define INIT_ACTION() ; @@ -1041,7 +1025,7 @@ long hb_lex_Hex2L( char* sHex ) return lSum; } -int hb_lex_CustomAction( int x, int iWordLen, int aiHold[], int *ptr_iHold, BOOL *ptr_bIgnoreWords, int iLastToken, int aiReturn[], int *ptr_iReturn ) +int hb_lex_CustomAction( int x, int aiHold[], int *ptr_iHold, int iLastToken, int aiReturn[], int *ptr_iReturn ) { BOOL bRestored = FALSE; @@ -1080,90 +1064,6 @@ int hb_lex_CustomAction( int x, int iWordLen, int aiHold[], int *ptr_iHold, BOOL x = 0; break; - case HB_FUNCTION : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = FUNCTION; - x = 0; - break; - - case HB_PROCEDURE : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = PROCEDURE; - x = 0; - break; - - case HB_EXTERN : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = EXTERN; - x = 0; - break; - - case HB_DECLARE : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = DECLARE; - x = 0; - break; - - case HB_PUBLIC : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = PUBLIC; - x = 0; - break; - - case HB_PRIVATE : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = PRIVATE_; - x = 0; - break; - - case HB_LOCAL : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = LOCAL; - x = 0; - break; - - case HB_MEMVAR : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = MEMVAR; - x = 0; - break; - - case HB_FIELD : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = FIELD_; - x = 0; - break; - - case HB_PARAM : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = PARAMETERS; - x = 0; - break; - - case HB_FOR : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = FOR; - x = 0; - break; - - case HB_OPTIONAL : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = OPTIONAL; - x = 0; - break; - - case HB_CLASS : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = DECLARE_CLASS; - x = 0; - break; - - case HB_MEMBER : - *ptr_bIgnoreWords = TRUE; - aiHold[ (*ptr_iHold)++ ] = DECLARE_MEMBER; - x = 0; - break; - case HB_CHK_NEXT : if( hb_comp_wForCounter == 0 ) hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_NEXTFOR, NULL, NULL ); diff --git a/harbour/source/compiler/simplex.c b/harbour/source/compiler/simplex.c index bc7891bb20..93883eb7c7 100644 --- a/harbour/source/compiler/simplex.c +++ b/harbour/source/compiler/simplex.c @@ -119,7 +119,7 @@ typedef struct _LEX_PAIR /* Overidables. */ #define LEX_CUSTOM_ACTION -65 -#define ERR_TOO_COMPLEX_RULE -66 +#define SUSPEND_WORDS 8192 #define YY_BUF_SIZE 16384 #define YY_INPUT( a, b, c ) @@ -244,12 +244,12 @@ static void GenTrees( void ); DEBUG_INFO( printf("Now Holding %i Tokens: %i %i %i %i\n", iHold, aiHold[0], aiHold[1], aiHold[2], aiHold[3] ) ); \ } -#define RETURN_TOKEN(x, y) \ +#define RETURN_TOKEN(x) \ \ iRet = (x); \ if( (iRet) ) \ { \ - LEX_RETURN(iRet, y); \ + LEX_RETURN(iRet); \ } \ else \ { \ @@ -419,7 +419,7 @@ static void GenTrees( void ); iRet = CUSTOM_ACTION( iRet ); \ if( iRet ) \ { \ - RETURN_TOKEN( REDUCE( iRet ), (char*) sSelf ); \ + RETURN_TOKEN( REDUCE( iRet ) ); \ } \ else \ { \ @@ -428,7 +428,7 @@ static void GenTrees( void ); } \ else \ { \ - RETURN_TOKEN( REDUCE( aSelfs[iSelf].iToken ), (char*) sSelf ); \ + RETURN_TOKEN( REDUCE( aSelfs[iSelf].iToken ) ); \ } \ } \ } \ @@ -495,7 +495,7 @@ static void GenTrees( void ); \ DEBUG_INFO( printf( "Returning Ready: %i\n", iRet ) ); \ \ - LEX_RETURN(iRet, NULL); + LEX_RETURN(iRet); #define RELEASE_TOKEN() \ \ @@ -539,9 +539,9 @@ static void GenTrees( void ); \ DEBUG_INFO( printf( "Reducing Held: %i Pos: %i\n", iRet, iHold ) ); \ \ - RETURN_TOKEN( REDUCE( iRet ), sToken ); + RETURN_TOKEN( REDUCE( iRet ) ); -#define LEX_RETURN(x, y) \ +#define LEX_RETURN(x) \ \ if( x < LEX_CUSTOM_ACTION ) \ { \ @@ -1015,7 +1015,7 @@ YY_DECL { DEBUG_INFO( printf( "Reducing Left '%c'\n", chr ) ); iPairToken = 0; - RETURN_TOKEN( REDUCE( (int) chr ), NULL ); + RETURN_TOKEN( REDUCE( (int) chr ) ); } } @@ -1078,7 +1078,7 @@ YY_DECL iRet = CUSTOM_ACTION( iRet ); if( iRet ) { - RETURN_TOKEN( REDUCE( iRet ), NULL ); + RETURN_TOKEN( REDUCE( iRet ) ); } else { @@ -1087,7 +1087,7 @@ YY_DECL } else { - RETURN_TOKEN( REDUCE( iRet ), NULL ); + RETURN_TOKEN( REDUCE( iRet ) ); } } } @@ -1143,7 +1143,7 @@ YY_DECL DEBUG_INFO( printf( "Reducing NewLine '%c'\n", chr ) ); bIgnoreWords = FALSE; bNewLine = TRUE; - RETURN_TOKEN( REDUCE( (int) chr ), NULL ); + RETURN_TOKEN( REDUCE( (int) chr ) ); } } @@ -1184,7 +1184,7 @@ YY_DECL NEW_LINE_ACTION(); } - RETURN_TOKEN( REDUCE( (int) chr ), NULL ); + RETURN_TOKEN( REDUCE( (int) chr ) ); } } @@ -1265,7 +1265,7 @@ YY_DECL iRet = CUSTOM_ACTION( iRet ); if( iRet ) { - RETURN_TOKEN( REDUCE( iRet ), (char*) sToken ); + RETURN_TOKEN( REDUCE( iRet ) ); } else { @@ -1274,7 +1274,14 @@ YY_DECL } else { - RETURN_TOKEN( REDUCE( aKeys[ i - 1 ].iToken ), (char*) sToken ); + iRet = aKeys[ i - 1 ].iToken; + if( iRet > SUSPEND_WORDS ) + { + iRet -= SUSPEND_WORDS; + bIgnoreWords = TRUE; + } + + RETURN_TOKEN( REDUCE( iRet ) ); } } } @@ -1324,7 +1331,7 @@ YY_DECL iRet = CUSTOM_ACTION( iRet ); if( iRet ) { - RETURN_TOKEN( REDUCE( iRet ), (char*) sToken ); + RETURN_TOKEN( REDUCE( iRet ) ); } else { @@ -1333,7 +1340,14 @@ YY_DECL } else { - RETURN_TOKEN( REDUCE( aWords[ i - 1 ].iToken ), (char*) sToken ); + iRet = aWords[ i - 1 ].iToken; + if( iRet > SUSPEND_WORDS ) + { + iRet -= SUSPEND_WORDS; + bIgnoreWords = TRUE; + } + + RETURN_TOKEN( REDUCE( iRet ) ); } } } @@ -1344,7 +1358,7 @@ YY_DECL /* "Returns" the Token as iRet. */ ELEMENT_TOKEN( sToken ) - RETURN_TOKEN( REDUCE( iRet ), sToken ); + RETURN_TOKEN( REDUCE( iRet ) ); } } } diff --git a/harbour/source/macro/macro.slx b/harbour/source/macro/macro.slx index 25289c3f49..410c3c6aec 100644 --- a/harbour/source/macro/macro.slx +++ b/harbour/source/macro/macro.slx @@ -372,7 +372,7 @@ LANGUAGE_RULES_ARE { } #undef CUSTOM_ACTION - #define CUSTOM_ACTION(x) x = hb_lex_CustomAction(x, iWordLen, aiHold, &iHold, yylval_ptr, pMacro ) + #define CUSTOM_ACTION(x) x = hb_lex_CustomAction( x, aiHold, &iHold, yylval_ptr, pMacro ) long hb_lex_Hex2L( char* sHex ) { @@ -410,7 +410,7 @@ long hb_lex_Hex2L( char* sHex ) return lSum; } -int hb_lex_CustomAction( int x, int iWordLen, int aiHold[], int *ptr_iHold, YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro ) +int hb_lex_CustomAction( int x, int aiHold[], int *ptr_iHold, YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro ) { switch ( x ) {