2000-08-15 18:25 UTC+0800 Ron Pinkas <ron@profit-master.com>
* source/compiler/simplex.c
+ Added support for multi-charcters Stream Start and Stream End delimiters.
+ Added overidable MACROs STREAM_OPEN(x), STREAM_APPEND(x)
! Removed Hardcoded limits, changed to overidable #defines: MAX_STREAM, MAX_STREAM_STARTER, MAX_STREAM_TERMINATOR,
MAX_STREAM_EXCLUSIONS
* source/macro/macroslx.c
+ Added:
#define MAX_STREAM 2048 /* Max length of in-line LITERAL */
#define MAX_STREAM_STARTER 2
#define MAX_STREAM_TERMINATOR 2
#define MAX_STREAM_EXCLUSIONS 2
* source/compiler/hbslex.c
+ Added:
#define MAX_STREAM 2048 /* Max length of in-line LITERAL */
#define MAX_STREAM_STARTER 7 /* "QOUT([" */
#define MAX_STREAM_TERMINATOR 4 /* "])\n" */
#define MAX_STREAM_EXCLUSIONS 2
* source/macro/macro.slx
* Replaced AND_IGNORE_DELIMITERS() with TEST_LEFT()
* source/compiler/harbour.slx
+ Added: #define NUMERALS_PER_LINE 512
* Replaced AND_IGNORE_DELIMITERS() with TEST_LEFT()
+ Added support for TEXT ENDTEXT (pending some more work in PP), nested [[]] strings and double delimiters stringified strings.
This commit is contained in:
@@ -1,3 +1,33 @@
|
||||
2000-08-15 18:25 UTC+0800 Ron Pinkas <ron@profit-master.com>
|
||||
* source/compiler/simplex.c
|
||||
+ Added support for multi-charcters Stream Start and Stream End delimiters.
|
||||
+ Added overidable MACROs STREAM_OPEN(x), STREAM_APPEND(x)
|
||||
! Removed Hardcoded limits, changed to overidable #defines: MAX_STREAM, MAX_STREAM_STARTER, MAX_STREAM_TERMINATOR,
|
||||
MAX_STREAM_EXCLUSIONS
|
||||
|
||||
* source/macro/macroslx.c
|
||||
+ Added:
|
||||
#define MAX_STREAM 2048 /* Max length of in-line LITERAL */
|
||||
#define MAX_STREAM_STARTER 2
|
||||
#define MAX_STREAM_TERMINATOR 2
|
||||
#define MAX_STREAM_EXCLUSIONS 2
|
||||
|
||||
* source/compiler/hbslex.c
|
||||
+ Added:
|
||||
#define MAX_STREAM 2048 /* Max length of in-line LITERAL */
|
||||
#define MAX_STREAM_STARTER 7 /* "QOUT([" */
|
||||
#define MAX_STREAM_TERMINATOR 4 /* "])\n" */
|
||||
#define MAX_STREAM_EXCLUSIONS 2
|
||||
|
||||
* source/macro/macro.slx
|
||||
* Replaced AND_IGNORE_DELIMITERS() with TEST_LEFT()
|
||||
|
||||
* source/compiler/harbour.slx
|
||||
+ Added: #define NUMERALS_PER_LINE 512
|
||||
* Replaced AND_IGNORE_DELIMITERS() with TEST_LEFT()
|
||||
+ Added support for TEXT ENDTEXT (pending some more work in PP), nested [[]] strings and double delimiters stringified strings.
|
||||
+ Added MACROs STREAM_OPEN( sStarter ) and STREAM_APPEND(x)
|
||||
|
||||
2000-08-15 21:15 GMT -3 Luiz Rafael Culik <culik@sl.conex.net>
|
||||
|
||||
*utils/hbdoc/hbdoc.prg
|
||||
@@ -9,12 +39,11 @@
|
||||
*include/hbexprc.c
|
||||
*source/compiler/exproptc.c
|
||||
*fixed unused variable warning
|
||||
|
||||
|
||||
source/compiler/harbour.l
|
||||
*fixed some warnings reported by BCC
|
||||
*some final optimization
|
||||
|
||||
|
||||
2000-08-15 14:40 GMT -3 Luiz Rafael Culik <culik@sl.conex.net>
|
||||
* doc/en/cmdline.txt
|
||||
* Formated text added by Victor
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
* their web site at http://www.gnu.org/).
|
||||
*/
|
||||
|
||||
#define NUMERALS_PER_LINE 512
|
||||
|
||||
//#define SHOW_LEX_TOKENS
|
||||
//#define DEBUG_LEX
|
||||
|
||||
@@ -56,12 +58,40 @@
|
||||
|
||||
#undef STREAM_EXCEPTION
|
||||
#define STREAM_EXCEPTION( sPair, cChar ) \
|
||||
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_STRING_TERMINATOR, sPair, NULL ); \
|
||||
aiReturn[ iReturn++ ] = '\n'; \
|
||||
aiReturn[ iReturn++ ] = LITERAL;
|
||||
if( sTerm[1] == ']' && iCloseSquare ) \
|
||||
{ \
|
||||
szBuffer -= ( ( strlen( sPair ) - iCloseSquare ) + 1 ); \
|
||||
memmove( (char*) &(sPair[1]), (char*) &(sPair[0]), iCloseSquare - 1 ); \
|
||||
sPair[0] = sStart[1]; \
|
||||
sPair[ iCloseSquare ] = '\0'; \
|
||||
aiReturn[ iReturn++ ] = HB_LIT_ACT; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
hb_compGenError( hb_comp_szErrors, 'E', HB_COMP_ERR_STRING_TERMINATOR, sPair, NULL ); \
|
||||
aiReturn[ iReturn++ ] = '\n'; \
|
||||
yylval.string = hb_compIdentifierNew( sPair, TRUE ); \
|
||||
aiReturn[ iReturn++ ] = LITERAL; \
|
||||
} \
|
||||
|
||||
static int iTexts = 0;
|
||||
static char * aTexts[512];
|
||||
#undef STREAM_APPEND
|
||||
#define STREAM_APPEND(x) \
|
||||
if( x == ']' && ! iCloseSquare ) iCloseSquare = iPairLen + 1; sPair[ iPairLen++ ] = x
|
||||
|
||||
#undef STREAM_OPEN
|
||||
#define STREAM_OPEN( sStarter ) \
|
||||
{ \
|
||||
iCloseSquare = 0; \
|
||||
\
|
||||
if( sStarter[0] == 'Q' ) \
|
||||
bTmp = FALSE /* TODO: hb_ppInsideTextBlock*/; \
|
||||
else \
|
||||
bTmp = TRUE; \
|
||||
} \
|
||||
if( bTmp )
|
||||
|
||||
static int iTexts = 0, iCloseSquare = 0;
|
||||
static char * aTexts[ NUMERALS_PER_LINE ];
|
||||
static char* sIdOnHold;
|
||||
|
||||
/*
|
||||
@@ -80,13 +110,19 @@ DELIMITER_BELONGS_TO_TOKEN_IF_ONE_OF_THESE( "" );
|
||||
/* Custom Action can be requested by setting reduction to LEX_CUSTOM_ACTION or lower. */
|
||||
|
||||
/* Intermediate Token needed to be expanded. */
|
||||
#define HB_LIT_ACT -1001
|
||||
#define HB_LIT_ACT -1001
|
||||
#define HB_QOUT_ACT -1002
|
||||
#define HB_RET_QOUT_LIT -1003
|
||||
|
||||
/* Stream Pairs. */
|
||||
DEFINE_STREAM_AS_ONE_OF_THESE {
|
||||
START_WITH('\'') END_WITH('\'') STOP_IF_ONE_OF_THESE("\n") AND_IGNORE_DELIMITERS(TRUE) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH('"') END_WITH('"' ) STOP_IF_ONE_OF_THESE("\n") AND_IGNORE_DELIMITERS(TRUE) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH('[') END_WITH(']' ) STOP_IF_ONE_OF_THESE("\n") AND_IGNORE_DELIMITERS(TRUE) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH("\'") END_WITH("\'") STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH("\"") END_WITH("\"" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH("[") END_WITH("]" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(TRUE ) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH("[\'") END_WITH("\']" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH("[\"") END_WITH("\"]" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH("[[") END_WITH("]]" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH("QOUT([") END_WITH("])\n") STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_QOUT_ACT)
|
||||
};
|
||||
|
||||
START_NEW_LINE_IF_ONE_OF_THESE( "\n;" );
|
||||
@@ -129,37 +165,37 @@ SELF_CONTAINED_WORDS_ARE {
|
||||
#define PRIVATE_ 1006
|
||||
|
||||
/* Custom Actions - Suspend reserved words after these (waiting for Identifier). */
|
||||
#define HB_FUNCTION -1002
|
||||
#define HB_PROCEDURE -1003
|
||||
#define HB_EXTERN -1004
|
||||
#define HB_DECLARE -1005
|
||||
#define HB_PUBLIC -1006
|
||||
#define HB_PRIVATE -1007
|
||||
#define HB_LOCAL -1008
|
||||
#define HB_MEMVAR -1009
|
||||
#define HB_FIELD -1010
|
||||
#define HB_PARAM -1011
|
||||
#define HB_FOR -1012
|
||||
#define HB_OPTIONAL -1013
|
||||
#define HB_FUNCTION -1004
|
||||
#define HB_PROCEDURE -1005
|
||||
#define HB_EXTERN -1006
|
||||
#define HB_DECLARE -1007
|
||||
#define HB_PUBLIC -1008
|
||||
#define HB_PRIVATE -1009
|
||||
#define HB_LOCAL -1010
|
||||
#define HB_MEMVAR -1011
|
||||
#define HB_FIELD -1012
|
||||
#define HB_PARAM -1013
|
||||
#define HB_FOR -1014
|
||||
#define HB_OPTIONAL -1015
|
||||
|
||||
/* When 2 identifiers are correct syntax like in class declaration, we have to temporarily store the 2nd identifier. */
|
||||
/*
|
||||
#define HB_ID_ON_HOLD -1015
|
||||
#define HB_ID_ON_HOLD -1016
|
||||
*/
|
||||
|
||||
#define HB_MACRO_ERR -1016
|
||||
#define HB_MACRO_ERR -1017
|
||||
|
||||
#define HB_CHK_NEXT -1017
|
||||
#define HB_CHK_EXIT -1018
|
||||
#define HB_CHK_LOOP -1019
|
||||
#define HB_CHK_IN -1020
|
||||
#define HB_CHK_NEXT -1018
|
||||
#define HB_CHK_EXIT -1019
|
||||
#define HB_CHK_LOOP -1020
|
||||
#define HB_CHK_IN -1021
|
||||
|
||||
#define HB_INIT_PROC -1021
|
||||
#define HB_EXIT_PROC -1022
|
||||
#define HB_INIT_FUNC -1023
|
||||
#define HB_EXIT_FUNC -1024
|
||||
#define HB_INIT_PROC -1022
|
||||
#define HB_EXIT_PROC -1023
|
||||
#define HB_INIT_FUNC -1024
|
||||
#define HB_EXIT_FUNC -1025
|
||||
|
||||
#define HB_RET_FUNID -1025
|
||||
#define HB_RET_FUNID -1026
|
||||
|
||||
/* Key Words. */
|
||||
LANGUAGE_KEY_WORDS_ARE {
|
||||
@@ -326,6 +362,8 @@ LANGUAGE_WORDS_ARE {
|
||||
#define _DEC_CR 3015
|
||||
#define _DEC_SEMI 3016
|
||||
|
||||
#define HB_QOUT_LIT 3017
|
||||
|
||||
LANGUAGE_RULES_ARE {
|
||||
IF_SEQUENCE_IS( '^' , 0 , 0 , 0 ) REDUCE_TO( POWER , 0 ),
|
||||
IF_SEQUENCE_IS( '!' , 0 , 0 , 0 ) REDUCE_TO( NOT , 0 ),
|
||||
@@ -719,7 +757,9 @@ LANGUAGE_RULES_ARE {
|
||||
|
||||
IF_SEQUENCE_IS( '&' , '\'' , 0 , 0 ) REDUCE_TO( HB_MACRO_ERR , 0 ),
|
||||
IF_SEQUENCE_IS( '&' , '"' , 0 , 0 ) REDUCE_TO( HB_MACRO_ERR , 0 ),
|
||||
IF_SEQUENCE_IS( '&' , '[' , 0 , 0 ) REDUCE_TO( HB_MACRO_ERR , 0 )
|
||||
IF_SEQUENCE_IS( '&' , '[' , 0 , 0 ) REDUCE_TO( HB_MACRO_ERR , 0 ),
|
||||
|
||||
IF_SEQUENCE_IS( HB_QOUT_LIT , 0 , 0 , 0 ) REDUCE_TO( HB_RET_QOUT_LIT , 0 )
|
||||
};
|
||||
|
||||
/* ------------------------------------------------- End of Language Definitions. ------------------------------------------------ */
|
||||
@@ -748,13 +788,12 @@ LANGUAGE_RULES_ARE {
|
||||
#undef INTERCEPT_ACTION
|
||||
#define INTERCEPT_ACTION(x) \
|
||||
\
|
||||
yytext = (char*) sToken; \
|
||||
/*\
|
||||
yytext = sToken; \
|
||||
/*\
|
||||
if( x == IDENTIFIER ) \
|
||||
{ \
|
||||
iIdentifier--; \
|
||||
} \
|
||||
*/\
|
||||
} */\
|
||||
\
|
||||
if( x == IDENTIFIER ) \
|
||||
printf( " IDENTIFIER = \"%s\"\n", yylval.string ); \
|
||||
@@ -786,14 +825,13 @@ LANGUAGE_RULES_ARE {
|
||||
#undef INTERCEPT_ACTION
|
||||
#define INTERCEPT_ACTION(x) \
|
||||
\
|
||||
yytext = (char*) sToken; \
|
||||
\
|
||||
/* \
|
||||
yytext = sToken; \
|
||||
/*\
|
||||
if( x == IDENTIFIER ) \
|
||||
{ \
|
||||
iIdentifier--; \
|
||||
} \
|
||||
*/ \
|
||||
}*/ \
|
||||
\
|
||||
if( x < 256 ) \
|
||||
{ \
|
||||
yytext[0] = x; \
|
||||
@@ -876,19 +914,15 @@ LANGUAGE_RULES_ARE {
|
||||
yytext[ HB_SYMBOL_NAME_LEN ] = '\0';\
|
||||
yyleng = HB_SYMBOL_NAME_LEN;\
|
||||
}\
|
||||
\
|
||||
/*\
|
||||
/*\
|
||||
if( iIdentifier )\
|
||||
{\
|
||||
sIdOnHold = hb_compIdentifierNew( yytext, TRUE );\
|
||||
iRet = HB_ID_ON_HOLD;\
|
||||
}\
|
||||
else\
|
||||
*/\
|
||||
else */\
|
||||
{\
|
||||
/*
|
||||
iIdentifier++;\
|
||||
*/\
|
||||
/* iIdentifier++; */\
|
||||
yylval.string = hb_compIdentifierNew( yytext, TRUE );\
|
||||
iRet = IDENTIFIER;\
|
||||
}\
|
||||
@@ -1050,6 +1084,22 @@ int hb_lex_CustomAction( int x, int iWordLen, int aiHold[], int *ptr_iHold, BOOL
|
||||
x = LITERAL;
|
||||
break;
|
||||
|
||||
case HB_QOUT_ACT :
|
||||
/* iIdentifier++; */
|
||||
yylval.string = hb_compIdentifierNew( "QOUT", TRUE );
|
||||
aiReturn[ (*ptr_iReturn)++ ] = '(';
|
||||
aiReturn[ (*ptr_iReturn)++ ] = IDENTIFIER;
|
||||
x = HB_QOUT_LIT;
|
||||
break;
|
||||
|
||||
case HB_RET_QOUT_LIT :
|
||||
yylval.string = hb_compIdentifierNew( sPair, TRUE );
|
||||
aiReturn[ (*ptr_iReturn)++ ] = '\n';
|
||||
aiReturn[ (*ptr_iReturn)++ ] = ')';
|
||||
aiReturn[ (*ptr_iReturn)++ ] = LITERAL;
|
||||
x = 0;
|
||||
break;
|
||||
|
||||
case HB_FUNCTION :
|
||||
*ptr_bIgnoreWords = TRUE;
|
||||
aiHold[ (*ptr_iHold)++ ] = FUNCTION;
|
||||
@@ -1454,14 +1504,15 @@ int hb_lex_CustomAction( int x, int iWordLen, int aiHold[], int *ptr_iHold, BOOL
|
||||
x = 0;
|
||||
break;
|
||||
|
||||
/*
|
||||
/*
|
||||
case HB_ID_ON_HOLD :
|
||||
bRestored = TRUE;
|
||||
yylval.string = sIdOnHold;
|
||||
iIdentifier++;
|
||||
x = IDENTIFIER;
|
||||
break;
|
||||
*/
|
||||
*/
|
||||
|
||||
default:
|
||||
printf( "WARNING! No Handler for Custom Action %i\n", x );
|
||||
}
|
||||
@@ -1469,12 +1520,8 @@ int hb_lex_CustomAction( int x, int iWordLen, int aiHold[], int *ptr_iHold, BOOL
|
||||
if( x == IDENTIFIER && ! bRestored )
|
||||
{
|
||||
yylval.string = hb_compIdentifierNew( (char*) sIdentifier, TRUE );
|
||||
|
||||
/*
|
||||
iIdentifier++;
|
||||
*/
|
||||
/* iIdentifier++; */
|
||||
aiHold[ (int)(*ptr_iHold)++ ] = x;
|
||||
|
||||
x = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,19 @@
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
#include "hbcomp.h"
|
||||
#include "harboury.h"
|
||||
#include "hbsetup.h"
|
||||
#include "hberrors.h"
|
||||
#include "hbdefs.h"
|
||||
|
||||
#define MAX_STREAM 2048 /* Max length of in-line LITERAL */
|
||||
#define MAX_STREAM_STARTER 7 /* "QOUT([" */
|
||||
#define MAX_STREAM_TERMINATOR 4 /* "])\n" */
|
||||
#define MAX_STREAM_EXCLUSIONS 2
|
||||
|
||||
#define TOKEN_SIZE HB_SYMBOL_NAME_LEN + 1
|
||||
|
||||
#define SLX_RULES "harbour.slx"
|
||||
|
||||
#include "simplex.c"
|
||||
|
||||
@@ -32,9 +32,12 @@
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
/* These are NOT overidable (yet). */
|
||||
/* NOT overidable (yet). */
|
||||
#define MAX_MATCH 4
|
||||
#define TOKEN_SIZE 64
|
||||
|
||||
#ifndef TOKEN_SIZE
|
||||
#define TOKEN_SIZE 64
|
||||
#endif
|
||||
|
||||
/* Language Definitions Readability. */
|
||||
#define SELF_CONTAINED_WORDS_ARE LEX_WORD const aSelfs[] =
|
||||
@@ -56,20 +59,37 @@
|
||||
#define START_WITH(x) { x,
|
||||
#define END_WITH(x) x,
|
||||
#define STOP_IF_ONE_OF_THESE(x) x,
|
||||
#define AND_IGNORE_DELIMITERS(x) x,
|
||||
#define TEST_LEFT(x) x,
|
||||
#define AS_PAIR_TOKEN(x) x }
|
||||
#define STREAM_EXCEPTION( sPair, chrPair) \
|
||||
if( chrPair ) \
|
||||
{ \
|
||||
printf( "Exception: %c for stream at: \"%s\"\n", chrPair, sPair ); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
printf( "Exception: <EOF> for stream at: \"%s\"\n", chrPair, sPair ); \
|
||||
} \
|
||||
|
||||
/* Pairs. */
|
||||
static char sPair[ 2048 ];
|
||||
static char cTerm;
|
||||
static BOOL bExclusive;
|
||||
#ifndef MAX_STREAM
|
||||
#define MAX_STREAM 2048
|
||||
#endif
|
||||
#ifndef MAX_STREAM_STARTER
|
||||
#define MAX_STREAM_STARTER 2
|
||||
#endif
|
||||
#ifndef MAX_STREAM_TERMINATOR
|
||||
#define MAX_STREAM_TERMINATOR 2
|
||||
#endif
|
||||
#ifndef MAX_STREAM_EXCLUSIONS
|
||||
#define MAX_STREAM_EXCLUSIONS 2
|
||||
#endif
|
||||
|
||||
static char sPair[ MAX_STREAM ];
|
||||
static char * sStart, * sTerm;
|
||||
static char * sExclude;
|
||||
static int iPairToken;
|
||||
static BOOL bTestLeft;
|
||||
static int iPairToken = 0;
|
||||
|
||||
/* Self Contained Words. */
|
||||
static char sSelf[ TOKEN_SIZE ];
|
||||
@@ -82,10 +102,10 @@ typedef struct _LEX_WORD
|
||||
|
||||
typedef struct _LEX_PAIR
|
||||
{
|
||||
char cStart;
|
||||
char cTerm;
|
||||
char sExclude[4];
|
||||
BOOL bExclusive;
|
||||
char sStart[MAX_STREAM_STARTER];
|
||||
char sTerm[MAX_STREAM_TERMINATOR];
|
||||
char sExclude[MAX_STREAM_EXCLUSIONS];
|
||||
BOOL bTestLeft;
|
||||
int iToken;
|
||||
} LEX_PAIR; /* support structure for Streams (Pairs). */
|
||||
|
||||
@@ -110,6 +130,8 @@ typedef struct _LEX_PAIR
|
||||
#define ELEMENT_TOKEN(x) -1
|
||||
#define DEBUG_INFO(x)
|
||||
#define LEX_CASE(x)
|
||||
#define STREAM_OPEN(x)
|
||||
#define STREAM_APPEND(x) sPair[ iPairLen++ ] = x
|
||||
|
||||
#include SLX_RULES
|
||||
|
||||
@@ -233,23 +255,77 @@ int Reduce( int iToken, BOOL bReal );
|
||||
if( *tmpPtr )
|
||||
|
||||
#define IF_BEGIN_PAIR(chr) \
|
||||
{ register int iPair = 0;\
|
||||
{\
|
||||
register int iPair = 0, iStartLen; \
|
||||
register char chrStart; \
|
||||
int iLastPair = 0, iLastLen = 0; \
|
||||
\
|
||||
DEBUG_INFO( printf( "Checking %i Streams for %c At: >%s<\n", iPairs, chr, szBuffer - 1 ) ); \
|
||||
\
|
||||
while( iPair < iPairs ) \
|
||||
{ \
|
||||
if( chr == aPairs[iPair].cStart ) \
|
||||
chrStart = LEX_CASE(chr);\
|
||||
\
|
||||
if( chrStart == aPairs[iPair].sStart[0] ) \
|
||||
{ \
|
||||
/* Terminator to look for. */ \
|
||||
cTerm = aPairs[iPair].cTerm; \
|
||||
bExclusive = aPairs[iPair].bExclusive; \
|
||||
sExclude = (char *) aPairs[iPair].sExclude; \
|
||||
iPairToken = aPairs[iPair].iToken; \
|
||||
break; \
|
||||
iStartLen = 1; \
|
||||
\
|
||||
if( aPairs[iPair].sStart[1] ) \
|
||||
{ \
|
||||
chrStart = LEX_CASE( *szBuffer ); \
|
||||
\
|
||||
while( aPairs[iPair].sStart[iStartLen] ) \
|
||||
{ \
|
||||
if( chrStart != aPairs[iPair].sStart[iStartLen] ) \
|
||||
{ \
|
||||
break; \
|
||||
} \
|
||||
\
|
||||
iStartLen++; \
|
||||
\
|
||||
/* Peek at Next Character. */ \
|
||||
chrStart = LEX_CASE( *( szBuffer + iStartLen - 1 ) ); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
/* Match */ \
|
||||
if( aPairs[iPair].sStart[iStartLen] == '\0' ) \
|
||||
{ \
|
||||
if( iStartLen > iLastLen ) \
|
||||
{ \
|
||||
iLastPair = iPair + 1; \
|
||||
iLastLen = iStartLen; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
iPair++; \
|
||||
} \
|
||||
bTmp = ( iPair < iPairs ); \
|
||||
\
|
||||
bTmp = FALSE; \
|
||||
\
|
||||
if( iLastPair ) \
|
||||
{ \
|
||||
iLastPair--; \
|
||||
STREAM_OPEN( aPairs[iLastPair].sStart )\
|
||||
{ \
|
||||
bTmp = TRUE; \
|
||||
\
|
||||
/* Last charcter read. */\
|
||||
chr = chrStart; \
|
||||
\
|
||||
/* Moving to next postion after the Stream Start position. */ \
|
||||
szBuffer += ( iLastLen - 1 ); \
|
||||
\
|
||||
/* Terminator to look for. */ \
|
||||
sStart = (char *) aPairs[iLastPair].sStart; \
|
||||
sTerm = (char *) aPairs[iLastPair].sTerm; \
|
||||
sExclude = (char *) aPairs[iLastPair].sExclude; \
|
||||
bTestLeft = aPairs[iLastPair].bTestLeft; \
|
||||
iPairToken = aPairs[iLastPair].iToken; \
|
||||
\
|
||||
DEBUG_INFO( printf( "Looking for Stream Terminator: >%s< Exclusions >%s<\n", sTerm, sExclude ) ); \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
/* Begin New Pair. */ \
|
||||
if( bTmp )
|
||||
@@ -870,6 +946,9 @@ YY_DECL
|
||||
{
|
||||
if ( iSize && *szBuffer )
|
||||
{
|
||||
if( iPairToken )
|
||||
goto ProcessStream;
|
||||
|
||||
cPrev = chr;
|
||||
|
||||
/* Get next character. */
|
||||
@@ -878,159 +957,154 @@ YY_DECL
|
||||
|
||||
IF_OMMIT(chr)
|
||||
{
|
||||
if ( iLen )
|
||||
{
|
||||
/* Terminate current token and check it. */
|
||||
sToken[ iLen ] = '\0';
|
||||
if ( iLen )
|
||||
{
|
||||
/* Terminate current token and check it. */
|
||||
sToken[ iLen ] = '\0';
|
||||
|
||||
DEBUG_INFO( printf( "Token: \"%s\" Ommited: \'%c\'\n", sToken, chr ) );
|
||||
DEBUG_INFO( printf( "Token: \"%s\" Ommited: \'%c\'\n", sToken, chr ) );
|
||||
|
||||
goto CheckToken;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
goto CheckToken;
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
CHECK_SELF_CONTAINED(chr);
|
||||
|
||||
/* Soft Pair Terminator ? */
|
||||
if ( cTerm && chr == cTerm )
|
||||
{
|
||||
/* Reset. */
|
||||
cTerm = 0;
|
||||
|
||||
/* Terminate current token and check it. */
|
||||
sToken[ iLen++ ] = chr;
|
||||
sToken[ iLen ] = '\0';
|
||||
|
||||
DEBUG_INFO( printf( "Pair at %c = %s\n", chr, sToken ) );
|
||||
|
||||
goto CheckToken;
|
||||
}
|
||||
|
||||
/* New Pair ? */
|
||||
IF_BEGIN_PAIR( chr )
|
||||
{
|
||||
if( iLen )
|
||||
{
|
||||
/* Resume here on next call. */
|
||||
szBuffer--;
|
||||
iSize++;
|
||||
cTerm = 0;
|
||||
/* So cPrev will remain intact. */
|
||||
chr = cPrev;
|
||||
if( iLen )
|
||||
{
|
||||
DEBUG_INFO( printf( "Holding Stream Mode: '%c' Buffer = >%s<\n", chr, szBuffer ) );
|
||||
|
||||
DEBUG_INFO( printf( "Pushed back: '%c' Buffer = >%s<\n", chr, szBuffer ) );
|
||||
/* Terminate and Check Token to the left. */
|
||||
sToken[ iLen ] = '\0';
|
||||
|
||||
/* Terminate and Check Token to the left. */
|
||||
sToken[ iLen ] = '\0';
|
||||
DEBUG_INFO( printf( "Token: \"%s\" before New Pair at: \'%c\'\n", sToken, chr ) );
|
||||
|
||||
DEBUG_INFO( printf( "Token: \"%s\" before New Pair at: \'%c\'\n", sToken, chr ) );
|
||||
goto CheckToken ;
|
||||
}
|
||||
|
||||
goto CheckToken ;
|
||||
}
|
||||
ProcessStream :
|
||||
|
||||
bIgnoreWords = FALSE;
|
||||
bIgnoreWords = FALSE;
|
||||
|
||||
IF_BELONG_LEFT( chr )
|
||||
{
|
||||
DEBUG_INFO( printf( "Reducing Left '%c'\n", chr ) );
|
||||
cTerm = 0;
|
||||
RETURN_TOKEN( REDUCE( (int) chr ), NULL );
|
||||
}
|
||||
if( bTestLeft )
|
||||
{
|
||||
IF_BELONG_LEFT( chr )
|
||||
{
|
||||
DEBUG_INFO( printf( "Reducing Left '%c'\n", chr ) );
|
||||
iPairToken = 0;
|
||||
RETURN_TOKEN( REDUCE( (int) chr ), NULL );
|
||||
}
|
||||
}
|
||||
|
||||
/* Soft ? */
|
||||
if ( bExclusive )
|
||||
{
|
||||
{
|
||||
register int iPairLen = 0;
|
||||
register char chrPair;
|
||||
{ register int iPairLen = 0;
|
||||
register char chrPair;
|
||||
|
||||
/* Look for the terminator. */
|
||||
while ( *szBuffer )
|
||||
/* Look for the terminator. */
|
||||
while ( *szBuffer )
|
||||
{
|
||||
/* Next Character. */
|
||||
chrPair = *szBuffer++ ;
|
||||
|
||||
/* Terminator ? */
|
||||
if( chrPair == sTerm[0] )
|
||||
{
|
||||
register int iTermLen = 1;
|
||||
|
||||
if( sTerm[1] )
|
||||
{
|
||||
/* Next Character. */
|
||||
chrPair = *szBuffer++ ;
|
||||
register char chrTerm = LEX_CASE( *szBuffer );
|
||||
|
||||
/* Check if exception. */
|
||||
IF_ABORT_PAIR( chrPair )
|
||||
{
|
||||
sPair[ iPairLen ] = '\0';
|
||||
while( sTerm[iTermLen] )
|
||||
{
|
||||
if( chrTerm != sTerm[iTermLen] )
|
||||
{
|
||||
/* Last charcter read. */
|
||||
chr = chrTerm;
|
||||
break;
|
||||
}
|
||||
|
||||
STREAM_EXCEPTION( sPair, chrPair);
|
||||
iTermLen++;
|
||||
|
||||
/* Resetting. */
|
||||
cTerm = 0;
|
||||
|
||||
/* Last charcter read. */
|
||||
chr = chrPair;
|
||||
|
||||
goto on_error;
|
||||
}
|
||||
/* Terminator found. */
|
||||
else if( chrPair == cTerm )
|
||||
{
|
||||
sPair[ iPairLen ] = '\0';
|
||||
|
||||
DEBUG_INFO( printf( "Returning Pair = >%s<\n", sPair ) );
|
||||
|
||||
/* Resetting. */
|
||||
cTerm = 0;
|
||||
|
||||
/* Last charcter read. */
|
||||
chr = chrPair;
|
||||
|
||||
if( bNewLine )
|
||||
{
|
||||
bNewLine = FALSE;
|
||||
NEW_LINE_ACTION();
|
||||
}
|
||||
|
||||
if( iPairToken < LEX_CUSTOM_ACTION )
|
||||
{
|
||||
iRet = iPairToken;
|
||||
iRet = CUSTOM_ACTION( iRet );
|
||||
if( iRet )
|
||||
{
|
||||
RETURN_TOKEN( REDUCE( iRet ), NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
goto Start;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RETURN_TOKEN( REDUCE( iPairToken ), NULL );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Accumulating. */
|
||||
sPair[ iPairLen++ ] = chrPair;
|
||||
}
|
||||
/* Peek at Next Character. */ \
|
||||
chrTerm = LEX_CASE( *( szBuffer + iTermLen - 1 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
STREAM_EXCEPTION( sPair, NULL );
|
||||
/* Match */ \
|
||||
if( sTerm[iTermLen] == '\0' ) \
|
||||
{ \
|
||||
/* Moving to next postion after the Stream Terminator. */ \
|
||||
szBuffer += ( iTermLen - 1 ); \
|
||||
|
||||
/* Resetting. */
|
||||
cTerm = 0;
|
||||
sPair[ iPairLen ] = '\0';
|
||||
|
||||
goto on_error;
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG_INFO( printf( "Opened Pair, looking for: %c\n", cTerm ) );
|
||||
DEBUG_INFO( printf( "Returning Pair = >%s<\n", sPair ) );
|
||||
|
||||
sToken[iLen++] = chr;
|
||||
if( bNewLine )
|
||||
{
|
||||
bNewLine = FALSE;
|
||||
NEW_LINE_ACTION();
|
||||
}
|
||||
|
||||
/* Scan next charcter. */
|
||||
continue;
|
||||
}
|
||||
/* Resetting. */
|
||||
iRet = iPairToken;
|
||||
iPairToken = 0;
|
||||
|
||||
if( iRet < LEX_CUSTOM_ACTION )
|
||||
{
|
||||
iRet = CUSTOM_ACTION( iRet );
|
||||
if( iRet )
|
||||
{
|
||||
RETURN_TOKEN( REDUCE( iRet ), NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
goto Start;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RETURN_TOKEN( REDUCE( iRet ), NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if exception. */
|
||||
IF_ABORT_PAIR( chrPair )
|
||||
{
|
||||
sPair[ iPairLen ] = '\0';
|
||||
|
||||
STREAM_EXCEPTION( sPair, chrPair);
|
||||
|
||||
/* Resetting. */
|
||||
iPairToken = 0;
|
||||
|
||||
/* Last charcter read. */
|
||||
chr = chrPair;
|
||||
|
||||
goto Start;
|
||||
}
|
||||
else
|
||||
{
|
||||
STREAM_APPEND( chrPair );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
STREAM_EXCEPTION( sPair, NULL );
|
||||
|
||||
/* Resetting. */
|
||||
iPairToken = 0;
|
||||
|
||||
goto Start;
|
||||
}
|
||||
/* End Pairs. */
|
||||
|
||||
@@ -1133,9 +1207,6 @@ YY_DECL
|
||||
}
|
||||
}
|
||||
|
||||
on_error:
|
||||
continue;
|
||||
|
||||
CheckToken:
|
||||
{
|
||||
if( bNewLine )
|
||||
|
||||
@@ -78,9 +78,9 @@ DELIMITER_BELONGS_TO_TOKEN_IF_ONE_OF_THESE( "" );
|
||||
|
||||
/* Stream Pairs. */
|
||||
DEFINE_STREAM_AS_ONE_OF_THESE {
|
||||
START_WITH('\'') END_WITH('\'') STOP_IF_ONE_OF_THESE("\n") AND_IGNORE_DELIMITERS(TRUE) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH('"') END_WITH('"' ) STOP_IF_ONE_OF_THESE("\n") AND_IGNORE_DELIMITERS(TRUE) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH('[') END_WITH(']' ) STOP_IF_ONE_OF_THESE("\n") AND_IGNORE_DELIMITERS(TRUE) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH("\'") END_WITH("\'") STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH("\"") END_WITH("\"" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(FALSE) AS_PAIR_TOKEN(HB_LIT_ACT),
|
||||
START_WITH("[") END_WITH("]" ) STOP_IF_ONE_OF_THESE("\n") TEST_LEFT(TRUE ) AS_PAIR_TOKEN(HB_LIT_ACT)
|
||||
};
|
||||
|
||||
START_NEW_LINE_IF_ONE_OF_THESE( "\n;" );
|
||||
|
||||
@@ -19,6 +19,13 @@
|
||||
#include "hberrors.h"
|
||||
#include "hbdefs.h"
|
||||
|
||||
#define MAX_STREAM 2048 /* Max length of in-line LITERAL */
|
||||
#define MAX_STREAM_STARTER 2
|
||||
#define MAX_STREAM_TERMINATOR 2
|
||||
#define MAX_STREAM_EXCLUSIONS 2
|
||||
|
||||
#define TOKEN_SIZE HB_SYMBOL_NAME_LEN + 1
|
||||
|
||||
/* NOTE: 02/08/2000 - maurilio.longo@libero.it, under OS/2 GCC I need to use relative paths in include command */
|
||||
/* this is relative to position of simplex.c in harbour source tree */
|
||||
#define SLX_RULES "../macro/macro.slx"
|
||||
|
||||
Reference in New Issue
Block a user