[comp.sources.amiga] v90i233: flex 2.3 - fast lexical analyzer generator, Part06/13

amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator) (08/20/90)

Submitted-by: loftus@wpllabs.uucp (William P Loftus)
Posting-number: Volume 90, Issue 233
Archive-name: unix/flex-2.3/part06

#!/bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 6 (of 13)."
# Contents:  MISC/Atari.patches flexdef.h
# Wrapped by tadguy@abcfd20 on Sun Aug 19 18:41:45 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'MISC/Atari.patches' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MISC/Atari.patches'\"
else
echo shar: Extracting \"'MISC/Atari.patches'\" \(29474 characters\)
sed "s/^X//" >'MISC/Atari.patches' <<'END_OF_FILE'
X(Message inbox:32)
XDate:          Mon, 03 Jul 89 21:15:32 CET
XFrom:  V61%DHDURZ1.BITNET@lbl.gov
XSubject:       Flex, bug fix, improvments, patches for Minix & TOS
XTo:  vern@lbl-csam.arpa
X
XAt first I have to thank you for your wonderful program. I had ported the
Xold version to OS9,TOS (Atari ST) and Minix and the new version 2.1 Beta
Xto Minix and TOS.
X     
XWhile porting and using flex I detected a bug and made some improvements.
XI have included a  shared, compressed and uuencoded file contaning all cdiffs
Xand additional files (Sorry, but I'm on EBCDIC-Bitnet) and a short discussion
Xof the changes. Even some of the TOS specific changes might be of general
Xinterest !
X     
XI posted these cdiffs to the minix discussion group, but I think it's up
Xto you to post them to the unix-sources group. If you plan to post even
Xthe TOS compiler specific patches please contact me because there might be
Xfurther compiler (P.D.) additions. If you have an interest I could also
Xport the new version to OS9 -- this is a little bit more difficult, because
XOS9 uses CR as end of line character (the EOL char. is coded into the
Xinitscan.c tables,...). It is necessary to change all occurences of '\n' to
Xmacros and variables and it's useful to add a new -n options (see commented
Xline in main.c)
X     
X     
X     
XThe changes:                                                  (1.7.89 RAL)
X     
X - Bug fix: The original flex didn't like trailing spaces in exclusive start
X     condition lists ! If you add an trailing space to line 68 in scan.l
X     
X     "%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE "
X     
X     you get a misleading error message:
X     
X     "Syntax error at line 69: bad start condition list"
X     
X     This bug can either be fixed in parse.y or in scan.l . I have chosen the
X     last because there the fix is minimal: Just change the rule (line 128)
X     
X      "\n"    to   "{OPTWS}\n"
X     
X - Enhancements:
X    - new option "-?" that provides some help information about the other
X      flags (main.c)
X    - new option "-aTMPPATH" that allows a redefinition of the standard
X      path for the temporary file (this might be rather large >200k if
X      F,f options are selected). (main.c, flexdef.h (l.376))
X    - hexdump of illegal characters -- this proved to be a useful debugging
X      tool especialy if invisible control characters occur which weren't
X      covered by the rules. (scan.l  fprintf statement line 129,...)
X     
X - Patches due to TOS
X    - General: TOS uses CR,LF as end of line char., Flex wants only a single
X      LF as EOL char. Therefore all I/O must be translated using f* calls.
X      This is done everywhere besides the YY_INPUT macro (flex.skel (scan.c),
X      line 31) that uses a low level 'read'. This should be definitly changed
X      to fread, so that all I/O calls occur on the same level.
X    - the short action_file_name has been "flexXXXXXX.tmp", but that's too
X      much for TOS,MSDOS ! I changed it to "flexXXXX.tmp" in main.c (patch
X      covered by the -a option additions)
X    - some compilers don't like external names that are ambiguous within
X      the first 8 characters. I defined macros that change all these long
X      external names to names that are unique within the first 8 characters.
X      Just define SHORT_EXTERNAL_NAMES to use this feature (flexdef.h)
X    - some statement changes that some compiler don't like:
X      typedef *xxx[]  -> typedef **xxx       (flexdef.h.,l.308)
X      "/*" -> '/','*' within a comment in (scan.l, l.209)
X    - changed short "lexyy.c" to "lex_yy.c" what's more similar to the unix
X      "lex.yy.c" (main.c).
X    - a few further really compiler dependent changes provided with
X      #ifdef ATARI && LATTICE res. TURBO braces.
X     
X - Additional TOS only files
X    - Makefile.tos: Common makefile for all TOS compilers. If you add further
X      ones please email me the new makefile.
X    - flex.lnk: Lattice - GST linker argument extension file
X    - flex.tlk: Turbo linker argument extension file
X     
X     
XAdditional remarks:
X     
XI didn't add a new initscan.c (= flex -ist scan.l). The current one is good
Xenough for a first compilation. With this first version of flex you can
Xrebuild your own scan.c and the final flex version !
X     
XMinix ST :
X  - I had to "chmem =70000 cv" (>50000) to get flex linked
X  - 'memset' (PC 1.3, EFTH40,...) is necessary
X  - chmem =90000 flex may be sufficient
X     
XMinix PC :
X  It should be possible to port Flex to Minix PC. The current sizes of flex
X  are:
X                        Minix ST (ACK)    Lattice (TOS)    Turbo (TOS)
X     
X       size               75300             83305             57957
X       compilation time      22'               15'             3'40"
X       flex -is scan.l     1'49"               43"               30"
X     
X  The Minix ST size includes the bad generated code using only a subset of
X  the 68000 commands, long addresses only and a huge relocation table.
X  Therefore the PC size will be <64 k ! More serious is the fact that I had
X  to chmem =90000 flex to get scan.l converted to scan.c . But I never saw
X  a more complex lex source than scan.l -- so it should be possible to
X  reduce some array sizes without limitation for all day usage.
X     
X  No one volunteered yet for a Minix PC port -- but if someone will try it
X  I would provide him with a new scan.c and some hints.
X     
XTOS:
X  Don't forget to adapt the flexskel path within flexdef.h !
X     
X     
XBitnet:  V61@DHDURZ1                               Ronald Lamprecht
XUUCP:    ...!unido!DHDURZ1.bitnet!V61              Theoretische Physik
XARPAnet: V61%DHDURZ1.BITNET@CUNYVM.CUNY.EDU       (Heidelberg, West Germany)
X(Message inbox:36)
XDate:          Wed, 05 Jul 89 21:16:07 CET
XFrom:  V61%DHDURZ1.BITNET@csa2.lbl.gov
XSubject:       Re: What is TOS
XTo:  vern@lbl-csam.arpa
X
XTOS is the name of the Atari ST operating system that is very similar
Xto MSDOS (Both use CR,LF as end of line character). Therefore I have
Xbeen astonished that no EOL convertion porblems occur within MSDOS.
X     
XI have been aware of the double buffering when changing read to fread and  I
Xaccept your argument of a possible slow down. But if you integrate the other
XAtari - TOS changes, please insert a
X        #ifdef ATARI
X              fread ....
X        #else
X              read  ....
X        #endif
Xin flex.skel .
X     
XBitnet:  V61@DHDURZ1                               Ronald Lamprecht
XUUCP:    ...!unido!DHDURZ1.bitnet!V61              Theoretische Physik
XARPAnet: V61%DHDURZ1.BITNET@CUNYVM.CUNY.EDU       (Heidelberg, West Germany)
X
X
X
X
Xecho x - Makefile_cdiff
Xsed '/^X/s///' > Makefile_cdiff << '/'
XX*** Src_2.1/Makefile	Thu Jun 28 00:06:42 1989
XX--- Makefile	Thu Jul  3 02:12:48 1989
XX***************
XX*** 5,10 ****
XX--- 5,11 ----
XX  # Porting considerations:
XX  #
XX  #    For System V Unix machines, add -DSYS_V to CFLAGS.
XX+ #    For Minix (ST), add -DSYS_V to CFLAGS
XX  #    For Vax/VMS, add -DSYS_V to CFLAGS.
XX  #    For MS-DOS, add "-DMS_DOS -DSYS_V" to CFLAGS.  Create \tmp if not present.
XX  #         You will also want to rename flex.skel to something with a three
XX***************
XX*** 21,28 ****
XX  SKELETON_DIR = /usr/local/lib
XX  SKELETON_FILE = flex.skel
XX  SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\"
XX! CFLAGS = -O
XX! LDFLAGS = -s
XX  
XX  FLEX_FLAGS =
XX  FLEX = ./flex
XX--- 22,29 ----
XX  SKELETON_DIR = /usr/local/lib
XX  SKELETON_FILE = flex.skel
XX  SKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\"
XX! CFLAGS = -O -DSYS_V
XX! LDFLAGS = 
XX  
XX  FLEX_FLAGS =
XX  FLEX = ./flex
XX***************
XX*** 57,63 ****
XX  	yylex.c
XX  
XX  flex : $(FLEXOBJS)
XX! 	$(CC) $(CFLAGS) -o flex $(LDFLAGS) $(FLEXOBJS)
XX  
XX  first_flex:
XX  	cp initscan.c scan.c
XX--- 58,65 ----
XX  	yylex.c
XX  
XX  flex : $(FLEXOBJS)
XX! 	$(CC) $(CFLAGS) -o flex $(FLEXOBJS) $(LDFLAGS)
XX! 	chmem =150000 flex
XX  
XX  first_flex:
XX  	cp initscan.c scan.c
X/
Xecho x - flex.skel_cdif
Xsed '/^X/s///' > flex.skel_cdif << '/'
XX*** Src_2.1/flex.skel	Thu Jun 28 00:19:20 1989
XX--- flex.skel	Thu Jul  2 22:18:31 1989
XX***************
XX*** 28,34 ****
XX   * is returned in "result".
XX   */
XX  #define YY_INPUT(buf,result,max_size) \
XX! 	if ( (result = read( fileno(yyin), buf, max_size )) < 0 ) \
XX  	    YY_FATAL_ERROR( "read() in flex scanner failed" );
XX  #define YY_NULL 0
XX  #define yyterminate() return ( YY_NULL )
XX--- 28,34 ----
XX   * is returned in "result".
XX   */
XX  #define YY_INPUT(buf,result,max_size) \
XX! 	if ( (result = fread( buf,1, max_size, yyin )) < 0 ) \
XX  	    YY_FATAL_ERROR( "read() in flex scanner failed" );
XX  #define YY_NULL 0
XX  #define yyterminate() return ( YY_NULL )
X/
Xecho x - flexdef.h_cdif
Xsed '/^X/s///' > flexdef.h_cdif << '/'
XX*** Src_2.1/flexdef.h	Thu Jun 28 00:43:27 1989
XX--- flexdef.h	Thu Jul  3 02:45:50 1989
XX***************
XX*** 26,31 ****
XX--- 26,40 ----
XX  
XX  /* @(#) $Header: flexdef.h,v 2.0 89/06/20 15:49:50 vern Locked $ (LBL) */
XX  
XX+ #ifdef ATARI
XX+ #define SYS_V
XX+ #define abs(x) ((x) < 0 ? -(x) : (x))
XX+ #define SHORT_FILE_NAMES
XX+ #ifdef TURBO
XX+ #define SHORT_EXTERNAL_NAMES
XX+ #endif
XX+ #endif
XX+ 
XX  #ifndef FILE
XX  #include <stdio.h>
XX  #endif
XX***************
XX*** 41,47 ****
XX  #endif
XX  
XX  #ifndef VMS
XX! char *memset();
XX  #else
XX  /* memset is needed for old versions of the VMS C runtime library */
XX  #define memset(s, c, n) \
XX--- 50,58 ----
XX  #endif
XX  
XX  #ifndef VMS
XX! #ifndef ATARI && TURBO
XX! char *memset();
XX! #endif
XX  #else
XX  /* memset is needed for old versions of the VMS C runtime library */
XX  #define memset(s, c, n) \
XX***************
XX*** 81,91 ****
XX--- 92,129 ----
XX  #define true 1
XX  #define false 0
XX  
XX+ #ifdef ATARI
XX+ #define DEFAULT_SKELETON_FILE "D:\\include\\flexskel"
XX+ #endif
XX+ 
XX  
XX  #ifndef DEFAULT_SKELETON_FILE
XX  #define DEFAULT_SKELETON_FILE "flex.skel"
XX  #endif
XX  
XX+ #ifdef SHORT_EXTERNAL_NAMES
XX+ /* avoid long external names that are ambiguous within the first 8 characters */
XX+ #define current_mns                 c__mns
XX+ #define current_max_rules           c__max_rules
XX+ #define current_max_state_type      c__max_state_type
XX+ #define current_max_scs             c__max_scs
XX+ #define current_max_dfa_size        c__max__size
XX+ #define current_max_xpairs          c__max_xpairs
XX+ #define current_max_template_xpairs c__max_template_xpairs
XX+ #define current_max_dfas            c__max_dfas
XX+ #define current_maxccls             c__maxccles
XX+ #define current_max_ccl_tbl_size    c__max_ccl_tbl_size
XX+ #define indent_puts                 ind_puts
XX+ #define indent_put2s                ind_put2s
XX+ #define gen_next_compressed_state   gen_n_comressed_state
XX+ #define gen_next_match              gen_n_match
XX+ #define gen_next_state              gen_n_state
XX+ #define variable_trailing_context_rules  var_tr_context_rules
XX+ #define variable_trailing_rule           var_tr_rule
XX+ #define backtrack_report            backtr_report
XX+ #define backtrack_file              backtr_file
XX+ #endif
XX+ 
XX  /* special chk[] values marking the slots taking by end-of-buffer and action
XX   * numbers
XX   */
XX***************
XX*** 305,311 ****
XX      int int_val;
XX      } ;
XX  
XX! typedef struct hash_entry *hash_table[];
XX  
XX  #define NAME_TABLE_HASH_SIZE 101
XX  #define START_COND_HASH_SIZE 101
XX--- 343,349 ----
XX      int int_val;
XX      } ;
XX  
XX! typedef struct hash_entry **hash_table;
XX  
XX  #define NAME_TABLE_HASH_SIZE 101
XX  #define START_COND_HASH_SIZE 101
XX***************
XX*** 372,378 ****
XX  extern int datapos, dataline, linenum;
XX  extern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file;
XX  extern char *infilename;
XX! extern char action_file_name[];
XX  
XX  
XX  /* variables for stack of states having only one out-transition:
XX--- 410,416 ----
XX  extern int datapos, dataline, linenum;
XX  extern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file;
XX  extern char *infilename;
XX! extern char *action_file_name;
XX  
XX  
XX  /* variables for stack of states having only one out-transition:
X/
Xecho x - main.c_cdiff
Xsed '/^X/s///' > main.c_cdiff << '/'
XX*** Src_2.1/main.c	Thu Jun 28 00:30:39 1989
XX--- main.c	Thu Jul  3 02:27:47 1989
XX***************
XX*** 81,96 ****
XX  FILE *temp_action_file;
XX  FILE *backtrack_file;
XX  int end_of_buffer_state;
XX! #ifndef SHORT_FILE_NAMES
XX! char action_file_name[] = "/tmp/flexXXXXXX";
XX! #else
XX! char action_file_name[] = "flexXXXXXX.tmp";
XX! #endif
XX! 
XX  #ifndef SHORT_FILE_NAMES
XX  static char outfile[] = "lex.yy.c";
XX  #else
XX! static char outfile[] = "lexyy.c";
XX  #endif
XX  static int outfile_created = 0;
XX  
XX--- 81,91 ----
XX  FILE *temp_action_file;
XX  FILE *backtrack_file;
XX  int end_of_buffer_state;
XX! char *action_file_name;
XX  #ifndef SHORT_FILE_NAMES
XX  static char outfile[] = "lex.yy.c";
XX  #else
XX! static char outfile[] = "lex_yy.c";
XX  #endif
XX  static int outfile_created = 0;
XX  
XX***************
XX*** 328,333 ****
XX--- 323,329 ----
XX      {
XX      int i, sawcmpflag, use_stdout;
XX      char *arg, *skelname = NULL, *flex_gettime(), clower(), *mktemp();
XX+     char *tmp_action =(char *)0, *malloc();
XX  
XX      printstats = syntaxerror = trace = spprdflt = interactive = caseins = false;
XX      backtrack_report = performance_report = ddebug = fulltbl = fullspd = false;
XX***************
XX*** 349,354 ****
XX--- 345,355 ----
XX  	for ( i = 1; arg[i] != '\0'; ++i )
XX  	    switch ( arg[i] )
XX  		{
XX+ 		case 'a':
XX+ 		    if ( i != 1 )
XX+ 			flexerror( "-a flag must be given separately" );
XX+ 		    tmp_action = &arg[i+1];
XX+ 		    goto get_next_arg;
XX  		case 'b':
XX  		    backtrack_report = true;
XX  		    break;
XX***************
XX*** 445,452 ****
XX  		    printstats = true;
XX  		    break;
XX  
XX! 		default:
XX! 		    lerrif( "unknown flag %c", (int) arg[i] );
XX  		    break;
XX  		}
XX  
XX--- 446,458 ----
XX  		    printstats = true;
XX  		    break;
XX  
XX! 		case '?':
XX! 		    flexinfo(0);
XX! 		    break;
XX! 
XX! 		default:
XX! 		    fprintf(stderr,"flex : unknown flag %c\n", (int) arg[i] );
XX! 		    flexinfo(1);
XX  		    break;
XX  		}
XX  
XX***************
XX*** 454,459 ****
XX--- 460,493 ----
XX  	;
XX  	}
XX  
XX+ 
XX+ /* if you change the default tmp file names don't forget to change the
XX+    initialization for i, too !
XX+    
XX+ */
XX+ #ifndef SHORT_FILE_NAMES
XX+     i = 10;
XX+     if (!tmp_action) i += 5;
XX+ #else
XX+     i = 12;
XX+ #endif
XX+     if (tmp_action) 
XX+         i += strlen(tmp_action) + 1;
XX+     if((action_file_name = malloc(i+1)) == (char *)0)
XX+         flexerror("No memory for action_file_name");
XX+     *action_file_name = (char) NULL;
XX+     if (tmp_action) 
XX+         strcat(action_file_name,tmp_action);
XX+ #ifndef SHORT_FILE_NAMES
XX+     else
XX+         strcat(action_file_name,"/tmp");
XX+     strcat(action_file_name,"/flexXXXXXX");
XX+ #else
XX+     if (tmp_action)
XX+         strcat(action_file_name,"/");
XX+     strcat(action_file_name,"flexXXXX.tmp");
XX+ #endif
XX+     
XX      if ( (fulltbl || fullspd) && usemecs )
XX  	flexerror( "full table and -cm don't make sense together" );
XX  
XX***************
XX*** 520,526 ****
XX      if ( (skelfile = fopen( skelname, "r" )) == NULL )
XX  	lerrsf( "can't open skeleton file %s", skelname );
XX  
XX!     (void) mktemp( action_file_name );
XX  
XX      if ( (temp_action_file = fopen( action_file_name, "w" )) == NULL )
XX  	lerrsf( "can't open temporary action file %s", action_file_name );
XX--- 554,562 ----
XX      if ( (skelfile = fopen( skelname, "r" )) == NULL )
XX  	lerrsf( "can't open skeleton file %s", skelname );
XX  
XX! #ifndef ATARI && LATTICE
XX!     (void) mktemp( action_file_name );
XX! #endif
XX  
XX      if ( (temp_action_file = fopen( action_file_name, "w" )) == NULL )
XX  	lerrsf( "can't open temporary action file %s", action_file_name );
XX***************
XX*** 566,571 ****
XX--- 602,640 ----
XX      }
XX  
XX  
XX+ flexinfo(status)
XX+ int status;
XX+ {
XX+    fprintf(stderr,"Syntax  :  FLEX  inp_file\n");
XX+    fprintf(stderr,"Function: fast lexical analyzer generator  V%s\n",flex_version);
XX+    fprintf(stderr,"Options : a dir_path  : directory path for temporary files\n");
XX+    fprintf(stderr,"	- b  : generate backtracking information to lex.backtrack\n");
XX+    fprintf(stderr,"	- c  : compressed table, no equiv., no meta equiv.classes\n");
XX+    fprintf(stderr,"	   e : equivalence classes\n");
XX+    fprintf(stderr,"	   F : fast table\n");
XX+    fprintf(stderr,"	  |f : full table\n");
XX+    fprintf(stderr,"	  |m : meta equivalence classes\n");
XX+    fprintf(stderr,"	- d  : generate debugging scanner\n");
XX+    fprintf(stderr,"	- F  : fast table\n");
XX+    fprintf(stderr,"	- f  : full (not compressed) table\n");
XX+    fprintf(stderr,"	- I  : generate interactive scanner\n");
XX+    fprintf(stderr,"	- i  : generate case-insensitive scanner\n");
XX+    fprintf(stderr,"	- L  : supress #line directives\n");
XX+ /*   fprintf(stderr,"	- n hexnum : generate scanner using <hexnum> as newline char.\n");*/
XX+    fprintf(stderr,"	- p  : generate performance report to stderr\n");
XX+    fprintf(stderr,"	- S skeleton_path : file path for skeleton file\n");
XX+    fprintf(stderr,"	- s  : suppress echo of unmatched scanner input to stdout\n");
XX+    fprintf(stderr,"	- T  : run flex in trace mode\n");
XX+ #ifdef ATARI
XX+    fprintf(stderr,"	- t  : place result on stdout instead of lex_yy.c\n");
XX+ #else
XX+    fprintf(stderr,"	- t  : place result on stdout instead of lex.yy.c\n");
XX+ #endif
XX+    fprintf(stderr,"	- v  : print statistics of generated scanner\n");
XX+    fprintf(stderr,"     default =  -cem\n");
XX+    exit(status);
XX+ }
XX+ 
XX  /* readin - read in the rules section of the input file(s)
XX   *
XX   * synopsis
X/
Xecho x - scan.l_cdiff
Xsed '/^X/s///' > scan.l_cdiff << '/'
XX*** Src_2.1/scan.l	Thu Jun 30 19:42:00 1989
XX--- scan.l	Thu Jul  2 22:19:26 1989
XX***************
XX*** 125,132 ****
XX  
XX  {SCNAME}		RETURNNAME;
XX  ^{OPTWS}\n		++linenum; /* allows blank lines in section 1 */
XX! \n			++linenum; return ( '\n' );
XX! .			synerr( "illegal character" ); BEGIN(RECOVER);
XX  
XX  
XX  <C_COMMENT>"*/"		ECHO; BEGIN(0);
XX--- 125,136 ----
XX  
XX  {SCNAME}		RETURNNAME;
XX  ^{OPTWS}\n		++linenum; /* allows blank lines in section 1 */
XX! {OPTWS}\n		++linenum; return ( '\n' );
XX! .			{
XX! 			synerr( "illegal character" );
XX! 			fprintf(stderr,"Char : $%x\n",yytext[yyleng-1]);
XX! 			BEGIN(RECOVER);
XX! 			}
XX  
XX  
XX  <C_COMMENT>"*/"		ECHO; BEGIN(0);
XX***************
XX*** 206,212 ****
XX  <SECT2>^{OPTWS}\n	++linenum; /* allow blank lines in section 2 */
XX  
XX  	/* this horrible mess of a rule matches indented lines which
XX! 	 * do not contain "/*".  We need to make the distinction because
XX  	 * otherwise this rule will be taken instead of the rule which
XX  	 * matches the beginning of comments like this one
XX  	 */
XX--- 210,216 ----
XX  <SECT2>^{OPTWS}\n	++linenum; /* allow blank lines in section 2 */
XX  
XX  	/* this horrible mess of a rule matches indented lines which
XX! 	 * do not contain '/','*'.  We need to make the distinction because
XX  	 * otherwise this rule will be taken instead of the rule which
XX  	 * matches the beginning of comments like this one
XX  	 */
X/
Xecho x - Makefile.tos
Xsed '/^X/s///' > Makefile.tos << '/'
XX# make file for "flex" tool
XX
XX# @(#) $Header: Makefile,v 2.3 89/06/20 17:27:12 vern Exp $ (LBL)
XX
XX# Porting considerations:
XX#
XX#    For System V Unix machines, add -DSYS_V to CFLAGS.
XX#    For Vax/VMS, add -DSYS_V to CFLAGS.
XX#    For MS-DOS, add "-DMS_DOS -DSYS_V" to CFLAGS.  Create \tmp if not present.
XX#         You will also want to rename flex.skel to something with a three
XX#         character extension, change SKELETON_FILE below appropriately,
XX#    For Amiga, add "-DAMIGA -DSYS_V" to CFLAGS.
XX#
XX# A long time ago, flex was successfully built using Microsoft C and
XX# the following options: /AL, /stack:10000, -LARGE, -Ml, -Mt128, -DSYS_V
XX
XX
XX# the first time around use "make first_flex"
XX
XX# The following definitions must be set according to your compiler -
XX# examples for a Lattice Compiler with GST assembler and TURBO C with
XX# assembler are provided below and must just be updated (don't forget to
XX# update the linker argument extension files (*.lnk,*.tlk), too) :
XX#
XX#CCPATH  = path to compiler directory without trailing \
XX#CHPATH  = path to header files without trailing \
XX#CC      = filename of the compiler
XX#CFLAGS  = compiler option flags
XX#CIEXT   = extension of C sources that should be used for input filenames
XX#ASMPATH = path to assembler directory without trailing \
XX#ASM     = filename of the assembler
XX#AFLAGS  = assembler option flags
XX#AIEXT   = extension of assembler sources that should be used for assembler
XX#          input filenames
XX#AEXT    = general assembler filename extension
XX#LNKPATH = path to linker directory without trailing \
XX#LINK    = filename of the linker
XX#LFLAG0  = first option (full pathname of C startupcode) 
XX#LFLAG1  = further options + option flag for argument extension filename
XX#LFLAG2  = further options + option flag for output-filename 
XX#LNKEXT  = extension of linker argument extension file
XX#OIEXT   = extension of objects that should be used for linker input files
XX#OEXT    = general object file extension
XX
XX# Lattice definitions
XXCCPATH  = d:\latt
XXCHPATH  = d:\latt\include
XXCC      = lc.ttp
XXCFLAGS  = -h -n -cw -cc -i$(CHPATH)\ -g$(CCPATH)\ -dLATTICE -dATARI
XXCIEXT   =
XXASMPATH = d:\gst
XXASM     = assem.ttp
XXAFLAGS  = -nolist -errors errors.out
XXAIEXT   =
XXAEXT    = .asm
XXLNKPATH = d:\gst
XXLINK    = ld.ttp
XXLFLAG0  =
XXLFLAG1  = -with 
XXLFLAG2  = -nolist -sec -mem 200 -prog 
XXLNKEXT  = .lnk
XXOIEXT   =
XXOEXT    = .bin
XX
XX# Turbo definitions
XX#CCPATH  = d:\turbo
XX#CHPATH  = d:\turbo\include
XX#CC      = tcc.prg
XX#CFLAGS  = -GJMPRZ -H=$(CHPATH)\ -w- -DTURBO -DATARI
XX#CIEXT   = .c
XX#ASMPATH = d:\turbo
XX#ASM     = mas.prg
XX#AFLAGS  =
XX#AIEXT   = .s
XX#AEXT    = .s
XX#LNKPATH = d:\turbo
XX#LINK    = tlink.ttp
XX#LFLAG0  = $(LNKPATH)\lib\tcstart.o
XX#LFLAG1  = -I=
XX#LFLAG2  = -O=
XX#LNKEXT  = .tlk
XX#OIEXT   = .o
XX#OEXT    = .o
XX
XX# Other definitions
XX# (not used for Atari because of short argument string - defined in flexdef.h
XX
XXSKELETON_DIR = /usr/lib
XXSKELETON_FILE = flex.skel
XXSKELFLAGS = -DDEFAULT_SKELETON_FILE=\"$(SKELETON_DIR)/$(SKELETON_FILE)\"
XX
XX
XXFLEX       = d:\etc\flex.ttp
XXFLEX_FLAGS = -is
XXYACC       = d:\etc\yacc.ttp
XXRENAME     = d:\bin\rename
XXDEL        = d:\bin\del
XX
XX# Internal definitions
XXLNK     = $(LNKPATH)\$(LINK)
XX
XXFLEXOBJS = \
XX	ccl$(OEXT) \
XX	dfa$(OEXT) \
XX	ecs$(OEXT) \
XX	gen$(OEXT) \
XX	main$(OEXT) \
XX	misc$(OEXT) \
XX	nfa$(OEXT) \
XX	parse$(OEXT) \
XX	scan$(OEXT) \
XX	sym$(OEXT) \
XX	tblcmp$(OEXT) \
XX	yylex$(OEXT)
XX
XXFLEX_C_SOURCES = \
XX	ccl.c \
XX	dfa.c \
XX	ecs.c \
XX	gen.c \
XX	main.c \
XX	misc.c \
XX	nfa.c \
XX	parse.c \
XX	scan.c \
XX	sym.c \
XX	tblcmp.c \
XX	yylex.c
XX
XXflex : $(FLEXOBJS)
XX	 $(LNK) $(LFLAG0) $(LFLAG1)flex$(LNKEXT) $(LFLAG2)flex.ttp
XX
XXfirst_flex:
XX	cp initscan.c scan.c
XX	make $(MFLAGS) flex
XX
XXparse.h parse.c : parse.y
XX	$(YACC)   -d parse.y
XX	$(DEL)    parse.c
XX	$(RENAME) y_tab.c parse.c
XX	$(DEL)    parse.h
XX	$(RENAME) y_tab.h parse.h
XX
XXscan.c : scan.l
XX	$(FLEX)   $(FLEX_FLAGS) scan.l
XX	$(RENAME) lex_yy.c scan.c
XX
XXscan$(OEXT) : scan.c parse.h flexdef.h
XX	 $(CCPATH)\$(CC) $(CFLAGS) scan$(CIEXT)
XX
XXmain$(OEXT) : main.c flexdef.h
XX	 $(CCPATH)\$(CC) $(CFLAGS)  main$(CIEXT)
XX
XXccl$(OEXT) : ccl.c flexdef.h 
XX	 $(CCPATH)\$(CC) $(CFLAGS)  ccl$(CIEXT)
XX
XXdfa$(OEXT) : dfa.c flexdef.h
XX	 $(CCPATH)\$(CC) $(CFLAGS)  dfa$(CIEXT)
XX
XXecs$(OEXT) : ecs.c flexdef.h
XX	 $(CCPATH)\$(CC) $(CFLAGS)  ecs$(CIEXT)
XX
XXgen$(OEXT) : gen.c flexdef.h
XX	 $(CCPATH)\$(CC) $(CFLAGS)  gen$(CIEXT)
XX
XXmisc$(OEXT) : misc.c flexdef.h
XX	 $(CCPATH)\$(CC) $(CFLAGS)  misc$(CIEXT)
XX
XXnfa$(OEXT) : nfa.c flexdef.h
XX	 $(CCPATH)\$(CC) $(CFLAGS)  nfa$(CIEXT)
XX
XXparse$(OEXT) : parse.c flexdef.h
XX	 $(CCPATH)\$(CC) $(CFLAGS)  parse$(CIEXT)
XX
XXsym$(OEXT) : sym.c flexdef.h
XX	 $(CCPATH)\$(CC) $(CFLAGS)  sym$(CIEXT)
XX
XXtblcmp$(OEXT) : tblcmp.c flexdef.h
XX	 $(CCPATH)\$(CC) $(CFLAGS)  tblcmp$(CIEXT)
XX
XXyylex$(OEXT) : yylex.c flexdef.h 
XX	 $(CCPATH)\$(CC) $(CFLAGS)  yylex$(CIEXT)
XX
XXflex.man : flex.1
XX	nroff -man flex.1 >flex.man
XX
XXlint : $(FLEX_C_SOURCES)
XX	lint $(FLEX_C_SOURCES) > flex.lint
XX
XXdistrib :
XX	mv scan.c initscan.c
XX	chmod 444 initscan.c
XX	$(MAKE) $(MFLAGS) clean
XX
XXclean :
XX	rm -f core errs flex *$(OEXT) parse.c *.lint parse.h flex.man tags
XX
XXtags :
XX	ctags $(FLEX_C_SOURCES)
XX
XXvms :	flex.man
XX	$(MAKE) $(MFLAGS) distrib
XX
XXtest :
XX	$(FLEX) $(FLEX_FLAGS) scan.l
XX	$(RENAME) lex_yy.c scan.ctest
XX	cmp scan.c scan.ctest
XX
X/
Xecho x - Readme2
Xsed '/^X/s///' > Readme2 << '/'
XXThe changes:                                                  (1.7.89 RAL)
XX
XX - Bug fix: The original flex didn't like trailing spaces in exclusive start
XX     condition lists ! If you add an trailing space to line 68 in scan.l
XX     
XX     "%x SECT2 SECT2PROLOG SECT3 CODEBLOCK PICKUPDEF SC CARETISBOL NUM QUOTE "
XX     
XX     you get a misleading error message: 
XX     
XX     "Syntax error at line 69: bad start condition list"
XX     
XX     This bug can either be fixed in parse.y or in scan.l . I have chosen the
XX     last because there the fix is minimal: Just change the rule (line 128)
XX     
XX      "\n"    to   "{OPTWS}\n"
XX      
XX - Enhancements:
XX    - new option "-?" that provides some help information about the other
XX      flags (main.c)
XX    - new option "-aTMPPATH" that allows a redefinition of the standard
XX      path for the temporary file (this might be rather large >200k if 
XX      F,f options are selected). (main.c, flexdef.h (l.376))
XX    - hexdump of illegal characters -- this proved to be a useful debugging
XX      tool especialy if invisible control characters occur which weren't
XX      covered by the rules. (scan.l  fprintf statement line 129,...)
XX      
XX - Patches due to TOS
XX    - General: TOS uses CR,LF as end of line char., Flex wants only a single
XX      LF as EOL char. Therefore all I/O must be translated using f* calls.
XX      This is done everywhere besides the YY_INPUT macro (flex.skel (scan.c),
XX      line 31) that uses a low level 'read'. This should be definitly changed
XX      to fread, so that all I/O calls occur on the same level.
XX    - the short action_file_name has been "flexXXXXXX.tmp", but that's too 
XX      much for TOS,MSDOS ! I changed it to "flexXXXX.tmp" in main.c (patch
XX      covered by the -a option additions)
XX    - some compilers don't like external names that are ambiguous within
XX      the first 8 characters. I defined macros that change all these long
XX      external names to names that are unique within the first 8 characters.
XX      Just define SHORT_EXTERNAL_NAMES to use this feature (flexdef.h)
XX    - some statement changes that some compiler don't like:
XX      typedef *xxx[]  -> typedef **xxx       (flexdef.h.,l.308)
XX      "/*" -> '/','*' within a comment in (scan.l, l.209)
XX    - changed short "lexyy.c" to "lex_yy.c" what's more similar to the unix
XX      "lex.yy.c" (main.c).
XX    - a few further really compiler dependent changes provided with
XX      #ifdef ATARI && LATTICE res. TURBO braces.
XX      
XX - Additional TOS only files
XX    - Makefile.tos: Common makefile for all TOS compilers. If you add further
XX      ones please email me the new makefile.
XX    - flex.lnk: Lattice - GST linker argument extension file
XX    - flex.tlk: Turbo linker argument extension file
XX      
XX    
XXAdditional remarks:
XX 
XXI didn't add a new initscan.c (= flex -ist scan.l). The current one is good
XXenough for a first compilation. With this first version of flex you can
XXrebuild your own scan.c and the final flex version !
XX
XXMinix ST :
XX  - I had to "chmem =70000 cv" (>50000) to get flex linked
XX  - 'memset' (PC 1.3, EFTH40,...) is necessary
XX  - chmem =90000 flex may be sufficient
XX  
XXMinix PC :
XX  It should be possible to port Flex to Minix PC. The current sizes of flex
XX  are:
XX                        Minix ST (ACK)    Lattice (TOS)    Turbo (TOS)
XX       
XX       size               75300             83305             57957
XX       compilation time      22'               15'             3'40"
XX       flex -is scan.l     1'49"               43"               30"
XX       
XX  The Minix ST size includes the bad generated code using only a subset of
XX  the 68000 commands, long addresses only and a huge relocation table.
XX  Therefore the PC size will be <64 k ! More serious is the fact that I had
XX  to chmem =90000 flex to get scan.l converted to scan.c . But I never saw
XX  a more complex lex source than scan.l -- so it should be possible to
XX  reduce some array sizes without limitation for all day usage.
XX  
XX  No one volunteered yet for a Minix PC port -- but if someone will try it
XX  I would provide him with a new scan.c and some hints.
XX  
XXTOS: 
XX  Don't forget to adapt the flexskel path within flexdef.h !
XX
XX
X/
Xecho x - flex.lnk
Xsed '/^X/s///' > flex.lnk << '/'
XX*
XX*
XX*  linker control file for flex.ttp
XX*
XX*
XX*
XXINPUT   d:\latt\lib\startup.bin
XX*
XXINPUT ccl.bin
XXINPUT dfa.bin
XXINPUT ecs.bin
XXINPUT gen.bin
XXINPUT misc.bin
XXINPUT nfa.bin
XXINPUT parse.bin
XXINPUT sym.bin
XXINPUT tblcmp.bin
XXINPUT main.bin
XXINPUT yylex.bin
XXINPUT scan.bin
XX*
XXLIBRARY d:\latt\lib\clib.bin
XX
X/
Xecho x - flex.tlk
Xsed '/^X/s///' > flex.tlk << '/'
XXccl.o
XXdfa.o
XXecs.o
XXgen.o
XXmisc.o
XXnfa.o
XXparse.o
XXsym.o
XXtblcmp.o
XXyylex.o
XXmain.o
XXscan.o
XXd:\turbo\lib\tcstdlib.lib   ; standard lib
XXd:\turbo\lib\tcextlib.lib   ; extended lib
XXd:\turbo\lib\tctoslib.lib   ; TOS lib
XXd:\turbo\lib\tcgemlib.lib   ; AES and VDI lib
XX-S=200000
X/
END_OF_FILE
if test 29474 -ne `wc -c <'MISC/Atari.patches'`; then
    echo shar: \"'MISC/Atari.patches'\" unpacked with wrong size!
fi
# end of 'MISC/Atari.patches'
fi
if test -f 'flexdef.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'flexdef.h'\"
else
echo shar: Extracting \"'flexdef.h'\" \(28965 characters\)
sed "s/^X//" >'flexdef.h' <<'END_OF_FILE'
X/* flexdef - definitions file for flex */
X
X/*-
X * Copyright (c) 1990 The Regents of the University of California.
X * All rights reserved.
X *
X * This code is derived from software contributed to Berkeley by
X * Vern Paxson.
X * 
X * The United States Government has rights in this work pursuant
X * to contract no. DE-AC03-76SF00098 between the United States
X * Department of Energy and the University of California.
X *
X * Redistribution and use in source and binary forms are permitted provided
X * that: (1) source distributions retain this entire copyright notice and
X * comment, and (2) distributions including binaries display the following
X * acknowledgement:  ``This product includes software developed by the
X * University of California, Berkeley and its contributors'' in the
X * documentation or other materials provided with the distribution and in
X * all advertising materials mentioning features or use of this software.
X * Neither the name of the University nor the names of its contributors may
X * be used to endorse or promote products derived from this software without
X * specific prior written permission.
X * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
X * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
X * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
X */
X
X/* @(#) $Header: WPL:Generators/flex-2.3/RCS/flexdef.h,v 1.2 90/07/15 01:17:09 loftus Exp $ (LBL) */
X
X#ifndef FILE
X#include <stdio.h>
X#endif
X
X/* always be prepared to generate an 8-bit scanner */
X#define FLEX_8_BIT_CHARS
X
X#ifdef FLEX_8_BIT_CHARS
X#define CSIZE 256
X#define Char unsigned char
X#else
X#define Char char
X#define CSIZE 128
X#endif
X
X/* size of input alphabet - should be size of ASCII set */
X#ifndef DEFAULT_CSIZE
X#define DEFAULT_CSIZE 128
X#endif
X
X#ifndef PROTO
X#ifdef __STDC__
X#define PROTO(proto) proto
X#else
X#define PROTO(proto) ()
X#endif
X#endif
X
X
X#ifdef USG
X#define SYS_V
X#endif
X
X#ifdef SYS_V
X#include <string.h>
X#else
X
X#include <strings.h>
X#ifdef lint
Xchar *sprintf(); /* keep lint happy */
X#endif
X#ifdef SCO_UNIX
Xvoid *memset();
X#else
Xchar *memset();
X#endif
X#endif
X
X#ifdef AMIGA
X#define bzero(s, n) setmem((char *)(s), n, '\0')
X#define DEFAULT_SKELETON_FILE "s:flex.skel"
X#ifndef abs
X#define abs(x) ((x) < 0 ? -(x) : (x))
X#endif
X#else
X#define bzero(s, n) (void) memset((char *)(s), '\0', n)
X#endif
X
X#ifdef VMS
X#define unlink delete
X#define SHORT_FILE_NAMES
X#endif
X
X#ifndef AMIGA
Xchar *malloc(), *realloc();
X#endif
X
X
X/* maximum line length we'll have to deal with */
X#define MAXLINE BUFSIZ
X
X/* maximum size of file name */
X#define FILENAMESIZE 1024
X
X#ifndef min
X#define min(x,y) ((x) < (y) ? (x) : (y))
X#endif
X#ifndef max
X#define max(x,y) ((x) > (y) ? (x) : (y))
X#endif
X
X#ifdef MS_DOS
X#ifndef abs
X#define abs(x) ((x) < 0 ? -(x) : (x))
X#endif
X#define SHORT_FILE_NAMES
X#endif
X
X#define true 1
X#define false 0
X
X
X#ifndef DEFAULT_SKELETON_FILE
X#define DEFAULT_SKELETON_FILE "flex.skel"
X#endif
X
X/* special chk[] values marking the slots taking by end-of-buffer and action
X * numbers
X */
X#define EOB_POSITION -1
X#define ACTION_POSITION -2
X
X/* number of data items per line for -f output */
X#define NUMDATAITEMS 10
X
X/* number of lines of data in -f output before inserting a blank line for
X * readability.
X */
X#define NUMDATALINES 10
X
X/* transition_struct_out() definitions */
X#define TRANS_STRUCT_PRINT_LENGTH 15
X
X/* returns true if an nfa state has an epsilon out-transition slot
X * that can be used.  This definition is currently not used.
X */
X#define FREE_EPSILON(state) \
X	(transchar[state] == SYM_EPSILON && \
X	 trans2[state] == NO_TRANSITION && \
X	 finalst[state] != state)
X
X/* returns true if an nfa state has an epsilon out-transition character
X * and both slots are free
X */
X#define SUPER_FREE_EPSILON(state) \
X	(transchar[state] == SYM_EPSILON && \
X	 trans1[state] == NO_TRANSITION) \
X
X/* maximum number of NFA states that can comprise a DFA state.  It's real
X * big because if there's a lot of rules, the initial state will have a
X * huge epsilon closure.
X */
X#define INITIAL_MAX_DFA_SIZE 750
X#define MAX_DFA_SIZE_INCREMENT 750
X
X
X/* a note on the following masks.  They are used to mark accepting numbers
X * as being special.  As such, they implicitly limit the number of accepting
X * numbers (i.e., rules) because if there are too many rules the rule numbers
X * will overload the mask bits.  Fortunately, this limit is \large/ (0x2000 ==
X * 8192) so unlikely to actually cause any problems.  A check is made in
X * new_rule() to ensure that this limit is not reached.
X */
X
X/* mask to mark a trailing context accepting number */
X#define YY_TRAILING_MASK 0x2000
X
X/* mask to mark the accepting number of the "head" of a trailing context rule */
X#define YY_TRAILING_HEAD_MASK 0x4000
X
X/* maximum number of rules, as outlined in the above note */
X#define MAX_RULE (YY_TRAILING_MASK - 1)
X
X
X/* NIL must be 0.  If not, its special meaning when making equivalence classes
X * (it marks the representative of a given e.c.) will be unidentifiable
X */
X#define NIL 0
X
X#define JAM -1	/* to mark a missing DFA transition */
X#define NO_TRANSITION NIL
X#define UNIQUE -1	/* marks a symbol as an e.c. representative */
X#define INFINITY -1	/* for x{5,} constructions */
X
X#define INITIAL_MAX_CCLS 100	/* max number of unique character classes */
X#define MAX_CCLS_INCREMENT 100
X
X/* size of table holding members of character classes */
X#define INITIAL_MAX_CCL_TBL_SIZE 500
X#define MAX_CCL_TBL_SIZE_INCREMENT 250
X
X#define INITIAL_MAX_RULES 100	/* default maximum number of rules */
X#define MAX_RULES_INCREMENT 100
X
X#define INITIAL_MNS 2000	/* default maximum number of nfa states */
X#define MNS_INCREMENT 1000	/* amount to bump above by if it's not enough */
X
X#define INITIAL_MAX_DFAS 1000	/* default maximum number of dfa states */
X#define MAX_DFAS_INCREMENT 1000
X
X#define JAMSTATE -32766	/* marks a reference to the state that always jams */
X
X/* enough so that if it's subtracted from an NFA state number, the result
X * is guaranteed to be negative
X */
X#define MARKER_DIFFERENCE 32000
X#define MAXIMUM_MNS 31999
X
X/* maximum number of nxt/chk pairs for non-templates */
X#define INITIAL_MAX_XPAIRS 2000
X#define MAX_XPAIRS_INCREMENT 2000
X
X/* maximum number of nxt/chk pairs needed for templates */
X#define INITIAL_MAX_TEMPLATE_XPAIRS 2500
X#define MAX_TEMPLATE_XPAIRS_INCREMENT 2500
X
X#define SYM_EPSILON (CSIZE + 1)	/* to mark transitions on the symbol epsilon */
X
X#define INITIAL_MAX_SCS 40	/* maximum number of start conditions */
X#define MAX_SCS_INCREMENT 40	/* amount to bump by if it's not enough */
X
X#define ONE_STACK_SIZE 500	/* stack of states with only one out-transition */
X#define SAME_TRANS -1	/* transition is the same as "default" entry for state */
X
X/* the following percentages are used to tune table compression:
X
X * the percentage the number of out-transitions a state must be of the
X * number of equivalence classes in order to be considered for table
X * compaction by using protos
X */
X#define PROTO_SIZE_PERCENTAGE 15
X
X/* the percentage the number of homogeneous out-transitions of a state
X * must be of the number of total out-transitions of the state in order
X * that the state's transition table is first compared with a potential 
X * template of the most common out-transition instead of with the first
X * proto in the proto queue
X */
X#define CHECK_COM_PERCENTAGE 50
X
X/* the percentage the number of differences between a state's transition
X * table and the proto it was first compared with must be of the total
X * number of out-transitions of the state in order to keep the first
X * proto as a good match and not search any further
X */
X#define FIRST_MATCH_DIFF_PERCENTAGE 10
X
X/* the percentage the number of differences between a state's transition
X * table and the most similar proto must be of the state's total number
X * of out-transitions to use the proto as an acceptable close match
X */
X#define ACCEPTABLE_DIFF_PERCENTAGE 50
X
X/* the percentage the number of homogeneous out-transitions of a state
X * must be of the number of total out-transitions of the state in order
X * to consider making a template from the state
X */
X#define TEMPLATE_SAME_PERCENTAGE 60
X
X/* the percentage the number of differences between a state's transition
X * table and the most similar proto must be of the state's total number
X * of out-transitions to create a new proto from the state
X */
X#define NEW_PROTO_DIFF_PERCENTAGE 20
X
X/* the percentage the total number of out-transitions of a state must be
X * of the number of equivalence classes in order to consider trying to
X * fit the transition table into "holes" inside the nxt/chk table.
X */
X#define INTERIOR_FIT_PERCENTAGE 15
X
X/* size of region set aside to cache the complete transition table of
X * protos on the proto queue to enable quick comparisons
X */
X#define PROT_SAVE_SIZE 2000
X
X#define MSP 50	/* maximum number of saved protos (protos on the proto queue) */
X
X/* maximum number of out-transitions a state can have that we'll rummage
X * around through the interior of the internal fast table looking for a
X * spot for it
X */
X#define MAX_XTIONS_FULL_INTERIOR_FIT 4
X
X/* maximum number of rules which will be reported as being associated
X * with a DFA state
X */
X#define MAX_ASSOC_RULES 100
X
X/* number that, if used to subscript an array, has a good chance of producing
X * an error; should be small enough to fit into a short
X */
X#define BAD_SUBSCRIPT -32767
X
X/* absolute value of largest number that can be stored in a short, with a
X * bit of slop thrown in for general paranoia.
X */
X#define MAX_SHORT 32766
X
X
X/* Declarations for global variables. */
X
X/* variables for symbol tables:
X * sctbl - start-condition symbol table
X * ndtbl - name-definition symbol table
X * ccltab - character class text symbol table
X */
X
Xstruct hash_entry
X    {
X    struct hash_entry *prev, *next;
X    char *name;
X    char *str_val;
X    int int_val;
X    } ;
X
Xtypedef struct hash_entry *hash_table[];
X
X#define NAME_TABLE_HASH_SIZE 101
X#define START_COND_HASH_SIZE 101
X#define CCL_HASH_SIZE 101
X
Xextern struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE]; 
Xextern struct hash_entry *sctbl[START_COND_HASH_SIZE];
Xextern struct hash_entry *ccltab[CCL_HASH_SIZE];
X
X
X/* variables for flags:
X * printstats - if true (-v), dump statistics
X * syntaxerror - true if a syntax error has been found
X * eofseen - true if we've seen an eof in the input file
X * ddebug - if true (-d), make a "debug" scanner
X * trace - if true (-T), trace processing
X * spprdflt - if true (-s), suppress the default rule
X * interactive - if true (-I), generate an interactive scanner
X * caseins - if true (-i), generate a case-insensitive scanner
X * useecs - if true (-Ce flag), use equivalence classes
X * fulltbl - if true (-Cf flag), don't compress the DFA state table
X * usemecs - if true (-Cm flag), use meta-equivalence classes
X * fullspd - if true (-F flag), use Jacobson method of table representation
X * gen_line_dirs - if true (i.e., no -L flag), generate #line directives
X * performance_report - if true (i.e., -p flag), generate a report relating
X *   to scanner performance
X * backtrack_report - if true (i.e., -b flag), generate "lex.backtrack" file
X *   listing backtracking states
X * csize - size of character set for the scanner we're generating;
X *   128 for 7-bit chars and 256 for 8-bit
X * yymore_used - if true, yymore() is used in input rules
X * reject - if true, generate backtracking tables for REJECT macro
X * real_reject - if true, scanner really uses REJECT (as opposed to just
X *   having "reject" set for variable trailing context)
X * continued_action - true if this rule's action is to "fall through" to
X *   the next rule's action (i.e., the '|' action)
X * yymore_really_used - has a REALLY_xxx value indicating whether a
X *   %used or %notused was used with yymore()
X * reject_really_used - same for REJECT
X */
X
Xextern int printstats, syntaxerror, eofseen, ddebug, trace, spprdflt;
Xextern int interactive, caseins, useecs, fulltbl, usemecs;
Xextern int fullspd, gen_line_dirs, performance_report, backtrack_report, csize;
Xextern int yymore_used, reject, real_reject, continued_action;
X
X#define REALLY_NOT_DETERMINED 0
X#define REALLY_USED 1
X#define REALLY_NOT_USED 2
Xextern int yymore_really_used, reject_really_used;
X
X
X/* variables used in the flex input routines:
X * datapos - characters on current output line
X * dataline - number of contiguous lines of data in current data
X *    statement.  Used to generate readable -f output
X * linenum - current input line number
X * skelfile - the skeleton file
X * yyin - input file
X * temp_action_file - temporary file to hold actions
X * backtrack_file - file to summarize backtracking states to
X * infilename - name of input file
X * action_file_name - name of the temporary file
X * input_files - array holding names of input files
X * num_input_files - size of input_files array
X * program_name - name with which program was invoked 
X */
X
Xextern int datapos, dataline, linenum;
Xextern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file;
Xextern char *infilename;
Xextern char *action_file_name;
Xextern char **input_files;
Xextern int num_input_files;
Xextern char *program_name;
X
X
X/* variables for stack of states having only one out-transition:
X * onestate - state number
X * onesym - transition symbol
X * onenext - target state
X * onedef - default base entry
X * onesp - stack pointer
X */
X
Xextern int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
Xextern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
X
X
X/* variables for nfa machine data:
X * current_mns - current maximum on number of NFA states
X * num_rules - number of the last accepting state; also is number of
X *             rules created so far
X * current_max_rules - current maximum number of rules
X * lastnfa - last nfa state number created
X * firstst - physically the first state of a fragment
X * lastst - last physical state of fragment
X * finalst - last logical state of fragment
X * transchar - transition character
X * trans1 - transition state
X * trans2 - 2nd transition state for epsilons
X * accptnum - accepting number
X * assoc_rule - rule associated with this NFA state (or 0 if none)
X * state_type - a STATE_xxx type identifying whether the state is part
X *              of a normal rule, the leading state in a trailing context
X *              rule (i.e., the state which marks the transition from
X *              recognizing the text-to-be-matched to the beginning of
X *              the trailing context), or a subsequent state in a trailing
X *              context rule
X * rule_type - a RULE_xxx type identifying whether this a a ho-hum
X *             normal rule or one which has variable head & trailing
X *             context
X * rule_linenum - line number associated with rule
X */
X
Xextern int current_mns, num_rules, current_max_rules, lastnfa;
Xextern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
Xextern int *accptnum, *assoc_rule, *state_type, *rule_type, *rule_linenum;
X
X/* different types of states; values are useful as masks, as well, for
X * routines like check_trailing_context()
X */
X#define STATE_NORMAL 0x1
X#define STATE_TRAILING_CONTEXT 0x2
X
X/* global holding current type of state we're making */
X
Xextern int current_state_type;
X
X/* different types of rules */
X#define RULE_NORMAL 0
X#define RULE_VARIABLE 1
X
X/* true if the input rules include a rule with both variable-length head
X * and trailing context, false otherwise
X */
Xextern int variable_trailing_context_rules;
X
X
X/* variables for protos:
X * numtemps - number of templates created
X * numprots - number of protos created
X * protprev - backlink to a more-recently used proto
X * protnext - forward link to a less-recently used proto
X * prottbl - base/def table entry for proto
X * protcomst - common state of proto
X * firstprot - number of the most recently used proto
X * lastprot - number of the least recently used proto
X * protsave contains the entire state array for protos
X */
X
Xextern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
Xextern int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE];
X
X
X/* variables for managing equivalence classes:
X * numecs - number of equivalence classes
X * nextecm - forward link of Equivalence Class members
X * ecgroup - class number or backward link of EC members
X * nummecs - number of meta-equivalence classes (used to compress
X *   templates)
X * tecfwd - forward link of meta-equivalence classes members
X * tecbck - backward link of MEC's
X * xlation - maps character codes to their translations, or nil if no %t table
X * num_xlations - number of different xlation values
X */
X
X/* reserve enough room in the equivalence class arrays so that we
X * can use the CSIZE'th element to hold equivalence class information
X * for the NUL character.  Later we'll move this information into
X * the 0th element.
X */
Xextern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs;
X
X/* meta-equivalence classes are indexed starting at 1, so it's possible
X * that they will require positions from 1 .. CSIZE, i.e., CSIZE + 1
X * slots total (since the arrays are 0-based).  nextecm[] and ecgroup[]
X * don't require the extra position since they're indexed from 1 .. CSIZE - 1.
X */
Xextern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
X
Xextern int *xlation;
Xextern int num_xlations;
X
X
X/* variables for start conditions:
X * lastsc - last start condition created
X * current_max_scs - current limit on number of start conditions
X * scset - set of rules active in start condition
X * scbol - set of rules active only at the beginning of line in a s.c.
X * scxclu - true if start condition is exclusive
X * sceof - true if start condition has EOF rule
X * scname - start condition name
X * actvsc - stack of active start conditions for the current rule
X */
X
Xextern int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc;
Xextern char **scname;
X
X
X/* variables for dfa machine data:
X * current_max_dfa_size - current maximum number of NFA states in DFA
X * current_max_xpairs - current maximum number of non-template xtion pairs
X * current_max_template_xpairs - current maximum number of template pairs
X * current_max_dfas - current maximum number DFA states
X * lastdfa - last dfa state number created
X * nxt - state to enter upon reading character
X * chk - check value to see if "nxt" applies
X * tnxt - internal nxt table for templates
X * base - offset into "nxt" for given state
X * def - where to go if "chk" disallows "nxt" entry
X * nultrans - NUL transition for each state
X * NUL_ec - equivalence class of the NUL character
X * tblend - last "nxt/chk" table entry being used
X * firstfree - first empty entry in "nxt/chk" table
X * dss - nfa state set for each dfa
X * dfasiz - size of nfa state set for each dfa
X * dfaacc - accepting set for each dfa state (or accepting number, if
X *    -r is not given)
X * accsiz - size of accepting set for each dfa state
X * dhash - dfa state hash value
X * numas - number of DFA accepting states created; note that this
X *    is not necessarily the same value as num_rules, which is the analogous
X *    value for the NFA
X * numsnpairs - number of state/nextstate transition pairs
X * jambase - position in base/def where the default jam table starts
X * jamstate - state number corresponding to "jam" state
X * end_of_buffer_state - end-of-buffer dfa state number
X */
X
Xextern int current_max_dfa_size, current_max_xpairs;
Xextern int current_max_template_xpairs, current_max_dfas;
Xextern int lastdfa, lasttemp, *nxt, *chk, *tnxt;
Xextern int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz;
Xextern union dfaacc_union
X    {
X    int *dfaacc_set;
X    int dfaacc_state;
X    } *dfaacc;
Xextern int *accsiz, *dhash, numas;
Xextern int numsnpairs, jambase, jamstate;
Xextern int end_of_buffer_state;
X
X/* variables for ccl information:
X * lastccl - ccl index of the last created ccl
X * current_maxccls - current limit on the maximum number of unique ccl's
X * cclmap - maps a ccl index to its set pointer
X * ccllen - gives the length of a ccl
X * cclng - true for a given ccl if the ccl is negated
X * cclreuse - counts how many times a ccl is re-used
X * current_max_ccl_tbl_size - current limit on number of characters needed
X *	to represent the unique ccl's
X * ccltbl - holds the characters in each ccl - indexed by cclmap
X */
X
Xextern int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse;
Xextern int current_max_ccl_tbl_size;
Xextern Char *ccltbl;
X
X
X/* variables for miscellaneous information:
X * starttime - real-time when we started
X * endtime - real-time when we ended
X * nmstr - last NAME scanned by the scanner
X * sectnum - section number currently being parsed
X * nummt - number of empty nxt/chk table entries
X * hshcol - number of hash collisions detected by snstods
X * dfaeql - number of times a newly created dfa was equal to an old one
X * numeps - number of epsilon NFA states created
X * eps2 - number of epsilon states which have 2 out-transitions
X * num_reallocs - number of times it was necessary to realloc() a group
X *		  of arrays
X * tmpuses - number of DFA states that chain to templates
X * totnst - total number of NFA states used to make DFA states
X * peakpairs - peak number of transition pairs we had to store internally
X * numuniq - number of unique transitions
X * numdup - number of duplicate transitions
X * hshsave - number of hash collisions saved by checking number of states
X * num_backtracking - number of DFA states requiring back-tracking
X * bol_needed - whether scanner needs beginning-of-line recognition
X */
X
Xextern char *starttime, *endtime, nmstr[MAXLINE];
Xextern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
Xextern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
Xextern int num_backtracking, bol_needed;
X
Xvoid *allocate_array(), *reallocate_array();
X
X#define allocate_integer_array(size) \
X	(int *) allocate_array( size, sizeof( int ) )
X
X#define reallocate_integer_array(array,size) \
X	(int *) reallocate_array( (void *) array, size, sizeof( int ) )
X
X#define allocate_int_ptr_array(size) \
X	(int **) allocate_array( size, sizeof( int * ) )
X
X#define allocate_char_ptr_array(size) \
X	(char **) allocate_array( size, sizeof( char * ) )
X
X#define allocate_dfaacc_union(size) \
X	(union dfaacc_union *) \
X		allocate_array( size, sizeof( union dfaacc_union ) )
X
X#define reallocate_int_ptr_array(array,size) \
X	(int **) reallocate_array( (void *) array, size, sizeof( int * ) )
X
X#define reallocate_char_ptr_array(array,size) \
X	(char **) reallocate_array( (void *) array, size, sizeof( char * ) )
X
X#define reallocate_dfaacc_union(array, size) \
X	(union dfaacc_union *) \
X	reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) )
X
X#define allocate_character_array(size) \
X	(Char *) allocate_array( size, sizeof( Char ) )
X
X#define reallocate_character_array(array,size) \
X	(Char *) reallocate_array( (void *) array, size, sizeof( Char ) )
X
X
X/* used to communicate between scanner and parser.  The type should really
X * be YYSTYPE, but we can't easily get our hands on it.
X */
Xextern int yylval;
X
X
X/* external functions that are cross-referenced among the flex source files */
X
X
X/* from file ccl.c */
X
Xextern void ccladd PROTO((int, int));	/* Add a single character to a ccl */
Xextern int cclinit PROTO(());	/* make an empty ccl */
Xextern void cclnegate PROTO((int));	/* negate a ccl */
X
X/* list the members of a set of characters in CCL form */
Xextern void list_character_set PROTO((FILE*, int[]));
X
X
X/* from file dfa.c */
X
X/* increase the maximum number of dfas */
Xextern void increase_max_dfas PROTO(());
X
Xextern void ntod PROTO(());	/* convert a ndfa to a dfa */
X
X
X/* from file ecs.c */
X
X/* convert character classes to set of equivalence classes */
Xextern void ccl2ecl PROTO(());
X
X/* associate equivalence class numbers with class members */
Xextern int cre8ecs PROTO((int[], int[], int));
X
X/* associate equivalence class numbers using %t table */
Xextern int ecs_from_xlation PROTO((int[]));
X
X/* update equivalence classes based on character class transitions */
Xextern void mkeccl PROTO((Char[], int, int[], int[], int, int));
X
X/* create equivalence class for single character */
Xextern void mkechar PROTO((int, int[], int[]));
X
X
X/* from file gen.c */
X
Xextern void make_tables PROTO(());	/* generate transition tables */
X
X
X/* from file main.c */
X
Xextern void flexend PROTO((int));
X
X
X/* from file misc.c */
X
X/* write out the actions from the temporary file to lex.yy.c */
Xextern void action_out PROTO(());
X
X/* true if a string is all lower case */
Xextern int all_lower PROTO((register Char *));
X
X/* true if a string is all upper case */
Xextern int all_upper PROTO((register Char *));
X
X/* bubble sort an integer array */
Xextern void bubble PROTO((int [], int));
X
X/* shell sort a character array */
Xextern void cshell PROTO((Char [], int, int));
X
Xextern void dataend PROTO(());	/* finish up a block of data declarations */
X
X/* report an error message and terminate */
Xextern void flexerror PROTO((char[]));
X
X/* report a fatal error message and terminate */
Xextern void flexfatal PROTO((char[]));
X
X/* report an error message formatted with one integer argument */
Xextern void lerrif PROTO((char[], int));
X
X/* report an error message formatted with one string argument */
Xextern void lerrsf PROTO((char[], char[]));
X
X/* spit out a "# line" statement */
Xextern void line_directive_out PROTO((FILE*));
X
X/* generate a data statment for a two-dimensional array */
Xextern void mk2data PROTO((int));
X
Xextern void mkdata PROTO((int));	/* generate a data statement */
X
X/* return the integer represented by a string of digits */
Xextern int myctoi PROTO((Char []));
X
X/* write out one section of the skeleton file */
Xextern void skelout PROTO(());
X
X/* output a yy_trans_info structure */
Xextern void transition_struct_out PROTO((int, int));
X
X
X/* from file nfa.c */
X
X/* add an accepting state to a machine */
Xextern void add_accept PROTO((int, int));
X
X/* make a given number of copies of a singleton machine */
Xextern int copysingl PROTO((int, int));
X
X/* debugging routine to write out an nfa */
Xextern void dumpnfa PROTO((int));
X
X/* finish up the processing for a rule */
Xextern void finish_rule PROTO((int, int, int, int));
X
X/* connect two machines together */
Xextern int link_machines PROTO((int, int));
X
X/* mark each "beginning" state in a machine as being a "normal" (i.e.,
X * not trailing context associated) state
X */
Xextern void mark_beginning_as_normal PROTO((register int));
X
X/* make a machine that branches to two machines */
Xextern int mkbranch PROTO((int, int));
X
Xextern int mkclos PROTO((int));	/* convert a machine into a closure */
Xextern int mkopt PROTO((int));	/* make a machine optional */
X
X/* make a machine that matches either one of two machines */
Xextern int mkor PROTO((int, int));
X
X/* convert a machine into a positive closure */
Xextern int mkposcl PROTO((int));
X
Xextern int mkrep PROTO((int, int, int));	/* make a replicated machine */
X
X/* create a state with a transition on a given symbol */
Xextern int mkstate PROTO((int));
X
Xextern void new_rule PROTO(());	/* initialize for a new rule */
X
X
X/* from file parse.y */
X
X/* write out a message formatted with one string, pinpointing its location */
Xextern void format_pinpoint_message PROTO((char[], char[]));
X
X/* write out a message, pinpointing its location */
Xextern void pinpoint_message PROTO((char[]));
X
Xextern void synerr PROTO((char []));	/* report a syntax error */
Xextern int yyparse PROTO(());	/* the YACC parser */
X
X
X/* from file scan.l */
X
Xextern int flexscan PROTO(());	/* the Flex-generated scanner for flex */
X
X/* open the given file (if NULL, stdin) for scanning */
Xextern void set_input_file PROTO((char*));
X
Xextern int yywrap PROTO(());	/* wrapup a file in the lexical analyzer */
X
X
X/* from file sym.c */
X
X/* save the text of a character class */
Xextern void cclinstal PROTO ((Char [], int));
X
X/* lookup the number associated with character class */
Xextern int ccllookup PROTO((Char []));
X
Xextern void ndinstal PROTO((char[], Char[]));	/* install a name definition */
Xextern void scinstal PROTO((char[], int));	/* make a start condition */
X
X/* lookup the number associated with a start condition */
Xextern int sclookup PROTO((char[]));
X
X
X/* from file tblcmp.c */
X
X/* build table entries for dfa state */
Xextern void bldtbl PROTO((int[], int, int, int, int));
X
Xextern void cmptmps PROTO(());	/* compress template table entries */
Xextern void inittbl PROTO(());	/* initialize transition tables */
Xextern void mkdeftbl PROTO(());	/* make the default, "jam" table entries */
X
X/* create table entries for a state (or state fragment) which has
X * only one out-transition */
Xextern void mk1tbl PROTO((int, int, int, int));
X
X/* place a state into full speed transition table */
Xextern void place_state PROTO((int*, int, int));
X
X/* save states with only one out-transition to be processed later */
Xextern void stack1 PROTO((int, int, int, int));
X
X
X/* from file yylex.c */
X
Xextern int yylex PROTO(());
X
X
X/* The Unix kernel calls used here */
X
Xextern int read PROTO((int, char*, int));
Xextern int unlink PROTO((char*));
Xextern int write PROTO((int, char*, int));
END_OF_FILE
if test 28965 -ne `wc -c <'flexdef.h'`; then
    echo shar: \"'flexdef.h'\" unpacked with wrong size!
fi
# end of 'flexdef.h'
fi
echo shar: End of archive 6 \(of 13\).
cp /dev/null ark6isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 13 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0
-- 
Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
Mail comments to the moderator at <amiga-request@uunet.uu.net>.
Post requests for sources, and general discussion to comp.sys.amiga.