[comp.sources.misc] v06i112: glib part 11 of 15

allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (05/15/89)

Posting-number: Volume 6, Issue 112
Submitted-by: lee@uhccux.uhcc.Hawaii.Edu (Greg Lee )
Archive-name: glib/part11

#! /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 11 (of 15)."
# Contents:  menutoc.c
# Wrapped by lee@uhccux on Sun May  7 00:40:18 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'menutoc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'menutoc.c'\"
else
echo shar: Extracting \"'menutoc.c'\" \(30374 characters\)
sed "s/^X//" >'menutoc.c' <<'END_OF_FILE'
X#define YY_DEFAULT_ACTION ECHO;
X#define FLEX_USE_ECS
X#define FLEX_USE_MECS
X/* A lexical scanner generated by flex */
X
X/* macro definitions for compressed-table C/FTL programs generated by flex */
X
X/* common macro definitions for C/FTL programs generated by flex */
X
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;
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/* 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_c_buf_p = yy_full_match; /* restore possibly backed-over text */ \
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
X
X# line 1 "menutoc.l"
X#define INITIAL 0
X# line 2 "menutoc.l"
X/* $Id: menutoc.c,v 1.6 89/05/06 17:13:36 lee Exp $
X *	menutoc.l	-- Greg Lee, lee@uhccux.uhcc.hawaii.edu
X *			   February 1989
X * $Author: lee $
X * $Log:	menutoc.c,v $
X * Revision 1.6  89/05/06  17:13:36  lee
X * rel. to comp.sources.misc
X * 
X * Revision 1.6  89/05/06  09:51:46  lee
X * Scott Snyder fixed a bug (see comment below)
X * Mark Rinfret made a couple changes for Aztec C
X * now emits some (INT16) casts for lint
X * now emits #line directives
X * 
X * Revision 1.5  89/04/25  16:36:18  lee
X * modifications:
X * 
X
X	Generate C language menu module for Glib from menu specification.
X
XCompile:
X	flex menutoc.l
X	cc -o menutoc lex.yy.c
Xor
X	lex menutoc.l
X	cc -o menutoc lex.yy.c -ll
X
XUsage:
X	menutoc <file.menu >file.c
X
XDescription:
X
XMenutoc simplifies constructing and modifying synthesizer-specific
Xmodules for Tim Thompson's Glib.  It allows the form of the on-screen
Xmenu to be specified as a picture in the menu source file, and generates
X'setval' and 'getval' calls automatically.  This version works with
Xthe version of Glib modified by Michael Kesti.
X
X[The original version of flex distributed on Usenet has a bug which
X prevents setting the start state.  If this is a problem, you can
X fix it by making two changes to flex's skeleton files:
X	CHANGE
X	static int yy_start;
X	TO
X	static int yy_start = 0;
X
X	CHANGE
X		yy_start = 1;
X	TO
X		if (!yy_start) yy_start = 1;
X]
X
XThe following characterization of how menutoc works is probably
Xnot entirely clear.  Look at the example k1single.menu and the
Xsource code to get a more exact idea.  The source k1single.menu
Xgives the C file k1single.c after processing by menutoc.
X
XThe menu source file should contain five special preprocessor
Xdirectives: '#MENU' (once), '#END' (once), '#O' (one for each
Xlabel name), '#GETVAL' (once), and '#SETVAL' (once).  The source
Xfile has four sections:
X	(1) the portion before the '#MENU' directive is passed
X	    through unchanged to the output,
X	(2) a picture of the screen menu is given between the
X	    '#MENU' and '#END' directives,
X	(3) after the '#END' directive is C code with '#O' directives
X	    which specify the data offsets of variables and with
X	    '%%' or '@@' references to the screen locations for
X	    variable values, and
X	(4) more C code containing somewhere the '#SETVAL' and
X	    '#GETVAL' directives which cause a series of calls
X	    to the 'setval' and 'getval' functions to be generated,
X	    making use of the offset information given by the '#O'
X	    directives in the preceding section.
X
XThe picture of the screen menu has constant strings in the position
Xthey will be output to the screen and '%' or '@' in each position
Xwhere the current value of some variable is to be displayed by
XGlib.  The locations of the '%'s and '@'s are remembered in the
Xorder in which they are encountered (scanning left-to-right and
Xtop-to-bottom in the picture), then the corresponding row/column
Xcoordinates are substituted for '%%'s and '@@'s encountered in
Xsection 3 of the source file.  The '%'s and '@'s are stored
Xindependently so as to make it more convenient to specify menus
Xthat have two columns of values.
X
XThe '#O' specifications are given in the form:
X
X#O <NAME> <TYPE> <POS> <MAX> <OFFSET> <MASK> <SHIFT> <ADHOC>
X
XSuch a line generates one "paraminfo" entry for an array, and some of
Xthe information is saved and made use of in generating 'setval' and
X'getval' calls.  NAME is the name of a variable label (no caps); TYPE is
Xthe name of a vis-function used to display the current value on the
Xscreen; POS should be either '%%' or '@@', which will be replaced by row
Xand column coordinates of the position to display the value; MAX is the
Xmaximum value the glib editor is to accept (the minimum is assumed to be
X0); OFFSET is the offset of the byte containing the value in the data
Xarray.  (If OFFSET is negative, the (positive) value is taken to be the
Xinitial value rather than the offset.)
X
XThe NAME argument may begin with a digit specifying a repetition
Xcount.  It's a shortcut which is like giving several consecutive
X#O-lines for <NAME>1, <NAME>2, ...
X
XThe last three #O arguments are optional.  MASK is a number with 1-bits
Xin positions holding the value for those cases where part of a byte is
Xused for some other purpose.  SHIFT is the number of bits the bitfield
Xis shifted left in the byte.  So, for instance, if the synth keeps a
Xvalue in the 4th, 5th, and 6th bits, one would give '0x1C' for the MASK
Xand '3' for SHIFT.  (Use caps for hex digits A-F.)
X
XThere is no systematic provision for values some of whose bits are found
Xin one byte, some in another.  The ADHOC argument has the form
X'*<digit>' and is used in the example to provide for such a case.  The
Xcode below in this file was just made up ad hoc for two such cases I
Xencountered with the Kawai K1.
X
X*/
X
X/*
X * Modified 4-13-89 by Scott Snyder:
X *  1. Increased MAXVAL from 100 to 200 (for DX7).
X *  2. Changed type of temps from 'unsigned char' to 'unsigned' (for DX7).
X *  3. Added command line processing (since TMAKE doesn't support redirection).
X *
X * 4-19-18
X *  Fixed bug with zero offsets.
X */
X
X#ifdef AZTEC_C
Xlong atol();
X# define strtol(a, b, c) atol(a)
X#endif
X#define MAXLINE 133
X#define MAXVAL 200
X#define MAXVSTRINGS 200
X#define MAXBUF 2000
X
X	char *infname = "file.mnu";
X	int lcnt = 1;
X	int i, j, k, wcol=0, col=0, row=0;
X	char word[MAXLINE];
X	int wordp = 0;
X	int valpos[MAXVAL][2];
X	int valpos2[MAXVAL][2];
X	int valcnt = 0;
X	int valcnt2= 0;
X	int offset;
X	int nlist[MAXVSTRINGS][6];
X	int np = 0;
X	char buf[MAXBUF];
X	int bufp=0;
X	int multiple, special;
X        int vmin, vmax, vval, mask, vshift, vrow, vcol, iflag;
X	char visfunc[20];
X	int state;
X#define M 2
X#define IG 4
X#define VAL 6
X#define O 8
X#define P 10
X#define Q 12
X# line 160 "menutoc.l"
X#define YY_JAM 92
X#define YY_JAM_BASE 174
X#define YY_TEMPLATE 93
Xstatic char l[93] =
X    {   0,
X       -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,   -2,
X       -2,   -2,   -2,   -2,   33,    9,    7,    8,    6,    5,
X        4,    9,    3,    2,    3,   23,   24,   23,   23,   23,
X       23,   12,   13,   14,   15,   16,   17,   33,   33,   33,
X       18,   33,    6,    0,    0,    0,    0,   30,   29,    0,
X        0,    0,    0,    0,    0,   13,   14,   15,   16,   19,
X       22,   21,   18,   20,    0,    0,   27,   28,    0,   11,
X        0,    0,    0,    0,    0,    0,    0,   10,    0,    0,
X        0,    0,    1,    0,    0,    0,    0,    0,   26,    0,
X       25,    0
X
X    } ;
X
Xstatic char e[128] =
X    {   0,
X        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
X        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
X        1,    4,    1,    1,    5,    1,    6,    1,    1,    1,
X        1,    7,    1,    1,    8,    1,    1,    9,   10,   10,
X       10,   10,   10,   10,   10,   10,   10,    1,    1,    1,
X        1,    1,    1,   11,   12,   13,   13,   14,   15,   13,
X       16,    1,    1,    1,    1,   17,   18,   19,   20,    1,
X        1,    1,   21,   22,   23,   24,    1,    1,    1,    1,
X        1,   25,    1,    1,   26,    1,   27,   27,   27,   27,
X
X       27,   27,   27,   27,   27,   27,   27,   27,   27,   27,
X       27,   27,   27,   27,   27,   27,   27,   27,   27,   28,
X       27,   27,    1,    1,    1,    1,    1
X    } ;
X
Xstatic char m[29] =
X    {   0,
X        1,    1,    1,    1,    1,    1,    1,    2,    3,    3,
X        1,    2,    2,    2,    2,    1,    1,    1,    1,    1,
X        1,    1,    1,    1,    1,    4,    4,    3
X    } ;
X
Xstatic short int b[104] =
X    {   0,
X        0,    0,    0,   10,  121,    2,   14,   37,    0,    9,
X       61,    0,   88,    0,  174,  174,  174,  174,  119,  174,
X      174,   20,  174,  174,   27,  174,  174,  116,  110,   27,
X      115,  174,    0,   28,    0,   42,  174,  114,  108,  107,
X      106,  102,  108,   45,   92,   48,   95,  174,  174,  103,
X       97,   51,   92,   52,   91,    0,   55,    0,   71,  174,
X      174,   97,   96,  174,   79,   67,   79,   73,   61,   72,
X       60,   73,   77,   56,   54,   53,   66,  174,   65,   52,
X       49,   55,  174,   34,   24,   31,   23,   20,  174,    5,
X      174,  174,  136,  140,  144,  148,  150,  152,  155,  158,
X
X      162,  166,  170
X    } ;
X
Xstatic short int d[104] =
X    {   0,
X       93,   93,   94,   94,   95,   95,   96,   96,   93,   93,
X       93,   11,   93,   13,   92,   92,   92,   92,   92,   92,
X       92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
X       92,   92,   97,   92,   98,   92,   92,   92,   92,   99,
X       99,   92,   92,   92,   92,   92,   92,   92,   92,   92,
X       92,   92,   92,   92,   92,   97,   92,   98,   92,   92,
X       92,   99,   99,   92,   92,   92,   92,   92,   92,   92,
X       92,   99,  100,   92,   92,   92,  100,   92,  101,   92,
X       92,  101,   92,   92,   92,  102,  103,  102,   92,  103,
X       92,-32767,   92,   92,   92,   92,   92,   92,   92,   92,
X
X       92,   92,   92
X    } ;
X
Xstatic short int n[203] =
X    {   0,
X       92,   17,   18,   19,   24,   20,   25,   91,   32,   32,
X       21,   17,   18,   19,   22,   20,   27,   32,   32,   28,
X       21,   44,   89,   44,   29,   91,   33,   33,   46,   57,
X       46,   57,   50,   89,   45,   33,   33,   51,   30,   27,
X       87,   31,   28,   59,   47,   59,   44,   29,   44,   46,
X       86,   46,   52,   70,   52,   70,   57,   83,   57,   45,
X       85,   30,   34,   84,   34,   47,   53,   83,   78,   35,
X       35,   55,   59,   70,   59,   70,   81,   80,   79,   78,
X       72,   76,   75,   68,   67,   74,   35,   35,   35,   36,
X       37,   36,   73,   38,   39,   40,   41,   41,   42,   41,
X
X       41,   41,   41,   92,   72,   71,   69,   68,   67,   66,
X       65,   43,   64,   92,   62,   41,   52,   61,   52,   60,
X       49,   48,   43,   24,   92,   92,   92,   92,   92,   92,
X       53,   92,   92,   92,   54,   55,   15,   15,   15,   15,
X       16,   16,   16,   16,   23,   23,   23,   23,   26,   26,
X       26,   26,   56,   56,   58,   58,   63,   63,   77,   77,
X       77,   77,   82,   82,   82,   82,   88,   88,   88,   88,
X       90,   90,   90,   90,   92,   92,   92,   92,   92,   92,
X       92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
X       92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
X
X       92,   92
X    } ;
X
Xstatic short int c[203] =
X    {   0,
X        0,    3,    3,    3,    6,    3,    6,   90,    9,    9,
X        3,    4,    4,    4,    4,    4,    7,   10,   10,    7,
X        4,   22,   88,   22,    7,   87,    9,    9,   25,   34,
X       25,   34,   30,   86,   22,   10,   10,   30,    7,    8,
X       85,    8,    8,   36,   25,   36,   44,    8,   44,   46,
X       84,   46,   52,   54,   52,   54,   57,   82,   57,   44,
X       81,    8,   11,   80,   11,   46,   52,   79,   77,   11,
X       11,   52,   59,   70,   59,   70,   76,   75,   74,   73,
X       72,   71,   69,   68,   67,   66,   11,   11,   11,   13,
X       13,   13,   65,   13,   13,   13,   13,   13,   13,   13,
X
X       13,   13,   13,   63,   62,   55,   53,   51,   50,   47,
X       45,   43,   42,   41,   40,   13,   31,   39,   31,   38,
X       29,   28,   19,    5,    0,    0,    0,    0,    0,    0,
X       31,    0,    0,    0,   31,   31,   93,   93,   93,   93,
X       94,   94,   94,   94,   95,   95,   95,   95,   96,   96,
X       96,   96,   97,   97,   98,   98,   99,   99,  100,  100,
X      100,  100,  101,  101,  101,  101,  102,  102,  102,  102,
X      103,  103,  103,  103,   92,   92,   92,   92,   92,   92,
X       92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
X       92,   92,   92,   92,   92,   92,   92,   92,   92,   92,
X
X       92,   92
X    } ;
X
X
X/* these declarations have to come after the section 1 code or lint gets
X * confused about whether the variables are used
X */
XFILE *yyin = stdin, *yyout = stdout;
X
X/* these variables are all declared out here so that section 3 code can
X * manipulate them
X */
Xstatic int yy_start = 0, yy_b_buf_p, yy_c_buf_p, yy_e_buf_p;
Xstatic int yy_saw_eof, yy_init = 1;
X
X/* yy_ch_buf has to be 1 character longer than YY_BUF_SIZE, since when
X * setting up yytext we can try to put a '\0' just past the end of the
X * matched text
X */
Xstatic char yy_ch_buf[YY_BUF_SIZE + 1];
Xstatic int yy_st_buf[YY_BUF_SIZE];
Xstatic char yy_hold_char;
Xchar *yytext;
Xstatic int yyleng;
X
XYY_DECL
X    {
X    int yy_n_chars, yy_lp, yy_iii, yy_buf_pos, yy_act;
X#ifdef FLEX_REJECT_ENABLED
X    int yy_full_match;
X#endif
X
X
X
X
X    if ( yy_init )
X	{
X	YY_INIT;
X	if (!yy_start) yy_start = 1;
X	yy_init = 0;
X	}
X
X    goto get_next_token;
X
Xdo_action:
X
X#ifdef FLEX_REJECT_ENABLED
X    /* remember matched text in case we back up due to trailing context */
X    yy_full_match = yy_c_buf_p;
X#endif
X
X    for ( ; ; )
X	{
X	YY_DO_BEFORE_ACTION
X
X#ifdef FLEX_DEBUG
X	fprintf( stderr, "--accepting rule #%d\n", yy_act );
X#endif
X	switch ( yy_act )
X	    {
Xcase 1:
X# line 162 "menutoc.l"
X{ BEGIN(M); lcnt++; }
X	YY_BREAK
Xcase 2:
X# line 163 "menutoc.l"
X{ ECHO; lcnt++; }
X	YY_BREAK
Xcase 3:
X# line 164 "menutoc.l"
XECHO;
X	YY_BREAK
Xcase 4:
X# line 166 "menutoc.l"
X{	writeword();
X		if (valcnt2+1 >= MAXVAL) {
X		    fprintf(stderr,"menutoc: too many @s in menu\n");
X		    exit(1);
X		}
X		valpos2[valcnt2][0] = row;
X		valpos2[valcnt2++][1] = col;
X		col += 1;
X};
X	YY_BREAK
Xcase 5:
X# line 176 "menutoc.l"
X{	writeword();
X		if (valcnt+1 >= MAXVAL) {
X		    fprintf(stderr,"menutoc: too many %%s in menu\n");
X		    exit(1);
X		}
X		valpos[valcnt][0] = row;
X		valpos[valcnt++][1] = col;
X		col += 1;
X};
X	YY_BREAK
Xcase 6:
X# line 186 "menutoc.l"
X{	if (yyleng > 4) writeword();
X		else if (wordp) for (i=0; i<yyleng; i++) append(' ');
X		col += yyleng;
X};
X	YY_BREAK
Xcase 7:
X# line 191 "menutoc.l"
X{	writeword(); col = ((col + 8)/8)*8;
X};
X	YY_BREAK
Xcase 8:
X# line 194 "menutoc.l"
X{	writeword(); col = 0; row += 1; lcnt++;
X};
X	YY_BREAK
Xcase 9:
X# line 197 "menutoc.l"
X{		append(yytext[0]); col += 1;
X};
X	YY_BREAK
Xcase 10:
X# line 200 "menutoc.l"
X{
X		BEGIN(VAL); i = 0; j = 0; lcnt++;
X		printf("# line %d \"%s\"\n", lcnt, infname);
X};
X	YY_BREAK
Xcase 11:
X# line 205 "menutoc.l"
X{
X		if (np+1 >= MAXVSTRINGS) {
X		    fprintf(stderr,"menutoc: too many VSTRINGs\n");
X		    exit(1);
X		}
X		BEGIN(O);
X		multiple = special = 0;
X		vmax = offset = mask = vshift = vmin = vrow = vcol = iflag = 0;
X		state = 0;
X};
X	YY_BREAK
Xcase 12:
X# line 216 "menutoc.l"
Xmultiple = atoi(yytext);
X	YY_BREAK
Xcase 13:
X# line 218 "menutoc.l"
X{
X		if (bufp+yyleng >= MAXBUF) {
X		    fprintf(stderr,"menutoc: out of storage room\n");
X		    exit(1);
X		}
X		nlist[np][0] = bufp;
X		strcpy(buf+bufp, yytext);
X		bufp += yyleng+1;
X		BEGIN(P);
X};
X	YY_BREAK
Xcase 14:
X# line 229 "menutoc.l"
X;
X	YY_BREAK
Xcase 15:
X# line 230 "menutoc.l"
X{
X		strcpy(visfunc, yytext);
X		if (yyleng >= 20) {
X		    fprintf(stderr,"menutoc: vis name too long\n");
X		    exit(1);
X		}
X		BEGIN(Q);
X};
X	YY_BREAK
Xcase 16:
X# line 239 "menutoc.l"
X;
X	YY_BREAK
Xcase 17:
X# line 240 "menutoc.l"
X{	lcnt++;
X		if (special == 5) vmin = 1;
X		else vmin = 0;
X		if (offset < 0) vval = -offset;
X		else vval = 0;
X
X		if (multiple) for (k=0; k<multiple; k++) {
X			printf("\"%s%d\",NULL,-1,-1,%d,%d,vis%s,%d,%d,%d,0,\n",
X				buf+nlist[np][0], k+1, vrow, vcol, visfunc,
X				vmin, vmax, vval);
X			if (k+1 < multiple) {
X			if (iflag) {
X			    if (i < valcnt) {
X				vrow = valpos[i][0]; vcol = valpos[i++][1];
X			    } else
X			    fprintf(stderr,"menutoc: too many %%%%s\n");
X			} else
X			    if (j < valcnt2) {
X				vrow = valpos2[j][0]; vcol = valpos2[j++][1];
X			    } else
X			    fprintf(stderr,"menutoc: too many @@s\n");
X			}
X		}
X		else
X			printf("\"%s\",NULL,-1,-1,%d,%d,vis%s,%d,%d,%d,0,\n",
X			    buf+nlist[np][0], vrow, vcol, visfunc,
X			    vmin, vmax, vval);
X		if (multiple)
X			printf("# line %d \"%s\"\n", lcnt, infname);
X		nlist[np][1] = offset;
X		nlist[np][2] = mask;
X		nlist[np][3] = vshift;
X		nlist[np][4] = multiple;
X		nlist[np][5] = special;
X		np++;
X		BEGIN(VAL);
X};
X	YY_BREAK
Xcase 18:
X# line 278 "menutoc.l"
X{
X		k = (int)strtol(yytext, (char **)NULL, 0);
X		switch (state) {
X		  case 0: vmax = k;   break;
X		  case 1: offset = k; break;
X		  case 2: mask = k;   break;
X		  case 3: vshift = k; break;
X		  case 4: vmin = k;   break;
X                }
X                ++state;
X};
X	YY_BREAK
Xcase 19:
X# line 290 "menutoc.l"
X{	if (i < valcnt) {
X			vrow = valpos[i][0];
X			vcol = valpos[i][1];
X			i++;
X			iflag++;
X		}
X		else fprintf(stderr,"\nmenutoc: too many %%%%s\n");
X};
X	YY_BREAK
Xcase 20:
X# line 298 "menutoc.l"
X{	if (j < valcnt2) {
X			vrow = valpos2[j][0];
X			vcol = valpos2[j][1];
X			j++;
X		}
X		else fprintf(stderr,"\nmenutoc: too many @@s\n");
X};
X	YY_BREAK
Xcase 21:
X# line 305 "menutoc.l"
X{	vrow = -1;
X		vcol = -1;
X};
X	YY_BREAK
Xcase 22:
X# line 308 "menutoc.l"
X{
X		special = yytext[1] - '0';
X};
X	YY_BREAK
Xcase 23:
X# line 311 "menutoc.l"
XECHO;
X	YY_BREAK
Xcase 24:
X# line 312 "menutoc.l"
X{ ECHO; lcnt++; }
X	YY_BREAK
Xcase 25:
X# line 314 "menutoc.l"
X{
X		lcnt++;
X		/* make sure i,k will be used before declaring them */
X		for (k=0; k<np; k++)
X			if (nlist[k][1]>=0 && (nlist[k][5] || nlist[k][2])) {
X				printf("\tINT16 i, k;\n\n");
X				break;
X			}
X		for (k=0; k<np; k++) dosetval(k);
X		printf("# line %d \"%s\"\n", lcnt, infname);
X};
X	YY_BREAK
Xcase 26:
X# line 326 "menutoc.l"
X{
X		lcnt++;
X		/* make sure i,j,k will be used before declaring them */
X		for (k=0; k<np; k++)
X			if (nlist[k][1]>=0 && (nlist[k][5] || nlist[k][2])) {
X				printf("\tINT16 i, j, k;\n\n");
X				break;
X			}
X		for (k=0; k<np; k++) dogetval(k);
X		printf("# line %d \"%s\"\n", lcnt, infname);
X};
X	YY_BREAK
Xcase 27:
X# line 338 "menutoc.l"
Xprintf("%s", yytext+1);
X	YY_BREAK
Xcase 28:
X# line 339 "menutoc.l"
Xprintf("%s", yytext+1);
X	YY_BREAK
Xcase 29:
X# line 341 "menutoc.l"
X{	if (j < valcnt2) {
X			printf("%d, %d", valpos2[j][0], valpos2[j][1]);
X			j++;
X		}
X		else fprintf(stderr,"\nmenutoc: too many @@s\n");
X};
X	YY_BREAK
Xcase 30:
X# line 348 "menutoc.l"
X{	if (i < valcnt) {
X			printf("%d, %d", valpos[i][0], valpos[i][1]);
X			i++;
X		}
X		else fprintf(stderr,"\nmenutoc: too many %%%%s\n");
X};
X	YY_BREAK
Xcase 31:
X# line 355 "menutoc.l"
XECHO;
X	YY_BREAK
Xcase 32:
X# line 356 "menutoc.l"
X{ ECHO; lcnt++; }
X	YY_BREAK
Xcase 33:
X# line 358 "menutoc.l"
XYY_DEFAULT_ACTION;
X	YY_BREAK
X
Xcase YY_NEW_FILE:
Xbreak; /* begin reading from new file */
X
Xcase YY_DO_DEFAULT:
XYY_DEFAULT_ACTION;
Xbreak;
X
Xcase YY_END_TOK:
Xreturn ( YY_END_TOK );
X
Xdefault:
XYY_FATAL_ERROR( "fatal flex scanner internal error" );
X	    }
X
Xget_next_token:
X	{
X	register int yy_curst;
X	register char yy_sym;
X
X	YY_DO_BEFORE_SCAN
X
X	/* set up to begin running DFA */
X
X	yy_curst = yy_start;
X
X	if ( yy_ch_buf[yy_c_buf_p] == '\n' )
X	    ++yy_curst;
X
X	/* yy_b_buf_p points to the position in yy_ch_buf
X	 * of the start of the current run.
X	 */
X
X	yy_b_buf_p = yy_c_buf_p + 1;
X
X	do /* until the machine jams */
X	    {
X	    if ( yy_c_buf_p == yy_e_buf_p )
X		{ /* need more input */
X		if ( yy_e_buf_p >= YY_BUF_LIM )
X		    { /* not enough room to do another read */
X		    /* see if we can make some room for more chars */
X
X		    yy_n_chars = yy_e_buf_p - yy_b_buf_p;
X
X		    if ( yy_n_chars >= 0 )
X			/* shift down buffer to make room */
X			for ( yy_iii = 0; yy_iii <= yy_n_chars; ++yy_iii )
X			    {
X			    yy_buf_pos = yy_b_buf_p + yy_iii;
X			    yy_ch_buf[yy_iii] = yy_ch_buf[yy_buf_pos];
X			    yy_st_buf[yy_iii] = yy_st_buf[yy_buf_pos];
X			    }
X
X		    yy_b_buf_p = 0;
X		    yy_e_buf_p = yy_n_chars;
X
X		    if ( yy_e_buf_p >= YY_BUF_LIM )
X			YY_FATAL_ERROR( "flex input buffer overflowed" );
X
X		    yy_c_buf_p = yy_e_buf_p;
X		    }
X
X		else if ( yy_saw_eof )
X		    {
Xsaweof:		    if ( yy_b_buf_p > yy_e_buf_p )
X			{
X			if ( yywrap() )
X			    {
X			    yy_act = YY_END_TOK;
X			    goto do_action;
X			    }
X			
X			else
X			    {
X			    YY_INIT;
X			    yy_act = YY_NEW_FILE;
X			    goto do_action;
X			    }
X			}
X
X		    else /* do a jam to eat up more input */
X			{
X#ifndef FLEX_INTERACTIVE_SCANNER
X			/* we're going to decrement yy_c_buf_p upon doing
X			 * the jam.  In this case, that's wrong, since
X			 * it points to the last non-jam character.  So
X			 * we increment it now to counter the decrement.
X			 */
X			++yy_c_buf_p;
X#endif
X			break;
X			}
X		    }
X
X		YY_INPUT( (yy_ch_buf + yy_c_buf_p + 1), yy_n_chars,
X			  YY_MAX_LINE );
X
X		if ( yy_n_chars == YY_NULL )
X		    {
X		    if ( yy_saw_eof )
X	YY_FATAL_ERROR( "flex scanner saw EOF twice - shouldn't happen" );
X		    yy_saw_eof = 1;
X		    goto saweof;
X		    }
X
X		yy_e_buf_p += yy_n_chars;
X		}
X
X	    ++yy_c_buf_p;
X
X#ifdef FLEX_USE_ECS
X	    yy_sym = e[yy_ch_buf[yy_c_buf_p]];
X#else
X	    yy_sym = yy_ch_buf[yy_c_buf_p];
X#endif
X
X#ifdef FLEX_FULL_TABLE
X	    yy_curst = n[yy_curst][yy_sym];
X
X#else /* get next state from compressed table */
X
X	    while ( c[b[yy_curst] + yy_sym] != yy_curst )
X		{
X		yy_curst = d[yy_curst];
X
X#ifdef FLEX_USE_MECS
X		/* we've arrange it so that templates are never chained
X		 * to one another.  This means we can afford make a
X		 * very simple test to see if we need to convert to
X		 * yy_sym's meta-equivalence class without worrying
X		 * about erroneously looking up the meta-equivalence
X		 * class twice
X		 */
X
X		if ( yy_curst >= YY_TEMPLATE )
X		    yy_sym = m[yy_sym];
X#endif
X		}
X
X	    yy_curst = n[b[yy_curst] + yy_sym];
X
X#endif
X
X	    yy_st_buf[yy_c_buf_p] = yy_curst;
X
X	    }
X#ifdef FLEX_INTERACTIVE_SCANNER
X	while ( b[yy_curst] != YY_JAM_BASE );
X#else
X	while ( yy_curst != YY_JAM );
X	--yy_c_buf_p; /* put back character we jammed on */
X
X#endif
X
X	if ( yy_c_buf_p >= yy_b_buf_p )
X	    { /* we matched some text */
X	    yy_curst = yy_st_buf[yy_c_buf_p];
X	    yy_lp = l[yy_curst];
X
X#ifdef FLEX_REJECT_ENABLED
Xfind_rule: /* we branch to this label when doing a REJECT */
X#endif
X
X	    for ( ; ; ) /* until we find what rule we matched */
X		{
X#ifdef FLEX_REJECT_ENABLED
X		if ( yy_lp && yy_lp < l[yy_curst + 1] )
X		    {
X		    yy_act = a[yy_lp];
X		    goto do_action; /* "continue 2" */
X		    }
X#else
X		if ( yy_lp )
X		    {
X		    yy_act = yy_lp;
X		    goto do_action; /* "continue 2" */
X		    }
X#endif
X
X		if ( --yy_c_buf_p < yy_b_buf_p )
X		    break;
X
X		yy_curst = yy_st_buf[yy_c_buf_p];
X		yy_lp = l[yy_curst];
X		}
X	    }
X
X	/* if we got this far, then we didn't find any accepting
X	 * states
X	 */
X
X	/* so that the default applies to the first char read */
X	++yy_c_buf_p;
X
X	yy_act = YY_DO_DEFAULT;
X	}
X	}
X
X    /*NOTREACHED*/
X    }
X
X
Xstatic int unput( c )
Xchar c;
X
X    {
X    YY_DO_BEFORE_SCAN; /* undo effects of setting up yytext */
X
X    if ( yy_c_buf_p == 0 )
X	{
X	register int i;
X	register int yy_buf_pos = YY_BUF_MAX;
X
X	for ( i = yy_e_buf_p; i >= yy_c_buf_p; --i )
X	    {
X	    yy_ch_buf[yy_buf_pos] = yy_ch_buf[i];
X	    yy_st_buf[yy_buf_pos] = yy_st_buf[i];
X	    --yy_buf_pos;
X	    }
X
X	yy_c_buf_p = YY_BUF_MAX - yy_e_buf_p;
X	yy_e_buf_p = YY_BUF_MAX;
X	}
X
X    if ( yy_c_buf_p <= 0 )
X	YY_FATAL_ERROR( "flex scanner push-back overflow" );
X
X    if ( yy_c_buf_p >= yy_b_buf_p && yy_ch_buf[yy_c_buf_p] == '\n' )
X	yy_ch_buf[yy_c_buf_p - 1] = '\n';
X
X    yy_ch_buf[yy_c_buf_p--] = c;
X
X    YY_DO_BEFORE_ACTION; /* set up yytext again */
X    }
X
X
Xstatic int input()
X
X    {
X    int c;
X
X    YY_DO_BEFORE_SCAN
X
X    if ( yy_c_buf_p == yy_e_buf_p )
X	{ /* need more input */
X	int yy_n_chars;
X
X	/* we can throw away the entire current buffer */
X	if ( yy_saw_eof )
X	    {
X	    if ( yywrap() )
X		return ( EOF );
X
X	    YY_INIT;
X	    }
X
X	yy_b_buf_p = 0;
X	YY_INPUT( yy_ch_buf, yy_n_chars, YY_MAX_LINE );
X
X	if ( yy_n_chars == YY_NULL )
X	    {
X	    yy_saw_eof = 1;
X
X	    if ( yywrap() )
X		return ( EOF );
X
X	    YY_INIT;
X
X	    return ( input() );
X	    }
X
X	yy_c_buf_p = -1;
X	yy_e_buf_p = yy_n_chars - 1;
X	}
X
X    c = yy_ch_buf[++yy_c_buf_p];
X
X    YY_DO_BEFORE_ACTION;
X
X    return ( c );
X    }
X# line 358 "menutoc.l"
X
Xdosetval(k)
Xint k;
X{	int m;
X
X	special  = nlist[k][5];
X
X	if (special == 1 || special == 3) k++;
X	else if (special == 2 || special == 4) k--;
X
X	bufp     = nlist[k][0];
X	offset   = nlist[k][1];
X	mask     = nlist[k][2];
X	vshift   = nlist[k][3];
X	multiple = nlist[k][4];
X
X	if (offset < 0) return;
X
X	if (multiple) for (m = 1; m <= multiple; m++)
X	{	outsetval(m); offset++;		}
X	else	outsetval(0);
X}
X
Xoutsetval(m)
Xint m;
X{
X	if (!mask && !special) {
X		printf("setval(\"%s", buf+bufp);
X		if (m) printf("%d", m);
X		printf("\",(INT16)data[RESERVESIZE+%d]);\n",offset);
X		return;
X	}
X
X	printf("i = (INT16)data[RESERVESIZE+%d]; ", offset);
X	if (mask) {
X		printf("i &= %d; ", mask);
X		if (vshift) printf("i >>= %d; ", vshift);
X	}
X
X	if (special == 2) printf("i += k << 1;\n");
X	else if (special == 4) printf("i += k << 7;\n");
X
X	if (special == 1 || special == 3) printf("k = i;\n");
X	else {
X		printf("setval(\"%s", buf+bufp);
X		if (m) printf("%d", m);
X		printf("\",i);\n");
X	}
X}
X
Xdogetval(k)
Xint k;
X{	int m;
X
X	bufp     = nlist[k][0];
X	offset   = nlist[k][1];
X	mask     = nlist[k][2];
X	vshift   = nlist[k][3];
X	multiple = nlist[k][4];
X	special  = nlist[k][5];
X
X	if (offset < 0) return;
X
X	if (multiple) for (m = 1; m <= multiple; m++)
X	{	outgetval(m); offset++;		}
X	else	outgetval(0);
X}
X
Xoutgetval(m)
Xint m;
X{
X	if (!mask && !special) {
X		printf("data[RESERVESIZE+%d] = ", offset);
X		printf("getval(\"%s", buf+bufp);
X		if (m) printf("%d", m);
X		printf("\");\n");
X		return;
X	}
X
X	if (special == 2 || special == 4)
X		printf("i = k; ");
X	else {
X		printf("i = getval(\"%s", buf+bufp);
X		if (m) printf("%d", m);
X		printf("\"); ");
X	}
X
X	if (special == 1) printf("k = i >> 1; i &= 1;\n");
X	else if (special == 3) printf("k = i >> 7; i &= 0x7f;\n");
X
X	if (mask) {
X		printf("j = data[RESERVESIZE+%d]; ", offset);
X		if (vshift) printf("i <<= %d; ", vshift);
X		printf("j &= ~%d; ", mask);
X		printf("i = j|i; ");
X	}
X	printf("data[RESERVESIZE+%d] = i;\n", offset);
X}
X
Xmain(argc, argv)
Xint argc;
Xchar **argv;
X{	char *basename();
X
X  if (argc > 1) {
X    infname = basename(argv[1]);
X    if (freopen(argv[1], "r", stdin) == NULL) {
X      perror("Can't open input file");
X      exit(1);
X    }
X  }
X  if (argc > 2) {
X    if (freopen(argv[2], "w", stdout) == NULL) {
X      perror("Can't open output file");
X      exit(1);
X    }
X  }
X
X	word[0] = 0;
X	BEGIN(IG);
X	yylex();
X	if (i < valcnt) fprintf(stderr,"\nmenutoc: not enough %%%%s\n");
X	if (j < valcnt2) fprintf(stderr,"\nmenutoc: not enough @@s\n");
X	exit(0);
X}
X
Xchar   *basename(s)
Xchar   *s;
X{
X	char   *p;
X	char   *strrchr();
X
X	if (p = strrchr (s, '/'))
X		return (++p);
X	else
X		return (s);
X}
X
Xappend(c)
Xchar c;
X{
X	if (wordp+1 >= MAXLINE) {
X	    fprintf(stderr,"menutoc: string in menu too long\n");
X	    exit(1);
X	}
X	if (!wordp) wcol = col;
X	word[wordp++] = c;
X	word[wordp] = 0;
X}
X
Xwriteword()
X{
X	if (wordp) {
X		while (word[--wordp] == ' ') ;
X		word[++wordp] = 0;
X		printf("%d,%d,\"%s\",\n", row, wcol, word);
X		wordp = 0;
X		word[wordp] = 0;
X	}
X}
END_OF_FILE
if test 30374 -ne `wc -c <'menutoc.c'`; then
    echo shar: \"'menutoc.c'\" unpacked with wrong size!
fi
# end of 'menutoc.c'
fi
echo shar: End of archive 11 \(of 15\).
cp /dev/null ark11isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 15 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