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"
This commit is contained in:
Ron Pinkas
2000-05-15 01:59:21 +00:00
parent cd9e54dc06
commit 998c3e4c84
4 changed files with 44 additions and 33 deletions

View File

@@ -1,10 +1,15 @@
20000514-18:57 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
* source/compiler/harbour.y
! Corrected '@' to be accepted on any var in a Function Declaration.
! Simplified rules of Function Declaration Parameter list.
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 ).

View File

@@ -491,7 +491,7 @@ void hb_compVariableAdd( char * szVarName, BYTE cValueType )
if ( hb_comp_iWarnings < 3 )
return;
//printf( "\nAdding parameter: %s Type: %c\n", szVarName, cValueType );
printf( "\nAdding parameter: %s Type: %c\n", szVarName, cValueType );
hb_comp_pLastMethod->iParamCount++;
@@ -556,7 +556,10 @@ void hb_compVariableAdd( char * szVarName, BYTE cValueType )
pVar->pClass = hb_compClassFind( hb_comp_szClass );
if( ! pVar->pClass )
{
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szClass, szVarName );
pVar->cType = 'O';
}
}
if ( hb_comp_iVarScope & VS_PARAMETER )
@@ -804,7 +807,7 @@ PCOMCLASS hb_compClassAdd( char * szClassName )
{
PCOMCLASS pClass;
//printf( "\nDeclaring Class: %s\n", szClassName );
printf( "\nDeclaring Class: %s\n", szClassName );
if ( hb_comp_iWarnings < 3 )
return NULL;
@@ -857,7 +860,7 @@ PCOMMETHOD hb_compMethodAdd( PCOMCLASS pClass, char * szMethodName )
{
PCOMMETHOD pMethod;
//printf( "\nDeclaring Method: %s of Class: %s\n", szMethodName, pClass->szName );
printf( "\nDeclaring Method: %s of Class: %s\n", szMethodName, pClass->szName );
if ( hb_comp_iWarnings < 3 )
return NULL;
@@ -912,6 +915,8 @@ PCOMDECLARED hb_compDeclaredAdd( char * szDeclaredName )
if ( hb_comp_iWarnings < 3 )
return NULL;
printf( "\nDeclaring Function: %s\n", szDeclaredName, NULL );
if ( ( pDeclared = hb_compDeclaredFind( szDeclaredName ) ) != NULL )
{
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_DUP_DECLARATION, "Function", szDeclaredName );

View File

@@ -196,7 +196,7 @@ char * hb_comp_szAnnounce = NULL; /* ANNOUNCEd procedure */
%type <valInteger> NUM_INTEGER
%type <valLong> NUM_LONG
%type <iNumber> FunScope AsType AsArray
%type <iNumber> Params ParamList DecParams DecList FormalList OptList Optional
%type <iNumber> Params ParamList
%type <iNumber> IfBegin VarList ExtVarList
%type <iNumber> FieldList
%type <lNumber> WhileBegin
@@ -244,12 +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; }
| Declaration { 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 Declaration { hb_comp_EOL = FALSE; }
| Source Statement { hb_comp_EOL = FALSE; }
| Source VarDefs { hb_comp_EOL = FALSE; }
| Source FieldsDef { hb_comp_EOL = FALSE; }
@@ -266,7 +266,7 @@ Function : FunScope FUNCTION IdentName { hb_comp_cVarType = ' '; hb_compFunct
| FunScope PROCEDURE IdentName { hb_comp_cVarType = ' '; hb_compFunctionAdd( $3, ( HB_SYMBOLSCOPE ) $1, FUN_PROCEDURE ); } Params Crlf {}
;
Declare : DECLARE_FUN IdentName { hb_compDeclaredAdd( $2 ); hb_comp_szDeclaredFun = $2; } DecParams AsType Crlf { if( hb_comp_pLastDeclared )
Declaration: 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 = ' ';
@@ -304,26 +304,25 @@ Params : { $$ = 0; }
| '(' { hb_comp_iVarScope = VS_PARAMETER; } ParamList ')' { $$ = $3; }
;
DecParams : { $$ = 0; }
| '(' DecList ')' { $$ = $2; }
DecParams : {}
| '(' DecList ')'
;
DecList : { $$ = 0; }
DecList : {}
| FormalList
| FormalList OptList
;
FormalList : IdentName AsType { hb_compVariableAdd( $1, hb_comp_cVarType ); $$ = 1; }
| '@' IdentName AsType { hb_compVariableAdd( $2, hb_comp_cVarType + VT_OFFSET_BYREF ); $$ = 2; }
| FormalList ',' IdentName AsType { hb_compVariableAdd( $3, hb_comp_cVarType ); $$++; }
FormalList : IdentName AsType { hb_compVariableAdd( $1, hb_comp_cVarType ); }
| '@' IdentName AsType { hb_compVariableAdd( $2, hb_comp_cVarType + VT_OFFSET_BYREF ); }
| FormalList ',' IdentName AsType { hb_compVariableAdd( $3, hb_comp_cVarType ); }
| FormalList ',' '@' IdentName AsType { hb_compVariableAdd( $4, hb_comp_cVarType ); }
;
OptList : Optional
| OptList Optional
;
Optional : ',' OPTIONAL IdentName AsType { hb_compVariableAdd( $3, hb_comp_cVarType + VT_OFFSET_OPTIONAL ); $$ = 3; }
| ',' OPTIONAL '@' IdentName AsType { hb_compVariableAdd( $4, hb_comp_cVarType + VT_OFFSET_OPTIONAL + VT_OFFSET_BYREF ); $$ = 4; }
OptList : ',' OPTIONAL IdentName AsType { hb_compVariableAdd( $3, hb_comp_cVarType + VT_OFFSET_OPTIONAL ); }
| ',' OPTIONAL '@' IdentName AsType { hb_compVariableAdd( $4, hb_comp_cVarType + VT_OFFSET_OPTIONAL + VT_OFFSET_BYREF ); }
| OptList ',' OPTIONAL IdentName AsType { hb_compVariableAdd( $4, hb_comp_cVarType + VT_OFFSET_OPTIONAL ); }
| OptList ',' OPTIONAL '@' IdentName AsType { hb_compVariableAdd( $5, hb_comp_cVarType + VT_OFFSET_OPTIONAL + VT_OFFSET_BYREF ); }
;
AsType : /* not specified */ { hb_comp_cVarType = ' '; }

View File

@@ -49,26 +49,28 @@
#COMMAND DECLARE FUNCTION <*x*> =>
#endif
DECLARE FUNCTION nMyFunc( cVar AS STRING, nVar AS NUMERIC ) AS NUMERIC
//DECLARE Function nMyFunc AS NUMERIC
DECLARE FUNCTION cOtherFunc( @cVar as char, optional nVar as num, optional other as variant ) AS CHAR
DECLARE Function nMyFunc( cVar AS STRING, @nVar AS NUMERIC ) AS NUMERIC
DECLARE FUNCTION cOtherFunc( ) AS CHAR
DECLARE Function cOtherFunc( @cVar as char, optional nVar as num, optional other as variant ) AS CHAR
DECLARE FUNCTION seconds() AS NUM
DECLARE Function cOtherFunc( ) AS CHAR
DECLARE FUNCTION int( n AS NUMERIC ) AS NUMERIC
DECLARE Function seconds() AS NUM
DECLARE FUNCTION TEST AS NUMERIC
DECLARE Function int( n AS NUMERIC ) AS NUMERIC
DECLARE CLASS MyClass ;
Has METHOD nMyFunc( nVal As Num ) As Num ;
Has METHOD nMyFunc( nVal As Num ) As Num ;
Has Data cMyData ;
Has Method FinalMethod
DECLARE Function TEST AS NUMERIC
DECLARE CLASS MyClass ;
Has METHOD nMyFunc( nVal As Num ) As Num
DECLARE Class MyClass ;
Has Method nMyFunc( nVal As Num ) As Num ;
Has Method nMyFunc( nVal As Num ) As Num ;
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