19990621 Ron Pinkas
Many more strong typing features resolved many warnings on harbour.y
This commit is contained in:
@@ -12,7 +12,7 @@ typedef struct _VAR /* locals, static, public variables support */
|
||||
char *szName; /* variable name */
|
||||
char *szAlias; /* variable alias namespace */
|
||||
int iUsed; /* number of times used */
|
||||
char cType; /* future optional strong typing */
|
||||
char cType; /* optional strong typing */
|
||||
struct _VAR * pNext; /* pointer to next defined variable */
|
||||
} VAR, * PVAR;
|
||||
|
||||
@@ -42,8 +42,9 @@ typedef struct
|
||||
|
||||
typedef struct _COMSYMBOL /* compiler symbol support structure */
|
||||
{
|
||||
char * szName; /* the name of the symbol */
|
||||
char cScope; /* the scope of the symbol */
|
||||
char * szName; /* the name of the symbol */
|
||||
char cScope; /* the scope of the symbol */
|
||||
char cType;
|
||||
struct _COMSYMBOL * pNext; /* pointer to the next defined symbol */
|
||||
} COMSYMBOL, * PCOMSYMBOL;
|
||||
|
||||
|
||||
@@ -8,15 +8,15 @@
|
||||
/*
|
||||
* Errors generated by Harbour compiler
|
||||
*/
|
||||
#define ERR_OUTSIDE 1
|
||||
#define ERR_FUNC_DUPL 2
|
||||
#define ERR_VAR_DUPL 3
|
||||
#define ERR_FOLLOWS_EXEC 4
|
||||
#define ERR_OUTER_VAR 5
|
||||
#define ERR_NUMERIC_FORMAT 6
|
||||
#define ERR_STRING_TERMINATOR 7
|
||||
#define ERR_FUNC_RESERVED 8
|
||||
#define ERR_ILLEGAL_INIT 9
|
||||
#define ERR_OUTSIDE 1
|
||||
#define ERR_FUNC_DUPL 2
|
||||
#define ERR_VAR_DUPL 3
|
||||
#define ERR_FOLLOWS_EXEC 4
|
||||
#define ERR_OUTER_VAR 5
|
||||
#define ERR_NUMERIC_FORMAT 6
|
||||
#define ERR_STRING_TERMINATOR 7
|
||||
#define ERR_FUNC_RESERVED 8
|
||||
#define ERR_ILLEGAL_INIT 9
|
||||
#define ERR_CANT_OPEN_INCLUDE 10
|
||||
#define ERR_ENDIF 11
|
||||
#define ERR_ENDDO 12
|
||||
@@ -30,11 +30,17 @@
|
||||
#define ERR_SYNTAX2 20
|
||||
#define ERR_INCOMPLETE_STMT 21
|
||||
|
||||
#define WARN_AMBIGUOUS_VAR 1
|
||||
#define WARN_VAR_NOT_USED 2
|
||||
#define WARN_BLOCKVAR_NOT_USED 3
|
||||
#define WARN_ASSIGN_TYPE 4
|
||||
#define WARN_ASSIGN_SUSPECTED 5
|
||||
#define WARN_AMBIGUOUS_VAR 1
|
||||
#define WARN_VAR_NOT_USED 2
|
||||
#define WARN_BLOCKVAR_NOT_USED 3
|
||||
#define WARN_ASSIGN_TYPE 4
|
||||
#define WARN_LOGICAL_TYPE 5
|
||||
#define WARN_NUMERIC_TYPE 6
|
||||
#define WARN_OPERANDS_INCOMPATBLE 7
|
||||
#define WARN_ASSIGN_SUSPECT 8
|
||||
#define WARN_OPERAND_SUSPECT 9
|
||||
#define WARN_LOGICAL_SUSPECT 10
|
||||
#define WARN_NUMERIC_SUSPECT 11
|
||||
|
||||
void GenError( int, char*, char * ); /* generic parsing error management function */
|
||||
void GenWarning( int, char*, char * ); /* generic parsing warning management function */
|
||||
|
||||
@@ -77,7 +77,8 @@ int i_INDEX_STATE = 0;
|
||||
void yy_lex_count_lf( void )
|
||||
{
|
||||
char * pTmp = yytext;
|
||||
while( (pTmp = strchr(pTmp, '\n')) )
|
||||
pTmp = strchr(pTmp, '\n');
|
||||
while( pTmp )
|
||||
{
|
||||
++iLine;
|
||||
++pTmp;
|
||||
@@ -465,62 +466,7 @@ Separator {SpaceTab}|{Comment}
|
||||
%{
|
||||
/* ************************************************************************ */
|
||||
%}
|
||||
"end" { BEGIN END_; }
|
||||
<END_>{Separator}*[\[\(] { /* array, function call */
|
||||
yy_lex_count_lf();
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
if( _iState == LOOKUP )
|
||||
{ /* Clipper does not like end[] & end() at the begining of line */
|
||||
GenError( ERR_ENDIF, NULL, NULL );
|
||||
}
|
||||
yylval.string = yy_strdup( "END" );
|
||||
_iState =IDENTIFIER;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
return IDENTIFIER;
|
||||
}
|
||||
<END_>{Separator}*("->"|"++"|"--") { /* operators */
|
||||
yy_lex_count_lf();
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
if( _iState == LOOKUP )
|
||||
{ /* Clipper does not like end-> & end++ at the begining of line */
|
||||
GenError( ERR_ENDIF, NULL, NULL );
|
||||
}
|
||||
yylval.string = yy_strdup( "END" );
|
||||
_iState =IDENTIFIER;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
unput( yytext[ yyleng-2 ] );
|
||||
return IDENTIFIER;
|
||||
}
|
||||
<END_>{Separator}*[\+\-\:\=\|\$\%\*\,\/\[\]\)\}\^] { /* there is an operator after "end" */
|
||||
yy_lex_count_lf();
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
yylval.string = yy_strdup( "END" );
|
||||
_iState =IDENTIFIER;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
return IDENTIFIER;
|
||||
}
|
||||
<END_>{Separator}*;.*\n yy_lex_count_lf(); /* ignore any text after ';' */
|
||||
<END_>{Separator}*(\n|.) { /* not operator */
|
||||
yy_lex_count_lf();
|
||||
if( i_INDEX_STATE ) BEGIN INDEX; else BEGIN 0;
|
||||
if( yytext[ yyleng-1 ] == '\n' )
|
||||
--iLine;
|
||||
unput( yytext[ yyleng-1 ] );
|
||||
if( _iState == LOOKUP )
|
||||
{ /* it is first item in the line */
|
||||
_iState =END;
|
||||
return END;
|
||||
}
|
||||
else
|
||||
{ /* there is another item in line already */
|
||||
yylval.string = yy_strdup( "END" );
|
||||
_iState =IDENTIFIER;
|
||||
return IDENTIFIER;
|
||||
}
|
||||
}
|
||||
%{
|
||||
/* ************************************************************************ */
|
||||
%}
|
||||
|
||||
"endif"|"endi" { /* ENDIF can be used in one context only */
|
||||
if( _wIfCounter == 0 )
|
||||
GenError( ERR_ENDIF, NULL, NULL );
|
||||
@@ -536,9 +482,15 @@ Separator {SpaceTab}|{Comment}
|
||||
GenError( ERR_ENDDO, NULL, NULL );
|
||||
return ENDDO;
|
||||
}
|
||||
"end" { /* END can be used in one context only */
|
||||
if( _wIfCounter == 0 && _wCaseCounter == 0 && _wCaseCounter == 0 )
|
||||
printf( "END without an IF / CASE /or WHILE" );
|
||||
return END;
|
||||
}
|
||||
%{
|
||||
/* ************************************************************************ */
|
||||
%}
|
||||
|
||||
"exit" { BEGIN EXIT_; }
|
||||
<EXIT_>{Separator}*[\n] { /* EXIT last item in the line */
|
||||
yy_lex_count_lf();
|
||||
@@ -1125,12 +1077,14 @@ Separator {SpaceTab}|{Comment}
|
||||
}
|
||||
}
|
||||
|
||||
"as numeric" { return AS_NUMERIC; }
|
||||
"as character" { return AS_CHARACTER; }
|
||||
"as logical" { return AS_LOGICAL; }
|
||||
"as date" { return AS_DATE; }
|
||||
"as array" { return AS_ARRAY; }
|
||||
"as object" { return AS_OBJECT; }
|
||||
"as numeric" { return AS_NUMERIC; }
|
||||
"as character" { return AS_CHARACTER; }
|
||||
"as logical" { return AS_LOGICAL; }
|
||||
"as date" { return AS_DATE; }
|
||||
"as array" { return AS_ARRAY; }
|
||||
"as block" { return AS_BLOCK; }
|
||||
"as object" { return AS_OBJECT; }
|
||||
"declare function" { return DECLARE_FUN; }
|
||||
|
||||
%{
|
||||
/* ************************************************************************ */
|
||||
@@ -1441,5 +1395,6 @@ int yy_lex_input( char *buffer, int iBufferSize )
|
||||
|
||||
int yy_lex_input( char *buffer, int iBufferSize )
|
||||
{
|
||||
if( 0 && iBufferSize ) printf( "/* compiler warning */" );
|
||||
return PreProcess( yyin, (lPpo)? yyppo:NULL, buffer );
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user