20000521-14:15 GMT-8 Ron Pinkas <Ron@Profit-Master.com>

* source/compiler/harbour.l
     + Added "as class"

   * source/compiler/harbour.y
     ! Fixed shift conflicts and reduce conflicts.
     * Modified rules for syntax "AS Object ClassName" to "As Class ClassName"

   * tests/testwarn.prg
     ! Corrected the #translate to reflect latest syntax
     ! Corrected syntax to use AS CLASS ClassName instead of AS OBJECT ClassName.
This commit is contained in:
Ron Pinkas
2000-05-21 21:19:51 +00:00
parent 8e184f78a4
commit c7e237273e
4 changed files with 45 additions and 21 deletions

View File

@@ -1,3 +1,16 @@
20000521-14:15 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
* source/compiler/harbour.l
+ Added "as class"
* source/compiler/harbour.y
! Fixed shift conflicts and reduce conflicts.
* Modified rules for syntax "AS Object ClassName" to "As Class ClassName"
* tests/testwarn.prg
! Corrected the #translate to reflect latest syntax
! Corrected syntax to use AS CLASS ClassName instead of AS OBJECT ClassName.
20000520-21:30 GMT-8 Ron Pinkas <Ron@Profit-Master.com>
* include/hbvmpub.h

View File

@@ -1438,6 +1438,7 @@ Separator {SpaceTab}
"as char" { return AS_CHARACTER; }
"as character" { return AS_CHARACTER; }
"as string" { return AS_CHARACTER; }
"as class" { return AS_CLASS; }
"as date" { return AS_DATE; }
"as logical" { return AS_LOGICAL; }
"as bool" { return AS_LOGICAL; }
@@ -1456,6 +1457,7 @@ Separator {SpaceTab}
"as array of char" { return AS_CHARACTER_ARRAY; }
"as array of character" { return AS_CHARACTER_ARRAY; }
"as array of string" { return AS_CHARACTER_ARRAY; }
"as array of class" { return AS_CLASS_ARRAY; }
"as array of date" { return AS_DATE_ARRAY; }
"as array of logical" { return AS_LOGICAL_ARRAY; }
"as array of bool" { return AS_LOGICAL_ARRAY; }

View File

@@ -161,8 +161,8 @@ char * hb_comp_szAnnounce = NULL; /* ANNOUNCEd procedure */
%token PLUSEQ MINUSEQ MULTEQ DIVEQ POWER EXPEQ MODEQ EXITLOOP
%token PRIVATE BEGINSEQ BREAK RECOVER RECOVERUSING DO WITH SELF LINE
%token MACROVAR MACROTEXT
%token AS_ARRAY AS_BLOCK AS_CHARACTER AS_DATE AS_LOGICAL AS_NUMERIC AS_OBJECT AS_VARIANT DECLARE OPTIONAL
%token AS_ARRAY_ARRAY AS_BLOCK_ARRAY AS_CHARACTER_ARRAY AS_DATE_ARRAY AS_LOGICAL_ARRAY AS_NUMERIC_ARRAY AS_OBJECT_ARRAY
%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
/*the lowest precedence*/
/*postincrement and postdecrement*/
@@ -194,7 +194,7 @@ char * hb_comp_szAnnounce = NULL; /* ANNOUNCEd procedure */
%type <valDouble> NUM_DOUBLE
%type <valInteger> NUM_INTEGER
%type <valLong> NUM_LONG
%type <iNumber> FunScope AsType AsArray
%type <iNumber> FunScope
%type <iNumber> Params ParamList
%type <iNumber> IfBegin VarList ExtVarList
%type <iNumber> FieldList
@@ -284,9 +284,16 @@ AsType : /* not specified */ { hb_comp_cVarType = ' '; }
| AS_ARRAY { hb_comp_cVarType = 'A'; }
| AS_BLOCK { hb_comp_cVarType = 'B'; }
| AS_OBJECT { hb_comp_cVarType = 'O'; }
| AS_OBJECT IdentName { hb_comp_cVarType = 'S'; hb_comp_szFromClass = $2 }
| AS_CLASS IdentName { hb_comp_cVarType = 'S'; hb_comp_szFromClass = $2 }
| AS_VARIANT { hb_comp_cVarType = ' '; }
| AsArray
| AS_NUMERIC_ARRAY { hb_comp_cVarType = 'n'; }
| AS_CHARACTER_ARRAY { hb_comp_cVarType = 'c'; }
| AS_DATE_ARRAY { hb_comp_cVarType = 'd'; }
| AS_LOGICAL_ARRAY { hb_comp_cVarType = 'l'; }
| AS_ARRAY_ARRAY { hb_comp_cVarType = 'a'; }
| AS_BLOCK_ARRAY { hb_comp_cVarType = 'b'; }
| AS_OBJECT_ARRAY { hb_comp_cVarType = 'o'; }
| AS_CLASS_ARRAY IdentName { hb_comp_cVarType = 's'; hb_comp_szFromClass = $2 }
;
AsArray : AS_ARRAY { hb_comp_cVarType = 'A'; }
@@ -297,8 +304,8 @@ AsArray : AS_ARRAY { hb_comp_cVarType = 'A'; }
| AS_ARRAY_ARRAY { hb_comp_cVarType = 'a'; }
| AS_BLOCK_ARRAY { hb_comp_cVarType = 'b'; }
| AS_OBJECT_ARRAY { hb_comp_cVarType = 'o'; }
| AS_OBJECT_ARRAY IdentName { hb_comp_cVarType = 's'; hb_comp_szFromClass = $2 }
;
| AS_CLASS_ARRAY IdentName { hb_comp_cVarType = 's'; hb_comp_szFromClass = $2 }
;
ParamList : IdentName AsType { hb_compVariableAdd( $1, hb_comp_cVarType ); $$ = 1; }
| ParamList ',' IdentName AsType { hb_compVariableAdd( $3, hb_comp_cVarType ); $$++; }
@@ -1155,7 +1162,7 @@ DecMethod : IdentName '(' { hb_comp_pLastMethod = hb_compMethodAdd( hb_comp_pLa
if( ! hb_comp_pLastMethod->pClass )
{
hb_compGenWarning( hb_comp_szWarnings, 'W', HB_COMP_WARN_CLASS_NOT_FOUND, hb_comp_szFromClass, hb_comp_pLastMethod->szName );
hb_comp_pLastMethod->cType = ( isupper( hb_comp_cVarType ) ? 'O' :'o' );
hb_comp_pLastMethod->cType = ( isupper( hb_comp_cVarType ) ? 'O' : 'o' );
}
/* Resetting */

View File

@@ -11,6 +11,8 @@
#TRANSLATE AS ARRAY OF CHARACTER =>
#TRANSLATE AS ARRAY OF STRING =>
#TRANSLATE AS ARRAY OF CLASS <ClassName> =>
#TRANSLATE AS ARRAY OF NUM =>
#TRANSLATE AS ARRAY OF NUMERIC =>
@@ -31,6 +33,8 @@
#TRANSLATE AS CHARACTER =>
#TRANSLATE AS STRING =>
#TRANSLATE AS CLASS <ClassName> =>
#TRANSLATE AS NUM =>
#TRANSLATE AS NUMERIC =>
@@ -52,8 +56,6 @@
#COMMAND DECLARE <*x*> =>
#endif
//DECLARE Function nMyFunc AS NUMERIC
DECLARE nMyFunc( cVar AS STRING, @nVar AS NUMERIC ) AS NUMERIC
DECLARE cOtherFunc( ) AS CHAR
@@ -74,14 +76,14 @@ DECLARE MyClass ;
nMyFunc( nVal As Num ) As Num ;
cMyData ;
aInstances AS Array Of Object MyClass ;
oNext( oInstance AS Object MyClass ) As Object MyClass
oNext( oInstance AS Class MyClass ) As Class MyClass
DECLARE OtherClass ;
nMyFunc( nVal As Num ) As Num ;
nMyFunc( nVal As Num ) As Num ;
cMyData ;
aInstances AS Array Of Object MyClass ;
oNext( oInstance AS Object OtherClass ) As Object MyClass
oNext( oInstance AS Class OtherClass ) As Class MyClass
FIELD a AS CHAR
FIELD b AS CHAR
@@ -92,11 +94,11 @@ STATIC lGlobal AS LOGICAL
PROCEDURE THEMAIN( optional )
STATIC lStatic := 0, oMyObj As Object WrongClass
STATIC lStatic := 0, oMyObj As Class WrongClass
LOCAL cVar AS CHAR := [declare function]
LOCAL a As Char, ob AS Object MyClass, c AS Char, d AS Object OtherClass
LOCAL a As Char, oB AS Class MyClass, c AS Char, oD AS Class OtherClass
FIELD b AS NUM
USE TEMP
@@ -111,13 +113,13 @@ PROCEDURE THEMAIN( optional )
a := b:nMyFunc(2,3)
a := b:nMyFunc(2)
a := b:oNext( 1 ):cMyData
a := b:oNext( c ):cMyData2
a := b:oNext( d ):cMyData
a := b:oNext( ob ):cMyData
a := oB:oNext( 1 ):cMyData
a := oB:oNext( c ):cMyData2
a := oB:oNext( d ):cMyData
a := oB:oNext( oD ):cMyData
a := b:aInstances[1]:oNext:cMyData2
a := b:aInstances[1]:oNext:cMyData
a := oB:aInstances[1]:oNext:cMyData2
a := oB:aInstances[1]:oNext:cMyData
DO Optional WITH Var1
DO Optional WITH 1
@@ -139,7 +141,7 @@ PROCEDURE THEMAIN( optional )
a := 'A'
b := 'a'
oB := 'a'
if lStatic
Var1 := .F.