From 99ca708ef6d8d6f49b5e4ff6099b7e095c939785 Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Fri, 16 Jun 2000 04:07:14 +0000 Subject: [PATCH] 2000-06-15 20:56 UTC-0800 Ron Pinkas * source/compiler/harbour.l * source/compiler/harbour.y + Added support for _ProcReq_() - compile time function used to implement SET FORMAT TO and SET PROCEDURE TO. Clipper implementation doesn't allow a run time function with this name, Harbour will only intercept it as compile time function, if used at BOL. As compile time function it only accepts a single "Literal", or "Literal + Literal". * source/compiler/hbgenerr.c * source/pp/ppcomp.c ! Fixed line numbering. Warnnings and Errors, should now report correct line numbers. --- harbour/ChangeLog | 12 ++++++++++++ harbour/source/compiler/harbour.l | 2 ++ harbour/source/compiler/harbour.y | 12 +++++++++++- harbour/source/compiler/hbgenerr.c | 4 ++-- harbour/source/pp/ppcomp.c | 14 +++++++++----- 5 files changed, 36 insertions(+), 8 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 1b8ba94b48..fdadf5b1fc 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,15 @@ +2000-06-15 20:56 UTC-0800 Ron Pinkas + * source/compiler/harbour.l + * source/compiler/harbour.y + + Added support for _ProcReq_() - compile time function used to implement SET FORMAT TO and + SET PROCEDURE TO. Clipper implementation doesn't allow a run time function with this name, Harbour + will only intercept it as compile time function, if used at BOL. + As compile time function it only accepts a single "Literal", or "Literal + Literal". + + * source/compiler/hbgenerr.c + * source/pp/ppcomp.c + ! Fixed line numbering. Warnnings and Errors, should now report correct line numbers. + 2000-06-15 15:30 UTC-0400 David G. Holm + tests/mousetst.prg diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index 9670d84a46..ed0ffc24b5 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -355,6 +355,8 @@ Separator {SpaceTab} /* ************************************************************************ */ %} +^{Separator}*"_procreq_"{Separator}*"(" { return PROCREQ; } + "decl"("are"|"ar"|"a")? { BEGIN DECLARE_; yylval.string = hb_strupr( hb_strdup( yytext ) ); } diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 2809a65b48..3b032be1aa 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -162,6 +162,7 @@ char * hb_comp_szAnnounce = NULL; /* ANNOUNCEd procedure */ %token MACROVAR MACROTEXT %token AS_ARRAY AS_BLOCK AS_CHARACTER AS_CLASS AS_DATE AS_LOGICAL AS_NUMERIC AS_OBJECT AS_VARIANT DECLARE OPTIONAL %token AS_ARRAY_ARRAY AS_BLOCK_ARRAY AS_CHARACTER_ARRAY AS_CLASS_ARRAY AS_DATE_ARRAY AS_LOGICAL_ARRAY AS_NUMERIC_ARRAY AS_OBJECT_ARRAY +%token PROCREQ /*the lowest precedence*/ /*postincrement and postdecrement*/ @@ -189,7 +190,7 @@ char * hb_comp_szAnnounce = NULL; /* ANNOUNCEd procedure */ %right '\n' ';' ',' /*the highest precedence*/ -%type IdentName IDENTIFIER LITERAL SendId MACROVAR MACROTEXT +%type IdentName IDENTIFIER LITERAL SendId MACROVAR MACROTEXT CompTimeStr %type NUM_DOUBLE %type NUM_INTEGER %type NUM_LONG @@ -245,6 +246,7 @@ Source : Crlf { hb_comp_EOL = FALSE; } | Function { hb_comp_EOL = FALSE; } | Statement { hb_comp_EOL = FALSE; } | Line { hb_comp_EOL = FALSE; } + | ProcReq { hb_comp_EOL = FALSE; } | Source Crlf { hb_comp_EOL = FALSE; } | Source Function { hb_comp_EOL = FALSE; } | Source Statement { hb_comp_EOL = FALSE; } @@ -253,6 +255,7 @@ Source : Crlf { hb_comp_EOL = FALSE; } | Source MemvarDef { hb_comp_EOL = FALSE; } | Source Declaration { hb_comp_EOL = FALSE; } | Source Line { hb_comp_EOL = FALSE; } + | Source ProcReq { hb_comp_EOL = FALSE; } | Source error Crlf { hb_comp_EOL = FALSE; yyclearin; } ; @@ -260,6 +263,13 @@ Line : LINE NUM_INTEGER LITERAL Crlf | LINE NUM_INTEGER LITERAL '@' LITERAL Crlf /* Xbase++ style */ ; +ProcReq : PROCREQ CompTimeStr ')' Crlf { hb_compAutoOpenAdd( $2 ); } + ; + +CompTimeStr: LITERAL + | LITERAL '+' LITERAL { char szFileName[ _POSIX_PATH_MAX ]; sprintf( szFileName, "%s%s", $1, $3 ); $$ = szFileName; } + ; + Function : FunScope FUNCTION IdentName { hb_comp_cVarType = ' '; hb_compFunctionAdd( $3, ( HB_SYMBOLSCOPE ) $1, 0 ); } Params Crlf {} | FunScope PROCEDURE IdentName { hb_comp_cVarType = ' '; hb_compFunctionAdd( $3, ( HB_SYMBOLSCOPE ) $1, FUN_PROCEDURE ); } Params Crlf {} ; diff --git a/harbour/source/compiler/hbgenerr.c b/harbour/source/compiler/hbgenerr.c index 100d4d7eb2..20e382d958 100644 --- a/harbour/source/compiler/hbgenerr.c +++ b/harbour/source/compiler/hbgenerr.c @@ -127,7 +127,7 @@ void hb_compGenError( char * szErrors[], char cPrefix, int iError, char * szErro if( hb_comp_EOL ) --iLine; if( hb_comp_files.pLast != NULL && hb_comp_files.pLast->szFileName != NULL ) - printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, iLine + hb_pp_nEmptyStrings ); + printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, hb_comp_files.pLast->iLine - 1 ); printf( "Error %c%04i ", cPrefix, iError ); printf( szErrors[ iError - 1 ], szError1, szError2 ); printf( "\n" ); @@ -150,7 +150,7 @@ void hb_compGenWarning( char * szWarnings[], char cPrefix, int iWarning, char * if( ( szText[ 0 ] - '0' ) <= hb_comp_iWarnings ) { if( hb_comp_files.pLast != NULL && hb_comp_files.pLast->szFileName != NULL ) - printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, iLine + hb_pp_nEmptyStrings ); + printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, hb_comp_files.pLast->iLine - 1 ); printf( "Warning %c%04i ", cPrefix, iWarning ); printf( szText + 1, szWarning1, szWarning2 ); printf( "\n" ); diff --git a/harbour/source/pp/ppcomp.c b/harbour/source/pp/ppcomp.c index 039a52b075..12f03fa7a3 100644 --- a/harbour/source/pp/ppcomp.c +++ b/harbour/source/pp/ppcomp.c @@ -93,7 +93,11 @@ int hb_pp_Internal( FILE * handl_o, char * sOut ) if( !lContinue ) { - if( *s_szLine != '\0' ) + if( *s_szLine == '\0' ) + { + hb_pp_nEmptyStrings++; + } + else { ptr = s_szLine; @@ -120,9 +124,8 @@ int hb_pp_Internal( FILE * handl_o, char * sOut ) } else { + hb_pp_nEmptyStrings++; *s_szLine = '\0'; - /*hb_pp_nEmptyStrings++;*/ - hb_comp_files.pLast->iLine++; } } else @@ -155,8 +158,6 @@ int hb_pp_Internal( FILE * handl_o, char * sOut ) } } } - else - hb_pp_nEmptyStrings++; break; } @@ -221,6 +222,9 @@ int hb_pp_Internal( FILE * handl_o, char * sOut ) *( sOut + lens++ ) = '\n'; *( sOut + lens ) = '\0'; + hb_comp_files.pLast->iLine += hb_pp_nEmptyStrings; + hb_pp_nEmptyStrings = 0; + if( handl_o ) hb_pp_WrStr( handl_o, sOut );