diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a1fb75690e..e127701c3b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,15 @@ +19990621-13:27 Alexander Kresin + updated: + * source\hbpp\hbpp.c + * source\hbpp\buildgcc.bat + * source\hbpp\makefile.b16 + * source\hbpp\makefile.b32 + * source\compiler\harbour.l + Now keywords.prg compiles Ok. + Updated makefiles for standalone version of preprocessor. + From harbour.l removed all stuff related to early implementation of + preprocessor functionality. + 19990621-11:50 CET Victor Szel * source/compiler/harbour.y Some old PCODE name changed to new in diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index 55df93d2da..f8c9466927 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -38,19 +38,6 @@ extern int PreProcess( FILE*, FILE*, char *); int yy_lex_input( char *, int ); #define YY_INPUT( buf, result, max_size ) result = yy_lex_input( buf, max_size ); -typedef struct -{ - char * szDefine; - char * szValue; - void * pKeys; - void * pNext; -} _DEFINE, * PDEFINE; - -PDEFINE LastDef( PDEFINE pDef ); /* searches for the latest #define */ -void Define( char * szDefine ); /* add a new #define symbol */ -void DefineKey( char * szKey ); /* add a new key to a #define expression */ -PDEFINE FindDef( char * szText ); /* finds a #define */ - /* variables defined in harbour.y */ extern int _iQuiet; extern int _iRestrictSymbolLength; @@ -60,7 +47,6 @@ extern WORD _wIfCounter; extern WORD _wWhileCounter; extern WORD _wCaseCounter; -PDEFINE pDefs = 0; /* support for #defines */ int iLine = 0; long lNumber = 0; @@ -109,24 +95,16 @@ Array {Identifier}[ \t]*"[" ExpArray ")"[ \t]*"[" SubArray "]"[ \t]*"[" -Comment1 "/*"([^\*]|[\*][^\/])*"*/" -Comment2 [\/][\/].* -Comment ({Comment1}|{Comment2}) -Separator {SpaceTab}|{Comment} +Separator {SpaceTab} -%x COMMENT3 DEFINE DEFINE_PARAMS DEFINE_EXPR -%x IFDEF IFNDEF STRING1 STRING2 STRING3 +%x DEFINE STRING1 STRING2 STRING3 %x NEXT_ BREAK_ CASE_ DO_ WHILE_ WITH_ END_ EXIT_ EXTERNAL_ FIELD_ -%x FOR_ FUNCTION_ IIF_ IF_ IN_ INCLUDE_ INIT_ LOCAL_ LOOP_ +%x FOR_ FUNCTION_ IIF_ IF_ IN_ INIT_ LOCAL_ LOOP_ %x LINECONT_ %s INDEX %% -("//".*)|("&&".*) ; - -^{SpaceTab}*(\*|"NOTE").* ; -\n{SpaceTab}*(\*|"NOTE").* ++iLine; if( ! _iQuiet ) printf( "\rline: %i", iLine ); "&"("'"|\"|\[) { printf( "\nSyntax error : '%s'\n", yytext ); exit(1); } @@ -217,56 +195,7 @@ Separator {SpaceTab}|{Comment} return yytext[ 0 ]; } -"/*" BEGIN COMMENT3; -"*"["*"]*"/" { if( i_INDEX_STATE ) - { - BEGIN INDEX; - /*printf( "\nRESUMING INDEX STATE\n" );*/ - } - else - BEGIN 0; - } - -[^"*/"\n]* ; -"*" ; -[\/\"]+ ; -\n ++iLine; if( ! _iQuiet ) printf( "\rline: %i", iLine ); - -"#"{SpaceTab}*"define" BEGIN DEFINE; -{Identifier}/{SpaceTab}+ Define( yytext ); -{Identifier}/{SpaceTab}*\n Define( yytext ); BEGIN 0; -{SpaceTab} ; -{Identifier} LastDef( pDefs )->szValue = yy_strdup( yytext ); BEGIN 0; -{PseudoFunc} LastDef( pDefs )->szValue = yy_strdup( yytext ); BEGIN 0; --?{Number} LastDef( pDefs )->szValue = yy_strdup( yytext ); BEGIN 0; -{HexNumber} LastDef( pDefs )->szValue = yy_strdup( yytext ); BEGIN 0; -"/*".*"*/" ; -{Number}{SpaceTab}*[\(] yyerror( "Syntax error in #define" ); - -{Identifier}{SpaceTab}*[\(] Define( yytext ); BEGIN DEFINE_PARAMS; -{SpaceTab} ; -{Identifier} DefineKey( yytext ); -[\,] ; -[\)] BEGIN DEFINE_EXPR; -.*/\n LastDef( pDefs )->szValue = yy_strdup( yytext ); BEGIN 0; - -"#"{SpaceTab}*"ifdef" BEGIN IFDEF; -{Identifier} if( FindDef( yytext ) ) BEGIN 0; -"#"{SpaceTab}*"else"\n ++iLine; BEGIN 0; -"#"{SpaceTab}*"endif"\n ++iLine; BEGIN 0; -\n ++iLine; -[\(\),\"\/\.]* ; -"#"{SpaceTab}*"ifdef" ; -"#"{SpaceTab}*"else" BEGIN 0; -"#"{SpaceTab}*"else" BEGIN IFDEF; -"#"{SpaceTab}*"endif" BEGIN 0; - -"#"{SpaceTab}*"ifndef" BEGIN IFNDEF; -{Identifier} if( ! FindDef( yytext ) ) BEGIN 0; -"#endif"\n ++iLine; BEGIN 0; -\n ++iLine; - -"#"{SpaceTab}*"line".* ; +{Identifier}/{SpaceTab}*\n BEGIN 0; {SpaceTab} ; @@ -766,28 +695,6 @@ Separator {SpaceTab}|{Comment} %{ /* ************************************************************************ */ %} -"include" BEGIN INCLUDE_; -{Separator}+\" { /* only "" are allowed for filename */ - yy_lex_count_lf(); - if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; - unput( yytext[ yyleng-1 ] ); - _iState =INCLUDE; - return INCLUDE; - } -{Separator}*;.*\n yy_lex_count_lf(); /* ignore any text after ';' */ -{Separator}*[^\"] { - yy_lex_count_lf(); - if( yytext[ yyleng-1 ] == '\n' ) - --iLine; - if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; - unput( yytext[ yyleng-1 ] ); - yylval.string =yy_strdup( "INCLUDE" ); - _iState =IDENTIFIER; - return IDENTIFIER; - } -%{ -/* ************************************************************************ */ -%} "init" BEGIN INIT_; {Separator}+[fFpP] { /* FUNCTION or PROCEDURE after INIT */ yy_lex_count_lf(); @@ -1193,28 +1100,15 @@ Separator {SpaceTab}|{Comment} yytext[yyleng] = 0; { - PDEFINE pDef = FindDef( yytext ); - char * szText; int c; - - if( pDef ) + if( _iRestrictSymbolLength && strlen( yytext ) > 10 ) { - c = strlen( pDef->szValue ) - 1; - szText = pDef->szValue; - while( c >= 0 ) - unput( szText[ c-- ] ); - } - else - { - if( _iRestrictSymbolLength && strlen( yytext ) > 10 ) - { - yytext[ 10 ] = 0; - yyleng = 10; - } - yylval.string = yy_strupr( yy_strdup( yytext ) ); - /*printf( "\nIdentifier = '%s'\n", yy_strupr( yy_strdup( yytext ) ) );*/ - _iState = IDENTIFIER; - return IDENTIFIER; + yytext[ 10 ] = 0; + yyleng = 10; } + yylval.string = yy_strupr( yy_strdup( yytext ) ); + /*printf( "\nIdentifier = '%s'\n", yy_strupr( yy_strdup( yytext ) ) );*/ + _iState = IDENTIFIER; + return IDENTIFIER; } } @@ -1258,26 +1152,13 @@ Separator {SpaceTab}|{Comment} } {Identifier} { - PDEFINE pDef = FindDef( yytext ); - char * szText; int c; - _iState = IDENTIFIER; - if( pDef ) + if( _iRestrictSymbolLength && strlen( yytext ) > 10 ) { - c = strlen( pDef->szValue ) - 1; - szText = pDef->szValue; - while( c >= 0 ) - unput( szText[ c-- ] ); - } - else - { - if( _iRestrictSymbolLength && strlen( yytext ) > 10 ) - { - yytext[ 10 ] = 0; - yyleng = 10; - } - yylval.string = yy_strupr( yy_strdup( yytext ) ); - return IDENTIFIER; + yytext[ 10 ] = 0; + yyleng = 10; } + yylval.string = yy_strupr( yy_strdup( yytext ) ); + return IDENTIFIER; } %{ @@ -1289,110 +1170,6 @@ Separator {SpaceTab}|{Comment} %% -PDEFINE LastDef( PDEFINE pDef ) -{ - while( pDef->pNext ) - pDef = (PDEFINE) pDef->pNext; - - return pDef; -} - -void Define( char * szDefine ) -{ - PDEFINE pDef = ( PDEFINE ) malloc( sizeof( _DEFINE ) ); - - if( ! pDefs ) - pDefs = pDef; - else - LastDef( pDefs )->pNext = pDef; - - pDef->szDefine = yy_strdup( szDefine ); - pDef->szValue = 0; - pDef->pKeys = 0; - pDef->pNext = 0; -} - -void DefineKey( char * szKey ) -{ - PDEFINE pDef = ( PDEFINE ) malloc( sizeof( _DEFINE ) ); - PDEFINE pLast = LastDef( pDefs ); - - if( pLast->pKeys ) - LastDef( (PDEFINE) pLast->pKeys )->pNext = pDef; - else - pLast->pKeys = pDef; - - pDef->szDefine = yy_strdup( szKey ); - pDef->szValue = 0; - pDef->pKeys = 0; - pDef->pNext = 0; -} - -PDEFINE FindDef( char * szText ) -{ - PDEFINE pDef = pDefs; - - while( pDef ) - { - if( ! strcmp( pDef->szDefine, szText ) ) - return pDef; - else - { - if( pDef->pNext ) - pDef = (PDEFINE) pDef->pNext; - else - return 0; - } - } - return 0; -} - -/* Removed for preprocessor needs -void AddDefine( char * szId, char * szValue ) -{ - PDEFINE pDefine = FindDef( szId ); - - if( pDefine ) - { - if( pDefine->szValue ) - { - free( pDefine->szValue ); - pDefine->szValue = 0; - } - if( szValue ) - pDefine->szValue = yy_strdup( szValue ); - } - else - { - Define( szId ); - if( szValue ) - LastDef( pDefs )->szValue = yy_strdup( szValue ); - } -} - -int yy_lex_input( char *buffer, int iBufferSize ) -{ - int i; - static int _ineedLF = 1; - - if( ((i = fread(buffer, 1, iBufferSize, yyin)) == 0) && ferror(yyin) ) - YY_FATAL_ERROR( "input in flex scanner failed" ); - - if( i == iBufferSize ) - _ineedLF =( buffer[i-1] != '\n' ); - - else if( i < iBufferSize && _ineedLF ) - { - if( i == 0 ) - buffer[ i++ ] ='\n'; - else if( buffer[ i-1 ] != '\n' ) - buffer[ i++ ] ='\n'; - _ineedLF =0; - } - return i; -} -*/ - int yy_lex_input( char *buffer, int iBufferSize ) { if( 0 && iBufferSize ) printf( "/* compiler warning */" ); diff --git a/harbour/source/hbpp/buildgcc.bat b/harbour/source/hbpp/buildgcc.bat index 2dd9b42545..afc8432036 100644 --- a/harbour/source/hbpp/buildgcc.bat +++ b/harbour/source/hbpp/buildgcc.bat @@ -1 +1 @@ -gcc hbppmain.c hbpp.c table.c -o hbpp.exe +gcc hbppmain.c hbpp.c table.c -I..\..\include -o hbpp.exe diff --git a/harbour/source/hbpp/hbpp.c b/harbour/source/hbpp/hbpp.c index 84da5fbe05..d9bd3caae0 100644 --- a/harbour/source/hbpp/hbpp.c +++ b/harbour/source/hbpp/hbpp.c @@ -528,7 +528,8 @@ int ParseExpression( char* sLine, char* sOutLine ) { *sToken = *ptri++; *(sToken+1) = '\0'; lenToken = 1; } SKIPTABSPACES( ptri ); - if ( *ptri != ':' && *ptri != '=' && (ndef=ComSearch(sToken,0)) >= 0 ) + if ( *ptri != ':' && *ptri != '=' && (isname(*ptri) || *(ptri+1) != '=') + && (ndef=ComSearch(sToken,0)) >= 0 ) { ptro = sOutLine; i = WorkCommand( sToken, ptri, ptro, ndef ); diff --git a/harbour/source/hbpp/makefile.b16 b/harbour/source/hbpp/makefile.b16 index 68fe5eb275..9c27c5f36a 100644 --- a/harbour/source/hbpp/makefile.b16 +++ b/harbour/source/hbpp/makefile.b16 @@ -3,7 +3,7 @@ PROJECT: hbpp.exe hbpp.exe : hbpp.c harb.c table.c - bcc -ml hbppmain.c hbpp.c table.c + bcc -ml -I..\..\include hbppmain.c hbpp.c table.c del hbppmain.obj del hbpp.obj del table.obj \ No newline at end of file diff --git a/harbour/source/hbpp/makefile.b32 b/harbour/source/hbpp/makefile.b32 index cb6e43973d..62d6a58971 100644 --- a/harbour/source/hbpp/makefile.b32 +++ b/harbour/source/hbpp/makefile.b32 @@ -3,7 +3,7 @@ PROJECT: hbpp.exe hbpp.exe : hbppmain.c hbpp.c table.c - bcc32 -O2 hbppmain.c hbpp.c table.c + bcc32 -O2 -ehbpp.exe -I..\..\include hbppmain.c hbpp.c table.c del hbppmain.obj del hbpp.obj del table.obj \ No newline at end of file