From e9fda3ebb9f49205f61167d5fa442588d488da77 Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Sat, 5 May 2001 00:12:14 +0000 Subject: [PATCH] 2001-05-04 17:10 UTC-0800 Ron Pinkas * contrib/dot/pp.prg * contrib/dot/rp_run.ch ! Few corrections to Pre Processor, and Interpreter. * include/hbclass.ch + Added support for METHOD implementations without requiring the CLASS Clause. + Added support for METHOD implementations without requiring the "()" if no parameters needed. --- harbour/ChangeLog | 9 + harbour/contrib/dot/pp.prg | 341 +++++++++++++++++++++++++++++++--- harbour/contrib/dot/rp_run.ch | 2 + harbour/include/hbclass.ch | 52 ++++-- 4 files changed, 357 insertions(+), 47 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index aff7b3e862..3b83f34b11 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,12 @@ +2001-05-04 17:10 UTC-0800 Ron Pinkas + * contrib/dot/pp.prg + * contrib/dot/rp_run.ch + ! Few corrections to Pre Processor, and Interpreter. + + * include/hbclass.ch + + Added support for METHOD implementations without requiring the CLASS Clause. + + Added support for METHOD implementations without requiring the "()" if no parameters needed. + 2001-05-03 17:40 UTC-0800 Ron Pinkas * source/pp/ppcore.c ! Corrected minor bug with test for valid string prefixs diff --git a/harbour/contrib/dot/pp.prg b/harbour/contrib/dot/pp.prg index 506028a2ca..4d3e064f89 100644 --- a/harbour/contrib/dot/pp.prg +++ b/harbour/contrib/dot/pp.prg @@ -267,6 +267,8 @@ PROCEDURE Main( sSource, p1, p2, p3, p4, p5, p6, p7, p8, p9 ) Alert( "Not using standard rules." ) ENDIF + CompileDefine( "__PP__" ) + #ifdef __HARBOUR__ //ProcessLine( "#DEFINE __HARBOUR__", 0, '' ) CompileDefine( "__HARBOUR__" ) @@ -631,7 +633,262 @@ PROCEDURE CompileLine( sPPed, nLine ) s_aProcedures[s_nProcId] := { sSymbol, {} } ELSE IF sBlock = "PP__" - // ??? Might need to have logic for flow control here too. + IF sBlock = "PP__FOR" + s_nFlowId++ + aSize( s_acFlowType, s_nFlowId ) + s_acFlowType[ s_nFlowId ] := "F" + + sBlock := SubStr( sBlock, 9 ) + sCounter := Left( sBlock, ( nAt := AT( ":=", sBlock ) ) - 1 ) + sBlock := SubStr( sBlock, nAt + 2 ) + sStart := Left( sBlock, ( nAt := At( "~TO~", sBlock ) ) - 1 ) + sBlock := SubStr( sBlock, nAt + 4 ) + sEnd := Left( sBlock, ( nAt := At( "~STEP~", sBlock ) ) - 1 ) + sStep := SubStr( sBlock, nAt + 6 ) + IF sStep == "" + sStep := "1" + ENDIF + + aAdd( s_aProcedures[ s_nProcId ][2], { 0, &( "{||" + sCounter + ":=" + sStart + "}" ), nLine } ) // Loop back + + sBlock := sCounter + "<=" + sEnd + + s_nCompLoop++ + aSize( s_aLoopJumps, s_nCompLoop ) + s_aLoopJumps[ s_nCompLoop ] := { Len( s_aProcedures[ s_nProcId ][2] ) + 1, {}, "F", &( "{||" + sCounter + ":=" + sCounter + "+" + sStep + "}" ) } // Address of line to later place conditional Jump instruction into. + + ELSEIF sBlock = "PP__NEXT" + + IF s_nCompLoop == 0 .OR. s_aLoopJumps[ s_nCompLoop ][3] != "F" + Alert( "NEXT does not match FOR" ) + ELSE + aAdd( s_aProcedures[ s_nProcId ][2], { 0, s_aLoopJumps[ s_nCompLoop ][4], nLine } ) // STEP + aAdd( s_aProcedures[ s_nProcId ][2], { s_aLoopJumps[ s_nCompLoop ][1] - 1, NIL, nLine } ) // Loop back + s_aProcedures[ s_nProcId ][2][ s_aLoopJumps[s_nCompLoop][1] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the previous conditional Jump Instruction + + nJumps := Len( s_aLoopJumps[s_nCompLoop][2] ) + FOR nJump := 1 TO nJumps + s_aProcedures[ s_nProcId ][2][ s_aLoopJumps[s_nCompLoop][2][nJump] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the unconditional Jump Instruction + NEXT + + s_nCompLoop-- + //aSize( s_aIfJumps, s_nCompIf ) + ENDIF + + BREAK + + ELSEIF sBlock = "PP__WHILE" + s_nFlowId++ + aSize( s_acFlowType, s_nFlowId ) + s_acFlowType[ s_nFlowId ] := "W" + + sBlock := SubStr( sBlock, 11 ) + s_nCompLoop++ + aSize( s_aLoopJumps, s_nCompLoop ) + s_aLoopJumps[ s_nCompLoop ] := { Len( s_aProcedures[ s_nProcId ][2] ) + 1, {}, "W" } // Address of line to later place conditional Jump instruction into. + + ELSEIF sBlock = "PP__LOOP" + + IF s_nCompLoop == 0 + Alert( "LOOP with no loop in sight!" ) + ELSE + IF s_aLoopJumps[ s_nCompLoop ][3] == "F" + aAdd( s_aProcedures[ s_nProcId ][2], { 0, s_aLoopJumps[ s_nCompLoop ][4], nLine } ) // STEP + ENDIF + + aAdd( s_aProcedures[ s_nProcId ][2], { s_aLoopJumps[ s_nCompLoop ][1] - 1, NIL, nLine } ) // Loop back + ENDIF + + BREAK + + ELSEIF sBlock = "PP__EXIT" + + sBlock := "" + IF s_nCompLoop == 0 + Alert( "EXIT with no loop in sight!" ) + ELSE + aAdd( s_aLoopJumps[ s_nCompLoop ][2], Len( s_aProcedures[ s_nProcId ][2] ) + 1 ) // Address of line to later place unconditional Jump instruction into. + ENDIF + + ELSEIF sBlock = "PP__ENDDO" + s_nFlowId-- + //aSize( s_acFlowType, s_nFlowId ) + + IF s_nCompLoop == 0 + Alert( "ENDDO does not match WHILE" ) + ELSE + aAdd( s_aProcedures[ s_nProcId ][2], { s_aLoopJumps[ s_nCompLoop ][1] - 1, NIL, nLine } ) // Loop back + s_aProcedures[ s_nProcId ][2][ s_aLoopJumps[s_nCompLoop][1] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the previous conditional Jump Instruction + + nJumps := Len( s_aLoopJumps[s_nCompLoop][2] ) + FOR nJump := 1 TO nJumps + s_aProcedures[ s_nProcId ][2][ s_aLoopJumps[s_nCompLoop][2][nJump] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the unconditional Jump Instruction + NEXT + + s_nCompLoop-- + //aSize( s_aIfJumps, s_nCompIf ) + ENDIF + + BREAK + + ELSEIF sBlock = "PP__DOCASE" + s_nFlowId++ + aSize( s_acFlowType, s_nFlowId ) + s_acFlowType[ s_nFlowId ] := "C" + + sBlock := "" //SubStr( sBlock, 12 ) + s_nCompIf++ + aSize( s_aIfJumps, s_nCompIf ) + s_aIfJumps[ s_nCompIf ] := { 0, {}, "C", .F. } // Address of line to later place conditional Jump instruction into. + + ELSEIF sBlock = "PP__CASE" + + IF s_nCompIf == 0 .OR. s_aIfJumps[ s_nCompIf ][3] != "C" .OR. s_aIfJumps[ s_nCompIf ][4] + sBlock := "" + Alert( "CASE does not match DO CASE" ) + ELSE + IF s_aIfJumps[ s_nCompIf ][1] > 0 + aAdd( s_aProcedures[ s_nProcId ][2], { 0, NIL, nLine } ) // Place holder for unconditional Jump to END. + aAdd( s_aIfJumps[ s_nCompIf ][2], Len( s_aProcedures[ s_nProcId ][2] ) ) // Address of line to later place unconditional Jump instruction into. + s_aProcedures[ s_nProcId ][2][ s_aIfJumps[s_nCompIf][1] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the previous conditional Jump Instruction + ENDIF + + sBlock := SubStr( sBlock, 10 ) + s_aIfJumps[ s_nCompIf ][1] := Len( s_aProcedures[ s_nProcId ][2] ) + 1 // Address of line to later place conditional Jump instruction into. + ENDIF + + ELSEIF sBlock = "PP__OTHERWISE" + + sBlock := "" + IF s_nCompIf == 0 .OR. s_aIfJumps[ s_nCompIf ][3] != "C" .OR. s_aIfJumps[ s_nCompIf ][4] + Alert( "OTHERWISE does not match DO CASE" ) + ELSE + s_aIfJumps[ s_nCompIf ][4] := .T. + IF s_aIfJumps[ s_nCompIf ][1] > 0 + s_aProcedures[ s_nProcId ][2][ s_aIfJumps[s_nCompIf][1] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) + 1 // Patching the previous conditional Jump Instruction + s_aIfJumps[ s_nCompIf ][1] := Len( s_aProcedures[ s_nProcId ][2] ) + 1 // Address of line to later place Jump instruction into. + ENDIF + ENDIF + + ELSEIF sBlock = "PP__ENDCASE" + s_nFlowId-- + //aSize( s_acFlowType, s_nFlowId ) + + IF s_nCompIf == 0 + Alert( "ENDCASE with no DO CASE in sight!" ) + ELSE + IF s_aIfJumps[ s_nCompIf ][1] > 0 + s_aProcedures[ s_nProcId ][2][ s_aIfJumps[s_nCompIf][1] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the previous conditional Jump Instruction + + nJumps := Len( s_aIfJumps[s_nCompIf][2] ) + FOR nJump := 1 TO nJumps + s_aProcedures[ s_nProcId ][2][ s_aIfJumps[s_nCompIf][2][nJump] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the unconditional Jump Instruction + NEXT + ENDIF + + s_nCompIf-- + //aSize( s_aIfJumps, s_nCompIf ) + ENDIF + + BREAK + + ELSEIF sBlock = "PP__IF" + s_nFlowId++ + aSize( s_acFlowType, s_nFlowId ) + s_acFlowType[ s_nFlowId ] := "I" + + sBlock := SubStr( sBlock, 8 ) + s_nCompIf++ + aSize( s_aIfJumps, s_nCompIf ) + s_aIfJumps[ s_nCompIf ] := { Len( s_aProcedures[ s_nProcId ][2] ) + 1, {}, "I", .F. } // Address of line to later place conditional Jump instruction into. + + ELSEIF sBlock = "PP__ELSEIF" + + IF s_nCompIf == 0 .OR. s_aIfJumps[ s_nCompIf ][3] != "I" .OR. s_aIfJumps[ s_nCompIf ][4] + Alert( "ELSEIF does not match IF" ) + BREAK + ELSE + IF s_aIfJumps[ s_nCompIf ][1] > 0 + aAdd( s_aProcedures[ s_nProcId ][2], { 0, NIL, nLine } ) // Place holder for unconditional Jump to END. + aAdd( s_aIfJumps[ s_nCompIf ][2], Len( s_aProcedures[ s_nProcId ][2] ) ) // Address of line to later place unconditional Jump instruction into. + s_aProcedures[ s_nProcId ][2][ s_aIfJumps[s_nCompIf][1] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the previous conditional Jump Instruction + ENDIF + + sBlock := SubStr( sBlock, 12 ) + s_aIfJumps[ s_nCompIf ][1] := Len( s_aProcedures[ s_nProcId ][2] ) + 1 // Address of line to later place Jump instruction into. + ENDIF + + ELSEIF sBlock = "PP__ELSE" + + sBlock := "" + IF s_nCompIf == 0 .OR. s_aIfJumps[ s_nCompIf ][3] != "I" .OR. s_aIfJumps[ s_nCompIf ][4] + Alert( "ELSE does not match IF" ) + BREAK + ELSE + s_aIfJumps[ s_nCompIf ][4] := .T. + s_aProcedures[ s_nProcId ][2][ s_aIfJumps[s_nCompIf][1] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) + 1 // Patching the prebvious conditional Jump Instruction + s_aIfJumps[ s_nCompIf ][1] := Len( s_aProcedures[ s_nProcId ][2] ) + 1 // Address of line to later place Jump instruction into. + ENDIF + + ELSEIF sBlock = "PP__ENDIF" + s_nFlowId-- + //aSize( s_acFlowType, s_nFlowId ) + + IF s_nCompIf == 0 + Alert( "ENDIF does not match IF" ) + ELSE + s_aProcedures[ s_nProcId ][2][ s_aIfJumps[s_nCompIf][1] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the previous conditional Jump Instruction + + nJumps := Len( s_aIfJumps[s_nCompIf][2] ) + FOR nJump := 1 TO nJumps + s_aProcedures[ s_nProcId ][2][ s_aIfJumps[s_nCompIf][2][nJump] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the unconditional Jump Instruction + NEXT + + s_nCompIf-- + //aSize( s_aIfJumps, s_nCompIf ) + ENDIF + + BREAK + + ELSEIF sBlock = "PP__END" + + IF s_nCompIf == 0 .AND. s_nCompLoop == 0 + Alert( "END with no Flow-Control structure in sight!" ) + ELSE + IF s_acFlowType[ s_nFlowId ] $ "FW" + IF s_acFlowType[ s_nFlowId ] $ "F" + aAdd( s_aProcedures[ s_nProcId ][2], { 0, s_aLoopJumps[ s_nCompLoop ][4], nLine } ) // STEP + ENDIF + aAdd( s_aProcedures[ s_nProcId ][2], { s_aLoopJumps[ s_nCompLoop ][1] - 1, NIL, nLine } ) // Loop back + + s_aProcedures[ s_nProcId ][2][ s_aLoopJumps[s_nCompLoop][1] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the previous conditional Jump Instruction + + nJumps := Len( s_aLoopJumps[s_nCompLoop][2] ) + FOR nJump := 1 TO nJumps + s_aProcedures[ s_nProcId ][2][ s_aLoopJumps[s_nCompLoop][2][nJump] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the unconditional Jump Instruction + NEXT + + s_nCompLoop-- + //aSize( s_aLoopJumps, s_nCompLoop ) + ELSE + s_aProcedures[ s_nProcId ][2][ s_aIfJumps[s_nCompIf][1] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the previous conditional Jump Instruction + + nJumps := Len( s_aIfJumps[s_nCompIf][2] ) + FOR nJump := 1 TO nJumps + s_aProcedures[ s_nProcId ][2][ s_aIfJumps[s_nCompIf][2][nJump] ][1] := Len( s_aProcedures[ s_nProcId ][2] ) // Patching the unconditional Jump Instruction + NEXT + + s_nCompIf-- + //aSize( s_aIfJumps, s_nCompIf ) + ENDIF + ENDIF + + s_nFlowId-- + //aSize( s_acFlowType, s_nFlowId ) + + BREAK + + ENDIF ELSE nAt := At( "=", sBlock ) IF nAt > 1 @@ -755,14 +1012,13 @@ PROCEDURE CompileLine( sPPed, nLine ) ELSEIF sBlock = "PP__EXIT" + sBlock := "" IF s_nCompLoop == 0 Alert( "EXIT with no loop in sight!" ) ELSE aAdd( s_aLoopJumps[ s_nCompLoop ][2], Len( s_aProcedures[ s_nProcId ][2] ) + 1 ) // Address of line to later place unconditional Jump instruction into. ENDIF - BREAK - ELSEIF sBlock = "PP__ENDDO" s_nFlowId-- //aSize( s_acFlowType, s_nFlowId ) @@ -789,7 +1045,7 @@ PROCEDURE CompileLine( sPPed, nLine ) aSize( s_acFlowType, s_nFlowId ) s_acFlowType[ s_nFlowId ] := "C" - sBlock := SubStr( sBlock, 12 ) + sBlock := ""//SubStr( sBlock, 12 ) s_nCompIf++ aSize( s_aIfJumps, s_nCompIf ) s_aIfJumps[ s_nCompIf ] := { 0, {}, "C", .F. } // Address of line to later place conditional Jump instruction into. @@ -812,6 +1068,7 @@ PROCEDURE CompileLine( sPPed, nLine ) ELSEIF sBlock = "PP__OTHERWISE" + sBlock := "" IF s_nCompIf == 0 .OR. s_aIfJumps[ s_nCompIf ][3] != "C" .OR. s_aIfJumps[ s_nCompIf ][4] Alert( "OTHERWISE does not match DO CASE" ) ELSE @@ -822,8 +1079,6 @@ PROCEDURE CompileLine( sPPed, nLine ) ENDIF ENDIF - BREAK - ELSEIF sBlock = "PP__ENDCASE" s_nFlowId-- //aSize( s_acFlowType, s_nFlowId ) @@ -1587,7 +1842,7 @@ FUNCTION ProcessFile( sSource ) LOCAL hSource, sBuffer, sLine, nPosition, sExt, cPrev LOCAL nLen, nMaxPos, cChar := '', nClose, nBase, nNext, nLine := 0 LOCAL sRight, nPath := 0, nPaths := Len( s_asPaths ), nNewLine, bBlanks := .T. - LOCAL sPath := "", cError + LOCAL sPath := "", cError, sPrevFile := s_sFile IF At( '.', sSource ) == 0 sSource += ".prg" @@ -1606,6 +1861,7 @@ FUNCTION ProcessFile( sSource ) IF hSource == -1 Alert( "ERROR! opening: [" + sSource + "] O/S Error: " + Str( FError(), 2 ) ) + s_sFile := sPrevFile RETURN .F. ENDIF @@ -1622,6 +1878,7 @@ FUNCTION ProcessFile( sSource ) ENDIF IF hPP == -1 Alert( "ERROR! creating '.pp$' file, O/S Error: " + Str( FError(), 2 ) ) + s_sFile := sPrevFile RETURN .F. ENDIF ELSE @@ -2053,6 +2310,8 @@ FUNCTION ProcessFile( sSource ) //? "Done: " + sSource //WAIT + s_sFile := sPrevFile + RETURN .T. //--------------------------------------------------------------// @@ -2277,6 +2536,7 @@ FUNCTION ProcessLine( sLine, nLine, sSource ) aAdd( aDefined, nRule ) ENDIF + nPosition := 0 WHILE ( nNewLineAt := At( ';', sLine ) ) > 0 nPendingLines++ IF nPendingLines > Len( aPendingLines ) @@ -2294,17 +2554,12 @@ FUNCTION ProcessLine( sLine, nLine, sSource ) IF ( sLine == '' ) EXIT ELSE - IF nPendingLines > 0 + IF nPosition > 0 nPendingLines++ IF nPendingLines > Len( aPendingLines ) aSize( aPendingLines, nPendingLines ) ENDIF - // *** Check this !!! - IF nPosition >= Len( aPendingLines ) - aSize( aPendingLines, nPosition + 1 ) - ENDIF - nPosition++ aIns( aPendingLines, nPosition ) @@ -2332,6 +2587,7 @@ FUNCTION ProcessLine( sLine, nLine, sSource ) aAdd( aTranslated, nRule ) ENDIF + nPosition := 0 WHILE ( nNewLineAt := At( ';', sLine ) ) > 0 nPendingLines++ IF nPendingLines > Len( aPendingLines ) @@ -2349,7 +2605,7 @@ FUNCTION ProcessLine( sLine, nLine, sSource ) IF ( sLine == '' ) EXIT ELSE - IF nPendingLines > 0 + IF nPosition > 0 nPendingLines++ IF nPendingLines > Len( aPendingLines ) aSize( aPendingLines, nPendingLines ) @@ -2400,7 +2656,7 @@ FUNCTION ProcessLine( sLine, nLine, sSource ) IF ( sLine == '' ) EXIT ELSE - IF nPendingLines > 0 + IF nPosition > 0 nPendingLines++ IF nPendingLines > Len( aPendingLines ) @@ -2429,13 +2685,15 @@ FUNCTION ProcessLine( sLine, nLine, sSource ) ENDDO - sOut := '' + sOut := "" nLines := Len( asOutLines ) //? nLines //WAIT FOR Counter := 1 TO nLines + //? Counter, asOutLines[Counter] + //WAIT sOut += asOutLines[Counter] IF Counter < nLines .OR. ! ( sPassed == '' ) sOut += ' ;' @@ -2530,8 +2788,9 @@ FUNCTION MatchRule( sKey, sLine, aRules, aResults, bStatement, bUpper ) ENDIF IF nMatches == 0 - IF bStatement .AND. ! ( sWorkLine == '' ) + IF bStatement .AND. ! Empty( NextToken( sWorkLine, .T. ) ) IF bDbgMatch + ? "*** Unmatched remainder: >", sWorkLine, "<" ? "Statement failed" WAIT ENDIF @@ -2875,11 +3134,11 @@ FUNCTION MatchRule( sKey, sLine, aRules, aResults, bStatement, bUpper ) ENDIF IF nMatch == nMatches - IF bStatement .AND. ! ( sWorkLine == '' ) + IF bStatement .AND. ! Empty( NextToken( sWorkLine, .T. ) ) bNext := .T. IF bDbgMatch - ? "Unmatched remainder: " + sWorkLine + ? "*** Unmatched remainder: >", sWorkLine, "<" ? "Statement failed, try next rule...'" WAIT ENDIF @@ -2953,10 +3212,11 @@ FUNCTION MatchRule( sKey, sLine, aRules, aResults, bStatement, bUpper ) /* Optional (last) didn't match - Rule can still match. */ IF nMatch == nMatches - IF bStatement .AND. ! ( sWorkLine == '' ) + IF bStatement .AND. ! Empty( NextToken( sWorkLine, .T. ) ) bNext := .T. IF bDbgMatch + ? "*** Unmatched remainder: >", sWorkLine, "<" ? "Statement failed, try next rule..." WAIT ENDIF @@ -3057,8 +3317,9 @@ FUNCTION MatchRule( sKey, sLine, aRules, aResults, bStatement, bUpper ) LOOP ELSE - IF bStatement .AND. ! ( sWorkLine == '' ) + IF bStatement .AND. ! Empty( NextToken( sWorkLine, .T. ) ) IF bDbgMatch + ? "*** Unmatched remainder: >", sWorkLine, "<" ? "Statement failed, try next rule..." WAIT ENDIF @@ -3166,6 +3427,10 @@ FUNCTION NextToken( sLine, bCheckRules ) //? bCheckRules, "Called from: " + ProcName(1) + " Line: " + Str( ProcLine(1) ) + " Scaning: " + sLine + IF Empty( sLine ) + RETURN NIL + ENDIF + IF sLeft2Chars == "==" sReturn := sLeft2Chars @@ -3389,6 +3654,7 @@ FUNCTION NextToken( sLine, bCheckRules ) ENDIF IF MatchRule( sReturn, @sLine, aTransRules, aTransResults, .F., .T. ) > 0 + //? '>', sLine, '<' RETURN NextToken( @sLine, .T. ) ENDIF @@ -3409,17 +3675,17 @@ FUNCTION NextExp( sLine, cType, aWords, aExp, sNextAnchor ) //? ProcName(1), ProcLine(1), cType, sLine + IF Empty( sLine ) + RETURN NIL + ENDIF + DO CASE CASE cType == '*' - IF sLine == '' - sExp := NIL - ELSE - sExp := sLine - ENDIF + sExp := sLine - sLine := '' - //? "EXP (*): " + sExp - RETURN sExp + sLine := '' + //? "EXP (*): " + sExp + RETURN sExp CASE cType == ':' sWorkLine := sLine @@ -3724,6 +3990,15 @@ FUNCTION NextExp( sLine, cType, aWords, aExp, sNextAnchor ) ENDIF IF Left( sLine, 1 ) == '.' + + /* Macro terminator without suffix */ + IF SubStr( sLine, 2, 1 ) == ' ' + sExp += '.' + sLine := SubStr( sLine, 2 ) + sExp += ExtractLeadingWS( @sLine ) + LOOP + ENDIF + // Get the macro terminator. IF cType == 'A' sExp += NextExp( @sLine, '<', NIL, NIL, sNextAnchor ) @@ -3847,7 +4122,7 @@ FUNCTION NextExp( sLine, cType, aWords, aExp, sNextAnchor ) LOOP - ELSEIF Left( sLine, 1 ) $ "+-*/:=^!>" ) ) ) + ELSEIF Left( sLine, 1 ) $ "+-*/:=^!>" ) ) ) sExp += Left( sLine, 1 ) @@ -4072,6 +4347,12 @@ FUNCTION PPOut( aResults, aMarkers ) WAIT ENDIF + /* TODO: Add space rule compiler if no anchor. + IF ( ! sResult == "" ) .AND. Right( sResult, 1 ) != ' ' + sResult += ' ' + ENDIF + */ + DO CASE /* <-x-> Ommit. */ CASE aResults[2][Counter] == 0 diff --git a/harbour/contrib/dot/rp_run.ch b/harbour/contrib/dot/rp_run.ch index 88a6364e41..b19749daf7 100644 --- a/harbour/contrib/dot/rp_run.ch +++ b/harbour/contrib/dot/rp_run.ch @@ -6,6 +6,8 @@ #TRANSLATE AS => #TRANSLATE AS ARRAY OF => #TRANSLATE AS CLASS => +#COMMAND _HB_CLASS <*x*> => Alert( "Declaration" ) +#COMMAND _HB_MEMBER <*x*> => #COMMAND MEMVAR <*x*> => diff --git a/harbour/include/hbclass.ch b/harbour/include/hbclass.ch index 63bf044685..25768a2ec8 100644 --- a/harbour/include/hbclass.ch +++ b/harbour/include/hbclass.ch @@ -65,17 +65,6 @@ * */ -DECLARE TClass ; - New( cName AS String, OPTIONAL SuperParams ) AS CLASS TClass ; - Create() AS Object; - Instance() AS Object ; - AddClsMthds( cName AS String, @MethodName(), nScope AS Numeric, n2 AS Numeric, n3 AS Numeric ); - AddMultiClsData( cType AS String, uVal, nScope AS Numeric, aDatas AS Array OF String ); - AddMultiData( cType AS String, uVal, nScope AS Numeric, aDatas AS Array OF String ); - AddMethod( cName AS String, @MethodName(), nScope AS Numeric ); - AddInLine( cName AS String, bBlock AS CodeBlock, nScope AS Numeric ); - AddVirtual( cName AS String ) - #ifndef HB_CLASS_CH_ #define HB_CLASS_CH_ @@ -108,6 +97,17 @@ DECLARE TClass ; /* #define HB_CLS_NOAUTOINIT */ /* Idem */ /* #define HB_CLS_ALLOWCLASS */ /* Work in progress, don't define it now */ +DECLARE TClass ; + New( cName AS String, OPTIONAL SuperParams ) AS CLASS TClass ; + Create() AS Object; + Instance() AS Object ; + AddClsMthds( cName AS String, @MethodName(), nScope AS Numeric, n2 AS Numeric, n3 AS Numeric ); + AddMultiClsData( cType AS String, uVal, nScope AS Numeric, aDatas AS Array OF String ); + AddMultiData( cType AS String, uVal, nScope AS Numeric, aDatas AS Array OF String ); + AddMethod( cName AS String, @MethodName(), nScope AS Numeric ); + AddInLine( cName AS String, bBlock AS CodeBlock, nScope AS Numeric ); + AddVirtual( cName AS String ) + #ifdef HB_CLS_NOTOBJECT #define __HB_CLS_PAR __CLS_PAR00 #else @@ -152,8 +152,10 @@ DECLARE TClass ; local MetaClass,nScope := HB_OO_CLSTP_EXPORTED ;; if s_oClass == NIL ;; s_oClass := IIF(<.metaClass.>, <(metaClass)> ,TClass():new( <(ClassName)> , __HB_CLS_PAR ( [ <(SuperClass1)> ] [ ,<(SuperClassN)> ] ) ) ) ;; - #undef _CLASS_NAME_ ;; + #undef _CLASS_NAME_ ;; #define _CLASS_NAME_ ;; + #undef _CLASS_MODE_ ;; + #define _CLASS_MODE_ _CLASS_DECLARATION_ ;; #translate CLSMETH () => @_() ; [ ; #translate Super( ) : => ::: ] ; [ ; #translate Super( ) : => ::: ] ; @@ -170,8 +172,10 @@ DECLARE TClass ; local MetaClass,nScope := HB_OO_CLSTP_EXPORTED ;; if s_oClass == NIL ;; s_oClass := IIF(<.metaClass.>,<(metaClass)>,TClass():new(<(ClassName)>, __HB_CLS_PAR ( [ <(SuperClass1)> ] [ ,<(SuperClassN)> ] ) ) ) ;; - #undef _CLASS_NAME_ ;; + #undef _CLASS_NAME_ ;; #define _CLASS_NAME_ ;; + #undef _CLASS_MODE_ ;; + #define _CLASS_MODE_ _CLASS_DECLARATION_ ;; #translate CLSMETH () => @() ; [ ; #translate Super( ) : => ::: ] ; [ ; #translate Super( ) : => ::: ] ; @@ -312,11 +316,11 @@ DECLARE TClass ; #xcommand CONSTRUCTOR New( [] ) => METHOD New( [] ) CONSTRUCTOR -#xcommand METHOD [ ] [ AS ] [ ] [] [