2000-06-25 22:14 UTC-0800 Ron Pinkas <Ron@Profit-Master.com>

* source/compiler/harbour.l
     + Added rule for orphan "]"
     * Monor improvments to INDEX

   * source/compiler/hbgenerr.c
     * Minor improvements

   * source/pp/ppcomp.c
     ! Corrected line number was adding EmptyLines twice.
This commit is contained in:
Ron Pinkas
2000-06-26 05:30:43 +00:00
parent 2a7952bc28
commit 4f5dd5cb17
4 changed files with 122 additions and 78 deletions

View File

@@ -1,3 +1,22 @@
2000-06-25 22:14 UTC-0800 Ron Pinkas <Ron@Profit-Master.com>
* source/compiler/harbour.l
+ Added rule for orphan "]"
* Monor improvments to INDEX
* source/compiler/hbgenerr.c
* Minor improvements
* source/pp/ppcomp.c
! Corrected line number was adding EmptyLines twice.
2000-06-25 03:35 UTC-0800 Ron Pinkas <Ron@Profit-Master.com>
* source/compiler/hbgenerr.c
! Refined line numbers reported.
* source/compiler/harbour.l
! Rewrote (again) rules for STRING1 STRING2 STRING3 INDEX. Rules for strings much simpler.
/* Flex had some problem with $ that caused output of strings. */
2000-06-25 23:58 UTC+0100 Ryszard Glab <rglab@imid.med.pl>
*source/vm/garbage.c
@@ -6,9 +25,9 @@
*source/rtl/errorapi.c
*fixed call for hb_itemInit()
*tests/onidle.prg
*commented self-referencing codeblock since it requires some
*commented self-referencing codeblock since it requires some
more work
2000-06-25 21:52 UTC+0100 Victor Szakats <info@szelvesz.hu>

View File

@@ -157,9 +157,10 @@ Separator {SpaceTab}
^[ \t]*"do"[ \t]*"while"[ \t]*"[" { BEGIN STRING3; return WHILE; }
<INITIAL>\[ { BEGIN STRING3; }
<INITIAL>\] { hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, "orphan \"]\"", NULL ); }
<STRING1>[^'\n]*\n {
unput( '\n' );
yytext[--yyleng] = '\0';
#ifdef DEBUG_STRINGS
@@ -167,16 +168,17 @@ Separator {SpaceTab}
#endif
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_STRING_TERMINATOR, yytext, NULL );
iIndexSets = 0;
i_INDEX_STATE = 0;
hb_comp_iState = LOOKUP;
BEGIN 0;
return LITERAL;
}
<STRING2>[^"\n]*\n {
unput( '\n' );
yytext[--yyleng] = '\0';
#ifdef DEBUG_STRINGS
@@ -184,59 +186,66 @@ Separator {SpaceTab}
#endif
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_STRING_TERMINATOR, yytext, NULL );
iIndexSets = 0;
i_INDEX_STATE = 0;
hb_comp_iState = LOOKUP;
BEGIN 0;
return LITERAL;
}
<STRING3>[^]\n]*\n {
<STRING3>[^\]\n]*\n {
unput( '\n' );
yytext[--yyleng] = '\0';
#ifdef DEBUG_STRINGS
printf("\nEOL in STRING3\n");
printf("\nEOL in STRING3\n");
#endif
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_STRING_TERMINATOR, yytext, NULL );
iIndexSets = 0;
i_INDEX_STATE = 0;
hb_comp_iState = LOOKUP;
BEGIN 0;
return LITERAL;
}
}
<STRING1>[^'\n]*' { if( i_INDEX_STATE )
BEGIN INDEX;
else
BEGIN 0;
<STRING1>[^'\n]*' {
if( i_INDEX_STATE )
BEGIN INDEX;
else
BEGIN 0;
yytext[yyleng--] = '\0';
yylval.string = hb_strdup( yytext );
return LITERAL;
}
yytext[yyleng--] = '\0';
yylval.string = hb_strdup( yytext );
<STRING2>[^"\n]*\" { if( i_INDEX_STATE )
BEGIN INDEX;
else
BEGIN 0;
return LITERAL;
}
yytext[yyleng--] = '\0';
yylval.string = hb_strdup( yytext );
return LITERAL;
}
<STRING2>[^"\n]*\" { if( i_INDEX_STATE )
BEGIN INDEX;
else
BEGIN 0;
<STRING3>[^\]\n]*] { if( i_INDEX_STATE )
BEGIN INDEX;
else
BEGIN 0;
yytext[yyleng--] = '\0';
yylval.string = hb_strdup( yytext );
yytext[yyleng--] = '\0';
yylval.string = hb_strdup( yytext );
return LITERAL;
}
return LITERAL;
}
<STRING3>[^\]\n]*] { if( i_INDEX_STATE )
BEGIN INDEX;
else
BEGIN 0;
yytext[yyleng--] = '\0';
yylval.string = hb_strdup( yytext );
return LITERAL;
}
<INDEX>\[[^;\n]*[;\n] {
{
@@ -257,61 +266,78 @@ Separator {SpaceTab}
}
}
/* No Closing Bracket - Error! */
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_UNTERM_ARRAY_INDEX, NULL, NULL );
i_INDEX_STATE = 0;
iIndexSets = 0;
hb_comp_iState = LOOKUP;
BEGIN 0;
return yytext[yyleng -1];
}
}
<INDEX>\][^;\n]*[;\n] { if( iIndexSets )
iIndexSets-- ;
<INDEX>\][^;\n]*[;\n] {
iIndexSets-- ;
#ifdef DEBUG_INDEX
printf( "Closed: %i At: >%s<\n", iIndexSets, yytext );
#endif
#ifdef DEBUG_INDEX
printf( "Closed: %i At: >%s<\n", iIndexSets, yytext );
#endif
if( iIndexSets == 0 )
{
char * tmpStr = yytext + 1;
if( iIndexSets == 0 )
{
char * tmpStr = yytext + 1;
/* Default to no immediate Opening Bracket. */
i_INDEX_STATE = 0;
BEGIN 0;
/* Default to no immediate Opening Bracket. */
i_INDEX_STATE = 0;
BEGIN 0;
#ifdef DEBUG_INDEX
printf( "Assumed Normal but Searching...\n" );
#endif
#ifdef DEBUG_INDEX
printf( "Assumed Normal but Searching...\n" );
#endif
/* We have to BEGIN INDEX because lex ate the ']' so it will misss the "]"[ \t]"[" SubArray rule. */
while( ( *tmpStr == ' ' || *tmpStr == '\t' || *tmpStr == '[' ) && *tmpStr != '\0' )
{
if( *tmpStr++ == '[' )
{
#ifdef DEBUG_INDEX
printf( "Retained! Found: >%s<\n", tmpStr );
#endif
/* We have to BEGIN INDEX because lex ate the ']' so it will misss the "]"[ \t]"[" SubArray rule. */
while( ( *tmpStr == ' ' || *tmpStr == '\t' || *tmpStr == '[' || *tmpStr == ']' ) && *tmpStr != '\0' )
{
if( *tmpStr == ']' )
{
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, "orphan \"]\"", NULL );
break;
}
else if( *tmpStr == '[' )
{
#ifdef DEBUG_INDEX
printf( "Retained! Found: >%s<\n", tmpStr );
#endif
i_INDEX_STATE = 1;
BEGIN INDEX;
break;
}
}
}
else
{
#ifdef DEBUG_INDEX
printf( "Still Open: %i\n", iIndexSets );
#endif
}
i_INDEX_STATE = 1;
BEGIN INDEX;
yyless(1);
hb_comp_iState = OPERATOR;
return ']';
}
break;
}
tmpStr++;
}
if( i_INDEX_STATE == 0 )
{
#ifdef DEBUG_INDEX
printf( "Resumed NORMAL!\n" );
#endif
}
}
else
{
#ifdef DEBUG_INDEX
printf( "Still Open: %i\n", iIndexSets );
#endif
}
yyless(1);
hb_comp_iState = OPERATOR;
return ']';
}
{SpaceTab} ;

View File

@@ -129,10 +129,6 @@ void hb_compGenError( char * szErrors[], char cPrefix, int iError, char * szErro
if( cPrefix != 'F' && hb_comp_bError )
return;
#ifdef DEBUG_ERRORS
printf( "PP %i Empty: %i >%s<\n", hb_comp_files.pLast->iLine, hb_pp_nEmptyStrings, yytext );
#endif
printf( "\r%s(%i) ", hb_comp_szFile, iLine );
printf( "Error %c%04i ", cPrefix, iError );
@@ -151,11 +147,14 @@ void hb_compGenError( char * szErrors[], char cPrefix, int iError, char * szErro
void hb_compGenWarning( char * szWarnings[], char cPrefix, int iWarning, char * szWarning1, char * szWarning2)
{
char * szText = szWarnings[ iWarning - 1 ];
int iLine = 0;
if( hb_comp_files.pLast && hb_comp_files.pLast->iLine )
iLine = hb_comp_files.pLast->iLine - 1;
if( ( szText[ 0 ] - '0' ) <= hb_comp_iWarnings )
{
if( hb_comp_files.pLast && hb_comp_files.pLast->szFileName )
printf( "\r%s(%i) ", hb_comp_files.pLast->szFileName, hb_comp_files.pLast->iLine - 1 );
printf( "\r%s(%i) ", hb_comp_szFile, iLine );
printf( "Warning %c%04i ", cPrefix, iWarning );
printf( szText + 1, szWarning1, szWarning2 );

View File

@@ -236,7 +236,7 @@ int hb_pp_Internal( FILE * handl_o, char * sOut )
if( lLine )
{
sprintf( ptrOut, "#line %d \"%s\"", ( hb_comp_files.pLast->iLine += hb_pp_nEmptyStrings ) , hb_comp_files.pLast->szFileName );
sprintf( ptrOut, "#line %d \"%s\"", ( hb_comp_files.pLast->iLine + hb_pp_nEmptyStrings ) , hb_comp_files.pLast->szFileName );
while( *ptrOut ) ptrOut++;
/* Ron Pinkas added 2000-06-14 */