From 0fef17cf67a9e3bb96a087babdaf3d7f2d66dd2f Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Sat, 24 Mar 2001 10:28:28 +0000 Subject: [PATCH] 2001-03-24 02:20 UTC-0800 Ron Pinkas * source/compiler/simplex.c * Minor fix for VC++ - Removed 2 unused defines + Added #define MAX_RULES 1024 * source/compiler/harbour.slx * Changed // to /* */ * tests/keywords.prg * Corrected 3 warnings. --- harbour/ChangeLog | 12 +++++++++++ harbour/source/compiler/harbour.slx | 10 ++++++--- harbour/source/compiler/simplex.c | 33 +++++++++-------------------- harbour/tests/keywords.prg | 3 ++- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index c73123add7..284fdda053 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,15 @@ +2001-03-24 02:20 UTC-0800 Ron Pinkas + * source/compiler/simplex.c + * Minor fix for VC++ + - Removed 2 unused defines + + Added #define MAX_RULES 1024 + + * source/compiler/harbour.slx + * Changed // to /* */ + + * tests/keywords.prg + * Corrected 3 warnings. + 2001-03-23 00:55 UTC-0800 Brian Hays * contrib/rdd_ads/testmg.prg * fixed header diff --git a/harbour/source/compiler/harbour.slx b/harbour/source/compiler/harbour.slx index 0fa1a2ee5b..b62e820666 100644 --- a/harbour/source/compiler/harbour.slx +++ b/harbour/source/compiler/harbour.slx @@ -27,8 +27,10 @@ #define NUMERALS_PER_LINE 3000 -//#define SHOW_LEX_TOKENS -//#define DEBUG_LEX +/* +#define SHOW_LEX_TOKENS +#define DEBUG_LEX +*/ #ifdef DEBUG_LEX #undef DEBUG_INFO @@ -535,7 +537,9 @@ int hb_comp_SLX_InterceptAction( int iRet, char *sToken ) { if( iRet == '\n' || iRet == ';' ) printf( "***NEW LINE %i\n", hb_comp_iLine - 1 ); - else + else if( iRet == -1 ) + printf( "!!!\n" ); + else printf( " DELIMITER = \"%c\"\n", iRet ); } else diff --git a/harbour/source/compiler/simplex.c b/harbour/source/compiler/simplex.c index 47750d319f..6fb49d13ca 100644 --- a/harbour/source/compiler/simplex.c +++ b/harbour/source/compiler/simplex.c @@ -128,6 +128,7 @@ typedef struct _LEX_PAIR #define LEX_CUSTOM_ACTION -65 #define DONT_REDUCE 1024 #define YY_BUF_SIZE 16384 +#define MAX_RULES 1024 #define YY_INPUT( a, b, c ) @@ -142,8 +143,6 @@ typedef struct _LEX_PAIR #define LEX_CASE(x) #define STREAM_OPEN(x) #define STREAM_APPEND(x) sPair[ iPairLen++ ] = x -#define KEYWORD_ACTION() -#define WORD_ACTION() #include SLX_RULES @@ -221,7 +220,7 @@ typedef struct _TREE_NODE } TREE_NODE; /* support structure for Streams (Pairs). */ /* Indexing System. */ -static TREE_NODE aPairNodes[256], aSelfNodes[256], aKeyNodes[256], aWordNodes[256], aRuleNodes[1024]; +static TREE_NODE aPairNodes[256], aSelfNodes[256], aKeyNodes[256], aWordNodes[256], aRuleNodes[MAX_RULES]; static char acOmmit[256], acNewLine[256]; static int acReturn[256]; @@ -497,18 +496,6 @@ YY_DECL if( iSize == 0 ) { - /* - if( szLexBuffer == NULL ) - { - szLexBuffer = malloc( YY_BUF_SIZE ); - } - - if( yytext == NULL ) - { - yytext = malloc( YY_BUF_SIZE ); - } - */ - if( bStart ) { bStart = FALSE; @@ -894,10 +881,10 @@ int Reduce( int iToken ) DEBUG_INFO( printf( "Returning Dont Reduce %i\n", iLastToken ) ); return iLastToken; } - else if( iToken == 0 ) + else if( iToken <= 0 || iToken >= MAX_RULES ) { - DEBUG_INFO( printf( "Returning 0\n" ) ); - return 0; + DEBUG_INFO( printf( "Passing through (out of range): %i\n", iToken ) ); + return iToken; } iLastToken = iToken; @@ -1357,8 +1344,6 @@ void SimpLex_CheckWords( void ) bIgnoreWords = TRUE; - KEYWORD_ACTION() - iRet = aCheck[ iTentative ].iToken; if( iRet < LEX_CUSTOM_ACTION ) { @@ -1377,8 +1362,10 @@ void SimpLex_CheckWords( void ) void * yy_create_buffer( FILE * pFile, int iBufSize ) #endif { - HB_SYMBOL_UNUSED( pFile ); - HB_SYMBOL_UNUSED( iBufSize ); + /* Avoid warning of unused symbols. */ + (void) pFile; + (void) iBufSize; + iSize = 0; #ifdef __cplusplus @@ -1449,7 +1436,7 @@ static void GenTrees( void ) i++; } - while( i < 1024 ) + while( i < MAX_RULES ) { aRuleNodes[i].iMin = -1; aRuleNodes[i].iMax = -1; diff --git a/harbour/tests/keywords.prg b/harbour/tests/keywords.prg index 43d1ca8e24..8da263ad43 100644 --- a/harbour/tests/keywords.prg +++ b/harbour/tests/keywords.prg @@ -797,7 +797,7 @@ PRIVATE &using ENDDO BEGIN SEQUENCE - ? USIN + ? USING RECOVER USIN using ? using END @@ -850,6 +850,7 @@ RETURN static */ FUNCTION RETURN STAT return +LOCAL Self PRIVATE &return EVAL( return )