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