From c7e237273e75c645d3982c3a0654e03594a01f3f Mon Sep 17 00:00:00 2001 From: Ron Pinkas Date: Sun, 21 May 2000 21:19:51 +0000 Subject: [PATCH] 20000521-14:15 GMT-8 Ron Pinkas * 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. --- harbour/ChangeLog | 13 +++++++++++++ harbour/source/compiler/harbour.l | 2 ++ harbour/source/compiler/harbour.y | 23 +++++++++++++++-------- harbour/tests/testwarn.prg | 28 +++++++++++++++------------- 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0770c53d8b..c96b331351 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,16 @@ +20000521-14:15 GMT-8 Ron Pinkas + + * 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 * include/hbvmpub.h diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index 0c14bcc296..4e960ac5dc 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -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; } diff --git a/harbour/source/compiler/harbour.y b/harbour/source/compiler/harbour.y index 2cfcdf01f8..448dd9ec42 100644 --- a/harbour/source/compiler/harbour.y +++ b/harbour/source/compiler/harbour.y @@ -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 NUM_DOUBLE %type NUM_INTEGER %type NUM_LONG -%type FunScope AsType AsArray +%type FunScope %type Params ParamList %type IfBegin VarList ExtVarList %type 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 */ diff --git a/harbour/tests/testwarn.prg b/harbour/tests/testwarn.prg index 92214fc887..3cde6aea84 100644 --- a/harbour/tests/testwarn.prg +++ b/harbour/tests/testwarn.prg @@ -11,6 +11,8 @@ #TRANSLATE AS ARRAY OF CHARACTER => #TRANSLATE AS ARRAY OF STRING => + #TRANSLATE AS ARRAY OF CLASS => + #TRANSLATE AS ARRAY OF NUM => #TRANSLATE AS ARRAY OF NUMERIC => @@ -31,6 +33,8 @@ #TRANSLATE AS CHARACTER => #TRANSLATE AS STRING => + #TRANSLATE AS CLASS => + #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.