20000514-12:20 GMT-8 Ron Pinkas <Ron@Profit-Master.com>

* source/compiler/harbour.y
    + Seperated the DECLARE... from Function, moved into a Declare, and Added Declare as type of Source.
    ! Added reset of hb_comp_iVarScope to DECLARE... to fix wrong "Statement not allowed outside of procedure or function"


   * source/compiler/hbgenerr.c
     * Modified : "3Duplicate Declaration of %s \'%s\'" to accept 1st parameter type of redeclaration ( Function, Class, Method ).

   * source/compiler/harbour.c
     * Modified calls to hb_compGenWarning() to use additional parameter of redclaration type.
This commit is contained in:
Ron Pinkas
2000-05-14 19:22:22 +00:00
parent 7943176b91
commit cd9e54dc06
5 changed files with 35 additions and 13 deletions

View File

@@ -1,3 +1,16 @@
20000514-12:20 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
* source/compiler/harbour.y
+ Seperated the DECLARE... from Function, moved into a Declare, and Added Declare as type of Source.
! Added reset of hb_comp_iVarScope to DECLARE... to fix wrong "Statement not allowed outside of procedure or function"
* source/compiler/hbgenerr.c
* Modified : "3Duplicate Declaration of %s \'%s\'" to accept 1st parameter type of redeclaration ( Function, Class, Method ).
* source/compiler/harbour.c
* Modified calls to hb_compGenWarning() to use additional parameter of redclaration type.
20000514-10:07 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
* source/compiler/harbour.l

View File

@@ -811,7 +811,7 @@ PCOMCLASS hb_compClassAdd( char * szClassName )
if ( ( pClass = hb_compClassFind( szClassName ) ) != NULL )
{
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_DUP_DECLARATION, szClassName, NULL );
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_DUP_DECLARATION, "Class", szClassName );
return pClass;
}
@@ -864,7 +864,7 @@ PCOMMETHOD hb_compMethodAdd( PCOMCLASS pClass, char * szMethodName )
if ( ( pMethod = hb_compMethodFind( pClass, szMethodName ) ) != NULL )
{
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_DUP_DECLARATION, szMethodName, NULL );
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_DUP_DECLARATION, "Method", szMethodName );
return pMethod;
}
@@ -914,7 +914,7 @@ PCOMDECLARED hb_compDeclaredAdd( char * szDeclaredName )
if ( ( pDeclared = hb_compDeclaredFind( szDeclaredName ) ) != NULL )
{
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_DUP_DECLARATION, szDeclaredName, NULL );
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_DUP_DECLARATION, "Function", szDeclaredName );
return pDeclared;
}

View File

@@ -244,10 +244,12 @@ Source : Crlf { hb_comp_EOL = FALSE; }
| FieldsDef { hb_comp_EOL = FALSE; }
| MemvarDef { hb_comp_EOL = FALSE; }
| Function { hb_comp_EOL = FALSE; }
| Declare { hb_comp_EOL = FALSE; }
| Statement { hb_comp_EOL = FALSE; }
| Line { hb_comp_EOL = FALSE; }
| Source Crlf { hb_comp_EOL = FALSE; }
| Source Function { hb_comp_EOL = FALSE; }
| Source Declare { hb_comp_EOL = FALSE; }
| Source Statement { hb_comp_EOL = FALSE; }
| Source VarDefs { hb_comp_EOL = FALSE; }
| Source FieldsDef { hb_comp_EOL = FALSE; }
@@ -262,12 +264,16 @@ Line : LINE NUM_INTEGER LITERAL Crlf
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 {}
| DECLARE_FUN IdentName { hb_compDeclaredAdd( $2 ); hb_comp_szDeclaredFun = $2; } DecParams AsType Crlf { if( hb_comp_pLastDeclared )
;
Declare : DECLARE_FUN IdentName { hb_compDeclaredAdd( $2 ); hb_comp_szDeclaredFun = $2; } DecParams AsType Crlf { if( hb_comp_pLastDeclared )
hb_comp_pLastDeclared->cType = hb_comp_cVarType;
hb_comp_szDeclaredFun = NULL;
hb_comp_cVarType = ' '; }
| DECLARE_CLASS IdentName { hb_comp_pLastClass = hb_compClassAdd( $2 ); } ClassInfo Crlf {}
;
hb_comp_cVarType = ' ';
hb_comp_iVarScope = VS_NONE;
}
| DECLARE_CLASS IdentName { hb_comp_pLastClass = hb_compClassAdd( $2 ); } ClassInfo Crlf { hb_comp_iVarScope = VS_NONE; }
;
ClassInfo : DecMethod
| ClassInfo DecMethod
@@ -1165,7 +1171,7 @@ DimIndex : '[' Expression { $$ = hb_compExprNewArgList( $2 ); }
;
FieldsDef : FIELD { hb_comp_iVarScope = VS_FIELD; } FieldList Crlf
FieldsDef : FIELD { hb_comp_iVarScope = VS_FIELD; } FieldList Crlf { hb_comp_cVarType = ' '; }
;
FieldList : IdentName AsType { $$=hb_compFieldsCount(); hb_compVariableAdd( $1, hb_comp_cVarType ); }
@@ -1173,7 +1179,7 @@ FieldList : IdentName AsType { $$=hb_compFieldsCount(); hb_compVa
| FieldList IN IdentName { hb_compFieldSetAlias( $3, $<iNumber>1 ); }
;
MemvarDef : MEMVAR { hb_comp_iVarScope = VS_MEMVAR; } MemvarList Crlf
MemvarDef : MEMVAR { hb_comp_iVarScope = VS_MEMVAR; } MemvarList Crlf { hb_comp_cVarType = ' '; }
;
MemvarList : IdentName AsType { hb_compVariableAdd( $1, hb_comp_cVarType ); }

View File

@@ -107,7 +107,7 @@ char * hb_comp_szWarnings[] =
"3Incompatible return type: \'%s\' expected: \'%s\'",
"3Invalid number of parameters: %s expected: %s",
"3Incompatible parameter # %s expected: \'%s\'",
"3Duplicate Declaration of Function %s",
"3Duplicate Declaration of %s \'%s\'",
"3Function \'%s\' conflicting with its declaration",
"3Variable \'%s\' used but never initialized",
"3Value of Variable \'%s\' never used",

View File

@@ -67,6 +67,9 @@ DECLARE CLASS MyClass ;
Has Data cMyData ;
Has Method FinalMethod
DECLARE CLASS MyClass ;
Has METHOD nMyFunc( nVal As Num ) As Num
FIELD a AS CHAR
FIELD b AS CHAR
@@ -89,9 +92,9 @@ PROCEDURE THEMAIN( optional )
PRIVATE TEST AS CHAR
DO Proc WITH
DO Optional WITH
DO Optional WITH Var1
DO Optional WITH 1
DO Optional WITH "something"
FOR Conter := Optional TO 10
? "For with End"