🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sources.mac
Article #63

Flex for the Mac (part 7 of 7)

#63
From: Earle R. Horton
Date: Sat, 02 Jul 1988 21:37
1064 lines
32960 bytes
[Flex for the Mac - part 7 of 7]

---
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	flex/yylex.c
#	flex/fastskeldef.h
#	flex/flexdef.h
#	flex/flexskelcom.h
#	flex/flexskeldef.h
# This archive created: Wed Jun 29 07:03:31 1988
# By:	Roger L. Long (bytebug@dhw68k.cts.com)
export PATH; PATH=/bin:$PATH
echo shar: extracting "'yylex.c'" '(3554 characters)'
if test -f 'yylex.c'
then
	echo shar: will not over-write existing file "'yylex.c'"
else
sed 's/^X//' << \SHAR_EOF > 'yylex.c'
X/* yylex - scanner front-end for flex */
X
X#include "flexdef.h"
X#include "parse.h"
X
X/*
X * Copyright (c) 1987, the University of California
X * 
X * The United States Government has rights in this work pursuant to
X * contract no. DE-AC03-76SF00098 between the United States Department of
X * Energy and the University of California.
X * 
X * This program may be redistributed.  Enhancements and derivative works
X * may be created provided the new works, if made available to the general
X * public, are made available for use by anyone.
X */
X
X/* yylex - scan for a regular expression token
X *
X * synopsis
X *
X *   token = yylex();
X *
X *     token - return token found
X */
X
Xint yylex()
X
X    {
X    int toktype;
X    static int beglin = false;
X
X    if ( eofseen )
X	toktype = EOF;
X    else
X	toktype = flexscan();
X
X    if ( toktype == EOF )
X	{
X	eofseen = 1;
X
X	if ( sectnum == 1 )
X	    {
X	    synerr( "unexpected EOF" );
X	    sectnum = 2;
X	    toktype = SECTEND;
X	    }
X
X	else if ( sectnum == 2 )
X	    {
X	    sectnum = 3;
X	    toktype = SECTEND;
X	    }
X
X	else
X	    toktype = 0;
X	}
X
X    if ( trace )
X	{
X	if ( beglin )
X	    {
X	    fprintf( stderr, "%d\t", accnum + 1 );
X	    beglin = 0;
X	    }
X
X	switch ( toktype )
X	    {
X	    case '<':
X	    case '>':
X	    case '^':
X	    case '$':
X	    case '"':
X	    case '[':
X	    case ']':
X	    case '{':
X	    case '}':
X	    case '|':
X	    case '(':
X	    case ')':
X	    case '-':
X	    case '/':
X	    case '\\':
X	    case '?':
X	    case '.':
X	    case '*':
X	    case '+':
X	    case ',':
X		(void) putc( toktype, stderr );
X		break;
X
X	    case '\n':
X		(void) putc( '\n', stderr );
X
X		if ( sectnum == 2 )
X		    beglin = 1;
X
X		break;
X
X	    case SCDECL:
X		fputs( "%s", stderr );
X		break;
X
X	    case XSCDECL:
X		fputs( "%x", stderr );
X		break;
X
X	    case WHITESPACE:
X		(void) putc( ' ', stderr );
X		break;
X
X	    case SECTEND:
X		fputs( "%%\n", stderr );
X
X		/* we set beglin to be true so we'll start
X		 * writing out numbers as we echo rules.  flexscan() has
X		 * already assigned sectnum
X		 */
X
X		if ( sectnum == 2 )
X		    beglin = 1;
X
X		break;
X
X	    case NAME:
X		fprintf( stderr, "'%s'", nmstr );
X		break;
X
X	    case CHAR:
X		switch ( yylval )
X		    {
X		    case '<':
X		    case '>':
X		    case '^':
X		    case '$':
X		    case '"':
X		    case '[':
X		    case ']':
X		    case '{':
X		    case '}':
X		    case '|':
X		    case '(':
X		    case ')':
X		    case '-':
X		    case '/':
X		    case '\\':
X		    case '?':
X		    case '.':
X		    case '*':
X		    case '+':
X		    case ',':
X			fprintf( stderr, "\\%c", yylval );
X			break;
X
X		    case 1:
X		    case 2:
X		    case 3:
X		    case 4:
X		    case 5:
X		    case 6:
X		    case 7:
X		    case 8:
X		    case 9:
X		    case 10:
X		    case 11:
X		    case 12:
X		    case 13:
X		    case 14:
X		    case 15:
X		    case 16:
X		    case 17:
X		    case 18:
X		    case 19:
X		    case 20:
X		    case 21:
X		    case 22:
X		    case 23:
X		    case 24:
X		    case 25:
X		    case 26:
X		    case 27:
X		    case 28:
X		    case 29:
X		    case 30:
X		    case 31:
X			fprintf( stderr, "^%c", 'A' + yylval - 1 );
X			break;
X
X		    case 127:
X			(void) putc( '^', stderr );
X			(void) putc( '@', stderr );
X			break;
X
X		    default:
X			(void) putc( yylval, stderr );
X			break;
X		    }
X			
X		break;
X
X	    case NUMBER:
X		fprintf( stderr, "%d", yylval );
X		break;
X
X	    case PREVCCL:
X		fprintf( stderr, "[%d]", yylval );
X		break;
X
X	    case 0:
X		fprintf( stderr, "End Marker" );
X		break;
X
X	    default:
X		fprintf( stderr, "*Something Weird* - tok: %d val: %d\n",
X			 toktype, yylval );
X		break;
X	    }
X	}
X	    
X    return ( toktype );
X    }
SHAR_EOF
if test 3554 -ne "`wc -c < 'yylex.c'`"
then
	echo shar: error transmitting "'yylex.c'" '(should have been 3554 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'fastskeldef.h'" '(2842 characters)'
if test -f 'fastskeldef.h'
then
	echo shar: will not over-write existing file "'fastskeldef.h'"
else
sed 's/^X//' << \SHAR_EOF > 'fastskeldef.h'
X/*  macro definitions for fast/full-table  C/FTL programs generated by flex */
X
X#include "flexskelcom.h"
X
X#define YY_END_OF_BUFFER_CHAR 0
X
X/* action number for "not an accepting state; back-track (not implemented)" */
X#define YY_BACK_TRACK 0
X
X/* action number for end-of-buffer was seen */
X#define YY_END_OF_BUFFER -3
X
X/* reinitializes everything except the current start condition.  The last
X * input character is set to a newline so an initial beginning-of-line
X * rule will match
X */
X#define YY_FAST_INIT \
X	{ \
X	yytext = yy_c_buf_p = &yy_ch_buf[1]; \
X	yyleng = 0; \
X	yy_hold_char = *yy_c_buf_p; \
X	}
X
X/* done before the next pattern has been matched action
X * change both of these if you change them at all!
X */
X#define YY_DO_BEFORE_SCAN \
X	*yy_c_buf_p = yy_hold_char
X#define YY_DO_BEFORE_RESTART \
X	yy_hold_char = *yy_c_buf_p
X
X/* done after the current pattern has been matched and before the
X * corresponding action
X */
X#define YY_DO_BEFORE_ACTION \
X	yytext = yy_b_buf_p; \
X	yyleng = YY_LENG; \
X	yy_hold_char = *yy_c_buf_p; \
X	*yy_c_buf_p = '\0'
X
X/* returns the length of the matched text */
X#define YY_LENG (yy_c_buf_p - yy_b_buf_p)
X
X#ifdef FLEX_FULL_TABLE
X#define YY_CS_TYPE int
X#else
X#define YY_CS_TYPE struct yy_trans_info *
X#endif
X
X/* find starting state */
X#ifdef FLEX_FULL_TABLE
X#    define YY_FIND_START_STATE( x ) \
X	    x = yy_start; \
X	    if ( yy_b_buf_p[-1] == '\n' ) \
X		++x
X#else
X#    define YY_FIND_START_STATE( x ) \
X	    x = yy_state_ptr[yy_start]; \
X	    if ( yy_b_buf_p[-1] == '\n' ) \
X		x = yy_state_ptr[yy_start + 1]
X#endif
X
X# ifdef FLEX_USE_ECS
X#     define yy_eq(x) e[x]
X# else
X#     define yy_eq(x) x
X# endif
X
X/* get next jam state from packed table */
X#ifdef FLEX_FULL_TABLE
X#    define YY_FIND_NEXT_MATCH \
X	    { \
X	    register int yy_state_info; \
X	    while ( (yy_state_info = n[yy_current_state][yy_eq(*yy_c_buf_p)] ) != YY_JAM ) \
X		{ \
X		yy_current_state = yy_state_info; \
X		YY_BACKTRACKING_ACTION \
X		yy_c_buf_p++; \
X		} \
X	    }
X#else
X#    define YY_FIND_NEXT_MATCH \
X	    for ( yy_c = yy_eq(*yy_c_buf_p); \
X		  (yy_trans_info = &yy_current_state[yy_c])->v == yy_c; \
X		  yy_c = yy_eq(*++yy_c_buf_p) ) \
X		{ \
X		yy_current_state += yy_trans_info->n; \
X		YY_BACKTRACKING_ACTION \
X		}
X#endif
X
X#ifdef FLEX_FULL_TABLE
X#    define YY_FIND_ACTION( x ) x = l[yy_current_state]
X#else
X#    define YY_FIND_ACTION( x ) x = yy_current_state[-1].n
X#endif
X
X
X#ifdef FLEX_FULL_TABLE
X#    define YY_GET_NEXT_STATE yy_cur_state = n[yy_cur_state][*(yy_temp_char_ptr++)]
X#else
X#    define YY_GET_NEXT_STATE yy_cur_state += yy_cur_state[*(yy_temp_char_ptr++)].n
X#endif
X
X#define EOB_ACT_RESTART_SCAN 2
X#define EOB_ACT_END_OF_FILE 3
X#define EOB_ACT_LAST_MATCH 4
X
X#ifdef FLEX_FULL_TABLE
X#define YY_DECLARE_YY_CS_PARAM int *yy_current_state
X#else
X#define YY_DECLARE_YY_CS_PARAM struct yy_trans_info *yy_current_state
X#endif
SHAR_EOF
if test 2842 -ne "`wc -c < 'fastskeldef.h'`"
then
	echo shar: error transmitting "'fastskeldef.h'" '(should have been 2842 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'flexdef.h'" '(17911 characters)'
if test -f 'flexdef.h'
then
	echo shar: will not over-write existing file "'flexdef.h'"
else
sed 's/^X//' << \SHAR_EOF > 'flexdef.h'
X/*
X *  Definitions for flex.
X *
X * modification history
X * --------------------
X * 02b kg, vp   30sep87  .added definitions for fast scanner; misc. cleanup
X * 02a vp       27jun86  .translated into C/FTL
X */
X
X/*
X * Copyright (c) 1987, the University of California
X * 
X * The United States Government has rights in this work pursuant to
X * contract no. DE-AC03-76SF00098 between the United States Department of
X * Energy and the University of California.
X * 
X * This program may be redistributed.  Enhancements and derivative works
X * may be created provided the new works, if made available to the general
X * public, are made available for use by anyone.
X */
X
X#include <stdio.h>
X
X#ifdef MPW
X#include <string.h>
X#else
X#ifdef SV
X#include <string.h>
X#define bzero(s, n) memset((char *)(s), '\000', (unsigned)(n))
X#else
X#include <strings.h>
X#endif
X#endif
X
X/* Critical where characters are signed. */
X#ifndef BYTEMASK
X#define BYTEMASK	0xFF
X#endif
X
X
Xchar *sprintf(); /* keep lint happy */
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#define min(x,y) (x < y ? x : y)
X#define max(x,y) (x > y ? x : y)
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#ifndef FAST_SKELETON_FILE
X#define FAST_SKELETON_FILE "flex.fastskel"
X#endif
X
X/* special nxt[] action number for the "at the end of the input buffer" state */
X/* note: -1 is already taken by YY_NEW_FILE */
X#define END_OF_BUFFER_ACTION -3
X/* action number for default action for fast scanners */
X#define DEFAULT_ACTION -2
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/* array names to be used in generated machine.  They're short because
X * we write out one data statement (which names the array) for each element
X * in the array.
X */
X
X#define ALIST 'l'	/* points to list of rules accepted for a state */
X#define ACCEPT 'a'	/* list of rules accepted for a state */
X#define ECARRAY 'e'	/* maps input characters to equivalence classes */
X#define MATCHARRAY 'm'	/* maps equivalence classes to meta-equivalence classes */
X#define BASEARRAY 'b'	/* "base" array */
X#define DEFARRAY 'd'	/* "default" array */
X#define NEXTARRAY 'n'	/* "next" array */
X#define CHECKARRAY 'c'	/* "check" array */
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/* size of input alphabet - should be size of ASCII set */
X#ifdef MPW
X#define CSIZE 255
X#else
X#define CSIZE 127
X#endif
X
X#define INITIAL_MAXCCLS 100	/* max number of unique character classes */
X#define MAXCCLS_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_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 0	/* 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_FOR_FULL_INTERIOR_FIT 4
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    unsigned char *name;
X    unsigned 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 * reject - if true (-r flag), generate tables for REJECT macro
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 */
X
Xextern int printstats, syntaxerror, eofseen, ddebug, trace, spprdflt;
Xextern int interactive, caseins, useecs, fulltbl, usemecs, reject;
Xextern int fullspd, gen_line_dirs;
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 * skelfile - fd of the skeleton file
X * yyin - input file
X * temp_action_file - temporary file to hold actions
X * action_file_name - name of the temporary file
X * infilename - name of input file
X * linenum - current input line number
X */
X
Xextern int datapos, dataline, linenum;
Xextern FILE *skelfile, *yyin, *temp_action_file;
Xextern char *infilename;
Xextern char *action_file_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
X#ifdef MALLOC_BUFFERS
Xextern int *onestate,*onesym,*onenext,*onedef,onesp;
X#else
Xextern int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
Xextern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
X#endif
X
X
X/* variables for nfa machine data:
X * current_mns - current maximum on number of NFA states
X * accnum - number of the last accepting state
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 * lastnfa - last nfa state number created
X */
X
Xextern int current_mns;
Xextern int accnum, *firstst, *lastst, *finalst, *transchar;
Xextern int *trans1, *trans2, *accptnum, lastnfa;
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#ifdef MALLOC_BUFFERS
Xextern int numtemps, numprots, *protprev, *protnext, *prottbl;
Xextern int *protcomst, firstprot, lastprot,
X#else
Xextern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
Xextern int protcomst[MSP], firstprot, lastprot,
X#endif
X#ifdef MALLOC_BUFFERS
X	*protsave;
X#else
X	protsave[PROT_SAVE_SIZE];
X#endif
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 */
X#ifdef MALLOC_BUFFERS
Xextern int numecs, *nextecm, *ecgroup, nummecs;
Xextern int *tecfwd, *tecbck;
X#else
Xextern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs;
Xextern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
X#endif
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 * actvsc - stack of active start conditions for the current rule
X */
X
Xextern int lastsc, current_max_scs, *scset, *scbol, *scxclu, *actvsc;
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 * 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 * todo - queue of DFAs still to be processed
X * todo_head - head of todo queue
X * todo_next - next available entry on todo queue
X * numas - number of DFA accepting states created; note that this
X *    is not necessarily the same value as accnum, 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, tblend, firstfree, **dss, *dfasiz;
Xextern union dfaacc_union
X    {
X    int *dfaacc_set;
X    int dfaacc_state;
X    } *dfaacc;
Xextern int *accsiz, *dhash, *todo, todo_head, todo_next, 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 */
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;
X
Xchar *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( (char *) array, size, sizeof( int ) )
X
X#define allocate_integer_pointer_array(size) \
X	(int **) allocate_array( size, sizeof( int * ) )
X
X#define allocate_dfaacc_union(size) \
X	(union dfaacc_union *) \
X		allocate_array( size, sizeof( union dfaacc_union ) )
X
X#define reallocate_integer_pointer_array(array,size) \
X	(int **) reallocate_array( (char *) array, size, sizeof( int * ) )
X
X#define reallocate_dfaacc_union(array, size) \
X	(union dfaacc_union *)  reallocate_array( (char *) array, size, sizeof( union dfaacc_union ) )
X
X#define allocate_character_array(size) allocate_array( size, sizeof( char ) )
X
X#define reallocate_character_array(array,size) \
X	reallocate_array( 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;
SHAR_EOF
if test 17911 -ne "`wc -c < 'flexdef.h'`"
then
	echo shar: error transmitting "'flexdef.h'" '(should have been 17911 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'flexskelcom.h'" '(2466 characters)'
if test -f 'flexskelcom.h'
then
	echo shar: will not over-write existing file "'flexskelcom.h'"
else
sed 's/^X//' << \SHAR_EOF > 'flexskelcom.h'
X/* common macro definitions for C/FTL programs generated by flex */
X
X/* Critical where characters are signed. */
X#define BYTEMASK	0xFF
X
X/* returned upon end-of-file */
X#define YY_END_TOK 0
X
X/* action number for an "end-of-file was seen and yywrap indicated that we
X * should continue processing"
X */
X#define YY_NEW_FILE -1
X
X/* action number for "the default action should be done" */
X#define YY_DO_DEFAULT -2
X
X#ifndef BUFSIZ
X#include <stdio.h>
X#endif
X
X#define YY_BUF_SIZE (BUFSIZ * 2) /* size of input buffer */
X
X/* number of characters one rule can match.  One less than YY_BUF_SIZE to make
X * sure we never access beyond the end of an array
X */
X#define YY_BUF_MAX (YY_BUF_SIZE - 1)
X
X/* we will never use more than the first YY_BUF_LIM + YY_MAX_LINE positions
X * of the input buffer
X */
X#ifndef YY_MAX_LINE
X#define YY_MAX_LINE BUFSIZ
X#endif
X
X#define YY_BUF_LIM (YY_BUF_MAX - YY_MAX_LINE)
X
X/* copy whatever the last rule matched to the standard output */
X
X#define ECHO fputs( yytext, yyout )
X
X/* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
X * is returned in "result".
X */
X#define YY_INPUT(buf,result,max_size) \
X	if ( (result = read( fileno(yyin), buf, max_size )) < 0 ) \
X	    YY_FATAL_ERROR( "read() in flex scanner failed" );
X#define YY_NULL 0
X
X/* macro used to output a character */
X#define YY_OUTPUT(c) putc( c, yyout );
X
X/* report a fatal error */
X#define YY_FATAL_ERROR(msg) \
X	{ \
X	fputs( msg, stderr ); \
X	putc( '\n', stderr ); \
X	exit( 1 ); \
X	}
X
X/* returns the first character of the matched text */
X#define YY_FIRST_CHAR yy_ch_buf[yy_b_buf_p]
X
X/* default yywrap function - always treat EOF as an EOF */
X#define yywrap() 1
X
X/* enter a start condition.  This macro really ought to take a parameter,
X * but we do it the disgusting crufty way that old Unix-lex does it
X */
X#define BEGIN yy_start = 1 +
X
X/* callable from YY_INPUT to set things up so that '%' will match.  Proper
X * usage is "YY_SET_BOL(array,pos)"
X */
X#define YY_SET_BOL(array,pos) array[pos - 1] = '\n';
X
X/* default declaration of generated scanner - a define so the user can
X * easily add parameters
X */
X#define YY_DECL int yylex()
X
X/* return all but the first 'n' matched characters back to the input stream */
X#define yyless(n) \
X	{ \
X	YY_DO_BEFORE_SCAN; /* undo effects of setting up yytext */ \
X	yy_c_buf_p = yy_b_buf_p + n - 1; \
X	YY_DO_BEFORE_ACTION; /* set up yytext again */ \
X	}
X
X/* code executed at the end of each rule */
X#define YY_BREAK break;
SHAR_EOF
if test 2466 -ne "`wc -c < 'flexskelcom.h'`"
then
	echo shar: error transmitting "'flexskelcom.h'" '(should have been 2466 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'flexskeldef.h'" '(1197 characters)'
if test -f 'flexskeldef.h'
then
	echo shar: will not over-write existing file "'flexskeldef.h'"
else
sed 's/^X//' << \SHAR_EOF > 'flexskeldef.h'
X/* macro definitions for compressed-table C/FTL programs generated by flex */
X
X#include "flexskelcom.h"
X
X/* reinitializes everything except the current start condition.  The last
X * input character is set to a newline so an initial beginning-of-line
X * rule will match
X */
X#define YY_INIT \
X	{ \
X	yyleng = yy_c_buf_p = yy_e_buf_p = 0; \
X	yy_hold_char = yy_ch_buf[yy_c_buf_p] = '\n'; \
X	yytext = &yy_ch_buf[yy_c_buf_p]; \
X	yy_saw_eof = 0; \
X	}
X
X/* returns the length of the matched text */
X#define YY_LENG (yy_c_buf_p - yy_b_buf_p + 1)
X
X/* done before the next pattern has been matched action */
X#define YY_DO_BEFORE_SCAN \
X	yytext[yyleng] = yy_hold_char;
X
X/* done after the current pattern has been matched and before the corresponding action */
X#define YY_DO_BEFORE_ACTION \
X	yytext = &yy_ch_buf[yy_b_buf_p]; \
X	yyleng = YY_LENG; \
X	yy_hold_char = yytext[yyleng]; \
X	yytext[yyleng] = '\0';
X
X/* find the next rule matched */
X#ifdef FLEX_REJECT_ENABLED
X#define REJECT \
X        { \
X	YY_DO_BEFORE_SCAN; /* undo effects of setting up yytext */ \
X        ++yy_lp; \
X        goto find_rule; \
X        }
X#else
X#define REJECT YY_FATAL_ERROR( "REJECT used and scanner was not generated using -r" )
X#endif
SHAR_EOF
if test 1197 -ne "`wc -c < 'flexskeldef.h'`"
then
	echo shar: error transmitting "'flexskeldef.h'" '(should have been 1197 characters)'
fi
fi # end of overwriting check
#	End of shell archive
exit 0
--- end of part 7 ---
Technical Details
Message-ID: <9452@dhw68k.cts.com>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!think!ames!ucsd!ucsdhub!hp-sdd!hplabs!felix!dhw68k!macintosh
References: <9364@dhw68k.cts.com> <9368@dhw68k.cts.com> <9382@dhw68k.cts.com> <9386@dhw68k.cts.com> <9427@dhw68k.cts.com> <9429@dhw68k.cts.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!husc6!think!ames!ucsd!ucsdhub!hp-sdd!hplabs!felix!dhw68k!macintosh
From: earleh@eleazar.dartmouth.edu (Earle R. Horton)
Newsgroups: comp.sources.mac
Subject: Flex for the Mac (part 7 of 7)
Message-ID: <9452@dhw68k.cts.com>
Date: 2 Jul 88 21:37:39 GMT
References: <9364@dhw68k.cts.com> <9368@dhw68k.cts.com> <9382@dhw68k.cts.com> <9386@dhw68k.cts.com> <9427@dhw68k.cts.com> <9429@dhw68k.cts.com>
Sender: macintosh@dhw68k.cts.com
Organization: Dartmouth College, Hanover, NH
Lines: 1064
Approved: bytebug@dhw68k.cts.com (Roger L. Long)