From 4dac40f9e033a5a46ff354d881739e678ec6d10c Mon Sep 17 00:00:00 2001 From: Ryszard Glab Date: Sun, 26 Sep 1999 12:25:49 +0000 Subject: [PATCH] ChangeLog 19990926-14:10 GMT+2 --- harbour/ChangeLog | 10 ++++++++++ harbour/include/hberrors.h | 1 + harbour/source/compiler/harbour.y | 31 +++++++++++++++++++------------ 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e23cd33f1d..2329b7bfb3 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,13 @@ +19990926-14:10 GMT+2 Ryszard Glab + + *source/compiler/harbour.y + * fixed generation of invalid pcodes when nested IIF were used + * added an error message when any statements are used after + DO CASE and before the first CASE or the OTHERWISE + + *include/hberrors.h + * added ERR_MAYHEM_IN_CASE error code + 19990925-11:10 GMT+3 Alexander Kresin * source/hbpp/hbpp.c * Fixed some bugs, noted by Victor Szel, Andi Jahja and Antonio Linares diff --git a/harbour/include/hberrors.h b/harbour/include/hberrors.h index 946f4771b1..be2e822284 100644 --- a/harbour/include/hberrors.h +++ b/harbour/include/hberrors.h @@ -75,6 +75,7 @@ #define ERR_BADOPTION 34 #define ERR_BADPARAM 35 #define ERR_BADFILENAME 36 +#define ERR_MAYHEM_IN_CASE 37 #define WARN_AMBIGUOUS_VAR 1 #define WARN_MEMVAR_ASSUMED 2 diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index aad6886dd9..f7609f58f8 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -48,6 +48,7 @@ * 7) Change the pcode generated by ::cVar from Self:cVar to QSELF():cVar * 8) Support this syntax: _FIELD->c->mmezo := mt * 9) Support this syntax: nPtr := @Hello() + *10) Support for syntax: FOR [ array | object | alias_expr | other ] := value */ /* Compile using: bison -d -v harbour.y */ @@ -332,7 +333,8 @@ char * _szCErrors[] = "Can't create preprocessed output file: \'%s\'", "Bad command line option: \'%s\'", "Bad command line parameter: \'%s\'", - "Invalid filename: \'%s\'" + "Invalid filename: \'%s\'", + "Mayhem in CASE handler" }; /* Table with parse warnings */ @@ -637,19 +639,19 @@ Statement : ExecFlow Crlf {} | BREAK { GenBreak(); } Crlf { Do( 0 ); } | BREAK { GenBreak(); } Expression Crlf { Do( 1 ); } - | RETURN Crlf { - if( _wSeqCounter ) - { --iLine; - GenError( _szCErrors, 'E', ERR_EXIT_IN_SEQUENCE, "RETURN", NULL ); + | RETURN Crlf { + if( _wSeqCounter ) + { --iLine; + GenError( _szCErrors, 'E', ERR_EXIT_IN_SEQUENCE, "RETURN", NULL ); } GenPCode1( HB_P_ENDPROC ); } - | RETURN Expression Crlf { - if( _wSeqCounter ) + | RETURN Expression Crlf { + if( _wSeqCounter ) { --iLine; - GenError( _szCErrors, 'E', ERR_EXIT_IN_SEQUENCE, "RETURN", NULL ); + GenError( _szCErrors, 'E', ERR_EXIT_IN_SEQUENCE, "RETURN", NULL ); } - GenPCode1( HB_P_RETVALUE ); GenPCode1( HB_P_ENDPROC ); + GenPCode1( HB_P_RETVALUE ); GenPCode1( HB_P_ENDPROC ); } | PUBLIC { iVarScope = VS_PUBLIC; } VarList Crlf | PRIVATE { iVarScope = VS_PRIVATE; } VarList Crlf @@ -836,7 +838,7 @@ IndexList : Expression /*NOTE: If _bRValue is TRUE then the expression is on the right side of assignment * operator (or +=, -= ...) - in this case a variable is not pushed by - * a reference it is a part of DO WITH ... statement + * a reference if it is a part of DO WITH ... statement */ VarAssign : IDENTIFIER INASSIGN { _bRValue = TRUE; } Expression { PopId( $1 ); PushId( $1 ); } | IDENTIFIER PLUSEQ { PushId( $1 ); _bRValue = TRUE; } Expression { GenPCode1( HB_P_PLUS ); PopId( $1 ); PushId( $1 ); } @@ -1138,7 +1140,11 @@ EndCase : ENDCASE { --_wCaseCounter; } | END { --_wCaseCounter; } ; -DoCaseBegin : DOCASE { ++_wCaseCounter; } Crlf { Line(); } +DoCaseStart : DOCASE { ++_wCaseCounter; } Crlf { Line(); } + ; + +DoCaseBegin : DoCaseStart { } + | DoCaseStart Statements { --iLine; GenError( _szCErrors, 'E', ERR_MAYHEM_IN_CASE, NULL, NULL ); } ; Cases : CASE Expression Crlf { $$ = JumpFalse( 0 ); Line(); } CaseStmts { $$ = GenElseIf( 0, Jump( 0 ) ); JumpHere( $4 ); Line(); } @@ -2387,7 +2393,8 @@ void ExpListPush( void ) _pExpList->pNext = pExp; pExp->pPrev = _pExpList; /* save currently used pcode buffer */ - _pExpList->exprSize = functions.pLast->lPCodePos; + _pExpList->exprSize = functions.pLast->lPCodePos; + _pExpList->exprPCode = functions.pLast->pCode; } _pExpList = pExp;