ChangeLog 2000-07-29 15:55 UTC+0100

This commit is contained in:
Ryszard Glab
2000-07-29 13:48:20 +00:00
parent 7b75b62b6e
commit 2493328906
4 changed files with 59 additions and 56 deletions

View File

@@ -1,3 +1,13 @@
2000-07-29 15:55 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
*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 <rglab@imid.med.pl>
*include/hbcomp.h

View File

@@ -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 );
}
<DECLARE_>{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;
}
}
<DECLARE_>{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;
}
}
<DECLARE_>{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 );
}
<DECLARE_>{Separator}+[_a-zA-Z] { /* an Identifier after DECLARE */
unput( yytext[ yyleng-1 ] );
BEGIN DECLARE_ID_;
}
<DECLARE_>{Separator}+[\&] { /* a macro after DECLARE */
BEGIN 0;
unput( yytext[ yyleng-1 ] );
hb_comp_iState = PRIVATE;
return PRIVATE;
}
<DECLARE_>. { /* any other character after DECLARE */
BEGIN 0;
unput( yytext[ yyleng-1 ] );
hb_comp_iState = IDENTIFIER;
return IDENTIFIER;
}
<DECLARE_ID_>({Identifier}|{MacroTxt}){Separator}*[\n\,\[\:\;] { /* variable declaration */
BEGIN 0;
yyless(0);
hb_comp_iState = PRIVATE;
return PRIVATE;
}
<DECLARE_ID_>. {
BEGIN 0;
unput( yytext[ yyleng-1 ] );
hb_comp_iState = DECLARE;
return DECLARE;
}
%{
/* ************************************************************************ */
%}

View File

@@ -117,6 +117,7 @@ PRG_SOURCES=\
testcdx.prg \
testcgi.prg \
testdbf.prg \
testdecl.prg \
testerro.prg \
testfor.prg \
testinc.prg \

View File

@@ -1,4 +1,7 @@
#INCLUDE "HBCLASS.CH"
// Test for DECLARE statement
// $Id$
//
#include "hbclass.ch"
#TRANSLATE AS NEW <ClassName> => AS CLASS <ClassName> := <ClassName>():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