From c895bed3810df8f8cdc201c932b030cf06a1e1d3 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 8 Dec 2009 10:44:31 +0000 Subject: [PATCH] 2009-12-08 11:43 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/macro/Makefile - src/macro/macro.l * src/compiler/Makefile - src/compiler/harbour.l - src/compiler/fixflex.c * INSTALL * config/c.mk * config/rules.mk * Deleted references to Flex and related files. Flex is not used since long. It couldn't generate MT safe lexer code. --- harbour/ChangeLog | 12 + harbour/INSTALL | 4 - harbour/config/c.mk | 14 +- harbour/config/rules.mk | 4 - harbour/src/compiler/Makefile | 7 - harbour/src/compiler/fixflex.c | 351 ------ harbour/src/compiler/harbour.l | 1912 -------------------------------- harbour/src/macro/Makefile | 20 - harbour/src/macro/macro.l | 376 ------- 9 files changed, 13 insertions(+), 2687 deletions(-) delete mode 100644 harbour/src/compiler/fixflex.c delete mode 100644 harbour/src/compiler/harbour.l delete mode 100644 harbour/src/macro/macro.l diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 79c2b2424c..53eb4318ff 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,18 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-12-08 11:43 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * src/macro/Makefile + - src/macro/macro.l + * src/compiler/Makefile + - src/compiler/harbour.l + - src/compiler/fixflex.c + * INSTALL + * config/c.mk + * config/rules.mk + * Deleted references to Flex and related files. + Flex is not used since long. It couldn't generate MT safe lexer code. + 2009-12-08 11:30 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + contrib/hbqt/hbqt_hbqtmymainwindow.cpp * contrib/hbqt/hbqt_slots.cpp diff --git a/harbour/INSTALL b/harbour/INSTALL index 98eb4b404e..fa5b6f03ad 100644 --- a/harbour/INSTALL +++ b/harbour/INSTALL @@ -1294,10 +1294,6 @@ HARBOUR Subversion (Version Control System) [multiplatform, free, open-source] http://subversion.tigris.org/ - GNU Flex (lexical analyzer) [multiplatform, free, open-source] - Windows binary: - http://gnuwin32.sourceforge.net/packages/flex.htm - (not verified with current Harbour version) GNU Bison (grammer paser generator) [multiplatform, free, open-source] Windows binary: http://gnuwin32.sourceforge.net/packages/bison.htm diff --git a/harbour/config/c.mk b/harbour/config/c.mk index 108adfcb4a..794866c024 100644 --- a/harbour/config/c.mk +++ b/harbour/config/c.mk @@ -19,14 +19,7 @@ ifdef YACC_SOURCE endif endif -ifdef LEX_SOURCE - LEX_BASE := $(LEX_SOURCE:.l=) - LEX_C := $(LEX_BASE)l.c - LEX_OBJ := $(LEX_C:.c=$(OBJ_EXT)) - LEX_HB_H := $(foreach h, $(LEX_HEADERS), $(HB_INC_COMPILE)/$(h)) -endif - -ALL_C_OBJS := $(YACC_OBJ) $(LEX_OBJ) $(C_OBJS) $(C_MAIN_OBJ) +ALL_C_OBJS := $(YACC_OBJ) $(C_OBJS) $(C_MAIN_OBJ) $(YACC_OBJ) : $(YACC_C) @@ -38,8 +31,3 @@ else $(CP) $(subst /,$(DIRSEP),$<) $@ $(CP) $(subst /,$(DIRSEP),$(<:.yyc=.yyh)) $(@:.c=.h) endif - -$(LEX_OBJ) : $(LEX_C) - -$(LEX_C) : $(GRANDP)$(LEX_SOURCE) $(LEX_HB_H) - $(LEX) $(LEX_FLAGS) -o$@ $< diff --git a/harbour/config/rules.mk b/harbour/config/rules.mk index 7636d83165..7aa09e2e17 100644 --- a/harbour/config/rules.mk +++ b/harbour/config/rules.mk @@ -6,10 +6,6 @@ YACC := bison YACC_FLAGS := -d $(YACC_FLAGS) -# How to run lex. -LEX := flex -LEX_FLAGS := -i -8 $(LEX_FLAGS) - ifeq ($(HB_BUILD_DEBUG),yes) HB_CFLAGS := -DHB_TR_LEVEL_DEBUG $(HB_CFLAGS) else diff --git a/harbour/src/compiler/Makefile b/harbour/src/compiler/Makefile index 12eb23772a..72488597b1 100644 --- a/harbour/src/compiler/Makefile +++ b/harbour/src/compiler/Makefile @@ -4,13 +4,6 @@ ROOT := ../../ -#LEX_FLAGS := -Phb_comp -C -#LEX_SOURCE := harbour.l -#LEX_HEADERS := \ -# hbsetup.h \ -# hberrors.h \ -# hbdefs.h \ - #YACC_FLAGS := -p hb_comp YACC_SOURCE := harbour.y YACC_DEPEND := complex.c diff --git a/harbour/src/compiler/fixflex.c b/harbour/src/compiler/fixflex.c deleted file mode 100644 index dda0aec835..0000000000 --- a/harbour/src/compiler/fixflex.c +++ /dev/null @@ -1,351 +0,0 @@ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Flex/Bison generated source code splitter for 16-bit compilers - * - * Copyright 1999 David G. Holm - * www - http://www.harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -/* - * ChangeLog: - * - * V 1.5 David G. Holm Switched from using a series of if - * statements for the smaller large files - * to using an array of table names and a - * for loop and removed yy_acclist, which - * is no longer used - * V 1.4 Gonzalo A. Diethelm Added RCS Id keyword - * V 1.3 David G. Holm Split the two largest tables into - * separate modules and the four next - * largest tables into a third module - * V 1.2 David G. Holm Modified to work with both C and - * C++ compilers - * V 1.1 David G. Holm Submitted to the Harbor Project - * V 1.0 David G. Holm Original Version - * - */ - -/* NOTE: This file contains an external program that splits the Harbour Flex - and Bison generated source code into multiple modules so that they - can be compiled by 16-bit C compilers with a 64KB per module data size - limit. */ - -#include -#include -#include -#include -#include -#include -#include - -#define BUF_SIZE 4095 - -void fixup( char * inbuf, char * outbuf, int c_plus_plus ) -{ - char * ptr; - if( c_plus_plus ) - { - /* If compiling for C++, the arrays need to be extern "C" in both modules */ - static char s_tempbuf[ BUF_SIZE + 1 ]; - hb_strncpy( s_tempbuf, "extern \"C\" ", BUF_SIZE ); - hb_strncpy( outbuf, s_tempbuf, BUF_SIZE ); - hb_strncat( outbuf, inbuf + 7, BUF_SIZE ); - hb_strncat( s_tempbuf, inbuf + 7, BUF_SIZE ); - hb_strncpy( inbuf, s_tempbuf, BUF_SIZE ); - } - else - { - /* if compiling for C, the arrays only need to be extern in lexyy.c */ - hb_strncpy( outbuf, inbuf + 7, BUF_SIZE ); - memcpy( inbuf, "extern", 6 ); - } - ptr = strchr( inbuf, '=' ); - if( ptr ) *ptr = ';'; -} - -int main( int argc, char * argv [] ) -{ - int c_plus_plus = 0, rc = 0; - char backup[ MAXPATH ]; - - if( argc < 4 ) - { - /* Must have at least 4 arguments. */ - rc = 1; - puts( "\nUsage: FIXFLEX source dest1 dest2 dest3 [-P[+|-]]\n\n" - "Where source is the name of the generated FLEX source file, dest1 and dest2\n" - "are the names of the source files to extract the two largest flex tables into\n" - "and -P or -P+ is needed when compiling Harbour using C++ instead of C.\n" - "Note: -P- may be used to indicate the default of compiling Harbour using ANSI C." ); - } - else - { - int i; - size_t len; - for( i = 5; i < argc; i++ ) - { - if( strcmp( argv[ i ], "-P" ) == 0 ) c_plus_plus = 1; - if( strcmp( argv[ i ], "-P+" ) == 0 ) c_plus_plus = 1; - if( strcmp( argv[ i ], "-P-" ) == 0 ) c_plus_plus = 0; - } - /* Rename source to backup. */ - hb_strncpy( backup, argv[ 1 ], sizeof( backup ) - 1 ); - len = strlen( backup ); - for( i = 1; i < 4; i++ ) if( backup[ len - i ] == '.' ) backup[ len - i ] = 0; - hb_strncat( backup, ".bak", sizeof( backup ) - 1 ); - if( rename( argv[ 1 ], backup ) ) - { - rc = 10; - printf( "\nError %d (DOS error %02xd) renaming %s to %s.", errno, _doserrno, argv[ 1 ], backup ); - } - } - if( rc == 0 ) - { - /* Read from backup as source. */ - FILE * source = fopen( backup, "r" ); - if( ! source ) - { - rc = 11; - printf( "\nUnable to open %s for reading.", backup ); - } - else - { - /* Create new source. */ - FILE * replace = fopen( argv[ 1 ], "w" ); - if( ! replace ) - { - rc = 12; - printf( "\nUnable to create %s for writing (after renaming to %s).", argv[ 1 ], backup ); - } - else - { - /* Create dest 1. */ - FILE * dest1, * dest2, * dest3; - dest1 = fopen( argv[ 2 ], "w" ); - if( ! dest1 ) - { - rc = 13; - printf( "\nUnable to create %s for writing.", argv[ 2 ] ); - } - /* Create dest 2. */ - dest2 = fopen( argv[ 3 ], "w" ); - if( ! dest2 ) - { - rc = 17; - printf( "\nUnable to create %s for writing.", argv[ 3 ] ); - } - /* Create dest 2. */ - dest3 = fopen( argv[ 4 ], "w" ); - if( ! dest3 ) - { - rc = 19; - printf( "\nUnable to create %s for writing.", argv[ 4 ] ); - } - if( rc == 0 ) - { - /* Initialize. */ - int copy = 0, move1 = 0, move2 = 0, move3 = 0, check_count = 6; - int defer_move = 0, defer_end = 0; - static char inbuf[ BUF_SIZE + 1 ]; - static char outbuf[ sizeof( inbuf ) ]; - - do - { - /* Read from source */ - fgets( inbuf, BUF_SIZE, source ); - if( ferror( source ) ) - { - rc = 14; - printf( "\nError %d (DOS error %02xd) reading from %s.", errno, _doserrno, backup ); - } - else - { - char * ptr; - hb_strncpy( outbuf, inbuf, BUF_SIZE ); - - /* Check for stuff to copy or move to dest. */ - if( check_count > 0 && !move1 && !move2 && !move3 && !copy ) - { - ptr = strstr( inbuf, "yy_nxt" ); - if( ptr ) - { - /* It's the first of the two big tables. - Move it out of source into dest1, leaving only - an extern or extern "C" declaration. */ - printf( "\nLocated table yy_nxt" ); - fixup( inbuf, outbuf, c_plus_plus ); - move1 = 1; - defer_move = 1; - check_count--; - } - else - { - ptr = strstr( inbuf, "yy_chk" ); - if( ptr ) - { - /* It's the second of the two big tables. - Move it out of source into dest2, leaving only - an extern or extern "C" declaration. */ - printf( "\nLocated table yy_chk" ); - fixup( inbuf, outbuf, c_plus_plus ); - move2 = 1; - defer_move = 1; - check_count--; - } - else - { - ptr = strstr( inbuf, "#define FLEX_SCANNER" ); - if( ptr ) - { - /* It's the start of various #defines that - need to be copied from source to dest in - order to set up the yyconst define. */ - printf( "\nLocated first #define to copy" ); - copy = 1; - check_count--; - } - else - { - #define TABLE_MAX 3 - int i; - char * table[ TABLE_MAX ] = - { "yy_accept", "yy_base", "yy_def" }; - ptr = 0; - for( i = 0; i < TABLE_MAX && !ptr; i++ ) - { - ptr = strstr( inbuf, table[ i ] ); - if( ptr ) printf( "\nLocated table %s", table[ i ] ); - } - if( ptr ) - { - /* It's one of the smaller big tables. - Move them all out of source into dest3, leaving - only an extern or extern "C" declaration. */ - fixup( inbuf, outbuf, c_plus_plus ); - move3 = 1; - defer_move = 1; - check_count--; - } - } - } - } - } - else if( move1 || move2 || move3 || copy ) - { - /* Check for stuff to end copy or move. */ - ptr = strstr( inbuf, "}" ); - if( ptr && ( move1 || move2 || move3 ) ) defer_end = 1; /* End of table to move. */ - else - { - ptr = strstr( inbuf, "#ifdef YY_USE_PROTOS" ); - if( ptr && copy ) - { - printf( "\nLocated last #define to copy" ); - copy = 0; /* End of #defines to copy. */ - } - } - } - if( move1 || move2 || move3 || copy ) - { - /* If moving or copying from source to dest, do so. */ - if( copy || move1 ) - { - fputs( outbuf, dest1 ); - if( ferror( dest1 ) ) - { - rc = 15; - printf( "\nError %d (DOS error %02xd) writing to %s.", errno, _doserrno, argv[ 2 ] ); - } - } - if( copy || move2 ) - { - fputs( outbuf, dest2 ); - if( ferror( dest2 ) ) - { - rc = 18; - printf( "\nError %d (DOS error %02xd) writing to %s.", errno, _doserrno, argv[ 3 ] ); - } - } - if( copy || move3 ) - { - fputs( outbuf, dest3 ); - if( ferror( dest3 ) ) - { - rc = 20; - printf( "\nError %d (DOS error %02xd) writing to %s.", errno, _doserrno, argv[ 4 ] ); - } - } - } - if( !feof( source ) && ( ( !move1 && !move2 && !move3 ) || defer_move ) && rc == 0 ) - { - /* If not moving to dest, then write to new source. */ - fputs( inbuf, replace ); - if( ferror( replace ) ) - { - rc = 16; - printf( "\nError %d (DOS error %02xd) writing to %s (after renaming to %s).", - errno, _doserrno, argv[ 1 ], backup ); - } - } - /* Clean up. */ - if( defer_move ) defer_move = 0; - if( defer_end ) - { - move1 = 0; - move2 = 0; - move3 = 0; - defer_end = 0; - } - } - } while( !feof( source ) && rc == 0 ); - } - } - } - } - - return rc; -} diff --git a/harbour/src/compiler/harbour.l b/harbour/src/compiler/harbour.l deleted file mode 100644 index 6cf3570fd8..0000000000 --- a/harbour/src/compiler/harbour.l +++ /dev/null @@ -1,1912 +0,0 @@ -%option noyywrap -%{ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Compiler LEX rules - * - * Copyright 1999 Antonio Linares - * www - http://www.harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit - * their web site at http://www.gnu.org/). - * - */ - -/* Compile using: flex -i -8 -oyylex.c harbour.l */ - -/* TODO: VOID strong typing keyword should be added as a new type for NIL. - [vszakats] */ - -#include -#include -#include -#include -#include "hbcomp.h" -#include "harboury.h" -#include "hbsetup.h" /* main configuration file */ -#include "hberrors.h" -#include "hbdefs.h" -#include "hbdate.h" - -#undef alloca -#define alloca hb_xgrab -#undef malloc -#define malloc hb_xgrab -#undef realloc -#define realloc hb_xrealloc -#undef free -#define free hb_xfree - -/* declaration of yylex function - * NOTE: yylval is paassed automaticaly by bison if %pure_parser is used - */ -#undef YY_DECL -#define YY_DECL int yylex( YYSTYPE *yylval_ptr, HB_COMP_DECL ) - -/* helper functions */ -static int yy_ConvertNumber( YYSTYPE *yylval_ptr, char * szBuffer ); -static int yy_ConvertDate( YYSTYPE *yylval_ptr, char * szBuffer ); - -/* YACC functions */ -static void yyunput( int, char * ); -#undef YY_INPUT /* to implement our own YY_INPUT function to manage PRGs without \n at the end */ - -/* Following two lines added for preprocessor */ -int yy_lex_input( char *, int ); -#define YY_INPUT( buf, result, max_size ) result = yy_lex_input( buf, max_size ); - -/* NOTE: Uncomment this YY_USER_ACTION definition if you want to use - '^' match marker (beginning of line) -*/ -/* -#define YY_USER_ACTION \ - if ( yyleng > 0 ) \ - yy_current_buffer->yy_at_bol = ( yytext[yyleng - 1] == '\n' || yytext[0] == '\n' ); -*/ - -#define LOOKUP 0 /* scan from the begining of line */ -#define OPERATOR -1 -#define LSEPARATOR -2 -#define RSEPARATOR -4 -#define LINDEX -8 -#define RINDEX -16 -#define LARRAY -32 -#define RARRAY -64 - -static int hb_comp_iState = LOOKUP; -static int hb_comp_iLineINLINE = 0; -static int hb_comp_iLinePRG; - -/* flex is not MT safe :-( */ -static HB_COMP_PTR s_pComp; - -#define YY_OPERATOR_RET(t) hb_comp_iState = OPERATOR; pComp->pLex->lasttok = yytext; return (t) -#define YY_TOKEN_RET(s,t) hb_comp_iState = (s); pComp->pLex->lasttok = yytext; return (t) - -#define DEBUG_STRINGS - -void yy_breakFlex( void ){ }; - -%} - -%{ -#ifdef __WATCOMC__ -/* disable warnings for unreachable code */ -#pragma warning 13 9 -#endif - -#ifdef _MSC_VER - #define YY_NEVER_INTERACTIVE TRUE -#endif -%} - -SpaceTab [ \t]+ -Number ([0-9]+)|([0-9]*\.[0-9]+)|(0x[0-9A-Fa-f]+) -InvalidNumber [0-9]+\. -Identifier (([a-zA-Z])|([_a-zA-Z][_a-zA-Z0-9]+)) -Date 0d[0-9]{8} - -MacroVar \&{Identifier}[\.]? -MacroEnd \&{Identifier}\.([_a-zA-Z0-9]*) -%{ -/* -MacroId ({Identifier}\&(({Identifier}[\.]?)|({Identifier}\.([_a-zA-Z0-9]*)))) -*/ -%} -MacroId ({Identifier}({MacroVar}|{MacroEnd})) -MacroTxt ([_]*({MacroVar}|{MacroEnd}|{MacroId}))+ - -TrueValue "."[t|y]"." -FalseValue "."[f|n]"." - -Separator {SpaceTab} - -%x STRINGEXT STRING1 STRING2 STRING3 STRING4START STRING4 STRING5 -%x NEXT_ BREAK_ CASE_ DO_ DOIDENT_ WHILE_ WITH_ END_ FIELD_ -%x FOR_ FOREACH_ FUNCTION_ IIF_ IF_ IN_ INIT_ -%x RETURN_ RECOVER_ -%x SWITCH_ -%x INVALIDNUM_ OTHERWISE_ PROCEDURE_ -%x DECLARE_ DECLARE_ID_ - -%% - -%{ - /* flex is not MT safe :-( */ - s_pComp = HB_COMP_PARAM; -%} - -"&"(\x27|\x22|\[) { hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, yytext, NULL ); } - -"e"\x22 BEGIN STRINGEXT; -\x27 BEGIN STRING1; -\x22 BEGIN STRING2; - -\[ { - if( (hb_comp_iState == OPERATOR) || - (hb_comp_iState == LSEPARATOR) || - (hb_comp_iState == LARRAY) || - (hb_comp_iState == IF) || - (hb_comp_iState == ELSEIF) || - (hb_comp_iState == CASE) || - (hb_comp_iState == BREAK) || - (hb_comp_iState == RETURN) || - (hb_comp_iState == WITH) || - (hb_comp_iState == WHILE) - ) - { - BEGIN STRING3; - } - else - { - hb_comp_iState = LINDEX; - pComp->pLex->lasttok = "["; - return '['; - } - } - -([^\x22\n]|\\\x22)*\n { BEGIN 0; - unput( '\n' ); - yytext[--yyleng] = '\0'; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_STRING_TERMINATOR, yytext, NULL ); - hb_comp_iState = LOOKUP; - pComp->pLex->lasttok = yytext; - return NIL; - } - -([^\x22\n]|\\\x22)*\x22 { BEGIN 0; - yytext[--yyleng] = '\0'; - { - ULONG len = yyleng; - hb_strRemEscSeq( yytext, &len ); - yyleng = len; - } - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, yytext, HB_IDENT_COPY ); - hb_comp_iState = LITERAL; - - return LITERAL; - } - -[^\x27\n]*\n { BEGIN 0; - unput( '\n' ); - yytext[--yyleng] = '\0'; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_STRING_TERMINATOR, yytext, NULL ); - hb_comp_iState = LOOKUP; - pComp->pLex->lasttok = yytext; - - return NIL; - } - -[^\x27\n]*\x27 { BEGIN 0; - yytext[--yyleng] = '\0'; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, yytext, HB_IDENT_COPY ); - hb_comp_iState = LITERAL; - - return LITERAL; - } - -[^\x22\n]*\x22 { BEGIN 0; - yytext[--yyleng] = '\0'; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, yytext, HB_IDENT_COPY ); - hb_comp_iState = LITERAL; - - return LITERAL; - } - -[^\x22\n]*\n { BEGIN 0; - unput( '\n' ); - yytext[--yyleng] = '\0'; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_STRING_TERMINATOR, yytext, NULL ); - hb_comp_iState = LOOKUP; - pComp->pLex->lasttok = yytext; - - return NIL; - } - -.*\n { - /* Preprocessed strings can contain embeded ] chars, for example - #translate TEST_STRING( ) => # - ? TEST_STRING( "['']" ) is preprocessed into ["['']"] so the string - terminator is "] pair - ? TEST_STRING( ['""'] ) is preprocessed into \[\['""'\]\] so the string - terminator is \]\] pair - There is however a single problem: any string with nested [] - created by the preprocessor is compiled correctly in Clipper but - the same string passed directly in the code is compiled until - the first closing bracket is found! We are not following it here - because at this moment there is no possibility to distinguish - strings created by the preprocessor. - */ - char StopChar = yytext[ 0 ]; - int iFirstPos = 0; - BEGIN 0; - - if( (StopChar == '"') || (StopChar == '\'') || (StopChar == '[') ) - { - int i; - if( StopChar == '[' ) - StopChar = ']'; - for( i = 0; i < yyleng-1; ++i ) - { - if( (yytext[ i ] == StopChar) && yytext[ i + 1 ] == ']' ) - { - /* "] or '] terminator was found */ - yyless( i+2 ); - yytext[ i+1 ] = '\0'; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, yytext, HB_IDENT_COPY ); - hb_comp_iState = LITERAL; - - return LITERAL; - } - else if( (yytext[ i ] == ']') && iFirstPos == 0 ) - iFirstPos = i; - } - if( iFirstPos > 0 ) - { - yyless( iFirstPos+1 ); - yytext[ iFirstPos ] = '\0'; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, yytext, HB_IDENT_COPY ); - hb_comp_iState = LITERAL; - - return LITERAL; - } - } - else - { - /* look for the first closing ] character */ - int i; - for( i = 0; i < yyleng - 1; ++i ) - { - if( yytext[ i ] == ']' ) - { - yyless( i+1 ); - yytext[ i ] = '\0'; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, yytext, HB_IDENT_COPY ); - hb_comp_iState = LITERAL; - - return LITERAL; - } - } - } - /* If we are here then the terminator was not found - report an error */ - unput( '\n' ); - yytext[--yyleng] = '\0'; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_STRING_TERMINATOR, yytext, NULL ); - hb_comp_iState = LOOKUP; - pComp->pLex->lasttok = yytext; - - return NIL; -} - -.*\n { - /* Preprocessed strings can contain embeded ] chars - look for the last - closing ']' - */ - int i; - - BEGIN 0; - yy_breakFlex(); - for( i = yyleng-1; i; --i ) - { - if( yytext[ i ] == ']' ) - { - /* ] terminator was found */ - yyless( i+1 ); - yytext[ i ] = '\0'; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, yytext, HB_IDENT_COPY ); - hb_comp_iState = LITERAL; - - return LITERAL; - } - } -} - -\( { BEGIN STRING4; return( '(' ); } -. { BEGIN 0; unput( yytext[ yyleng-1 ] ); } - -.*\]\)\n { BEGIN 0; - unput( '\n' ); - unput( ')' ); - yyleng -= 3; - yytext[ yyleng ] = '\0'; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, yytext, HB_IDENT_COPY ); - hb_comp_iState = LITERAL; - - return LITERAL; - } -. { BEGIN STRING3; unput( yytext[ yyleng-1 ] ); } - -%{ -/* ************************************************************************ */ -%} - -{SpaceTab} ; - -\n { - hb_comp_iState = LOOKUP; - pComp->pLex->lasttok = "\n"; - return '\n'; - } -%{ -/* ************************************************************************ */ -%} -; { - #ifdef DEBUG_NEWLINE - printf( "New Line\n" ); - #endif - - yy_set_bol(1); - hb_comp_iState = LOOKUP; - pComp->pLex->lasttok = ";"; - return ';'; - } -%{ -/* ************************************************************************ */ -%} -"announce"|"announc"|"announ"|"annou"|"anno" { - hb_comp_iState =IDENTIFIER; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - return ANNOUNCE; - } -%{ -/* ************************************************************************ */ -%} -"begin"{Separator}+"sequ"("ence"|"enc"|"en"|"e")? { - pComp->pLex->lasttok = yytext; - return BEGINSEQ; - } -%{ -/* ************************************************************************ */ -%} -"break" { if( hb_comp_iState == LOOKUP ) - BEGIN BREAK_; - else - { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -{Separator}* ; -[\n;] { /* at the end of line */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - return BREAK; - } -[\[] { BEGIN 0; -/* NOTE: Clipper does not like break[] in any context - * There are no resons to limit this use in Harbour. - */ - unput( yytext[ yyleng-1 ] ); - if( HB_COMP_ISSUPPORTED( HB_COMPFLAG_HARBOUR ) ) - { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "BREAK", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - else - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, yytext, NULL ); - } -(":="|"+="|"-="|"->"|"*="|"/="|"^="|"==") { /* operators */ - BEGIN 0; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "BREAK", HB_IDENT_STATIC ); - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } -("++"|"--") { /* operators */ - /* NOTE: It is not possible to distinguish between - * break++ and break ++i - * For this reason we are allowing the BREAK statement only - */ - BEGIN 0; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "BREAK", HB_IDENT_STATIC ); - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - hb_comp_iState =BREAK; - return BREAK; - } -[\=\(] { /* operators = ( */ - BEGIN 0; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "BREAK", HB_IDENT_STATIC ); - unput( yytext[ yyleng-1 ] ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } -. { /* all other cases */ - /* NOTE: This state includes break&var - */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState =BREAK; - return BREAK; - } -%{ -/* ************************************************************************ */ -%} -"case" BEGIN CASE_; -{Separator}* ; -[\:\=\|\$\%\*\,\/\]\)\}\^] { /* there is an operator after "case" */ - BEGIN 0; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "CASE", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - unput( yytext[ yyleng-1 ] ); - return IDENTIFIER; - } -("+="|"-="|"->") { /* operators */ - BEGIN 0; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "CASE", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - return IDENTIFIER; - } -("::") { /* send operators */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - if( HB_COMP_PARAM->wCaseCounter == 0 && HB_COMP_PARAM->wSwitchCounter == 0 ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_CASE, NULL, NULL ); - hb_comp_iState =CASE; - return CASE; - } -(\n|.) { /* not operator */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { /* it is first item in the line */ - if( HB_COMP_PARAM->wCaseCounter == 0 && HB_COMP_PARAM->wSwitchCounter == 0 ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_CASE, NULL, NULL ); - hb_comp_iState =CASE; - return CASE; - } - else - { /* there is another item in line already */ - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "CASE", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -%{ -/* ************************************************************************ */ -%} -"_procreq_(" { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "_PROCREQ_", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return PROCREQ; - } -%{ -/* ************************************************************************ */ -%} - -"decl"|"decla"|"declar"|"declare" { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - if( hb_comp_iState == DO ) - { - hb_comp_iState = IDENTIFIER; - return IDENTIFIER; - } - else - BEGIN DECLARE_; -} -{Separator}+[_a-zA-Z] { /* an Identifier after DECLARE */ - unput( yytext[ yyleng-1 ] ); - BEGIN DECLARE_ID_; -} -{Separator}+[\&] { /* a macro after DECLARE */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState = PRIVATE; - return PRIVATE; -} -.|\n { /* any other character after DECLARE */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState = IDENTIFIER; - return IDENTIFIER; -} - -({Identifier}|{MacroTxt}){Separator}*[\n\,\[\:\;] { /* variable declaration */ - BEGIN 0; - yyless(0); - hb_comp_iState = PRIVATE; - return PRIVATE; -} - -({Identifier}|{MacroTxt}){Separator}*"as"{Separator}+ { /* variable declaration */ - BEGIN 0; - yyless(0); - hb_comp_iState = PRIVATE; - return PRIVATE; -} - -.|\n { - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState = DECLARE; - return DECLARE; -} -%{ -/* ************************************************************************ */ -%} -"opti"|"optio"|"option"|"optiona"|"optional" { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - return OPTIONAL; -} -%{ -/* ************************************************************************ */ -%} -"do" BEGIN DO_; -{Separator}+"case" { /* DO CASE statement */ - BEGIN 0; - hb_comp_iState =DOCASE; - pComp->pLex->lasttok = yytext; - return DOCASE; - } -{Separator}+"while" { /* DO WHILE found -move it to WHILE state */ - /* NOTE: we cannot decide here if it is DO WHILE - * or DO while [WITH ] - */ - BEGIN 0; - hb_comp_iState =DO; - yyless( yyleng-5 ); - } -{Separator}+"whil" { /* DO WHILE found -move it to WHILE state */ - /* NOTE: we cannot decide here if it is DO WHILE - * or DO while [WITH ] - */ - BEGIN 0; - hb_comp_iState =DO; - yyless( yyleng-4 ); - } -{Separator}+[\&] { /* 'DO &id WITH' */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { /* it is first item in the line */ - hb_comp_iState =DO; - pComp->pLex->lasttok = yytext; - return DO; - } - else - { /* there is another item in line already */ - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "DO", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -{Separator}+[_a-zA-Z] { /* an identifier 'DO id WITH' */ - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { /* it is first item in the line */ - BEGIN DOIDENT_; - } - else - { /* there is another item in line already */ - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "DO", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - BEGIN 0; - return IDENTIFIER; - } - } -{Separator}*(.|\n) { /* end of line or any operator */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "DO", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } -{Identifier} { /* DO identifier WITH */ - BEGIN 0; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, yytext, HB_IDENT_COPY ); - hb_comp_iState =IDENTIFIER; - return DOIDENT; - } -%{ -/* ************************************************************************ */ -%} -"descend" { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "DESCEND", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return DESCEND; - } -%{ -/* ************************************************************************ */ -%} -"else" { /* ELSE can be used in one context only */ - if( HB_COMP_PARAM->wIfCounter == 0 ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_UNMATCHED_ELSE, NULL, NULL ); - hb_comp_iState =ELSE; - pComp->pLex->lasttok = yytext; - return ELSE; - } -"elseif" { /* ELSEIF can be used in one context only */ - if( HB_COMP_PARAM->wIfCounter == 0 ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_UNMATCHED_ELSEIF, NULL, NULL ); - hb_comp_iState =ELSEIF; - pComp->pLex->lasttok = yytext; - return ELSEIF; - } -"end"{Separator}+"sequ"("ence"|"enc"|"en"|"e")? { - if( HB_COMP_PARAM->wSeqCounter == 0 ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_ENDIF, NULL, NULL ); - pComp->pLex->lasttok = yytext; - return END; - } -%{ -/* ************************************************************************ */ -%} - -"endif"|"endi" { /* ENDIF can be used in one context only */ - if( HB_COMP_PARAM->wIfCounter == 0 ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_ENDIF, NULL, NULL ); - pComp->pLex->lasttok = yytext; - return ENDIF; - } -"endc"("ase"|"as"|"a")? { /* ENDCASE can be used in one context only */ - if( HB_COMP_PARAM->wCaseCounter == 0 ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_ENDCASE, NULL, NULL ); - pComp->pLex->lasttok = yytext; - return ENDCASE; - } -"enddo"|"endd" { /* ENDDO can be used in one context only */ - if( HB_COMP_PARAM->wWhileCounter == 0 ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_ENDDO, NULL, NULL ); - pComp->pLex->lasttok = yytext; - return ENDDO; - } -%{ -/* ************************************************************************ */ -%} -"end" { BEGIN END_; } -{Separator}* ; -[\[\(] { /* array, function call */ - BEGIN 0; - if( hb_comp_iState == LOOKUP ) - { /* Clipper does not like end[] & end() at the begining of line */ - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_ENDIF, NULL, NULL ); - } - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "END", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - unput( yytext[ yyleng-1 ] ); - return IDENTIFIER; - } -("->"|"++"|"--") { /* operators */ - BEGIN 0; - if( hb_comp_iState == LOOKUP ) - { /* Clipper does not like end-> & end++ at the begining of line */ - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_ENDIF, NULL, NULL ); - } - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "END", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - return IDENTIFIER; - } -[\+\-\:\=\|\$\%\*\,\/\[\]\)\}\^] { /* there is an operator after "end" */ - BEGIN 0; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "END", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - unput( yytext[ yyleng-1 ] ); - return IDENTIFIER; - } -(.|\n) { /* not operator */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { /* it is first item in the line */ - hb_comp_iState =END; - return END; - } - else - { /* there is another item in line already */ - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "END", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -%{ -/* ************************************************************************ */ -%} - -"exit" { - hb_comp_iState =IDENTIFIER; - pComp->pLex->lasttok = yytext; - return EXIT; - } -%{ -/* ************************************************************************ */ -%} -"exte"|"exter"|"extern"|"externa"|"external" { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - hb_comp_iState =IDENTIFIER; - return EXTERN; - } -%{ -/* ************************************************************************ */ -%} -"_fie"|"_fiel"|"_field" { BEGIN FIELD_; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - } - -"fiel"|"field" { BEGIN FIELD_; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - } -{Separator}+[_a-zA-Z] { /* an identifier after the FIELD */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { - hb_comp_iState =FIELD; - return FIELD; - } - else - { - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -{Separator}*"->" { /* alias expression */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - hb_comp_iState =FIELD; - return FIELD; - } -.|\n { - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } -%{ -/* ************************************************************************ */ -%} -"for" { BEGIN FOR_; } -{Separator}+"each" { BEGIN FOREACH_;} -{Separator}+[&_a-zA-Z] { /* an identifier or a macro after the FOR */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { - hb_comp_iState =FOR; - pComp->pLex->lasttok = yytext; - pComp->pLex->lasttok = yytext; - return FOR; - } - else - { /* for example: DO for WITH variable */ - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "FOR", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -{Separator}*[\(] { /* function call */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { /* Clipper always assume FOR (somevar):=1 TO ... here */ - hb_comp_iState =FOR; - pComp->pLex->lasttok = yytext; - return FOR; - } - else - { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "FOR", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -.|\n { /* there is no identifier after "FOR" */ - BEGIN 0; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "FOR", HB_IDENT_STATIC ); - unput( yytext[ yyleng-1 ] ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } -{Separator}*[\:\=] { /* FOR each:= or FOR each= */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - unput( 'h' ); unput( 'c' ); unput( 'a' ); unput( 'e' ); - hb_comp_iState = FOR; - pComp->pLex->lasttok = yytext; - return FOR; - } -. { - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState = FOREACH; - pComp->pLex->lasttok = yytext; - return FOREACH; - } -%{ -/* ************************************************************************ */ -%} -"func"|"funct"|"functi"|"functio"|"function" { BEGIN FUNCTION_; } -{Separator}+[_a-zA-Z] { - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState=FUNCTION; - pComp->pLex->lasttok = yytext; - return FUNCTION; - } -.|\n { /* Clipper needs FUNCTION in one context only */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, ((yytext[ yyleng-1 ]=='\n')?"FUNCTION":yytext), NULL ); - } - -%{ -/* ************************************************************************ */ -%} - -"hb_inline" { - - HB_SYMBOL_UNUSED( pComp ); - - /* NOTE: hb_compiLineINLINE is being RESET in ppcomp.c - hb_pp_Internal() */ - - if( ! HB_COMP_ISSUPPORTED( HB_COMPFLAG_HB_INLINE ) ) - { - pComp->pLex->lasttok = yylval_ptr->string = "HB_INLINE"; - hb_comp_iState = IDENTIFIER; - return IDENTIFIER; - } - - if( hb_comp_iLineINLINE ) - { - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_TOOMANY_INLINE, "on the same line", NULL ); - } - else - { - #define INLINE_NORMAL 0 - #define INLINE_SINGLE_QUOT 1 - #define INLINE_DOUBLE_QUOT 2 - #define INLINE_COMMENT 3 - - char sBuffer[ YY_BUF_SIZE ], *pBuffer, sInlineSym[] = "HB_INLINE_0", cMode = INLINE_NORMAL; - int iSize, iBraces = 0; - PINLINE pInline; - - hb_comp_iLineINLINE = hb_pp_line( HB_COMP_PARAM->pLex->pPP ) + 1; - hb_pp_StreamBlock = HB_PP_STREAM_DUMP_C; - - sInlineSym[10] = hb_comp_cInlineID++; - - switch( sInlineSym[10] ) - { - case '9' + 1 : - sInlineSym[10] = 'A'; - break; - - case 'Z' + 1 : - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_TOOMANY_INLINE, NULL, NULL ); - break; - } - - pInline = hb_compInlineAdd( pComp, hb_compIdentifierNew( HB_COMP_PARAM, sInlineSym, HB_IDENT_COPY ), hb_pp_line( pComp->pLex->pPP ) + 1 ); - - DigestInline: - - YY_INPUT( (char*) sBuffer, iSize, YY_BUF_SIZE ); - if( iSize == 0 ) - { - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_INVALID_INLINE, HB_COMP_PARAM->functions.pLast->szName, NULL ); - hb_pp_StreamBlock = 0; - return '\n'; - } - pBuffer = (char*) sBuffer; - - while( *pBuffer ) - { - switch( cMode ) - { - case INLINE_NORMAL : - if( *pBuffer == '{' ) - { - iBraces++; - } - else if( *pBuffer == '}' && iBraces > 1 ) - { - iBraces--; - } - else if( *pBuffer == '}' ) - { - hb_pp_StreamBlock = 0; - break; - } - else if( *pBuffer == '\'' ) - { - cMode = INLINE_SINGLE_QUOT; - } - else if( *pBuffer == '"' ) - { - cMode = INLINE_DOUBLE_QUOT; - } - else if( *pBuffer == '/' && *(pBuffer+1) == '/' ) - { - goto SaveInline; - } - else if( *pBuffer == '/' && *(pBuffer+1) == '*' ) - { - pBuffer++; - cMode = INLINE_COMMENT; - } - break; - - case INLINE_SINGLE_QUOT : - if( *pBuffer == '\\' ) - { - pBuffer++; - } - else if( *pBuffer == '\'' ) - { - cMode = INLINE_NORMAL; - } - break; - - case INLINE_DOUBLE_QUOT : - if( *pBuffer == '\\' ) - { - pBuffer++; - } - else if( *pBuffer == '"' ) - { - cMode = INLINE_NORMAL; - } - break; - - case INLINE_COMMENT : - if( *pBuffer == '*' && *(pBuffer+1) == '/' ) - { - pBuffer++; - cMode = INLINE_NORMAL; - } - break; - } - - pBuffer++; - } - - SaveInline: - - iSize = strlen( (char*) sBuffer ); - if( pInline->pCode == NULL ) - { - pInline->pCode = (BYTE *) hb_strdup( sBuffer ); - } - else - { - pInline->pCode = (BYTE *) hb_xrealloc( pInline->pCode, pInline->lPCodeSize + iSize + 1 ); - memcpy( (char *) (pInline->pCode + pInline->lPCodeSize), sBuffer, iSize + 1 ); - } - pInline->lPCodeSize += iSize; - - if( hb_pp_StreamBlock ) - { - goto DigestInline; - } - else - { - if( hb_comp_iLanguage != HB_LANG_C ) - { - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_REQUIRES_C, NULL, NULL ); - hb_xfree( ( void * ) pInline->pCode ); - hb_xfree( ( void * ) pInline->szFileName ); - hb_xfree( ( void * ) pInline ); /* NOTE: szName will be released by hb_compSymbolKill() */ - } - - hb_comp_iLinePRG = hb_pp_line( HB_COMP_PARAM->pLex->pPP ); - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, sInlineSym, HB_IDENT_COPY ); - return IDENTIFIER; - } - } - } -%{ -/* ************************************************************************ */ -%} -"iif" { - if( hb_comp_iState == FUNCTION || hb_comp_iState == PROCEDURE ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, "IIF", NULL ); - else - BEGIN IIF_; - /* Note: In Clipper: - IIF( expression ) - ENDIF - is not a valid statement -this is why we have to separate - IF and IIF - */ - } -{Separator}* ; -"(" { - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState=IIF; - pComp->pLex->lasttok = yytext; - return IIF; - } -[^\(] { - BEGIN 0; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, ((yytext[ yyleng-1 ]=='\n')?"IIF":yytext), NULL ); - } -%{ -/* ************************************************************************ */ -%} -"if" { - if( hb_comp_iState == FUNCTION || hb_comp_iState == PROCEDURE ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, "IF", NULL ); - else - BEGIN IF_; - } -{Separator}* ; -"(" { BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - hb_comp_iState =IF; - else - hb_comp_iState =IIF; - pComp->pLex->lasttok = yytext; - return hb_comp_iState; - } -[\)\]\/\^\*\%\=\$\@] { BEGIN 0; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX2, yytext, "IF" ); - } -"->" { BEGIN 0; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX2, yytext, "IF" ); - } -\n { BEGIN 0; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, "IF", NULL ); - } -("++"|"--")/[\n] { BEGIN 0; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX2, yytext, "IF" ); - } -. { BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState =IF; - pComp->pLex->lasttok = yytext; - return IF; - } -%{ -/* ************************************************************************ */ -%} -"in" { hb_comp_iState =IDENTIFIER; pComp->pLex->lasttok = yytext; - return IN; } -%{ -/* ************************************************************************ */ -%} -"init" BEGIN INIT_; -{Separator}+[fFpP] { /* FUNCTION or PROCEDURE after INIT */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { /* it is first item in the line */ - hb_comp_iState =INIT; - pComp->pLex->lasttok = yytext; - return INIT; - } - else - { /* there is another item in line already */ - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "INIT", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -.|\n { /* any character (not identifier) after INIT */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "INIT", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } -%{ -/* ************************************************************************ */ -%} -"#"{Separator}*"line" { pComp->pLex->lasttok = yytext; return LINE; } -%{ -/* ************************************************************************ */ -%} -"loca"|"local" { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - hb_comp_iState =IDENTIFIER; - return LOCAL; - } -%{ -/* ************************************************************************ */ -%} -"loop" { hb_comp_iState =IDENTIFIER; pComp->pLex->lasttok = yytext; - return LOOP; } -%{ -/* ************************************************************************ */ -%} -"memv"|"memva"|"memvar" { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - hb_comp_iState =IDENTIFIER; - return MEMVAR; - } -%{ -/* ************************************************************************ */ -%} -"next" BEGIN NEXT_; -{Separator}* ; -[\n\;] { /* at the end of line */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { /* it is first item in the line */ - if( HB_COMP_PARAM->wForCounter == 0 ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_NEXTFOR, NULL, NULL ); - hb_comp_iState =NEXT; - pComp->pLex->lasttok = yytext; - return NEXT; - } - else - { /* there is another item in line already */ - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "NEXT", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -[\[\(] { /* array, function call */ - BEGIN 0; - if( hb_comp_iState == LOOKUP ) - { /* Clipper does not like NEXT[] & NEXT() at the begining of line */ - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_NEXTFOR, NULL, NULL ); - } - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "NEXT", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - unput( yytext[ yyleng-1 ] ); - return IDENTIFIER; - } -("->"|"++"|"--") { /* operators */ - BEGIN 0; - if( hb_comp_iState == LOOKUP ) - { /* Clipper does not like next-> & next++ at the begining of line */ - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_NEXTFOR, NULL, NULL ); - } - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "NEXT", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - return IDENTIFIER; - } -[^_a-zA-Z] { /* there is no identifier after "next" */ - BEGIN 0; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "NEXT", HB_IDENT_STATIC ); - unput( yytext[ yyleng-1 ] ); - return IDENTIFIER; - } -. { /* an identifier follows NEXT statement */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { - if( HB_COMP_PARAM->wForCounter == 0 ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_NEXTFOR, NULL, NULL ); - hb_comp_iState =NEXT; - pComp->pLex->lasttok = yytext; - return NEXT; - } - else - { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "NEXT", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -%{ -/* ************************************************************************ */ -%} -"nil" { hb_comp_iState =LITERAL; pComp->pLex->lasttok = yytext; - return NIL; } -%{ -/* ************************************************************************ */ -%} -"othe"|"other"|"otherw"|"otherwi"|"otherwis"|"otherwise" { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - BEGIN OTHERWISE_; - } -{Separator}* ; -[\n\;] { /* end of line */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { /* it is the first item in the line */ - if( HB_COMP_PARAM->wCaseCounter == 0 && HB_COMP_PARAM->wSwitchCounter == 0 ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_CASE, NULL, NULL ); - hb_comp_iState = OTHERWISE; - return OTHERWISE; - } - else - { /* there is another item in line already */ - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -. { - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState = IDENTIFIER; - return IDENTIFIER; - } -%{ -/* ************************************************************************ */ -%} -"para"|"param"|"parame"|"paramet"|"paramete"|"parameter"|"parameters" { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - hb_comp_iState =IDENTIFIER; - return PARAMETERS; - } -%{ -/* ************************************************************************ */ -%} -"priv"("ate"|"at"|"a")? { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - hb_comp_iState =IDENTIFIER; - return PRIVATE; - } -%{ -/* ************************************************************************ */ -%} -"proc"|"proce"|"proced"|"procedu"|"procedur"|"procedure" BEGIN PROCEDURE_; -{Separator}+[_a-zA-Z] { - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState = PROCEDURE; - pComp->pLex->lasttok = yytext; - return PROCEDURE; - } -.|\n { /* Clipper needs PROCEDURE in one context only */ - BEGIN 0; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_SYNTAX, ((yytext[ yyleng-1 ]=='\n')?"PROCEDURE":yytext), NULL ); - } -%{ -/* ************************************************************************ */ -%} -"publ"("ic"|"i")? { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - hb_comp_iState =IDENTIFIER; - return PUBLIC; - } -%{ -/* ************************************************************************ */ -%} -"qself"{SpaceTab}*[(]{SpaceTab}*[)] { pComp->pLex->lasttok = yytext; return SELF; } -%{ -/* ************************************************************************ */ -%} -"reco"|"recov"|"recove"|"recover" { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - BEGIN RECOVER_; - } -{Separator}* ; -\n { /* end of line */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { /* it is first item in the line */ - hb_comp_iState = RECOVER; - return RECOVER; - } - else - { /* there is another item in line already */ - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -("using"|"usin") { /* USING */ - BEGIN 0; - hb_comp_iState = RECOVERUSING; - return RECOVERUSING; - } -. { /* all other cases */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } -%{ -/* ************************************************************************ */ -%} -"retu"|"retur"|"return" { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - BEGIN RETURN_; - } -{Separator}* -[\&_a-zA-Z0-9] { /* an identifier, numbers or macro */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { /* it is the first item in the line */ - hb_comp_iState = RETURN; - return RETURN; - } - else - { /* there is another item in line already */ - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -("+="|"-="|"->") { /* operators */ - BEGIN 0; - hb_comp_iState =IDENTIFIER; - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - return IDENTIFIER; - } -("++"|"--") { /* operators */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - if( hb_comp_iState == LOOKUP ) - { /* it is the first item in the line */ - hb_comp_iState = RETURN; - return RETURN; - } - else - { /* there is another item in line already */ - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -"::" { /* SELF operator */ - BEGIN 0; - hb_comp_iState = RETURN; - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - return RETURN; - } -[\n\;\(\[\{\"\'\.\-\+\!] { - /* EOL or '()', '[]', '{}', '""', "''" , '.T.', '-', '+', '!' */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { /* it is the first item in the line */ - hb_comp_iState = RETURN; - return RETURN; - } - else - { /* there is another item in line already */ - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -. { /* any other character after RETURN */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } -%{ -/* ************************************************************************ */ -%} -"stat"|"stati"|"static" { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - hb_comp_iState = IDENTIFIER; - return STATIC; - } -%{ -/* ************************************************************************ */ -%} -"step" { hb_comp_iState = IDENTIFIER; return STEP; } -%{ -/* ************************************************************************ */ -%} -"switch" BEGIN SWITCH_; -{Separator}* ; -[\:\=\|\$\%\*\,\/\]\)\}\^] { /* there is an operator after "switch" */ - BEGIN 0; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "SWITCH", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - unput( yytext[ yyleng-1 ] ); - return IDENTIFIER; - } -("+="|"-="|"->") { /* operators */ - BEGIN 0; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "SWITCH", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - return IDENTIFIER; - } -("::") { /* send operators */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - hb_comp_iState =DOSWITCH; - pComp->pLex->lasttok = yytext; - return DOSWITCH; - } -(\n|.) { /* not operator */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP ) - { /* it is first item in the line */ - hb_comp_iState =DOSWITCH; - pComp->pLex->lasttok = yytext; - return DOSWITCH; - } - else - { /* there is another item in line already */ - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "SWITCH", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -%{ -/* ************************************************************************ */ -%} -"to" { hb_comp_iState = IDENTIFIER; pComp->pLex->lasttok = yytext; - return TO; } -%{ -/* ************************************************************************ */ -%} -"while"|"whil" { BEGIN WHILE_; - /* store it for later use */ - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, yytext, HB_IDENT_COPY ); - } -{Separator}* ; -\n { /* end of line */ - BEGIN 0; - unput( '\n' ); - if( hb_comp_iState == DO ) - { /* we have DO while */ - return DOIDENT; - } - else - { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "WHILE", HB_IDENT_STATIC ); - return IDENTIFIER; - } - } -[\:\=\|\$\%\*\,\/\]\)\}\^] { /* there is an operator after "while" */ - BEGIN 0; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "WHILE", HB_IDENT_STATIC ); - unput( yytext[ yyleng-1 ] ); - return IDENTIFIER; - } -("+="|"-="|"->") { /* operators */ - BEGIN 0; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "WHILE", HB_IDENT_STATIC ); - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - return IDENTIFIER; - } -"::" { /* send operators */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - unput( yytext[ yyleng-2 ] ); - hb_comp_iState =WHILE; - return WHILE; - } -. { /* identifiers and literals */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == LOOKUP || hb_comp_iState == DO ) - { /* it is first item in the line or after DO or FIELD */ - hb_comp_iState =WHILE; - return WHILE; - } - else - { /* there is another item in line already */ - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "WHILE", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } -%{ -/* ************************************************************************ */ -%} -"with" BEGIN WITH_; -{Separator}* ; -\n { /* at the end of line */ - BEGIN 0; - unput( '\n' ); - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "WITH", HB_IDENT_STATIC ); - return IDENTIFIER; - } -"with" { - BEGIN 0; - yyless( yyleng-4 ); - if( hb_comp_iState == DO ) - { /* DO with WITH */ - hb_comp_iState =IDENTIFIER; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "WITH", HB_IDENT_STATIC ); - return IDENTIFIER; - } - else - { /* DO WITH with */ - hb_comp_iState =WITH; - pComp->pLex->lasttok = yytext; - return WITH; - } - } -"object" { - BEGIN 0; - if( hb_comp_iState == LOOKUP ) - { - hb_comp_iState = WITHOBJECT; - pComp->pLex->lasttok = yytext; - return WITHOBJECT; - } - else - { - yyless( yyleng-6 ); - hb_comp_iState =WITH; - pComp->pLex->lasttok = yytext; - return WITH; - } - - } -[\)] { /* ( with ) or with() */ - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - hb_comp_iState =IDENTIFIER; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "WITH", HB_IDENT_STATIC ); - return IDENTIFIER; - } -. { - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - if( hb_comp_iState == WHILE || - hb_comp_iState == DO || - hb_comp_iState == MACROVAR || - hb_comp_iState == MACROTEXT || - hb_comp_iState == IDENTIFIER || - hb_comp_iState == RSEPARATOR ) - { /* DO WITH */ - hb_comp_iState =WITH; - pComp->pLex->lasttok = yytext; - return WITH; - } - else - { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, "WITH", HB_IDENT_STATIC ); - hb_comp_iState =IDENTIFIER; - return IDENTIFIER; - } - } - -%{ -/* ************************************************************************ */ -%} -"\{"{Separator}*"\|".*/\n { /* codeblock scanning */ - /* - We have to know if the codeblock contains the macro - expression &var or &(var) - In case of &var we have to store in the pcode the source code - of the codeblock - the string with the whole codeblock - have to be saved. At runtime, this string is macro - expanded and the result string is next macro compiled to - create a codeblock - this is called 'the early macro evaluation'. - In contrast, the late macro evaluation &(var) creates - the codeblock at compile time - the macro is expanded - during the codeblock evaluation. - The following code: - //early evaluation - PRIVATE a - FOR i:=1 TO 3 - a:=STR(i) - cb[i] := {|| &a} //the same as cb[i] := &( '{||'+a+'}' ) - NEXT - .... - FOR i:=1 TO 3 - ? EVAL( cb[i] ) //prints '1','2','3' - NEXT - //late evaluation - FOR i:=1 TO 3 - a:=STR(i) - cb[i] := {|| &(a)} - NEXT - .... - FOR i:=1 TO 3 - ? EVAL( cb[i] ) //prints '3','3','3' - NEXT - */ - char *cText; - int iLen; - int iPos=0; - int iCode=1; - char cMark='\0'; - - yylval_ptr->asCodeblock.flags = 0; - cText = yytext+1; - iLen = 1; - - while( *cText || iLen < yyleng ) - { - iLen++; - if( *cText == '\'' && cMark == '\0' ) - cMark = '\''; - else if( *cText == '"' && cMark == '\0' ) - cMark = '"'; - else if( *cText == '[' && cMark == '\0' ) - cMark = ']'; - else if( *cText == cMark ) - cMark = '\0'; - else if( *cText == '|' && iPos == 0 ) - iPos = iLen; - else if( *cText == '&' && cMark == '\0' ) - { - yylval_ptr->asCodeblock.falgs |= HB_BLOCK_MACRO; - ++cText; - while( *cText == ' ' || *cText == '\t' ) - ++cText; - if( *cText == '(' ) - yylval_ptr->asCodeblock.flags |= HB_BLOCK_LATEEVAL; - --cText; - } - else if( *cText == '{' && cMark == '\0' ) - iCode++; - else if( *cText == '}' && cMark == '\0' ) - { - iCode--; - if( iCode == 0 ) - break; - } - cText++; - } - cMark = yytext[ iLen ]; - yylval_ptr->asCodeblock.string = (char *)hb_xgrab( iLen+1 ); - memcpy( (void *)yylval_ptr->asCodeblock.string, (void *)yytext, iLen ); - yylval_ptr->asCodeblock.string[iLen] = '\0'; - yylval_ptr->asCodeblock.length = iLen; - yyless( iPos ); /* restart scanning after '{|' */ - pComp->pLex->lasttok = yytext; - return CBSTART; - } - -%{ -/* ************************************************************************ */ -%} -"as"{Separator}+("arra"|"array") { pComp->pLex->lasttok = yytext; return AS_ARRAY; } -"as"{Separator}+("code"|"codeb"|"codebl"|"codeblo"|"codebloc"|"codeblock") { pComp->pLex->lasttok = yytext; return AS_BLOCK; } -"as"{Separator}+("stri"|"strin"|"string") { pComp->pLex->lasttok = yytext; return AS_CHARACTER; } -"as"{Separator}+("char"|"chara"|"charac"|"charact"|"characte"|"character") { pComp->pLex->lasttok = yytext; return AS_CHARACTER; } -"as"{Separator}+("clas"|"class") { pComp->pLex->lasttok = yytext; return AS_CLASS; } -"as"{Separator}+"date" { pComp->pLex->lasttok = yytext; return AS_DATE; } -"as"{Separator}+("logi"|"logic"|"logica"|"logical") { pComp->pLex->lasttok = yytext; return AS_LOGICAL; } -"as"{Separator}+("nume"|"numer"|"numeri"|"numeric") { pComp->pLex->lasttok = yytext; return AS_NUMERIC; } -"as"{Separator}+("obje"|"objec"|"object") { pComp->pLex->lasttok = yytext; return AS_OBJECT; } -"as"{Separator}+("usua"|"usual") { pComp->pLex->lasttok = yytext; return AS_VARIANT; } -"as"{Separator}+("anyt"|"anytyp"|"anytype") { pComp->pLex->lasttok = yytext; return AS_VARIANT; } - -"as"{Separator}+("arra"|"array"){Separator}+"of"{Separator}+("usua"|"usual") { pComp->pLex->lasttok = yytext; return AS_ARRAY; } -"as"{Separator}+("arra"|"array"){Separator}+"of"{Separator}+("anyt"|"anytyp"|"anytype") { pComp->pLex->lasttok = yytext; return AS_ARRAY; } -"as"{Separator}+("arra"|"array"){Separator}+"of"{Separator}+("arra"|"array") { pComp->pLex->lasttok = yytext; return AS_ARRAY_ARRAY; } -"as"{Separator}+("arra"|"array"){Separator}+"of"{Separator}+("code"|"codeb"|"codebl"|"codeblo"|"codebloc"|"codeblock") { pComp->pLex->lasttok = yytext; return AS_BLOCK_ARRAY; } -"as"{Separator}+("arra"|"array"){Separator}+"of"{Separator}+("stri"|"strin"|"string") { pComp->pLex->lasttok = yytext; return AS_CHARACTER_ARRAY; } -"as"{Separator}+("arra"|"array"){Separator}+"of"{Separator}+("char"|"chara"|"charac"|"charact"|"characte"|"character") { pComp->pLex->lasttok = yytext; return AS_CHARACTER_ARRAY; } -"as"{Separator}+("arra"|"array"){Separator}+"of"{Separator}+("clas"|"class") { pComp->pLex->lasttok = yytext; return AS_CLASS_ARRAY; } -"as"{Separator}+("arra"|"array"){Separator}+"of"{Separator}+"date" { pComp->pLex->lasttok = yytext; return AS_DATE_ARRAY; } -"as"{Separator}+("arra"|"array"){Separator}+"of"{Separator}+("logi"|"logic"|"logica"|"logical") { pComp->pLex->lasttok = yytext; return AS_LOGICAL_ARRAY; } -"as"{Separator}+("arra"|"array"){Separator}+"of"{Separator}+("nume"|"numer"|"numeri"|"numeric") { pComp->pLex->lasttok = yytext; return AS_NUMERIC_ARRAY; } -"as"{Separator}+("arra"|"array"){Separator}+"of"{Separator}+("obje"|"objec"|"object") { pComp->pLex->lasttok = yytext; return AS_OBJECT_ARRAY; } - -"_hb_class" { YY_OPERATOR_RET( DECLARE_CLASS ); } -"_hb_member" { YY_OPERATOR_RET( DECLARE_MEMBER ); } - -%{ -/* ************************************************************************ */ -%} -"#" YY_OPERATOR_RET( NE1 ); -"=" YY_OPERATOR_RET( yytext[ 0 ] ); -"+" YY_OPERATOR_RET( yytext[ 0 ] ); -"-" YY_OPERATOR_RET( yytext[ 0 ] ); -"*" YY_OPERATOR_RET( yytext[ 0 ] ); -[\/] YY_OPERATOR_RET( yytext[ 0 ] ); -"%" YY_OPERATOR_RET( yytext[ 0 ] ); -"$" YY_OPERATOR_RET( yytext[ 0 ] ); -"<>"|"!=" YY_OPERATOR_RET( NE2 ); -":=" YY_OPERATOR_RET( INASSIGN ); -"==" YY_OPERATOR_RET( EQ ); -"++" YY_OPERATOR_RET( INC ); -"--" YY_OPERATOR_RET( DEC ); -"->" YY_OPERATOR_RET( ALIASOP ); -"<=" YY_OPERATOR_RET( LE ); -">=" YY_OPERATOR_RET( GE ); -"+=" YY_OPERATOR_RET( PLUSEQ ); -"-=" YY_OPERATOR_RET( MINUSEQ ); -"*=" YY_OPERATOR_RET( MULTEQ ); -"/=" YY_OPERATOR_RET( DIVEQ ); -"^=" YY_OPERATOR_RET( EXPEQ ); -"%=" YY_OPERATOR_RET( MODEQ ); -"**"|"^" YY_OPERATOR_RET( POWER ); -".and." YY_OPERATOR_RET( AND ); -".or." YY_OPERATOR_RET( OR ); -"!"|".not." YY_OPERATOR_RET( NOT ); -"::" unput( ':' ); unput( 'f' ); unput( 'l' ); unput( 'e' ); unput( 'S' ); -"..." YY_OPERATOR_RET( EPSILON ); -[,\|\#\&\.\:\<\>\@] YY_OPERATOR_RET( yytext[ 0 ] ); -[\{] YY_TOKEN_RET( LARRAY, yytext[ 0 ] ); -[\}] YY_TOKEN_RET( RARRAY, yytext[ 0 ] ); -[\]] YY_TOKEN_RET( RINDEX, yytext[ 0 ] ); -[\(] YY_TOKEN_RET( LSEPARATOR, yytext[ 0 ] ); -[\)] YY_TOKEN_RET( RSEPARATOR, yytext[ 0 ] ); - -[\x00-\x1F] pComp->pLex->lasttok = yytext; return yytext[ 0 ]; /* see below */ -[\~\`\?\_\\] pComp->pLex->lasttok = yytext; return yytext[ 0 ]; /* see below */ -[\x7F-\xFF] { - /* This have to be the last rule - any nonstandard and not handled - * characters should go to grammar analyser instead of printing it - * on stdout. - */ - pComp->pLex->lasttok = yytext; - return yytext[ 0 ]; - } - -%{ -/* ************************************************************************ */ -%} - -{InvalidNumber} BEGIN INVALIDNUM_; pComp->pLex->lasttok = yylval_ptr->string = hb_strdup( yytext ); -("."|{Separator}+) { - BEGIN 0; - hb_xfree( yylval_ptr->string ); - pComp->pLex->lasttok = NULL; - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'E', HB_COMP_ERR_NUMERIC_FORMAT, NULL, NULL ); - } -. { - int iRet; - char *pTmp = yylval_ptr->string; - BEGIN 0; - unput( yytext[ yyleng-1 ] ); - unput( '.' ); - yylval_ptr->string[ strlen(yylval_ptr->string) - 1 ] = '\0'; - pComp->pLex->lasttok = yylval_ptr->string; - iRet = yy_ConvertNumber( yylval_ptr, yylval_ptr->string ); - hb_xfree( pTmp ); - return iRet; - } - - -{Number} { pComp->pLex->lasttok = yytext; - return yy_ConvertNumber( yylval_ptr, yytext ); } - -{TrueValue} { YY_TOKEN_RET( RSEPARATOR, TRUEVALUE ); } -{FalseValue} { YY_TOKEN_RET( RSEPARATOR, FALSEVALUE ); } - -{Date} { pComp->pLex->lasttok = yytext; - return yy_ConvertDate( yylval_ptr, yytext ); } - -{MacroVar} { - if( yytext[ yyleng-1 ] == '.' ) - yytext[ yyleng-1 ] = '\0'; - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext+1 ), HB_IDENT_COPY ); - hb_comp_iState = MACROVAR; - return MACROVAR; - } - -{MacroEnd} { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - hb_comp_iState = MACROTEXT; - return MACROTEXT; - } - -{MacroId} { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - hb_comp_iState = MACROTEXT; - return MACROTEXT; - } - -{MacroTxt} { - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - hb_comp_iState = MACROTEXT; - return MACROTEXT; - } - - -{Identifier} { - if( strlen( yytext ) > HB_SYMBOL_NAME_LEN ) - { - yytext[ HB_SYMBOL_NAME_LEN ] = '\0'; - yyleng = HB_SYMBOL_NAME_LEN; - } - pComp->pLex->lasttok = yylval_ptr->string = hb_compIdentifierNew( HB_COMP_PARAM, hb_strupr( yytext ), HB_IDENT_COPY ); - hb_comp_iState = IDENTIFIER; - return IDENTIFIER; - } - -%{ -#ifdef __WATCOMC__ -/* enable warnings for unreachable code */ -#pragma warning 13 1 -#endif -%} - -%% - -int yy_lex_input( char *buffer, int iBufferSize ) -{ - /* FLEX is not MT safe :-( */ - HB_COMP_DECL = s_pComp; - char * szLine; - ULONG ulLen = 0; - - szLine = hb_pp_nextLine( HB_COMP_PARAM->pLex->pPP, &ulLen ); - - if( ulLen >= ( ULONG ) iBufferSize ) - hb_compGenError( HB_COMP_PARAM, hb_comp_szErrors, 'F', HB_COMP_ERR_BUFFER_OVERFLOW, NULL, NULL ); - else if( szLine ) - memcpy( buffer, szLine, ulLen + 1 ); - else - * buffer = '\0'; - - return ulLen; -} - -static int yy_ConvertNumber( YYSTYPE *yylval_ptr, char * szBuffer ) -{ - HB_LONG lNumber; - double dNumber; - int iDec, iWidth; - - if( hb_compStrToNum( szBuffer, strlen( szBuffer ), &lNumber, &dNumber, &iDec, &iWidth ) ) - { - yylval_ptr->valDouble.dNumber = dNumber; - yylval_ptr->valDouble.bDec = iDec; - yylval_ptr->valDouble.bWidth = iWidth; - yylval_ptr->valDouble.szValue = szBuffer; - return NUM_DOUBLE; - } - else - { - yylval_ptr->valLong.lNumber = lNumber; - yylval_ptr->valLong.szValue = szBuffer; - return NUM_LONG; - } -} - -static int yy_ConvertDate( YYSTYPE *yylval_ptr, char * szBuffer ) -{ - int year, month, day; - - hb_dateStrGet( szBuffer+2, &year, &month, &day ); - yylval_ptr->valLong.lNumber = hb_dateEncode( year, month, day ); - yylval_ptr->valLong.szValue = szBuffer; - - return NUM_DATE; -} - -void hb_compParserStop( HB_COMP_PTR pComp ) -{ - HB_SYMBOL_UNUSED( pComp ); - - yy_delete_buffer( yy_current_buffer ); -} diff --git a/harbour/src/macro/Makefile b/harbour/src/macro/Makefile index 1707a42188..c37cd3be50 100644 --- a/harbour/src/macro/Makefile +++ b/harbour/src/macro/Makefile @@ -4,26 +4,6 @@ ROOT := ../../ -# 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_macro -C -#LEX_SOURCE := macro.l -#LEX_HEADERS := \ -# hbsetup.h \ -# hberrors.h \ -# hbdefs.h \ -# hbmacro.h \ - #YACC_FLAGS := -p hb_macro YACC_SOURCE := macro.y YACC_DEPEND := macrolex.c diff --git a/harbour/src/macro/macro.l b/harbour/src/macro/macro.l deleted file mode 100644 index 2289d2c5da..0000000000 --- a/harbour/src/macro/macro.l +++ /dev/null @@ -1,376 +0,0 @@ -%option noyywrap -%option never-interactive -%{ -/* - * $Id$ - */ - -/* - * Harbour Project source code: - * Macro Compiler LEX rules - * - * Copyright 1999 Antonio Linares - * www - http://www.harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -/* Compile using: flex -i -8 -omacrol.c -Phb_comp -C macro.l - -NOTE: -C controls the speed/size ratio of generated scanner --Cf = fastest/biggest --CF --C = in between --Cm --Ce --Cem = slowest/smallest -*/ - -#define HB_MACRO_SUPPORT - -#include -#include -#include -#include - -#include "hbmacro.h" -#include "hbcomp.h" -#include "hbdate.h" - -#include "macroy.h" -#include "hbsetup.h" /* main configuration file */ -#include "hberrors.h" -#include "hbdefs.h" - -/* NOTE: these symbols are used internally in bison.simple - */ -#undef alloca -#define alloca hb_xgrab -#undef malloc -#define malloc hb_xgrab -#undef realloc -#define realloc hb_xrealloc -#undef free -#define free hb_xfree - - -/* declaration of yylex function - * NOTE: yylval is paassed automaticaly by bison if %pure_parser is used - */ -#undef YY_DECL -#define YY_DECL int yylex( YYSTYPE *yylval_ptr, HB_MACRO_PTR pMacro ) -#define YYLEX_PARAM pMacro - -/* code that fills input buffer - */ -#define YY_INPUT( buf, result, max_size ) result = 0; - - -#define LOOKUP 0 /* scan from the begining of line */ -#define SEPARATOR -1 -#define HB_FLEX_STATE ( ( PHB_MACRO_FLEX ) pMacro->pLex )->FlexState -typedef struct -{ - ULONG pos; /* current position inside of compiled string */ - int FlexState; /* internal flex state during parsing */ - YY_BUFFER_STATE pBuffer; /* FLEX buffer */ -} -HB_MACRO_FLEX, * PHB_MACRO_FLEX; - -%} - -%{ -#ifdef __WATCOMC__ -/* disable warnings for unreachable code */ -#pragma warning 13 9 -#endif -%} - -SpaceTab [ \t]+ -Number ([0-9]+)|([0-9]*\.[0-9]+)|(0x[0-9A-Fa-f]+) -InvalidNumber [0-9]+\. -Identifier (([a-zA-Z])|([_a-zA-Z][_a-zA-Z0-9]+)) -Date 0d[0-9]{8} - -MacroVar \&{Identifier}[\.]? -MacroEnd \&{Identifier}\.({Identifier})|([0-9]+) -MacroId ({Identifier}\&(({Identifier}[\.]?)|({Identifier}\.({Identifier})|([0-9]+)))) -MacroTxt ({MacroVar}|{MacroEnd}|{MacroId})+ - -%x STRING1 STRING2 STRING3 - -%% - - -"&"("'"|\"|\[) { hb_macroError( EG_SYNTAX, YYLEX_PARAM ); } - -' BEGIN STRING1; -\" BEGIN STRING2; - -\[ { - if( HB_FLEX_STATE == SEPARATOR ) - BEGIN STRING3; - else - return '['; - } - - -[^'^\n]* { hb_macroError( EG_SYNTAX, YYLEX_PARAM ); BEGIN 0; } -[^\"^\n]* { hb_macroError( EG_SYNTAX, YYLEX_PARAM ); BEGIN 0; } -[^\]]*\n { hb_macroError( EG_SYNTAX, YYLEX_PARAM ); BEGIN 0; } - -[^']*' { BEGIN 0; - HB_FLEX_STATE = LOOKUP; - yyleng--; - yytext[yyleng] = 0; - yylval_ptr->string = hb_strdup( yytext ); - return LITERAL; -} - -[^\"]*\" { BEGIN 0; - HB_FLEX_STATE = LOOKUP; - yyleng--; - yytext[yyleng] = 0; - yylval_ptr->string = hb_strdup( yytext ); - return LITERAL; -} - -[^\]]*\] { BEGIN 0; - HB_FLEX_STATE = LOOKUP; - yyleng--; - yytext[yyleng] = 0; - yylval_ptr->string = hb_strdup( yytext ); - return LITERAL; -} - -{SpaceTab} ; - -\n { HB_FLEX_STATE = LOOKUP; return '\n'; } - -%{ -/* ************************************************************************ */ -%} - -"_fie"|"_fiel"|"_field" { - HB_FLEX_STATE = LOOKUP; - return FIELD; -} - -"fiel"|"field" { - HB_FLEX_STATE = LOOKUP; - return FIELD; -} - -"iif" { - HB_FLEX_STATE = LOOKUP; - return IIF; -} - -"if" { - HB_FLEX_STATE = LOOKUP; - return IIF; -} - -"nil" { HB_FLEX_STATE = LOOKUP; return NIL; } - -"qself"{SpaceTab}*\({SpaceTab}*\) { HB_FLEX_STATE = LOOKUP; return SELF; } - -%{ -/* ************************************************************************ */ -%} - -"#" { HB_FLEX_STATE = SEPARATOR; return NE1; } -"<>"|"!=" { HB_FLEX_STATE = SEPARATOR; return NE2; } -":=" { HB_FLEX_STATE = SEPARATOR; return INASSIGN; } -"==" { HB_FLEX_STATE = SEPARATOR; return EQ; } -"++" { HB_FLEX_STATE = SEPARATOR; return INC; } -"--" { HB_FLEX_STATE = SEPARATOR; return DEC; } -"->" { HB_FLEX_STATE = SEPARATOR; return ALIASOP; } -"<=" { HB_FLEX_STATE = SEPARATOR; return LE; } -">=" { HB_FLEX_STATE = SEPARATOR; return GE; } -"+=" { HB_FLEX_STATE = SEPARATOR; return PLUSEQ; } -"-=" { HB_FLEX_STATE = SEPARATOR; return MINUSEQ; } -"*=" { HB_FLEX_STATE = SEPARATOR; return MULTEQ; } -"/=" { HB_FLEX_STATE = SEPARATOR; return DIVEQ; } -"^=" { HB_FLEX_STATE = SEPARATOR; return EXPEQ; } -"%=" { HB_FLEX_STATE = SEPARATOR; return MODEQ; } -"**"|"^" { HB_FLEX_STATE = SEPARATOR; return POWER; } -".and." { HB_FLEX_STATE = SEPARATOR; return AND; } -".or." { HB_FLEX_STATE = SEPARATOR; return OR; } -"."[t|y]"." { HB_FLEX_STATE = SEPARATOR; return TRUEVALUE; } -"."[f|n]"." { HB_FLEX_STATE = SEPARATOR; return FALSEVALUE; } -"!"|".not." { HB_FLEX_STATE = SEPARATOR; return NOT; } -"::" { HB_FLEX_STATE = SEPARATOR; unput( ':' ); unput( 'f' ); unput( 'l' ); unput( 'e' ); unput( 'S' ); } -[\{\(] { HB_FLEX_STATE = SEPARATOR; return yytext[ 0 ]; } -[\=\+\-\*\/\%\$\,\|\#\&\.\:\<\>\@] { HB_FLEX_STATE = SEPARATOR; return yytext[ 0 ]; } -[\]\}\)] { HB_FLEX_STATE = LOOKUP; return yytext[ 0 ]; } - -[\x00-\x1F] return yytext[ 0 ]; /* see below */ -[\~\`\?\_\\] return yytext[ 0 ]; /* see below */ -[\x7F-\xFF] { - /* This have to be the last rule - any nonstandard and - * unhandled characters should go to grammar analyser - * instead of printing it on stdout. - */ - return yytext[ 0 ]; - } - -%{ -/* ************************************************************************ */ -%} - -{Number} { - HB_LONG lNumber; - double dNumber; - int iDec, iWidth; - - HB_FLEX_STATE = LOOKUP; - - if( hb_compStrToNum( yytext, strlen( yytext ), &lNumber, &dNumber, &iDec, &iWidth ) ) - { - yylval_ptr->valDouble.dNumber = dNumber; - yylval_ptr->valDouble.bDec = iDec; - yylval_ptr->valDouble.bWidth = iWidth; - return NUM_DOUBLE; - } - else - { - yylval_ptr->valLong.lNumber = lNumber; - yylval_ptr->valLong.bWidth = iWidth; - return NUM_LONG; - } -} - -{Date} { - int year, month, day; - - hb_dateStrGet( yytext+2, &year, &month, &day ); - yylval_ptr->valLong.lNumber = hb_dateEncode( year, month, day ); - - return NUM_DATE; -} - -{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 ) ); - HB_FLEX_STATE = LOOKUP; - return MACROVAR; -} - -{MacroEnd} { - HB_TRACE(HB_TR_DEBUG, ("{MacroEnd}(%s)", yytext)); - yylval_ptr->string = hb_strupr( hb_strdup( yytext ) ); - HB_FLEX_STATE = LOOKUP; - return MACROTEXT; -} - -{MacroId} { - HB_TRACE(HB_TR_DEBUG, ("{MacroId}(%s)", yytext)); - yylval_ptr->string = hb_strupr( hb_strdup( yytext ) ); - HB_FLEX_STATE = LOOKUP; - return MACROTEXT; -} - -{MacroTxt} { - HB_TRACE(HB_TR_DEBUG, ("{MacroTxt}(%s)", yytext)); - yylval_ptr->string = hb_strupr( hb_strdup( yytext ) ); - HB_FLEX_STATE = 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 ) ); - HB_FLEX_STATE = LOOKUP; - return IDENTIFIER; -} - -%% - -#ifdef __WATCOMC__ -/* enable warnings for unreachable code */ -#pragma warning 13 1 -#endif - - -BOOL hb_macroLexNew( HB_MACRO_PTR pMacro ) -{ - PHB_MACRO_FLEX pLex; - YY_BUFFER_STATE pBuffer; - - HB_TRACE(HB_TR_DEBUG, ("hb_compFlexNew(%s, %i)", pMacro->string, pMacro->length)); - - /* This creates the scanner buffer based on passed string. - * Unfortunately it creates a copy of this string - the string can be - * modified during scanning and the string have to end with TWO zero bytes - * NOTE: It must be used in macro.l because yy_scan_bytes is not - * visible in macro.y - */ - pBuffer = yy_scan_bytes( pMacro->string, pMacro->length ); - if( pBuffer ) - { - pLex = ( PHB_MACRO_FLEX ) hb_xgrab( sizeof( HB_MACRO_FLEX ) ); - pLex->pos = 0; - pLex->FlexState = LOOKUP; - pLex->pBuffer = pBuffer; - pMacro->pLex = ( void * ) pLex; - } - - return pMacro->pLex != NULL; -} - -void hb_macroLexDelete( HB_MACRO_PTR pMacro ) -{ - if( pMacro->pLex ) - { - PHB_MACRO_FLEX pLex = ( PHB_MACRO_FLEX ) pMacro->pLex; - pMacro->pLex = NULL; - yy_delete_buffer( pLex->pBuffer ); - hb_xfree( pLex ); - } -}