19990615-23:20 PST Ron Pinkas <Ron@Profit-Master.com>

* compiler.h
    added member cType to struct VAR
  * harbour.y
    added { iVarScope = VS_MEMVAR; } to PRIVATE, PUBLIC, and PARAMETERS statements to avoid errounous error:
    "declaration follows executable statement"
    added: AliasExp '=' Expression Crlf { /* TODO */ GenPCode1( _POP ); }
    to statement definition to avoid parse error on M->Var = "Value" statments.
    the _POP will balance the stack but the assignment is not implemented yet.
    changed --iLine to iLine in yyerror() to correct errornous line numbers in parase error messages.
    added check for null pointer on few references to pVars->szName

  * hbpp.c, hbpmain.c, hbpint.c
    prefixed messages in all printf() with \n and postfixed with \n until modification to GenWarning() and GenError()
This commit is contained in:
Ron Pinkas
1999-06-18 04:50:48 +00:00
parent 3a349f1c2d
commit 55c69a0a18
7 changed files with 101 additions and 84 deletions

View File

@@ -1,3 +1,18 @@
19990615-23:20 PST Ron Pinkas <Ron@Profit-Master.com>
* compiler.h
added member cType to struct VAR
* harbour.y
added { iVarScope = VS_MEMVAR; } to PRIVATE, PUBLIC, and PARAMETERS statements to avoid errounous error:
"declaration follows executable statement"
added: AliasExp '=' Expression Crlf { /* TODO */ GenPCode1( _POP ); }
to statement definition to avoid parse error on M->Var = "Value" statments.
the _POP will balance the stack but the assignment is not implemented yet.
changed --iLine to iLine in yyerror() to correct errornous line numbers in parase error messages.
added check for null pointer on few references to pVars->szName
* hbpp.c, hbpmain.c, hbpint.c
prefixed messages in all printf() with \n and postfixed with \n until modification to GenWarning() and GenError()
19990617-18:55 EDT David G. Holm <dholm@jsd-llc.com>
* include/set.h
- SET DEBUG is numeric, not logical
@@ -45,70 +60,70 @@
Thu Jun 17 11:34:35 1999 Gonzalo A. Diethelm <Gonzalo.Diethelm@jda.cl>
* source/Makefile:
* source/compiler/Makefile:
* source/hbpp/Makefile:
* source/Makefile:
* source/compiler/Makefile:
* source/hbpp/Makefile:
Now the hbpp preprocessor is compiled before the compiler, and it
generates a library. No stand-alone preprocessor is generated. The
compiler links against the new preprocessor library.
* include/Makefile:
* tests/working/Makefile:
* include/Makefile:
* tests/working/Makefile:
Updated the list of files.
* include/compiler.h:
* include/ctoharb.h:
* include/dates.h:
* include/error.api:
* include/errorapi.h:
* include/extend.h:
* include/filesys.h:
* include/gtapi.h:
* include/hberrors.h:
* include/hbsetup.h:
* include/init.h:
* include/itemapi.h:
* include/pcode.h:
* include/set.h:
* include/types.h:
* include/version.h:
* source/compiler/fixflex.c:
* source/compiler/genobj32.c:
* source/compiler/harbour.l:
* source/compiler/harbour.y:
* source/hbpp/harb.h:
* source/hbpp/hbpp.c:
* source/rtl/asort.prg:
* source/rtl/descend.c:
* source/rtl/error.prg:
* source/rtl/errorsys.prg:
* source/rtl/hardcr.c:
* source/rtl/itemapi.c:
* source/rtl/mtran.c:
* source/rtl/objfunc.prg:
* source/rtl/tclass.prg:
* source/tools/asciisum.c:
* source/tools/ascpos.c:
* source/tools/atdiff.c:
* source/tools/chareven.c:
* source/tools/charmix.c:
* source/tools/charodd.c:
* source/tools/chrcount.c:
* source/tools/chrfirst.c:
* source/tools/chrtotal.c:
* source/tools/debug.c:
* source/tools/hb_f.c:
* source/tools/strasint.c:
* source/tools/strcount.c:
* source/tools/strcspn.c:
* source/tools/strdiff.c:
* source/tools/strexpan.c:
* source/tools/stringp.prg:
* source/tools/strleft.c:
* source/tools/strpbrk.c:
* source/tools/strright.c:
* source/vm/hvm.c:
* source/vm/initsymb.c:
* include/compiler.h:
* include/ctoharb.h:
* include/dates.h:
* include/error.api:
* include/errorapi.h:
* include/extend.h:
* include/filesys.h:
* include/gtapi.h:
* include/hberrors.h:
* include/hbsetup.h:
* include/init.h:
* include/itemapi.h:
* include/pcode.h:
* include/set.h:
* include/types.h:
* include/version.h:
* source/compiler/fixflex.c:
* source/compiler/genobj32.c:
* source/compiler/harbour.l:
* source/compiler/harbour.y:
* source/hbpp/harb.h:
* source/hbpp/hbpp.c:
* source/rtl/asort.prg:
* source/rtl/descend.c:
* source/rtl/error.prg:
* source/rtl/errorsys.prg:
* source/rtl/hardcr.c:
* source/rtl/itemapi.c:
* source/rtl/mtran.c:
* source/rtl/objfunc.prg:
* source/rtl/tclass.prg:
* source/tools/asciisum.c:
* source/tools/ascpos.c:
* source/tools/atdiff.c:
* source/tools/chareven.c:
* source/tools/charmix.c:
* source/tools/charodd.c:
* source/tools/chrcount.c:
* source/tools/chrfirst.c:
* source/tools/chrtotal.c:
* source/tools/debug.c:
* source/tools/hb_f.c:
* source/tools/strasint.c:
* source/tools/strcount.c:
* source/tools/strcspn.c:
* source/tools/strdiff.c:
* source/tools/strexpan.c:
* source/tools/stringp.prg:
* source/tools/strleft.c:
* source/tools/strpbrk.c:
* source/tools/strright.c:
* source/vm/hvm.c:
* source/vm/initsymb.c:
Made sure all *.{h,c,ch,api,prg,l,y} files under include/ and
source/ have an RCS Id keyword.
Got rid of the RCS Log keyword on several files; this keyword

View File

@@ -11,8 +11,9 @@ typedef struct _VAR /* locals, static, public variables support */
{
char *szName; /* variable name */
char *szAlias; /* variable alias namespace */
struct _VAR * pNext; /* pointer to next defined variable */
int iUsed; /* number of times used */
char cType; /* future optional strong typing */
struct _VAR * pNext; /* pointer to next defined variable */
} VAR, * PVAR;
typedef struct __FUNC /* functions definition support */

View File

@@ -425,7 +425,7 @@ PATHNAMES *_pIncludePath = NULL;
%token INC DEC ALIAS DOCASE CASE OTHERWISE ENDCASE ENDDO MEMVAR
%token WHILE EXIT LOOP END FOR NEXT TO STEP LE GE FIELD IN PARAMETERS
%token PLUSEQ MINUSEQ MULTEQ DIVEQ POWER EXPEQ MODEQ EXITLOOP
%token PRIVATE BEGINSEQ BREAK RECOVER USING DO WITH SELF
%token PRIVATE BEGINSEQ BREAK RECOVER USING DO WITH SELF MEMVAR
/*the lowest precedence*/
/*postincrement and postdecrement*/
@@ -527,6 +527,7 @@ Statement : ExecFlow Crlf {}
| VarAssign Crlf { GenPCode1( _POP ); }
| IDENTIFIER '=' Expression Crlf { PopId( $1 ); }
| AliasExp '=' Expression Crlf { /* TODO */ GenPCode1( _POP ); }
| VarId ArrayIndex '=' Expression Crlf { GenPCode1( _ARRAYPUT ); GenPCode1( _POP ); }
| FunArrayCall '=' Expression Crlf { GenPCode1( _ARRAYPUT ); GenPCode1( _POP ); }
| IdSend IDENTIFIER '=' { Message( SetData( $2 ) ); } Expression Crlf { Function( 1 ); }
@@ -537,9 +538,9 @@ Statement : ExecFlow Crlf {}
| BREAK Expression Crlf
| RETURN Crlf { GenReturn( Jump( 0 ) ); }
| RETURN Expression Crlf { GenPCode1( _RETVALUE ); GenReturn( Jump ( 0 ) ); }
| PUBLIC VarList Crlf
| PRIVATE VarList Crlf
| PARAMETERS IdentList Crlf
| PUBLIC { iVarScope = VS_MEMVAR; } VarList Crlf
| PRIVATE { iVarScope = VS_MEMVAR; } VarList Crlf
| PARAMETERS { iVarScope = VS_MEMVAR; } IdentList Crlf
| EXITLOOP Crlf { LoopExit(); }
| LOOP Crlf { LoopLoop(); }
| DoProc Crlf
@@ -976,7 +977,7 @@ Crlf : '\n'
void yyerror( char * s )
{
printf( "\n%s at line %i\n", s, --iLine );
printf( "\n%s at line %i\n", s, iLine );
exit( 1 );
}
@@ -1594,7 +1595,7 @@ void AddVar( char * szVarName )
pVar = ( PVAR ) OurMalloc( sizeof( VAR ) );
pVar->szName = szVarName;
pVar->szAlias = NULL;
/* pVar->cType = 'U'; */
pVar->cType = 'U';
pVar->iUsed = 0;
pVar->pNext = NULL;
@@ -2631,7 +2632,7 @@ WORD GetVarPos( PVAR pVars, char * szVarName ) /* returns the order + 1 of a var
while( pVars )
{
if( ! strcmp( pVars->szName, szVarName ) )
if( pVars->szName && ! strcmp( pVars->szName, szVarName ) )
{
if( _iWarnings )
pVars->iUsed = 1;
@@ -2702,7 +2703,7 @@ int GetLocalVarPos( char * szVarName ) /* returns the order + 1 of a variable if
pVar = (PVAR) OurMalloc( sizeof(VAR) );
pVar->szName = szVarName;
/* pVar->cType = 'U'; */
pVar->cType = 'U';
pVar->iUsed = 0;
pVar->pNext = NULL;
iVar = 1; /* first variable */
@@ -3190,7 +3191,7 @@ void FixReturns( void ) /* fixes all last defined function returns jumps offsets
pVar = functions.pLast->pLocals;
while ( pVar )
{
if( pVar->szName && ! pVar->iUsed )
if( pVar->szName && functions.pLast->szName && ! pVar->iUsed )
GenWarning( WARN_VAR_NOT_USED, pVar->szName, functions.pLast->szName );
pVar = pVar->pNext;
@@ -3199,7 +3200,7 @@ void FixReturns( void ) /* fixes all last defined function returns jumps offsets
pVar = functions.pLast->pStatics;
while ( pVar )
{
if( pVar->szName && ! pVar->iUsed )
if( pVar->szName && functions.pLast->szName && ! pVar->iUsed )
GenWarning( WARN_VAR_NOT_USED, pVar->szName, functions.pLast->szName );
pVar = pVar->pNext;

View File

@@ -144,7 +144,7 @@ int ParseDirective( char* sLine )
/* if ((handl_i = fopen(sLine, "r")) == NULL) */
if ( !OpenInclude( sLine, _pIncludePath, &handl_i ) )
{ printf("\nCan't open %s",sLine); return 1001; }
{ printf("\nCan't open %s\n",sLine); return 1001; }
lInclude++;
Hp_Parse(handl_i, 0 );
lInclude--;
@@ -178,7 +178,7 @@ int ParseDirective( char* sLine )
else if ( i == 5 && memcmp ( sDirective, "error", 5 ) == 0 )
{ /* --- #error --- */
printf ( " #error: %s", sLine );
printf ( "\n#error: %s\n", sLine );
return 2000;
}
else return 1;

View File

@@ -89,7 +89,7 @@ int PreProcess( FILE* handl_i, FILE* handl_o, char *sOut )
if ( (rezParse=ParseDirective( ptr+1 )) > 0 )
{
if ( !lInclude )
printf ( "\nError number %u in line %u", rezParse, nline );
printf ( "\nError number %u in line %u\n", rezParse, nline );
}
*sLine = '\0';
}
@@ -99,7 +99,7 @@ int PreProcess( FILE* handl_i, FILE* handl_o, char *sOut )
{
if ( (rezParse = ParseExpression( ptr, sOutLine)) > 0 )
{
printf ( "\nError number %u in line %u", rezParse, nline );
printf ( "\nError number %u in line %u\n", rezParse, nline );
}
}
else *sLine = '\0';
@@ -153,7 +153,7 @@ int Hp_Parse( FILE* handl_i, FILE* handl_o )
*sLine = '\0';
}
else
printf ( "\nNon directive in include file");
printf ( "\nNon directive in include file\n");
}
}
}

View File

@@ -71,7 +71,7 @@ int iArg = 1;
AddSearchPath( argv[ iArg ]+2, &_pIncludePath );
break;
default:
printf( "Invalid command line option: %s\n", &argv[ iArg ][ 1 ] );
printf( "\nInvalid command line option: %s\n", &argv[ iArg ][ 1 ] );
break;
}
}
@@ -84,15 +84,15 @@ int iArg = 1;
MakeFilename( szFileName, pFileName );
if ((handl_i = fopen(szFileName, "r")) == NULL)
{ printf("Can't open %s",szFileName); return 1; }
{ printf("\nCan't open %s\n",szFileName); return 1; }
}
else { printf("File name absent"); return 1; }
else { printf("\nFile name absent\n"); return 1; }
pFileName->extension =".ppo";
MakeFilename( szFileName, pFileName );
if ((handl_o = fopen(szFileName, "wt" )) == NULL)
{ printf("Can't open %s",szFileName); return 1; }
{ printf("\nCan't open %s\n",szFileName); return 1; }
aCondCompile = (int*) _xgrab( sizeof(int) * 5 );
aDefnew = ( DEFINES * ) _xgrab( sizeof(DEFINES) * 50 );
@@ -147,7 +147,7 @@ int Hp_Parse( FILE* handl_i, FILE* handl_o )
if ( (rezParse=ParseDirective( ptr+1 )) > 0 )
{
if ( !lInclude )
printf ( "\nError number %u in line %u", rezParse, nline );
printf ( "\nError number %u in line %u\n", rezParse, nline );
return rezParse;
}
*sLine = '\0';
@@ -158,7 +158,7 @@ int Hp_Parse( FILE* handl_i, FILE* handl_o )
{
if ( (rezParse = ParseExpression( ptr, sOutLine)) > 0 )
{
printf ( "\nError number %u in line %u", rezParse, nline );
printf ( "\nError number %u in line %u\n", rezParse, nline );
return rezParse;
}
}

View File

@@ -40,14 +40,14 @@ FUNCTION Main()
// Builds dynamic table replacement
WHILE (nPos := fRead( hFile, @cString, IF_BUFFER )) > 0
i := 1
DO WHILE i <= nPos
DO WHILE i <= nPos
IF substr( cString, i, 1 ) = chr( 13 )
i := i + 1
cLine := cBuf
cBuf := ""
IF left( cLine, 1 ) <> ';'
IF left( cLine, 1 ) <> ';'
cTable += '<TR>' + chr(10)+chr(13) + ;
'<TD WIDTH="50%"><FONT SIZE="2" FACE="Tahoma">' + ;
ParseString( cLine, ';', 1 ) + '</FONT></TD>' + chr(10)+chr(13) + ;
@@ -104,14 +104,14 @@ FUNCTION ParseString( cString, cDelim, nRet )
FOR i := 1 TO nSize
nPosFim := at( cDelim, cBuf )
IF nPosFim > 0
IF nPosFim > 0
aElem[i] := substr( cBuf, 1, nPosFim - 1 )
ELSE
aElem[i] := cBuf
ENDIF
cBuf := substr( cBuf, nPosFim + 1, len( cBuf ) )
NEXT i
RETURN( aElem[ nRet ] )