diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 7abb1b8ba7..0a3762d695 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1541,6 +1541,11 @@ May 31, 1999 Ron Pinkas a := aFunc() QOut( a[1] ) +May 31, 1999 Ron Pinkas + Harbour.l added support for "[String]" inside ARRAY INDEX expressions. + Added "Sysntax error :" message for the macro operator (&) + when followed by a string delimiter. + diff --git a/harbour/source/compiler/harbour.l b/harbour/source/compiler/harbour.l index 3ef342c878..5f2369e63b 100644 --- a/harbour/source/compiler/harbour.l +++ b/harbour/source/compiler/harbour.l @@ -111,8 +111,35 @@ Separator {SpaceTab}|{Comment}|{LineCont} ^{SpaceTab}*(\*|"NOTE").* ; \n{SpaceTab}*(\*|"NOTE").* ++iLine; if( ! _iQuiet ) printf( "\rline: %i", iLine ); +"&"("'"|\"|\[) { printf( "\nSyntax error : '%s'\n", yytext ); exit(1); } + ' BEGIN STRING1; \" BEGIN STRING2; + +"="[ \t]*"[" { BEGIN STRING3; _iState =OPERATOR; return '='; } +"+"[ \t]*"[" { BEGIN STRING3; _iState =OPERATOR; return '+'; } +"-"[ \t]*"[" { BEGIN STRING3; _iState =OPERATOR; return '-'; } +"*"[ \t]*"[" { BEGIN STRING3; _iState =OPERATOR; return '*'; } +"/"[ \t]*"[" { BEGIN STRING3; _iState =OPERATOR; return '/'; } +"%"[ \t]*"[" { BEGIN STRING3; _iState =OPERATOR; return '%'; } +"$"[ \t]*"[" { BEGIN STRING3; _iState =OPERATOR; return '$'; } +("<>"|"!=")[ \t]*"[" { BEGIN STRING3; _iState =NE2; return NE2; } +":="[ \t]*"[" { BEGIN STRING3; _iState =INASSIGN; return INASSIGN; } +"=="[ \t]*"[" { BEGIN STRING3; _iState =EQ; return EQ; } +"<="[ \t]*"[" { BEGIN STRING3; _iState =LE; return LE; } +">="[ \t]*"[" { BEGIN STRING3; _iState =GE; return GE; } +"+="[ \t]*"[" { BEGIN STRING3; _iState =PLUSEQ; return PLUSEQ; } +"-="[ \t]*"[" { BEGIN STRING3; _iState =MINUSEQ; return MINUSEQ; } +"*="[ \t]*"[" { BEGIN STRING3; _iState =MULTEQ; return MULTEQ; } +"/="[ \t]*"[" { BEGIN STRING3; _iState =DIVEQ; return DIVEQ; } +"^="[ \t]*"[" { BEGIN STRING3; _iState =EXPEQ; return EXPEQ; } +"%="[ \t]*"[" { BEGIN STRING3; _iState =MODEQ; return MODEQ; } +("**"|"^")[ \t]*"[" { BEGIN STRING3; _iState =POWER; return POWER; } +".and."[ \t]*"[" { BEGIN STRING3; return AND; } +".or."[ \t]*"[" { BEGIN STRING3; return OR; } +("!"|".not.")[ \t]*"[" { BEGIN STRING3; return NOT; } +(","|"{"|"<"|">"|"(")[ \t]*"[" { BEGIN STRING3; _iState = OPERATOR; yyleng = 1; yytext[1] = 0; return yytext[ 0 ]; } + \[ BEGIN STRING3; [^'^\n]* { GenError( ERR_STRING_TERMINATOR, yytext, NULL ); BEGIN 0; } @@ -124,8 +151,11 @@ Separator {SpaceTab}|{Comment}|{LineCont} else BEGIN 0; + yyleng--; + yytext[yyleng] = 0; yylval.string = strdup( yytext ); - yylval.string[ yyleng - 1 ] = 0; return LITERAL; + /*printf( "\nLITERAL = %s\n", yylval.string );*/ + return LITERAL; } [^\"]*\" { if( i_INDEX_STATE ) @@ -133,8 +163,10 @@ Separator {SpaceTab}|{Comment}|{LineCont} else BEGIN 0; + yyleng--; + yytext[yyleng] = 0; yylval.string = strdup( yytext ); - yylval.string[ yyleng - 1 ] = 0; + /*printf( "\nLITERAL = %s\n", yylval.string );*/ return LITERAL; } @@ -143,8 +175,11 @@ Separator {SpaceTab}|{Comment}|{LineCont} else BEGIN 0; + yyleng--; + yytext[yyleng] = 0; yylval.string = strdup( yytext ); - yylval.string[ yyleng - 1 ] = 0; return LITERAL; + /*printf( "\nLITERAL = %s\n", yylval.string );*/ + return LITERAL; } \n { yyerror( "Unterminated Array Index" ); exit(1); } @@ -924,7 +959,7 @@ Separator {SpaceTab}|{Comment}|{LineCont} yyleng = 10; } yylval.string = strupr( strdup( yytext ) ); - printf( "\nIdentifier = '%s'\n", strupr( strdup( yytext ) ) ); + /*printf( "\nIdentifier = '%s'\n", strupr( strdup( yytext ) ) );*/ _iState = IDENTIFIER; return IDENTIFIER; } diff --git a/harbour/tests/working/arrindex.prg b/harbour/tests/working/arrindex.prg index 66342417b7..04e14fad27 100644 --- a/harbour/tests/working/arrindex.prg +++ b/harbour/tests/working/arrindex.prg @@ -8,7 +8,7 @@ Function Main c := { 1 } - b := a [ c [ 1 ] ] [ 2 ] + b := a [ c [1] ] [ val( [2] ) ] QOut( b )