1 /* flexdef - definitions file for flex */
4 * Copyright (c) 1990 The Regents of the University of California.
7 * This code is derived from software contributed to Berkeley by
10 * The United States Government has rights in this work pursuant
11 * to contract no. DE-AC03-76SF00098 between the United States
12 * Department of Energy and the University of California.
14 * Redistribution and use in source and binary forms are permitted provided
15 * that: (1) source distributions retain this entire copyright notice and
16 * comment, and (2) distributions including binaries display the following
17 * acknowledgement: ``This product includes software developed by the
18 * University of California, Berkeley and its contributors'' in the
19 * documentation or other materials provided with the distribution and in
20 * all advertising materials mentioning features or use of this software.
21 * Neither the name of the University nor the names of its contributors may
22 * be used to endorse or promote products derived from this software without
23 * specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
25 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 /* @(#) $Id: flexdef.h,v 1.2 1994/06/24 10:56:52 ceriel Exp $ (LBL) */
35 /* always be prepared to generate an 8-bit scanner */
36 #define FLEX_8_BIT_CHARS
38 #ifdef FLEX_8_BIT_CHARS
40 #define Char unsigned char
46 /* size of input alphabet - should be size of ASCII set */
48 #define DEFAULT_CSIZE 128
53 #define PROTO(proto) proto
55 #define PROTO(proto) ()
71 char *sprintf(); /* keep lint happy */
80 extern char *strcpy();
85 #define bzero(s, n) setmem((char *)(s), n, '\0')
87 #define abs(x) ((x) < 0 ? -(x) : (x))
90 #define bzero(s, n) (void) memset((char *)(s), '\0', n)
92 #endif /* not ACK_MOD */
96 #define SHORT_FILE_NAMES
103 void *malloc( size_t );
109 #else /* ! __STDC__ */
110 char *malloc(), *realloc();
114 /* maximum line length we'll have to deal with */
115 #define MAXLINE BUFSIZ
117 /* maximum size of file name */
118 #define FILENAMESIZE 1024
121 #define min(x,y) ((x) < (y) ? (x) : (y))
124 #define max(x,y) ((x) > (y) ? (x) : (y))
129 #define abs(x) ((x) < 0 ? -(x) : (x))
131 #define SHORT_FILE_NAMES
138 #ifndef DEFAULT_SKELETON_FILE
139 #define DEFAULT_SKELETON_FILE "flex.skel"
142 /* special chk[] values marking the slots taking by end-of-buffer and action
145 #define EOB_POSITION -1
146 #define ACTION_POSITION -2
148 /* number of data items per line for -f output */
149 #define NUMDATAITEMS 10
151 /* number of lines of data in -f output before inserting a blank line for
154 #define NUMDATALINES 10
156 /* transition_struct_out() definitions */
157 #define TRANS_STRUCT_PRINT_LENGTH 15
159 /* returns true if an nfa state has an epsilon out-transition slot
160 * that can be used. This definition is currently not used.
162 #define FREE_EPSILON(state) \
163 (transchar[state] == SYM_EPSILON && \
164 trans2[state] == NO_TRANSITION && \
165 finalst[state] != state)
167 /* returns true if an nfa state has an epsilon out-transition character
168 * and both slots are free
170 #define SUPER_FREE_EPSILON(state) \
171 (transchar[state] == SYM_EPSILON && \
172 trans1[state] == NO_TRANSITION) \
174 /* maximum number of NFA states that can comprise a DFA state. It's real
175 * big because if there's a lot of rules, the initial state will have a
176 * huge epsilon closure.
178 #define INITIAL_MAX_DFA_SIZE 750
179 #define MAX_DFA_SIZE_INCREMENT 750
182 /* a note on the following masks. They are used to mark accepting numbers
183 * as being special. As such, they implicitly limit the number of accepting
184 * numbers (i.e., rules) because if there are too many rules the rule numbers
185 * will overload the mask bits. Fortunately, this limit is \large/ (0x2000 ==
186 * 8192) so unlikely to actually cause any problems. A check is made in
187 * new_rule() to ensure that this limit is not reached.
190 /* mask to mark a trailing context accepting number */
191 #define YY_TRAILING_MASK 0x2000
193 /* mask to mark the accepting number of the "head" of a trailing context rule */
194 #define YY_TRAILING_HEAD_MASK 0x4000
196 /* maximum number of rules, as outlined in the above note */
197 #define MAX_RULE (YY_TRAILING_MASK - 1)
200 /* NIL must be 0. If not, its special meaning when making equivalence classes
201 * (it marks the representative of a given e.c.) will be unidentifiable
205 #define JAM -1 /* to mark a missing DFA transition */
206 #define NO_TRANSITION NIL
207 #define UNIQUE -1 /* marks a symbol as an e.c. representative */
208 #define INFINITY -1 /* for x{5,} constructions */
210 #define INITIAL_MAX_CCLS 100 /* max number of unique character classes */
211 #define MAX_CCLS_INCREMENT 100
213 /* size of table holding members of character classes */
214 #define INITIAL_MAX_CCL_TBL_SIZE 500
215 #define MAX_CCL_TBL_SIZE_INCREMENT 250
217 #define INITIAL_MAX_RULES 100 /* default maximum number of rules */
218 #define MAX_RULES_INCREMENT 100
220 #define INITIAL_MNS 2000 /* default maximum number of nfa states */
221 #define MNS_INCREMENT 1000 /* amount to bump above by if it's not enough */
223 #define INITIAL_MAX_DFAS 1000 /* default maximum number of dfa states */
224 #define MAX_DFAS_INCREMENT 1000
226 #define JAMSTATE -32766 /* marks a reference to the state that always jams */
228 /* enough so that if it's subtracted from an NFA state number, the result
229 * is guaranteed to be negative
231 #define MARKER_DIFFERENCE 32000
232 #define MAXIMUM_MNS 31999
234 /* maximum number of nxt/chk pairs for non-templates */
235 #define INITIAL_MAX_XPAIRS 2000
236 #define MAX_XPAIRS_INCREMENT 2000
238 /* maximum number of nxt/chk pairs needed for templates */
239 #define INITIAL_MAX_TEMPLATE_XPAIRS 2500
240 #define MAX_TEMPLATE_XPAIRS_INCREMENT 2500
242 #define SYM_EPSILON (CSIZE + 1) /* to mark transitions on the symbol epsilon */
244 #define INITIAL_MAX_SCS 40 /* maximum number of start conditions */
245 #define MAX_SCS_INCREMENT 40 /* amount to bump by if it's not enough */
247 #define ONE_STACK_SIZE 500 /* stack of states with only one out-transition */
248 #define SAME_TRANS -1 /* transition is the same as "default" entry for state */
250 /* the following percentages are used to tune table compression:
252 * the percentage the number of out-transitions a state must be of the
253 * number of equivalence classes in order to be considered for table
254 * compaction by using protos
256 #define PROTO_SIZE_PERCENTAGE 15
258 /* the percentage the number of homogeneous out-transitions of a state
259 * must be of the number of total out-transitions of the state in order
260 * that the state's transition table is first compared with a potential
261 * template of the most common out-transition instead of with the first
262 * proto in the proto queue
264 #define CHECK_COM_PERCENTAGE 50
266 /* the percentage the number of differences between a state's transition
267 * table and the proto it was first compared with must be of the total
268 * number of out-transitions of the state in order to keep the first
269 * proto as a good match and not search any further
271 #define FIRST_MATCH_DIFF_PERCENTAGE 10
273 /* the percentage the number of differences between a state's transition
274 * table and the most similar proto must be of the state's total number
275 * of out-transitions to use the proto as an acceptable close match
277 #define ACCEPTABLE_DIFF_PERCENTAGE 50
279 /* the percentage the number of homogeneous out-transitions of a state
280 * must be of the number of total out-transitions of the state in order
281 * to consider making a template from the state
283 #define TEMPLATE_SAME_PERCENTAGE 60
285 /* the percentage the number of differences between a state's transition
286 * table and the most similar proto must be of the state's total number
287 * of out-transitions to create a new proto from the state
289 #define NEW_PROTO_DIFF_PERCENTAGE 20
291 /* the percentage the total number of out-transitions of a state must be
292 * of the number of equivalence classes in order to consider trying to
293 * fit the transition table into "holes" inside the nxt/chk table.
295 #define INTERIOR_FIT_PERCENTAGE 15
297 /* size of region set aside to cache the complete transition table of
298 * protos on the proto queue to enable quick comparisons
300 #define PROT_SAVE_SIZE 2000
302 #define MSP 50 /* maximum number of saved protos (protos on the proto queue) */
304 /* maximum number of out-transitions a state can have that we'll rummage
305 * around through the interior of the internal fast table looking for a
308 #define MAX_XTIONS_FULL_INTERIOR_FIT 4
310 /* maximum number of rules which will be reported as being associated
313 #define MAX_ASSOC_RULES 100
315 /* number that, if used to subscript an array, has a good chance of producing
316 * an error; should be small enough to fit into a short
318 #define BAD_SUBSCRIPT -32767
320 /* absolute value of largest number that can be stored in a short, with a
321 * bit of slop thrown in for general paranoia.
323 #define MAX_SHORT 32766
326 /* Declarations for global variables. */
328 /* variables for symbol tables:
329 * sctbl - start-condition symbol table
330 * ndtbl - name-definition symbol table
331 * ccltab - character class text symbol table
336 struct hash_entry *prev, *next;
342 typedef struct hash_entry *hash_table[];
344 #define NAME_TABLE_HASH_SIZE 101
345 #define START_COND_HASH_SIZE 101
346 #define CCL_HASH_SIZE 101
348 extern struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE];
349 extern struct hash_entry *sctbl[START_COND_HASH_SIZE];
350 extern struct hash_entry *ccltab[CCL_HASH_SIZE];
353 /* variables for flags:
354 * printstats - if true (-v), dump statistics
355 * syntaxerror - true if a syntax error has been found
356 * eofseen - true if we've seen an eof in the input file
357 * ddebug - if true (-d), make a "debug" scanner
358 * trace - if true (-T), trace processing
359 * spprdflt - if true (-s), suppress the default rule
360 * interactive - if true (-I), generate an interactive scanner
361 * caseins - if true (-i), generate a case-insensitive scanner
362 * useecs - if true (-Ce flag), use equivalence classes
363 * fulltbl - if true (-Cf flag), don't compress the DFA state table
364 * usemecs - if true (-Cm flag), use meta-equivalence classes
365 * fullspd - if true (-F flag), use Jacobson method of table representation
366 * gen_line_dirs - if true (i.e., no -L flag), generate #line directives
367 * performance_report - if true (i.e., -p flag), generate a report relating
368 * to scanner performance
369 * backtrack_report - if true (i.e., -b flag), generate "lex.backtrack" file
370 * listing backtracking states
371 * csize - size of character set for the scanner we're generating;
372 * 128 for 7-bit chars and 256 for 8-bit
373 * yymore_used - if true, yymore() is used in input rules
374 * reject - if true, generate backtracking tables for REJECT macro
375 * real_reject - if true, scanner really uses REJECT (as opposed to just
376 * having "reject" set for variable trailing context)
377 * continued_action - true if this rule's action is to "fall through" to
378 * the next rule's action (i.e., the '|' action)
379 * yymore_really_used - has a REALLY_xxx value indicating whether a
380 * %used or %notused was used with yymore()
381 * reject_really_used - same for REJECT
384 extern int printstats, syntaxerror, eofseen, ddebug, trace, spprdflt;
385 extern int interactive, caseins, useecs, fulltbl, usemecs;
386 extern int fullspd, gen_line_dirs, performance_report, backtrack_report, csize;
387 extern int yymore_used, reject, real_reject, continued_action;
389 #define REALLY_NOT_DETERMINED 0
390 #define REALLY_USED 1
391 #define REALLY_NOT_USED 2
392 extern int yymore_really_used, reject_really_used;
395 /* variables used in the flex input routines:
396 * datapos - characters on current output line
397 * dataline - number of contiguous lines of data in current data
398 * statement. Used to generate readable -f output
399 * linenum - current input line number
400 * skelfile - the skeleton file
402 * temp_action_file - temporary file to hold actions
403 * backtrack_file - file to summarize backtracking states to
404 * infilename - name of input file
405 * action_file_name - name of the temporary file
406 * input_files - array holding names of input files
407 * num_input_files - size of input_files array
408 * program_name - name with which program was invoked
411 extern int datapos, dataline, linenum;
412 extern FILE *skelfile, *yyin, *temp_action_file, *backtrack_file;
413 extern char *infilename;
414 extern char *action_file_name;
415 extern char **input_files;
416 extern int num_input_files;
417 extern char *program_name;
420 /* variables for stack of states having only one out-transition:
421 * onestate - state number
422 * onesym - transition symbol
423 * onenext - target state
424 * onedef - default base entry
425 * onesp - stack pointer
428 extern int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
429 extern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
432 /* variables for nfa machine data:
433 * current_mns - current maximum on number of NFA states
434 * num_rules - number of the last accepting state; also is number of
435 * rules created so far
436 * current_max_rules - current maximum number of rules
437 * lastnfa - last nfa state number created
438 * firstst - physically the first state of a fragment
439 * lastst - last physical state of fragment
440 * finalst - last logical state of fragment
441 * transchar - transition character
442 * trans1 - transition state
443 * trans2 - 2nd transition state for epsilons
444 * accptnum - accepting number
445 * assoc_rule - rule associated with this NFA state (or 0 if none)
446 * state_type - a STATE_xxx type identifying whether the state is part
447 * of a normal rule, the leading state in a trailing context
448 * rule (i.e., the state which marks the transition from
449 * recognizing the text-to-be-matched to the beginning of
450 * the trailing context), or a subsequent state in a trailing
452 * rule_type - a RULE_xxx type identifying whether this a a ho-hum
453 * normal rule or one which has variable head & trailing
455 * rule_linenum - line number associated with rule
458 extern int current_mns, num_rules, current_max_rules, lastnfa;
459 extern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
460 extern int *accptnum, *assoc_rule, *state_type, *rule_type, *rule_linenum;
462 /* different types of states; values are useful as masks, as well, for
463 * routines like check_trailing_context()
465 #define STATE_NORMAL 0x1
466 #define STATE_TRAILING_CONTEXT 0x2
468 /* global holding current type of state we're making */
470 extern int current_state_type;
472 /* different types of rules */
473 #define RULE_NORMAL 0
474 #define RULE_VARIABLE 1
476 /* true if the input rules include a rule with both variable-length head
477 * and trailing context, false otherwise
479 extern int variable_trailing_context_rules;
482 /* variables for protos:
483 * numtemps - number of templates created
484 * numprots - number of protos created
485 * protprev - backlink to a more-recently used proto
486 * protnext - forward link to a less-recently used proto
487 * prottbl - base/def table entry for proto
488 * protcomst - common state of proto
489 * firstprot - number of the most recently used proto
490 * lastprot - number of the least recently used proto
491 * protsave contains the entire state array for protos
494 extern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
495 extern int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE];
498 /* variables for managing equivalence classes:
499 * numecs - number of equivalence classes
500 * nextecm - forward link of Equivalence Class members
501 * ecgroup - class number or backward link of EC members
502 * nummecs - number of meta-equivalence classes (used to compress
504 * tecfwd - forward link of meta-equivalence classes members
505 * tecbck - backward link of MEC's
506 * xlation - maps character codes to their translations, or nil if no %t table
507 * num_xlations - number of different xlation values
510 /* reserve enough room in the equivalence class arrays so that we
511 * can use the CSIZE'th element to hold equivalence class information
512 * for the NUL character. Later we'll move this information into
515 extern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs;
517 /* meta-equivalence classes are indexed starting at 1, so it's possible
518 * that they will require positions from 1 .. CSIZE, i.e., CSIZE + 1
519 * slots total (since the arrays are 0-based). nextecm[] and ecgroup[]
520 * don't require the extra position since they're indexed from 1 .. CSIZE - 1.
522 extern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
525 extern int num_xlations;
528 /* variables for start conditions:
529 * lastsc - last start condition created
530 * current_max_scs - current limit on number of start conditions
531 * scset - set of rules active in start condition
532 * scbol - set of rules active only at the beginning of line in a s.c.
533 * scxclu - true if start condition is exclusive
534 * sceof - true if start condition has EOF rule
535 * scname - start condition name
536 * actvsc - stack of active start conditions for the current rule
539 extern int lastsc, current_max_scs, *scset, *scbol, *scxclu, *sceof, *actvsc;
540 extern char **scname;
543 /* variables for dfa machine data:
544 * current_max_dfa_size - current maximum number of NFA states in DFA
545 * current_max_xpairs - current maximum number of non-template xtion pairs
546 * current_max_template_xpairs - current maximum number of template pairs
547 * current_max_dfas - current maximum number DFA states
548 * lastdfa - last dfa state number created
549 * nxt - state to enter upon reading character
550 * chk - check value to see if "nxt" applies
551 * tnxt - internal nxt table for templates
552 * base - offset into "nxt" for given state
553 * def - where to go if "chk" disallows "nxt" entry
554 * nultrans - NUL transition for each state
555 * NUL_ec - equivalence class of the NUL character
556 * tblend - last "nxt/chk" table entry being used
557 * firstfree - first empty entry in "nxt/chk" table
558 * dss - nfa state set for each dfa
559 * dfasiz - size of nfa state set for each dfa
560 * dfaacc - accepting set for each dfa state (or accepting number, if
562 * accsiz - size of accepting set for each dfa state
563 * dhash - dfa state hash value
564 * numas - number of DFA accepting states created; note that this
565 * is not necessarily the same value as num_rules, which is the analogous
567 * numsnpairs - number of state/nextstate transition pairs
568 * jambase - position in base/def where the default jam table starts
569 * jamstate - state number corresponding to "jam" state
570 * end_of_buffer_state - end-of-buffer dfa state number
573 extern int current_max_dfa_size, current_max_xpairs;
574 extern int current_max_template_xpairs, current_max_dfas;
575 extern int lastdfa, lasttemp, *nxt, *chk, *tnxt;
576 extern int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz;
577 extern union dfaacc_union
582 extern int *accsiz, *dhash, numas;
583 extern int numsnpairs, jambase, jamstate;
584 extern int end_of_buffer_state;
586 /* variables for ccl information:
587 * lastccl - ccl index of the last created ccl
588 * current_maxccls - current limit on the maximum number of unique ccl's
589 * cclmap - maps a ccl index to its set pointer
590 * ccllen - gives the length of a ccl
591 * cclng - true for a given ccl if the ccl is negated
592 * cclreuse - counts how many times a ccl is re-used
593 * current_max_ccl_tbl_size - current limit on number of characters needed
594 * to represent the unique ccl's
595 * ccltbl - holds the characters in each ccl - indexed by cclmap
598 extern int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse;
599 extern int current_max_ccl_tbl_size;
603 /* variables for miscellaneous information:
604 * starttime - real-time when we started
605 * endtime - real-time when we ended
606 * nmstr - last NAME scanned by the scanner
607 * sectnum - section number currently being parsed
608 * nummt - number of empty nxt/chk table entries
609 * hshcol - number of hash collisions detected by snstods
610 * dfaeql - number of times a newly created dfa was equal to an old one
611 * numeps - number of epsilon NFA states created
612 * eps2 - number of epsilon states which have 2 out-transitions
613 * num_reallocs - number of times it was necessary to realloc() a group
615 * tmpuses - number of DFA states that chain to templates
616 * totnst - total number of NFA states used to make DFA states
617 * peakpairs - peak number of transition pairs we had to store internally
618 * numuniq - number of unique transitions
619 * numdup - number of duplicate transitions
620 * hshsave - number of hash collisions saved by checking number of states
621 * num_backtracking - number of DFA states requiring back-tracking
622 * bol_needed - whether scanner needs beginning-of-line recognition
625 extern char *starttime, *endtime, nmstr[MAXLINE];
626 extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
627 extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
628 extern int num_backtracking, bol_needed;
630 void *allocate_array(), *reallocate_array();
632 #define allocate_integer_array(size) \
633 (int *) allocate_array( size, sizeof( int ) )
635 #define reallocate_integer_array(array,size) \
636 (int *) reallocate_array( (void *) array, size, sizeof( int ) )
638 #define allocate_int_ptr_array(size) \
639 (int **) allocate_array( size, sizeof( int * ) )
641 #define allocate_char_ptr_array(size) \
642 (char **) allocate_array( size, sizeof( char * ) )
644 #define allocate_dfaacc_union(size) \
645 (union dfaacc_union *) \
646 allocate_array( size, sizeof( union dfaacc_union ) )
648 #define reallocate_int_ptr_array(array,size) \
649 (int **) reallocate_array( (void *) array, size, sizeof( int * ) )
651 #define reallocate_char_ptr_array(array,size) \
652 (char **) reallocate_array( (void *) array, size, sizeof( char * ) )
654 #define reallocate_dfaacc_union(array, size) \
655 (union dfaacc_union *) \
656 reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) )
658 #define allocate_character_array(size) \
659 (Char *) allocate_array( size, sizeof( Char ) )
661 #define reallocate_character_array(array,size) \
662 (Char *) reallocate_array( (void *) array, size, sizeof( Char ) )
665 /* used to communicate between scanner and parser. The type should really
666 * be YYSTYPE, but we can't easily get our hands on it.
671 /* external functions that are cross-referenced among the flex source files */
674 /* from file ccl.c */
676 extern void ccladd PROTO((int, int)); /* Add a single character to a ccl */
677 extern int cclinit PROTO(()); /* make an empty ccl */
678 extern void cclnegate PROTO((int)); /* negate a ccl */
680 /* list the members of a set of characters in CCL form */
681 extern void list_character_set PROTO((FILE*, int[]));
684 /* from file dfa.c */
686 /* increase the maximum number of dfas */
687 extern void increase_max_dfas PROTO(());
689 extern void ntod PROTO(()); /* convert a ndfa to a dfa */
692 /* from file ecs.c */
694 /* convert character classes to set of equivalence classes */
695 extern void ccl2ecl PROTO(());
697 /* associate equivalence class numbers with class members */
698 extern int cre8ecs PROTO((int[], int[], int));
700 /* associate equivalence class numbers using %t table */
701 extern int ecs_from_xlation PROTO((int[]));
703 /* update equivalence classes based on character class transitions */
704 extern void mkeccl PROTO((Char[], int, int[], int[], int, int));
706 /* create equivalence class for single character */
707 extern void mkechar PROTO((int, int[], int[]));
710 /* from file gen.c */
712 extern void make_tables PROTO(()); /* generate transition tables */
715 /* from file main.c */
717 extern void flexend PROTO((int));
720 /* from file misc.c */
722 /* write out the actions from the temporary file to lex.yy.c */
723 extern void action_out PROTO(());
725 /* true if a string is all lower case */
726 extern int all_lower PROTO((register Char *));
728 /* true if a string is all upper case */
729 extern int all_upper PROTO((register Char *));
731 /* bubble sort an integer array */
732 extern void bubble PROTO((int [], int));
734 /* shell sort a character array */
735 extern void cshell PROTO((Char [], int, int));
737 extern void dataend PROTO(()); /* finish up a block of data declarations */
739 /* report an error message and terminate */
740 extern void flexerror PROTO((char[]));
742 /* report a fatal error message and terminate */
743 extern void flexfatal PROTO((char[]));
745 /* report an error message formatted with one integer argument */
746 extern void lerrif PROTO((char[], int));
748 /* report an error message formatted with one string argument */
749 extern void lerrsf PROTO((char[], char[]));
751 /* spit out a "# line" statement */
752 extern void line_directive_out PROTO((FILE*));
754 /* generate a data statment for a two-dimensional array */
755 extern void mk2data PROTO((int));
757 extern void mkdata PROTO((int)); /* generate a data statement */
759 /* return the integer represented by a string of digits */
760 extern int myctoi PROTO((Char []));
762 /* write out one section of the skeleton file */
763 extern void skelout PROTO(());
765 /* output a yy_trans_info structure */
766 extern void transition_struct_out PROTO((int, int));
769 /* from file nfa.c */
771 /* add an accepting state to a machine */
772 extern void add_accept PROTO((int, int));
774 /* make a given number of copies of a singleton machine */
775 extern int copysingl PROTO((int, int));
777 /* debugging routine to write out an nfa */
778 extern void dumpnfa PROTO((int));
780 /* finish up the processing for a rule */
781 extern void finish_rule PROTO((int, int, int, int));
783 /* connect two machines together */
784 extern int link_machines PROTO((int, int));
786 /* mark each "beginning" state in a machine as being a "normal" (i.e.,
787 * not trailing context associated) state
789 extern void mark_beginning_as_normal PROTO((register int));
791 /* make a machine that branches to two machines */
792 extern int mkbranch PROTO((int, int));
794 extern int mkclos PROTO((int)); /* convert a machine into a closure */
795 extern int mkopt PROTO((int)); /* make a machine optional */
797 /* make a machine that matches either one of two machines */
798 extern int mkor PROTO((int, int));
800 /* convert a machine into a positive closure */
801 extern int mkposcl PROTO((int));
803 extern int mkrep PROTO((int, int, int)); /* make a replicated machine */
805 /* create a state with a transition on a given symbol */
806 extern int mkstate PROTO((int));
808 extern void new_rule PROTO(()); /* initialize for a new rule */
811 /* from file parse.y */
813 /* write out a message formatted with one string, pinpointing its location */
814 extern void format_pinpoint_message PROTO((char[], char[]));
816 /* write out a message, pinpointing its location */
817 extern void pinpoint_message PROTO((char[]));
819 extern void synerr PROTO((char [])); /* report a syntax error */
820 extern int yyparse PROTO(()); /* the YACC parser */
823 /* from file scan.l */
825 extern int flexscan PROTO(()); /* the Flex-generated scanner for flex */
827 /* open the given file (if NULL, stdin) for scanning */
828 extern void set_input_file PROTO((char*));
830 extern int yywrap PROTO(()); /* wrapup a file in the lexical analyzer */
833 /* from file sym.c */
835 /* save the text of a character class */
836 extern void cclinstal PROTO ((Char [], int));
838 /* lookup the number associated with character class */
839 extern int ccllookup PROTO((Char []));
841 extern void ndinstal PROTO((char[], Char[])); /* install a name definition */
842 extern void scinstal PROTO((char[], int)); /* make a start condition */
844 /* lookup the number associated with a start condition */
845 extern int sclookup PROTO((char[]));
848 /* from file tblcmp.c */
850 /* build table entries for dfa state */
851 extern void bldtbl PROTO((int[], int, int, int, int));
853 extern void cmptmps PROTO(()); /* compress template table entries */
854 extern void inittbl PROTO(()); /* initialize transition tables */
855 extern void mkdeftbl PROTO(()); /* make the default, "jam" table entries */
857 /* create table entries for a state (or state fragment) which has
858 * only one out-transition */
859 extern void mk1tbl PROTO((int, int, int, int));
861 /* place a state into full speed transition table */
862 extern void place_state PROTO((int*, int, int));
864 /* save states with only one out-transition to be processed later */
865 extern void stack1 PROTO((int, int, int, int));
868 /* from file yylex.c */
870 extern int yylex PROTO(());
873 /* The Unix kernel calls used here */
875 extern int read PROTO((int, char*, int));
876 extern int unlink PROTO((char*));
877 extern int write PROTO((int, char*, int));