ChangeLog 2000-08-01 18:20 UTC+0100

This commit is contained in:
Ryszard Glab
2000-08-01 16:17:13 +00:00
parent dfeb227c89
commit 39596ad2dd
7 changed files with 162 additions and 352 deletions

View File

@@ -1,3 +1,24 @@
2000-08-01 18:20 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
*include/hbapi.h
* modified HB_MACRO structure
*source/macro/macro.l
* optimized support for array index
*source/compiler/harbour.c
*source/compiler/harbour.y
*fixed some unreleased memory blocks reported by CodeGuard
*source/compiler/hbident.c
*changed size of hash table to 509
*source/macro/Makefile
* removed CR characters
NOTE:
All sources HAVE TO be rebuild !!!
2000-07-31 20:25 UTC+0800 Ron Pinkas <ron@profit-master.com>
* source/compiler/cmdcheck.c
+ Added support for multiple switches, without seperator, like: -n-w

View File

@@ -495,6 +495,7 @@ typedef struct HB_MACRO_ /* a macro compiled pcode container */
ULONG pos; /* current position inside of compiled string */
int Flags; /* some flags we may need */
int status; /* status of compilation */
int FlexState; /* internal flex state during parsing */
HB_PCODE_INFO_PTR pCodeInfo; /* pointer to pcode buffer and info */
void * pParseInfo; /* data needed by the parser - it should be 'void *' to allow different implementation of macr compiler */
USHORT uiNameLen; /* the maximum symbol name length */

View File

@@ -2519,7 +2519,7 @@ void hb_compGenPushFunCall( char * szFunName )
{
/* Abbreviated function name was used - change it for whole name
*/
hb_compGenPushSymbol( hb_strdup( szFunction ), 1 );
hb_compGenPushSymbol( hb_compIdentifierNew( szFunction, TRUE ), 1 );
}
else
hb_compGenPushSymbol( szFunName, 1 );
@@ -3371,7 +3371,7 @@ int hb_compCompile( char * szPrg, int argc, char * argv[] )
* will be not generated. The name cannot be placed as first symbol
* because this symbol can be used as function call or memvar's name.
*/
hb_compFunctionAdd( hb_strupr( hb_strdup( "" ) ), HB_FS_PUBLIC, FUN_PROCEDURE );
hb_compFunctionAdd( hb_compIdentifierNew( "", TRUE ), HB_FS_PUBLIC, FUN_PROCEDURE );
}
yyparse();
@@ -3537,7 +3537,8 @@ int hb_compCompile( char * szPrg, int argc, char * argv[] )
hb_compGenError( hb_comp_szErrors, 'F', HB_COMP_ERR_BADFILENAME, szPrg, NULL );
iStatus = EXIT_FAILURE;
}
hb_xfree( hb_comp_pFileName );
return iStatus;
}

View File

@@ -1617,6 +1617,15 @@ int hb_compYACCMain( char * szName )
*/
fclose( yyin );
while( hb_comp_files.pLast )
{
PFILE pFile = hb_comp_files.pLast;
if( pFile->pBuffer )
hb_xfree( (void *) pFile->pBuffer );
hb_xfree( (void *) pFile->szFileName );
hb_comp_files.pLast = pFile->pPrev;
hb_xfree( pFile );
}
hb_comp_files.pLast = NULL;
return 0;
@@ -1672,9 +1681,10 @@ BOOL hb_compInclude( char * szFileName, PATHNAMES * pSearch )
pFile->iBuffer = pFile->lenBuffer = 10;
pFile->szFileName = szFileName;
pFile->iLine = 0;
pFile->pPrev = NULL;
pFile->pPrev = hb_comp_files.pLast;
hb_comp_files.pLast = pFile;
#ifdef __cplusplus
yy_switch_to_buffer( ( YY_BUFFER_STATE ) ( hb_comp_buffer = ( char * ) yy_create_buffer( yyin, 8192 * 2 ) ) );
#else
@@ -1690,6 +1700,7 @@ int yywrap( void ) /* handles the EOF of the currently processed file */
if( hb_comp_files.iFiles == 1 )
{
hb_xfree( hb_comp_files.pLast->pBuffer );
hb_comp_files.pLast->pBuffer = NULL;
return 1; /* we have reached the main EOF */
}

View File

@@ -38,7 +38,7 @@
#include "hbhash.h"
#include "hbcomp.h"
#define HB_IDENT_TABLE_SIZE 523UL
#define HB_IDENT_TABLE_SIZE 509UL
static HB_HASH_TABLE_PTR s_comp_Identifiers; /* table of identifiers for reuse */

View File

@@ -1,105 +1,52 @@
#
# $Id$
#
ROOT = ../../
YACC_FLAGS = -p hb_comp
YACC_SOURCE=macro.y
YACC_HEADERS=\
hbmacro.h \
hbsetup.h \
hbpcode.h \
hbdefs.h \
ifeq ($(HB_LEX),SIMPLEX)
C_EXTRA=macroslx.c
else
#NOTE: You can pass additional parameters that control the speed/size
# ratio of generated flex scanner. These parameters are:
# -Cf - fastest/biggest
# -CF
# -C - in between
# -Cm
# -Ce
# -Cem - slowest/smallest
# see Flex documentation for full set of switches
LEX_FLAGS = -Phb_comp -C
LEX_SOURCE=macro.l
LEX_HEADERS=\
hbsetup.h \
hberrors.h \
hbdefs.h \
hbmacro.h \
endif
C_SOURCES=\
macroa.c \
macrob.c \
macroc.c \
$(C_EXTRA)
LIBNAME=macro
include $(TOP)$(ROOT)config/lib.cf


View File

@@ -85,13 +85,7 @@ NOTE: -C controls the speed/size ratio of generated scanner
#define LOOKUP 0 /* scan from the begining of line */
#define OPERATOR -1
#define SEPARATOR -2
static int _iOpenBracket = 0;
/* Support for Array Index */
static int iIndexSets = 0;
static int i_INDEX_STATE = 0;
#define SEPARATOR -1
%}
@@ -113,19 +107,7 @@ MacroEnd \&{Identifier}\.({Identifier})|([0-9]+)
MacroId ({Identifier}\&(({Identifier}[\.]?)|({Identifier}\.({Identifier})|([0-9]+))))
MacroTxt ({MacroVar}|{MacroEnd}|{MacroId})+
Array {Identifier}[ \t]*"["
MacroVarArray {MacroVar}[ \t]*"["
MacroTxtArray ({MacroEnd}|{MacroId}|{MacroTxt})[ \t]*"["
AtArray "}"[ \t]*"["
ExpArray ")"[ \t]*"["
SubArray "]"[ \t]*"["
Separator {SpaceTab}
%x STRING1 STRING2 STRING3
%x FIELD_ IIF_ IF_
%s INDEX
%%
@@ -135,155 +117,103 @@ Separator {SpaceTab}
' BEGIN STRING1;
\" BEGIN STRING2;
"="[ \t]*"[" { BEGIN STRING3; return '='; }
"+"[ \t]*"[" { BEGIN STRING3; return '+'; }
"-"[ \t]*"[" { BEGIN STRING3; return '-'; }
"*"[ \t]*"[" { BEGIN STRING3; return '*'; }
"/"[ \t]*"[" { BEGIN STRING3; return '/'; }
"%"[ \t]*"[" { BEGIN STRING3; return '%'; }
"$"[ \t]*"[" { BEGIN STRING3; return '$'; }
("<>"|"!=")[ \t]*"[" { BEGIN STRING3; return NE2; }
":="[ \t]*"[" { BEGIN STRING3; return INASSIGN; }
"=="[ \t]*"[" { BEGIN STRING3; return EQ; }
"<="[ \t]*"[" { BEGIN STRING3; return LE; }
">="[ \t]*"[" { BEGIN STRING3; return GE; }
"+="[ \t]*"[" { BEGIN STRING3; return PLUSEQ; }
"-="[ \t]*"[" { BEGIN STRING3; return MINUSEQ; }
"*="[ \t]*"[" { BEGIN STRING3; return MULTEQ; }
"/="[ \t]*"[" { BEGIN STRING3; return DIVEQ; }
"^="[ \t]*"[" { BEGIN STRING3; return EXPEQ; }
"%="[ \t]*"[" { BEGIN STRING3; return MODEQ; }
("**"|"^")[ \t]*"[" { BEGIN STRING3; return POWER; }
".and."[ \t]*"[" { BEGIN STRING3; return AND; }
".or."[ \t]*"[" { BEGIN STRING3; return OR; }
("!"|".not.")[ \t]*"[" { BEGIN STRING3; return NOT; }
(","|"{"|"<"|">"|"(")[ \t]*"[" { BEGIN STRING3; yyleng = 1; yytext[1] = 0; return yytext[ 0 ]; }
\[ {
if( pMacro->FlexState == SEPARATOR )
BEGIN STRING3;
else
return '[';
}
<INITIAL>\[ BEGIN STRING3;
<STRING1>[^'^\n]* { hb_macroError( EG_SYNTAX, YYLEX_PARAM ); BEGIN 0; }
<STRING2>[^\"^\n]* { hb_macroError( EG_SYNTAX, YYLEX_PARAM ); BEGIN 0; }
<STRING3>[^\]]*\n { hb_macroError( EG_SYNTAX, YYLEX_PARAM ); BEGIN 0; }
<STRING1>[^']*' { if( i_INDEX_STATE )
BEGIN INDEX;
else
BEGIN 0;
<STRING1>[^']*' { BEGIN 0;
pMacro->FlexState = LOOKUP;
yyleng--;
yytext[yyleng] = 0;
yylval_ptr->string = hb_strdup( yytext );
return LITERAL;
}
yyleng--;
yytext[yyleng] = 0;
yylval_ptr->string = hb_strdup( yytext );
return LITERAL;
}
<STRING2>[^\"]*\" { BEGIN 0;
pMacro->FlexState = LOOKUP;
yyleng--;
yytext[yyleng] = 0;
yylval_ptr->string = hb_strdup( yytext );
return LITERAL;
}
<STRING2>[^\"]*\" { if( i_INDEX_STATE )
BEGIN INDEX;
else
BEGIN 0;
yyleng--;
yytext[yyleng] = 0;
yylval_ptr->string = hb_strdup( yytext );
return LITERAL;
}
<STRING3>[^\]]*\] { if( i_INDEX_STATE )
BEGIN INDEX;
else
BEGIN 0;
yyleng--;
yytext[yyleng] = 0;
yylval_ptr->string = hb_strdup( yytext );
return LITERAL;
}
<INDEX>\n { hb_macroError( EG_SYNTAX, YYLEX_PARAM ); }
<INDEX>\[ { iIndexSets++; return yytext[ 0 ]; }
<INDEX>\] {
iIndexSets-- ;
if( iIndexSets == 0 )
{
/*printf( "\nIndex End\n" );*/
/* No longer in this state. */
i_INDEX_STATE = 0;
BEGIN 0;
}
return yytext[ 0 ];
}
<STRING3>[^\]]*\] { BEGIN 0;
pMacro->FlexState = LOOKUP;
yyleng--;
yytext[yyleng] = 0;
yylval_ptr->string = hb_strdup( yytext );
return LITERAL;
}
{SpaceTab} ;
\n.* {
yyless( 1 );
return '\n';
}
\n { pMacro->FlexState = LOOKUP; return '\n'; }
%{
/* ************************************************************************ */
%}
"_fie"|"_fiel"|"_field" {
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
return FIELD;
}
pMacro->FlexState = LOOKUP;
return FIELD;
}
"fiel"|"field" {
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
return FIELD;
}
pMacro->FlexState = LOOKUP;
return FIELD;
}
"iif" {
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
return IIF;
}
pMacro->FlexState = LOOKUP;
return IIF;
}
"if" {
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
return IF;
}
"if" {
pMacro->FlexState = LOOKUP;
return IF;
}
"nil" return NIL;
"nil" { pMacro->FlexState = LOOKUP; return NIL; }
"qself"{SpaceTab}*\({SpaceTab}*\) return SELF;
"qself"{SpaceTab}*\({SpaceTab}*\) { pMacro->FlexState = LOOKUP; return SELF; }
%{
/* ************************************************************************ */
%}
"#" return NE1;
"=" return yytext[ 0 ];
"+" return yytext[ 0 ];
"-" return yytext[ 0 ];
"*" return yytext[ 0 ];
[\/] return yytext[ 0 ];
"%" return yytext[ 0 ];
"$" return yytext[ 0 ];
"<>"|"!=" return NE2;
":=" return INASSIGN;
"==" return EQ;
"++" return INC;
"--" return DEC;
"->" return ALIASOP;
"<=" return LE;
">=" return GE;
"+=" return PLUSEQ;
"-=" return MINUSEQ;
"*=" return MULTEQ;
"/=" return DIVEQ;
"^=" return EXPEQ;
"%=" return MODEQ;
"**"|"^" return POWER;
".and." return AND;
".or." return OR;
"."[t|y]"." return TRUEVALUE;
"."[f|n]"." return FALSEVALUE;
"!"|".not." return NOT;
"::" unput( ':' ); unput( 'f' ); unput( 'l' ); unput( 'e' ); unput( 'S' );
[,\{\}\|\#\&\.\:\<\>\[\]\@] return yytext[ 0 ];
[\(] ++_iOpenBracket; return yytext[ 0 ];
[\)] --_iOpenBracket; return yytext[ 0 ];
"#" { pMacro->FlexState = SEPARATOR; return NE1; }
"<>"|"!=" { pMacro->FlexState = SEPARATOR; return NE2; }
":=" { pMacro->FlexState = SEPARATOR; return INASSIGN; }
"==" { pMacro->FlexState = SEPARATOR; return EQ; }
"++" { pMacro->FlexState = SEPARATOR; return INC; }
"--" { pMacro->FlexState = SEPARATOR; return DEC; }
"->" { pMacro->FlexState = SEPARATOR; return ALIASOP; }
"<=" { pMacro->FlexState = SEPARATOR; return LE; }
">=" { pMacro->FlexState = SEPARATOR; return GE; }
"+=" { pMacro->FlexState = SEPARATOR; return PLUSEQ; }
"-=" { pMacro->FlexState = SEPARATOR; return MINUSEQ; }
"*=" { pMacro->FlexState = SEPARATOR; return MULTEQ; }
"/=" { pMacro->FlexState = SEPARATOR; return DIVEQ; }
"^=" { pMacro->FlexState = SEPARATOR; return EXPEQ; }
"%=" { pMacro->FlexState = SEPARATOR; return MODEQ; }
"**"|"^" { pMacro->FlexState = SEPARATOR; return POWER; }
".and." { pMacro->FlexState = SEPARATOR; return AND; }
".or." { pMacro->FlexState = SEPARATOR; return OR; }
"."[t|y]"." { pMacro->FlexState = SEPARATOR; return TRUEVALUE; }
"."[f|n]"." { pMacro->FlexState = SEPARATOR; return FALSEVALUE; }
"!"|".not." { pMacro->FlexState = SEPARATOR; return NOT; }
"::" { pMacro->FlexState = SEPARATOR; unput( ':' ); unput( 'f' ); unput( 'l' ); unput( 'e' ); unput( 'S' ); }
[\{\(] { pMacro->FlexState = SEPARATOR; return yytext[ 0 ]; }
[\=\+\-\*\/\%\$\,\|\#\&\.\:\<\>\@] { pMacro->FlexState = SEPARATOR; return yytext[ 0 ]; }
[\]\}\)] { pMacro->FlexState = LOOKUP; return yytext[ 0 ]; }
[\x00-\x1F] return yytext[ 0 ]; /* see below */
[\x80-\xFF] {
@@ -301,6 +231,7 @@ Separator {SpaceTab}
{Number} {
char * ptr;
pMacro->FlexState = LOOKUP;
yylval_ptr->valDouble.dNumber = atof( yytext );
ptr = strchr( yytext, '.' );
if( ptr )
@@ -333,171 +264,68 @@ Separator {SpaceTab}
{HexNumber} {
long lNumber = 0;
long lNumber = 0;
pMacro->FlexState = LOOKUP;
sscanf( yytext, "%lxI", &lNumber );
sscanf( yytext, "%lxI", &lNumber );
if( ( double )LONG_MIN <= lNumber &&
lNumber <= ( double )LONG_MAX )
{
yylval_ptr->valLong.lNumber = lNumber;
yylval_ptr->valLong.szValue = yytext;
return NUM_LONG;
}
else
{
yylval_ptr->valDouble.dNumber = lNumber;
yylval_ptr->valDouble.bWidth = HB_DEFAULT_WIDTH;
yylval_ptr->valDouble.bDec = 0;
yylval_ptr->valDouble.szValue = yytext;
return NUM_DOUBLE;
}
}
{Array} {
HB_TRACE(HB_TR_DEBUG, ("{Array}(%s)", yytext));
if( ! i_INDEX_STATE )
{
BEGIN INDEX;
i_INDEX_STATE = 1;
}
unput( '[' );
yyleng--;
/* Remove optional white space between Identifier and Index */
while( yytext[ yyleng - 1 ] < 48 )
yyleng--;
yytext[yyleng] = 0;
{
if( ( USHORT ) strlen( yytext ) > YYLEX_PARAM->uiNameLen )
{
yytext[ YYLEX_PARAM->uiNameLen ] = '\0';
yyleng = YYLEX_PARAM->uiNameLen;
}
yylval_ptr->string = hb_strupr( hb_strdup( yytext ) );
return IDENTIFIER;
}
}
{MacroVarArray} {
if( ! i_INDEX_STATE )
{
BEGIN INDEX;
i_INDEX_STATE = 1;
}
unput( '[' );
yyleng--;
/* Remove optional white space between Identifier and Index */
while( yytext[ yyleng - 1 ] < 48 )
yyleng--;
yytext[yyleng] = 0;
if( yytext[ yyleng-1 ] == '.' )
yytext[ yyleng-1 ] = '\0';
yylval_ptr->string = hb_strupr( hb_strdup( yytext+1 ) );
return MACROVAR;
}
{MacroTxtArray} {
if( ! i_INDEX_STATE )
{
BEGIN INDEX;
i_INDEX_STATE = 1;
}
unput( '[' );
yyleng--;
/* Remove optional white space between Identifier and Index */
while( yytext[ yyleng - 1 ] < 48 )
yyleng--;
yytext[yyleng] = 0;
yylval_ptr->string = hb_strupr( hb_strdup( yytext ) );
return MACROTEXT;
}
{ExpArray} {
/* Must be recursive */
if( ! i_INDEX_STATE )
{
BEGIN INDEX;
i_INDEX_STATE = 1;
}
unput( '[' );
--_iOpenBracket;
return ')';
}
{SubArray} {
/* Must be recursive */
if( i_INDEX_STATE )
{
BEGIN INDEX;
i_INDEX_STATE = 1;
}
iIndexSets--;
unput( '[' );
return ']';
}
{AtArray} {
/* Must be recursive */
if( ! i_INDEX_STATE )
{
BEGIN INDEX;
i_INDEX_STATE = 1;
}
unput( '[' );
--_iOpenBracket;
return '}';
}
if( ( double )LONG_MIN <= lNumber && lNumber <= ( double )LONG_MAX )
{
yylval_ptr->valLong.lNumber = lNumber;
yylval_ptr->valLong.szValue = yytext;
return NUM_LONG;
}
else
{
yylval_ptr->valDouble.dNumber = lNumber;
yylval_ptr->valDouble.bWidth = HB_DEFAULT_WIDTH;
yylval_ptr->valDouble.bDec = 0;
yylval_ptr->valDouble.szValue = yytext;
return NUM_DOUBLE;
}
}
{MacroVar} {
HB_TRACE(HB_TR_DEBUG, ("{MacroVar}(%s)", yytext));
if( yytext[ yyleng-1 ] == '.' )
yytext[ yyleng-1 ] = '\0';
yylval_ptr->string = hb_strupr( hb_strdup( yytext+1 ) );
return MACROVAR;
}
HB_TRACE(HB_TR_DEBUG, ("{MacroVar}(%s)", yytext));
if( yytext[ yyleng-1 ] == '.' )
yytext[ yyleng-1 ] = '\0';
yylval_ptr->string = hb_strupr( hb_strdup( yytext+1 ) );
pMacro->FlexState = LOOKUP;
return MACROVAR;
}
{MacroEnd} {
HB_TRACE(HB_TR_DEBUG, ("{MacroEnd}(%s)", yytext));
yylval_ptr->string = hb_strupr( hb_strdup( yytext ) );
return MACROTEXT;
}
HB_TRACE(HB_TR_DEBUG, ("{MacroEnd}(%s)", yytext));
yylval_ptr->string = hb_strupr( hb_strdup( yytext ) );
pMacro->FlexState = LOOKUP;
return MACROTEXT;
}
{MacroId} {
HB_TRACE(HB_TR_DEBUG, ("{MacroId}(%s)", yytext));
yylval_ptr->string = hb_strupr( hb_strdup( yytext ) );
return MACROTEXT;
}
HB_TRACE(HB_TR_DEBUG, ("{MacroId}(%s)", yytext));
yylval_ptr->string = hb_strupr( hb_strdup( yytext ) );
pMacro->FlexState = LOOKUP;
return MACROTEXT;
}
{MacroTxt} {
HB_TRACE(HB_TR_DEBUG, ("{MacroTxt}(%s)", yytext));
yylval_ptr->string = hb_strupr( hb_strdup( yytext ) );
return MACROTEXT;
}
HB_TRACE(HB_TR_DEBUG, ("{MacroTxt}(%s)", yytext));
yylval_ptr->string = hb_strupr( hb_strdup( yytext ) );
pMacro->FlexState = LOOKUP;
return MACROTEXT;
}
{Identifier} {
HB_TRACE(HB_TR_DEBUG, ("{Identifier}(%s)", yytext));
if( ( USHORT ) strlen( yytext ) > YYLEX_PARAM->uiNameLen )
{
yytext[ YYLEX_PARAM->uiNameLen ] = '\0';
yyleng = YYLEX_PARAM->uiNameLen;
}
yylval_ptr->string = hb_strupr( hb_strdup( yytext ) );
return IDENTIFIER;
}
HB_TRACE(HB_TR_DEBUG, ("{Identifier}(%s)", yytext));
if( ( USHORT ) strlen( yytext ) > YYLEX_PARAM->uiNameLen )
{
yytext[ YYLEX_PARAM->uiNameLen ] = '\0';
yyleng = YYLEX_PARAM->uiNameLen;
}
yylval_ptr->string = hb_strupr( hb_strdup( yytext ) );
pMacro->FlexState = LOOKUP;
return IDENTIFIER;
}
%%
@@ -516,6 +344,7 @@ void * hb_compFlexNew( HB_MACRO_PTR pMacro )
* visible in macro.y
*/
HB_TRACE(HB_TR_DEBUG, ("hb_compFlexNew(%s, %i)", pMacro->string, pMacro->length));
pMacro->FlexState = LOOKUP;
return (void *) yy_scan_bytes( pMacro->string, pMacro->length );
}