From 249332890626d56ec180a2b22145f80f23951408 Mon Sep 17 00:00:00 2001 From: Ryszard Glab Date: Sat, 29 Jul 2000 13:48:20 +0000 Subject: [PATCH] ChangeLog 2000-07-29 15:55 UTC+0100 --- harbour/ChangeLog | 10 ++++ harbour/source/compiler/harbour.l | 89 ++++++++++++------------------- harbour/tests/Makefile | 1 + harbour/tests/testdecl.prg | 15 +++++- 4 files changed, 59 insertions(+), 56 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 464dae4865..bf49aefcd0 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,13 @@ +2000-07-29 15:55 UTC+0100 Ryszard Glab + + *source/compiler/harbour.l + * fixed to properly support 'DECLARE var' statement + + *tests/Makefile + *tests/testdecl.prg + * added testdecl.prg to Makefile + * added some more real life examples :) + 2000-07-29 09:45 UTC+0100 Ryszard Glab *include/hbcomp.h diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index 6737bd03a8..4fe6fe14bd 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -113,7 +113,7 @@ Separator {SpaceTab} %x FOR_ FUNCTION_ IIF_ IF_ IN_ INIT_ LOCAL_ LOOP_ %x MEMVAR_ PARAM_ PRIVATE_ PUBLIC_ STATIC_ RETURN_ RECOVER_ %x INVALIDNUM_ OTHERWISE_ PROCEDURE_ -%x DECLARE_ OPTIONAL_ +%x DECLARE_ DECLARE_ID_ OPTIONAL_ %% @@ -336,60 +336,39 @@ Separator {SpaceTab} ^{Separator}*"_procreq_"{Separator}*"(" { return PROCREQ; } -"decl"|"decla"|"declar"|"declare" { BEGIN DECLARE_; - yylval.string = hb_compIdentifierNew( hb_strupr( yytext ), TRUE ); - } -{Separator}+({Identifier}|{MacroVar}){Separator}*"[" { BEGIN 0; - - unput( '[' ); - yyleng--; - - /* Remove possible white space between the Identifier and the Index. */ - while( yytext[ yyleng - 1 ] < 48 ) - yyleng--; - - /* Pushback the Identifier */ - while( yytext[ yyleng - 1 ] > 32 ) - unput( yytext[ --yyleng ] ); - /* printf( "\nPushing: %c\n", yytext[ --yyleng ] ); */ - - - yytext[ yyleng ] = 0; - - if( hb_comp_iState == LOOKUP ) - { /* it is first item in the line */ - hb_comp_iState = PRIVATE; - return PRIVATE; - } - else - { /* there is another item in line already */ - hb_comp_iState = IDENTIFIER; - return IDENTIFIER; - } - } -{Separator}+[_a-zA-Z\&] { /* an Identifier after DECLARE */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - - if( hb_comp_iState == LOOKUP ) - { /* it is first item in the line */ - hb_comp_iState = DECLARE; - return DECLARE; - } - else - { /* there is another item in line already */ - hb_comp_iState = IDENTIFIER; - return IDENTIFIER; - } - } -{Separator}*[^a-zA-Z] { /* any character (not identifier) after DECLARE */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - - hb_comp_iState = IDENTIFIER; - return IDENTIFIER; - } - +"decl"|"decla"|"declar"|"declare" { + BEGIN DECLARE_; + yylval.string = hb_compIdentifierNew( hb_strupr( yytext ), TRUE ); +} +{Separator}+[_a-zA-Z] { /* an Identifier after DECLARE */ + unput( yytext[ yyleng-1 ] ); + BEGIN DECLARE_ID_; +} +{Separator}+[\&] { /* a macro after DECLARE */ + BEGIN 0; + unput( yytext[ yyleng-1 ] ); + hb_comp_iState = PRIVATE; + return PRIVATE; +} +. { /* any other character after DECLARE */ + BEGIN 0; + unput( yytext[ yyleng-1 ] ); + hb_comp_iState = IDENTIFIER; + return IDENTIFIER; +} + +({Identifier}|{MacroTxt}){Separator}*[\n\,\[\:\;] { /* variable declaration */ + BEGIN 0; + yyless(0); + hb_comp_iState = PRIVATE; + return PRIVATE; +} +. { + BEGIN 0; + unput( yytext[ yyleng-1 ] ); + hb_comp_iState = DECLARE; + return DECLARE; +} %{ /* ************************************************************************ */ %} diff --git a/harbour/tests/Makefile b/harbour/tests/Makefile index 5993c142fb..0a6aea0e3c 100644 --- a/harbour/tests/Makefile +++ b/harbour/tests/Makefile @@ -117,6 +117,7 @@ PRG_SOURCES=\ testcdx.prg \ testcgi.prg \ testdbf.prg \ + testdecl.prg \ testerro.prg \ testfor.prg \ testinc.prg \ diff --git a/harbour/tests/testdecl.prg b/harbour/tests/testdecl.prg index 1b98faa6cd..1fb142a35c 100644 --- a/harbour/tests/testdecl.prg +++ b/harbour/tests/testdecl.prg @@ -1,4 +1,7 @@ -#INCLUDE "HBCLASS.CH" +// Test for DECLARE statement +// $Id$ +// +#include "hbclass.ch" #TRANSLATE AS NEW => AS CLASS := ():New() @@ -8,11 +11,21 @@ DECLARE MyClass cVar AS CHAR Function Main() MEMVAR Var1, Var2, aVar + MEMVAR Var3, aVar5, aVar8, Var7 LOCAL MyObj AS NEW MyClass DECLARE Var1 DECLARE Var2 := 2 DECLARE aVar[2] + DECLARE Var3, Var4, aVar5[1] + DECLARE Var6, Var7:=7, aVar8[8] + DECLARE &var3 + DECLARE &Var3. + DECLARE &Var3. ; DECLARE &Var3.&Var3 + DECLARE &Var3.var3 + DECLARE Var3&Var3 + DECLARE Var3&Var3. + DECLARE Var3&Var3&Var3 M->Var1 := nMyFun() ? M->Var1