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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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$@ $<
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,351 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Flex/Bison generated source code splitter for 16-bit compilers
|
||||
*
|
||||
* Copyright 1999 David G. Holm <dholm@jsd-llc.com>
|
||||
* 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 <dir.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include <share.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
||||
@@ -1,376 +0,0 @@
|
||||
%option noyywrap
|
||||
%option never-interactive
|
||||
%{
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* Macro Compiler LEX rules
|
||||
*
|
||||
* Copyright 1999 Antonio Linares <alinares@fivetech.com>
|
||||
* 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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#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 '[';
|
||||
}
|
||||
|
||||
|
||||
<STRING1>[^'^\n]* { hb_macroError( EG_SYNTAX, YYLEX_PARAM ); BEGIN 0; }
|
||||
<STRING2>[^\"^\n]* { hb_macroError( EG_SYNTAX, YYLEX_PARAM ); BEGIN 0; }
|
||||
<STRING3>[^\]]*\n { hb_macroError( EG_SYNTAX, YYLEX_PARAM ); BEGIN 0; }
|
||||
|
||||
<STRING1>[^']*' { BEGIN 0;
|
||||
HB_FLEX_STATE = LOOKUP;
|
||||
yyleng--;
|
||||
yytext[yyleng] = 0;
|
||||
yylval_ptr->string = hb_strdup( yytext );
|
||||
return LITERAL;
|
||||
}
|
||||
|
||||
<STRING2>[^\"]*\" { BEGIN 0;
|
||||
HB_FLEX_STATE = LOOKUP;
|
||||
yyleng--;
|
||||
yytext[yyleng] = 0;
|
||||
yylval_ptr->string = hb_strdup( yytext );
|
||||
return LITERAL;
|
||||
}
|
||||
|
||||
<STRING3>[^\]]*\] { 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 );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user