diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 03687843be..75b58234d0 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,18 @@ +20000210-13:20 GMT+1 Ryszard Glab + + *source/compiler/harbour.l + * fixed syntax for RETURN statement + + *source/compiler/hbgenerr.c + * changed warning level for 'unreachable code' - it will be generated + if /w2 option is used + + *source/genc.c + * fixed 'unused "wSym" variable' warning + + *tests/keywords.prg + * added some more code related to RETURN statement + 20000209-22:37 EST Paul Tucker * source/rtl/tone.c * change _Windows to _WINDOWS_ diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index ae33bd32ec..a22e1faf5e 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -106,7 +106,6 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou if( ! hb_comp_bStartProc ) pSym = pSym->pNext; /* starting procedure is always the first symbol */ - wSym = 0; /* symbols counter */ while( pSym ) { if( pSym->szName[ 0 ] == '(' ) @@ -148,7 +147,6 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou else fprintf( yyc, ", 0, 0 }" ); /* memvar */ } - ++wSym; if( pSym != hb_comp_symbols.pLast ) fprintf( yyc, ",\n" ); diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index c89bf7de95..229200633a 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -1084,7 +1084,7 @@ Separator {SpaceTab} yylval.string = hb_strupr( hb_strdup( yytext ) ); BEGIN RETURN_; } -{Separator}+[\[\"\'\.\!\&\{\;\:_a-zA-Z0-9] { /* an identifier after RETURN, macro, or .NOT., or string, or EOL */ +{Separator}+[\&_a-zA-Z0-9] { /* an identifier, numbers or macro */ unput( yytext[ yyleng-1 ] ); if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; if( hb_comp_iState == LOOKUP ) @@ -1099,7 +1099,23 @@ Separator {SpaceTab} return IDENTIFIER; } } -{Separator}*[\n\(] { /* '(' after RETURN or end of line */ +{Separator}*("+="|"-="|"->"|"++"|"--") { /* operators */ + if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; + hb_comp_iState =IDENTIFIER; + unput( yytext[ yyleng-1 ] ); + unput( yytext[ yyleng-2 ] ); + return IDENTIFIER; + } +{Separator}*("::") { /* SELF operator */ + if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; + hb_xfree( (void *) yylval.string ); + hb_comp_iState = RETURN; + unput( yytext[ yyleng-1 ] ); + unput( yytext[ yyleng-2 ] ); + return RETURN; + } +{Separator}*[\n\;\(\[\{\"\'\.\-\+\!] { + /* EOL or '()', '[]', '{}', '""', "''" , '.T.', '-', '+', '!' */ unput( yytext[ yyleng-1 ] ); if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; if( hb_comp_iState == LOOKUP ) @@ -1114,7 +1130,7 @@ Separator {SpaceTab} return IDENTIFIER; } } -{Separator}*. { /* any character after RETURN */ +{Separator}*. { /* any other character after RETURN */ unput( yytext[ yyleng-1 ] ); if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0; hb_comp_iState =IDENTIFIER; diff --git a/harbour/source/compiler/hbgenerr.c b/harbour/source/compiler/hbgenerr.c index 34577eb5bf..a857807e6a 100644 --- a/harbour/source/compiler/hbgenerr.c +++ b/harbour/source/compiler/hbgenerr.c @@ -106,7 +106,7 @@ char * hb_comp_szWarnings[] = "3Suspicious operand type: \'UnKnown\' expected: \'Logical\'", "3Suspicious operand type: \'UnKnown\' expected: \'Numeric\'", "0Meaningless use of expression: \'%s\'", - "1Unreachable code", + "2Unreachable code", "1Redundant \'ANNOUNCE %s\' statement ignored" }; diff --git a/harbour/tests/keywords.prg b/harbour/tests/keywords.prg index 4314b255f3..c592a50323 100644 --- a/harbour/tests/keywords.prg +++ b/harbour/tests/keywords.prg @@ -842,6 +842,23 @@ PRIVATE &return ENDIF return := return( return ) + return += return + return-=return + return->return ^= 3 + return:return() + + return::return + return ::return + return-1 + return -1 + return+2 + return +2 + return++ + return-- + ++return + --return + return!return + return &return DO WHILE return ++return