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 /* @(#) $Header: /home/daffy/u0/vern/flex/RCS/flexdef.h,v 2.53 95/04/20 11:17:36 vern Exp $ (LBL) */
30 /* $FreeBSD: src/usr.bin/lex/flexdef.h,v 1.5 1999/10/27 07:56:44 obrien Exp $ */
43 #ifdef HAVE_SYS_TYPES_H
44 #include <sys/types.h>
55 /* As an aid for the internationalization patch to flex, which
56 * is maintained outside this distribution for copyright reasons.
58 #define _(String) (String)
60 /* Always be prepared to generate an 8-bit scanner. */
62 #define Char unsigned char
64 /* Size of input alphabet - should be size of ASCII set. */
66 #define DEFAULT_CSIZE 128
70 #define PROTO(proto) proto
75 /* Maximum line length we'll have to deal with. */
79 #define MIN(x,y) ((x) < (y) ? (x) : (y))
82 #define MAX(x,y) ((x) > (y) ? (x) : (y))
85 #define ABS(x) ((x) < 0 ? -(x) : (x))
89 /* ANSI C does not guarantee that isascii() is defined */
91 #define isascii(c) ((c) <= 0177)
97 #define unspecified -1
100 /* Special chk[] values marking the slots taking by end-of-buffer and action
103 #define EOB_POSITION -1
104 #define ACTION_POSITION -2
106 /* Number of data items per line for -f output. */
107 #define NUMDATAITEMS 10
109 /* Number of lines of data in -f output before inserting a blank line for
112 #define NUMDATALINES 10
114 /* transition_struct_out() definitions. */
115 #define TRANS_STRUCT_PRINT_LENGTH 14
117 /* Returns true if an nfa state has an epsilon out-transition slot
118 * that can be used. This definition is currently not used.
120 #define FREE_EPSILON(state) \
121 (transchar[state] == SYM_EPSILON && \
122 trans2[state] == NO_TRANSITION && \
123 finalst[state] != state)
125 /* Returns true if an nfa state has an epsilon out-transition character
126 * and both slots are free
128 #define SUPER_FREE_EPSILON(state) \
129 (transchar[state] == SYM_EPSILON && \
130 trans1[state] == NO_TRANSITION) \
132 /* Maximum number of NFA states that can comprise a DFA state. It's real
133 * big because if there's a lot of rules, the initial state will have a
134 * huge epsilon closure.
136 #define INITIAL_MAX_DFA_SIZE 750
137 #define MAX_DFA_SIZE_INCREMENT 750
140 /* A note on the following masks. They are used to mark accepting numbers
141 * as being special. As such, they implicitly limit the number of accepting
142 * numbers (i.e., rules) because if there are too many rules the rule numbers
143 * will overload the mask bits. Fortunately, this limit is \large/ (0x2000 ==
144 * 8192) so unlikely to actually cause any problems. A check is made in
145 * new_rule() to ensure that this limit is not reached.
148 /* Mask to mark a trailing context accepting number. */
149 #define YY_TRAILING_MASK 0x2000
151 /* Mask to mark the accepting number of the "head" of a trailing context
154 #define YY_TRAILING_HEAD_MASK 0x4000
156 /* Maximum number of rules, as outlined in the above note. */
157 #define MAX_RULE (YY_TRAILING_MASK - 1)
160 /* NIL must be 0. If not, its special meaning when making equivalence classes
161 * (it marks the representative of a given e.c.) will be unidentifiable.
165 #define JAM -1 /* to mark a missing DFA transition */
166 #define NO_TRANSITION NIL
167 #define UNIQUE -1 /* marks a symbol as an e.c. representative */
168 #define INFINITY -1 /* for x{5,} constructions */
170 #define INITIAL_MAX_CCLS 100 /* max number of unique character classes */
171 #define MAX_CCLS_INCREMENT 100
173 /* Size of table holding members of character classes. */
174 #define INITIAL_MAX_CCL_TBL_SIZE 500
175 #define MAX_CCL_TBL_SIZE_INCREMENT 250
177 #define INITIAL_MAX_RULES 100 /* default maximum number of rules */
178 #define MAX_RULES_INCREMENT 100
180 #define INITIAL_MNS 2000 /* default maximum number of nfa states */
181 #define MNS_INCREMENT 1000 /* amount to bump above by if it's not enough */
183 #define INITIAL_MAX_DFAS 1000 /* default maximum number of dfa states */
184 #define MAX_DFAS_INCREMENT 1000
186 #define JAMSTATE -32766 /* marks a reference to the state that always jams */
188 /* Maximum number of NFA states. */
189 #define MAXIMUM_MNS 31999
191 /* Enough so that if it's subtracted from an NFA state number, the result
192 * is guaranteed to be negative.
194 #define MARKER_DIFFERENCE (MAXIMUM_MNS+2)
196 /* Maximum number of nxt/chk pairs for non-templates. */
197 #define INITIAL_MAX_XPAIRS 2000
198 #define MAX_XPAIRS_INCREMENT 2000
200 /* Maximum number of nxt/chk pairs needed for templates. */
201 #define INITIAL_MAX_TEMPLATE_XPAIRS 2500
202 #define MAX_TEMPLATE_XPAIRS_INCREMENT 2500
204 #define SYM_EPSILON (CSIZE + 1) /* to mark transitions on the symbol epsilon */
206 #define INITIAL_MAX_SCS 40 /* maximum number of start conditions */
207 #define MAX_SCS_INCREMENT 40 /* amount to bump by if it's not enough */
209 #define ONE_STACK_SIZE 500 /* stack of states with only one out-transition */
210 #define SAME_TRANS -1 /* transition is the same as "default" entry for state */
212 /* The following percentages are used to tune table compression:
214 * The percentage the number of out-transitions a state must be of the
215 * number of equivalence classes in order to be considered for table
216 * compaction by using protos.
218 #define PROTO_SIZE_PERCENTAGE 15
220 /* The percentage the number of homogeneous out-transitions of a state
221 * must be of the number of total out-transitions of the state in order
222 * that the state's transition table is first compared with a potential
223 * template of the most common out-transition instead of with the first
224 * proto in the proto queue.
226 #define CHECK_COM_PERCENTAGE 50
228 /* The percentage the number of differences between a state's transition
229 * table and the proto it was first compared with must be of the total
230 * number of out-transitions of the state in order to keep the first
231 * proto as a good match and not search any further.
233 #define FIRST_MATCH_DIFF_PERCENTAGE 10
235 /* The percentage the number of differences between a state's transition
236 * table and the most similar proto must be of the state's total number
237 * of out-transitions to use the proto as an acceptable close match.
239 #define ACCEPTABLE_DIFF_PERCENTAGE 50
241 /* The percentage the number of homogeneous out-transitions of a state
242 * must be of the number of total out-transitions of the state in order
243 * to consider making a template from the state.
245 #define TEMPLATE_SAME_PERCENTAGE 60
247 /* The percentage the number of differences between a state's transition
248 * table and the most similar proto must be of the state's total number
249 * of out-transitions to create a new proto from the state.
251 #define NEW_PROTO_DIFF_PERCENTAGE 20
253 /* The percentage the total number of out-transitions of a state must be
254 * of the number of equivalence classes in order to consider trying to
255 * fit the transition table into "holes" inside the nxt/chk table.
257 #define INTERIOR_FIT_PERCENTAGE 15
259 /* Size of region set aside to cache the complete transition table of
260 * protos on the proto queue to enable quick comparisons.
262 #define PROT_SAVE_SIZE 2000
264 #define MSP 50 /* maximum number of saved protos (protos on the proto queue) */
266 /* Maximum number of out-transitions a state can have that we'll rummage
267 * around through the interior of the internal fast table looking for a
270 #define MAX_XTIONS_FULL_INTERIOR_FIT 4
272 /* Maximum number of rules which will be reported as being associated
275 #define MAX_ASSOC_RULES 100
277 /* Number that, if used to subscript an array, has a good chance of producing
278 * an error; should be small enough to fit into a short.
280 #define BAD_SUBSCRIPT -32767
282 /* Absolute value of largest number that can be stored in a short, with a
283 * bit of slop thrown in for general paranoia.
285 #define MAX_SHORT 32700
288 /* Declarations for global variables. */
290 /* Variables for symbol tables:
291 * sctbl - start-condition symbol table
292 * ndtbl - name-definition symbol table
293 * ccltab - character class text symbol table
298 struct hash_entry *prev, *next;
304 typedef struct hash_entry **hash_table;
306 #define NAME_TABLE_HASH_SIZE 101
307 #define START_COND_HASH_SIZE 101
308 #define CCL_HASH_SIZE 101
310 extern struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE];
311 extern struct hash_entry *sctbl[START_COND_HASH_SIZE];
312 extern struct hash_entry *ccltab[CCL_HASH_SIZE];
315 /* Variables for flags:
316 * printstats - if true (-v), dump statistics
317 * syntaxerror - true if a syntax error has been found
318 * eofseen - true if we've seen an eof in the input file
319 * ddebug - if true (-d), make a "debug" scanner
320 * trace - if true (-T), trace processing
321 * nowarn - if true (-w), do not generate warnings
322 * spprdflt - if true (-s), suppress the default rule
323 * interactive - if true (-I), generate an interactive scanner
324 * caseins - if true (-i), generate a case-insensitive scanner
325 * lex_compat - if true (-l), maximize compatibility with AT&T lex
326 * do_yylineno - if true, generate code to maintain yylineno
327 * useecs - if true (-Ce flag), use equivalence classes
328 * fulltbl - if true (-Cf flag), don't compress the DFA state table
329 * usemecs - if true (-Cm flag), use meta-equivalence classes
330 * fullspd - if true (-F flag), use Jacobson method of table representation
331 * gen_line_dirs - if true (i.e., no -L flag), generate #line directives
332 * performance_report - if > 0 (i.e., -p flag), generate a report relating
333 * to scanner performance; if > 1 (-p -p), report on minor performance
335 * backing_up_report - if true (i.e., -b flag), generate "lex.backup" file
336 * listing backing-up states
337 * C_plus_plus - if true (i.e., -+ flag), generate a C++ scanner class;
338 * otherwise, a standard C scanner
339 * long_align - if true (-Ca flag), favor long-word alignment.
340 * use_read - if true (-f, -F, or -Cr) then use read() for scanner input;
341 * otherwise, use fread().
342 * yytext_is_array - if true (i.e., %array directive), then declare
343 * yytext as a array instead of a character pointer. Nice and inefficient.
344 * do_yywrap - do yywrap() processing on EOF. If false, EOF treated as
346 * csize - size of character set for the scanner we're generating;
347 * 128 for 7-bit chars and 256 for 8-bit
348 * yymore_used - if true, yymore() is used in input rules
349 * reject - if true, generate back-up tables for REJECT macro
350 * real_reject - if true, scanner really uses REJECT (as opposed to just
351 * having "reject" set for variable trailing context)
352 * continued_action - true if this rule's action is to "fall through" to
353 * the next rule's action (i.e., the '|' action)
354 * in_rule - true if we're inside an individual rule, false if not.
355 * yymore_really_used - whether to treat yymore() as really used, regardless
356 * of what we think based on references to it in the user's actions.
357 * reject_really_used - same for REJECT
360 extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn, spprdflt;
361 extern int interactive, caseins, lex_compat, do_yylineno;
362 extern int useecs, fulltbl, usemecs, fullspd;
363 extern int gen_line_dirs, performance_report, backing_up_report;
364 extern int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap;
366 extern int yymore_used, reject, real_reject, continued_action, in_rule;
368 extern int yymore_really_used, reject_really_used;
371 /* Variables used in the flex input routines:
372 * datapos - characters on current output line
373 * dataline - number of contiguous lines of data in current data
374 * statement. Used to generate readable -f output
375 * linenum - current input line number
376 * out_linenum - current output line number
377 * skelfile - the skeleton file
378 * skel - compiled-in skeleton array
379 * skel_ind - index into "skel" array, if skelfile is nil
381 * backing_up_file - file to summarize backing-up states to
382 * infilename - name of input file
383 * outfilename - name of output file
384 * did_outfilename - whether outfilename was explicitly set
385 * prefix - the prefix used for externally visible names ("yy" by default)
386 * yyclass - yyFlexLexer subclass to use for YY_DECL
387 * do_stdinit - whether to initialize yyin/yyout to stdin/stdout
388 * use_stdout - the -t flag
389 * input_files - array holding names of input files
390 * num_input_files - size of input_files array
391 * program_name - name with which program was invoked
393 * action_array - array to hold the rule actions
394 * action_size - size of action_array
395 * defs1_offset - index where the user's section 1 definitions start
397 * prolog_offset - index where the prolog starts in action_array
398 * action_offset - index where the non-prolog starts in action_array
399 * action_index - index where the next action should go, with respect
403 extern int datapos, dataline, linenum, out_linenum;
404 extern FILE *skelfile, *yyin, *backing_up_file;
405 extern const char *skel[];
407 extern char *infilename, *outfilename;
408 extern int did_outfilename;
409 extern char *prefix, *yyclass;
410 extern int do_stdinit, use_stdout;
411 extern char **input_files;
412 extern int num_input_files;
413 extern char *program_name;
415 extern char *action_array;
416 extern int action_size;
417 extern int defs1_offset, prolog_offset, action_offset, action_index;
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 * num_eof_rules - number of <<EOF>> rules
437 * default_rule - number of the default rule
438 * current_max_rules - current maximum number of rules
439 * lastnfa - last nfa state number created
440 * firstst - physically the first state of a fragment
441 * lastst - last physical state of fragment
442 * finalst - last logical state of fragment
443 * transchar - transition character
444 * trans1 - transition state
445 * trans2 - 2nd transition state for epsilons
446 * accptnum - accepting number
447 * assoc_rule - rule associated with this NFA state (or 0 if none)
448 * state_type - a STATE_xxx type identifying whether the state is part
449 * of a normal rule, the leading state in a trailing context
450 * rule (i.e., the state which marks the transition from
451 * recognizing the text-to-be-matched to the beginning of
452 * the trailing context), or a subsequent state in a trailing
454 * rule_type - a RULE_xxx type identifying whether this a ho-hum
455 * normal rule or one which has variable head & trailing
457 * rule_linenum - line number associated with rule
458 * rule_useful - true if we've determined that the rule can be matched
461 extern int current_mns, current_max_rules;
462 extern int num_rules, num_eof_rules, default_rule, lastnfa;
463 extern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
464 extern int *accptnum, *assoc_rule, *state_type;
465 extern int *rule_type, *rule_linenum, *rule_useful;
467 /* Different types of states; values are useful as masks, as well, for
468 * routines like check_trailing_context().
470 #define STATE_NORMAL 0x1
471 #define STATE_TRAILING_CONTEXT 0x2
473 /* Global holding current type of state we're making. */
475 extern int current_state_type;
477 /* Different types of rules. */
478 #define RULE_NORMAL 0
479 #define RULE_VARIABLE 1
481 /* True if the input rules include a rule with both variable-length head
482 * and trailing context, false otherwise.
484 extern int variable_trailing_context_rules;
487 /* Variables for protos:
488 * numtemps - number of templates created
489 * numprots - number of protos created
490 * protprev - backlink to a more-recently used proto
491 * protnext - forward link to a less-recently used proto
492 * prottbl - base/def table entry for proto
493 * protcomst - common state of proto
494 * firstprot - number of the most recently used proto
495 * lastprot - number of the least recently used proto
496 * protsave contains the entire state array for protos
499 extern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
500 extern int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE];
503 /* Variables for managing equivalence classes:
504 * numecs - number of equivalence classes
505 * nextecm - forward link of Equivalence Class members
506 * ecgroup - class number or backward link of EC members
507 * nummecs - number of meta-equivalence classes (used to compress
509 * tecfwd - forward link of meta-equivalence classes members
510 * tecbck - backward link of MEC's
513 /* Reserve enough room in the equivalence class arrays so that we
514 * can use the CSIZE'th element to hold equivalence class information
515 * for the NUL character. Later we'll move this information into
518 extern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs;
520 /* Meta-equivalence classes are indexed starting at 1, so it's possible
521 * that they will require positions from 1 .. CSIZE, i.e., CSIZE + 1
522 * slots total (since the arrays are 0-based). nextecm[] and ecgroup[]
523 * don't require the extra position since they're indexed from 1 .. CSIZE - 1.
525 extern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
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
538 extern int lastsc, *scset, *scbol, *scxclu, *sceof;
539 extern int current_max_scs;
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 (if using REJECT), or accepting
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, *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, *cclmap, *ccllen, *cclng, cclreuse;
599 extern int current_maxccls, current_max_ccl_tbl_size;
603 /* Variables for miscellaneous information:
604 * nmstr - last NAME scanned by the scanner
605 * sectnum - section number currently being parsed
606 * nummt - number of empty nxt/chk table entries
607 * hshcol - number of hash collisions detected by snstods
608 * dfaeql - number of times a newly created dfa was equal to an old one
609 * numeps - number of epsilon NFA states created
610 * eps2 - number of epsilon states which have 2 out-transitions
611 * num_reallocs - number of times it was necessary to realloc() a group
613 * tmpuses - number of DFA states that chain to templates
614 * totnst - total number of NFA states used to make DFA states
615 * peakpairs - peak number of transition pairs we had to store internally
616 * numuniq - number of unique transitions
617 * numdup - number of duplicate transitions
618 * hshsave - number of hash collisions saved by checking number of states
619 * num_backing_up - number of DFA states requiring backing up
620 * bol_needed - whether scanner needs beginning-of-line recognition
623 extern char nmstr[MAXLINE];
624 extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
625 extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
626 extern int num_backing_up, bol_needed;
628 void *allocate_array PROTO((int, size_t));
629 void *reallocate_array PROTO((void*, int, size_t));
631 void *flex_alloc PROTO((size_t));
632 void *flex_realloc PROTO((void*, size_t));
633 void flex_free PROTO((void*));
635 #define allocate_integer_array(size) \
636 (int *) allocate_array( size, sizeof( int ) )
638 #define reallocate_integer_array(array,size) \
639 (int *) reallocate_array( (void *) array, size, sizeof( int ) )
641 #define allocate_int_ptr_array(size) \
642 (int **) allocate_array( size, sizeof( int * ) )
644 #define allocate_char_ptr_array(size) \
645 (char **) allocate_array( size, sizeof( char * ) )
647 #define allocate_dfaacc_union(size) \
648 (union dfaacc_union *) \
649 allocate_array( size, sizeof( union dfaacc_union ) )
651 #define reallocate_int_ptr_array(array,size) \
652 (int **) reallocate_array( (void *) array, size, sizeof( int * ) )
654 #define reallocate_char_ptr_array(array,size) \
655 (char **) reallocate_array( (void *) array, size, sizeof( char * ) )
657 #define reallocate_dfaacc_union(array, size) \
658 (union dfaacc_union *) \
659 reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) )
661 #define allocate_character_array(size) \
662 (char *) allocate_array( size, sizeof( char ) )
664 #define reallocate_character_array(array,size) \
665 (char *) reallocate_array( (void *) array, size, sizeof( char ) )
667 #define allocate_Character_array(size) \
668 (Char *) allocate_array( size, sizeof( Char ) )
670 #define reallocate_Character_array(array,size) \
671 (Char *) reallocate_array( (void *) array, size, sizeof( Char ) )
674 /* Used to communicate between scanner and parser. The type should really
675 * be YYSTYPE, but we can't easily get our hands on it.
680 /* External functions that are cross-referenced among the flex source files. */
683 /* from file ccl.c */
685 extern void ccladd PROTO((int, int)); /* add a single character to a ccl */
686 extern int cclinit PROTO((void)); /* make an empty ccl */
687 extern void cclnegate PROTO((int)); /* negate a ccl */
689 /* List the members of a set of characters in CCL form. */
690 extern void list_character_set PROTO((FILE*, int[]));
693 /* from file dfa.c */
695 /* Check a DFA state for backing up. */
696 extern void check_for_backing_up PROTO((int, int[]));
698 /* Check to see if NFA state set constitutes "dangerous" trailing context. */
699 extern void check_trailing_context PROTO((int*, int, int*, int));
701 /* Construct the epsilon closure of a set of ndfa states. */
702 extern int *epsclosure PROTO((int*, int*, int[], int*, int*));
704 /* Increase the maximum number of dfas. */
705 extern void increase_max_dfas PROTO((void));
707 extern void ntod PROTO((void)); /* convert a ndfa to a dfa */
709 /* Converts a set of ndfa states into a dfa state. */
710 extern int snstods PROTO((int[], int, int[], int, int, int*));
713 /* from file ecs.c */
715 /* Convert character classes to set of equivalence classes. */
716 extern void ccl2ecl PROTO((void));
718 /* Associate equivalence class numbers with class members. */
719 extern int cre8ecs PROTO((int[], int[], int));
721 /* Update equivalence classes based on character class transitions. */
722 extern void mkeccl PROTO((Char[], int, int[], int[], int, int));
724 /* Create equivalence class for single character. */
725 extern void mkechar PROTO((int, int[], int[]));
728 /* from file gen.c */
730 extern void do_indent PROTO((void)); /* indent to the current level */
732 /* Generate the code to keep backing-up information. */
733 extern void gen_backing_up PROTO((void));
735 /* Generate the code to perform the backing up. */
736 extern void gen_bu_action PROTO((void));
738 /* Generate full speed compressed transition table. */
739 extern void genctbl PROTO((void));
741 /* Generate the code to find the action number. */
742 extern void gen_find_action PROTO((void));
744 extern void genftbl PROTO((void)); /* generate full transition table */
746 /* Generate the code to find the next compressed-table state. */
747 extern void gen_next_compressed_state PROTO((char*));
749 /* Generate the code to find the next match. */
750 extern void gen_next_match PROTO((void));
752 /* Generate the code to find the next state. */
753 extern void gen_next_state PROTO((int));
755 /* Generate the code to make a NUL transition. */
756 extern void gen_NUL_trans PROTO((void));
758 /* Generate the code to find the start state. */
759 extern void gen_start_state PROTO((void));
761 /* Generate data statements for the transition tables. */
762 extern void gentabs PROTO((void));
764 /* Write out a formatted string at the current indentation level. */
765 extern void indent_put2s PROTO((char[], char[]));
767 /* Write out a string + newline at the current indentation level. */
768 extern void indent_puts PROTO((char[]));
770 extern void make_tables PROTO((void)); /* generate transition tables */
773 /* from file main.c */
775 extern void check_options PROTO((void));
776 extern void flexend PROTO((int));
777 extern void usage PROTO((void));
780 /* from file misc.c */
782 /* Add a #define to the action file. */
783 extern void action_define PROTO(( char *defname, int value ));
785 /* Add the given text to the stored actions. */
786 extern void add_action PROTO(( char *new_text ));
788 /* True if a string is all lower case. */
789 extern int all_lower PROTO((char *));
791 /* True if a string is all upper case. */
792 extern int all_upper PROTO((char *));
794 /* Bubble sort an integer array. */
795 extern void bubble PROTO((int [], int));
797 /* Check a character to make sure it's in the expected range. */
798 extern void check_char PROTO((int c));
800 /* Replace upper-case letter to lower-case. */
801 extern Char clower PROTO((int));
803 /* Returns a dynamically allocated copy of a string. */
804 extern char *copy_string PROTO((const char *));
806 /* Returns a dynamically allocated copy of a (potentially) unsigned string. */
807 extern Char *copy_unsigned_string PROTO((Char *));
809 /* Shell sort a character array. */
810 extern void cshell PROTO((Char [], int, int));
812 /* Finish up a block of data declarations. */
813 extern void dataend PROTO((void));
815 /* Flush generated data statements. */
816 extern void dataflush PROTO((void));
818 /* Report an error message and terminate. */
819 extern void flexerror PROTO((const char[]));
821 /* Report a fatal error message and terminate. */
822 extern void flexfatal PROTO((const char[]));
824 /* Convert a hexadecimal digit string to an integer value. */
825 extern int htoi PROTO((Char[]));
827 /* Report an error message formatted with one integer argument. */
828 extern void lerrif PROTO((const char[], int));
830 /* Report an error message formatted with one string argument. */
831 extern void lerrsf PROTO((const char[], const char[]));
833 /* Spit out a "#line" statement. */
834 extern void line_directive_out PROTO((FILE*, int));
836 /* Mark the current position in the action array as the end of the section 1
839 extern void mark_defs1 PROTO((void));
841 /* Mark the current position in the action array as the end of the prolog. */
842 extern void mark_prolog PROTO((void));
844 /* Generate a data statment for a two-dimensional array. */
845 extern void mk2data PROTO((int));
847 extern void mkdata PROTO((int)); /* generate a data statement */
849 /* Return the integer represented by a string of digits. */
850 extern int myctoi PROTO((char []));
852 /* Return character corresponding to escape sequence. */
853 extern Char myesc PROTO((Char[]));
855 /* Convert an octal digit string to an integer value. */
856 extern int otoi PROTO((Char [] ));
858 /* Output a (possibly-formatted) string to the generated scanner. */
859 extern void out PROTO((const char []));
860 extern void out_dec PROTO((const char [], int));
861 extern void out_dec2 PROTO((const char [], int, int));
862 extern void out_hex PROTO((const char [], unsigned int));
863 extern void out_line_count PROTO((const char []));
864 extern void out_str PROTO((const char [], const char []));
866 PROTO((const char [], const char [], const char [], const char []));
867 extern void out_str_dec PROTO((const char [], const char [], int));
868 extern void outc PROTO((int));
869 extern void outn PROTO((const char []));
871 /* Return a printable version of the given character, which might be
874 extern char *readable_form PROTO((int));
876 /* Write out one section of the skeleton file. */
877 extern void skelout PROTO((void));
879 /* Output a yy_trans_info structure. */
880 extern void transition_struct_out PROTO((int, int));
882 /* Only needed when using certain broken versions of bison to build parse.c. */
883 extern void *yy_flex_xmalloc PROTO(( int ));
885 /* Set a region of memory to 0. */
886 extern void zero_out PROTO((char *, size_t));
889 /* from file nfa.c */
891 /* Add an accepting state to a machine. */
892 extern void add_accept PROTO((int, int));
894 /* Make a given number of copies of a singleton machine. */
895 extern int copysingl PROTO((int, int));
897 /* Debugging routine to write out an nfa. */
898 extern void dumpnfa PROTO((int));
900 /* Finish up the processing for a rule. */
901 extern void finish_rule PROTO((int, int, int, int));
903 /* Connect two machines together. */
904 extern int link_machines PROTO((int, int));
906 /* Mark each "beginning" state in a machine as being a "normal" (i.e.,
907 * not trailing context associated) state.
909 extern void mark_beginning_as_normal PROTO((int));
911 /* Make a machine that branches to two machines. */
912 extern int mkbranch PROTO((int, int));
914 extern int mkclos PROTO((int)); /* convert a machine into a closure */
915 extern int mkopt PROTO((int)); /* make a machine optional */
917 /* Make a machine that matches either one of two machines. */
918 extern int mkor PROTO((int, int));
920 /* Convert a machine into a positive closure. */
921 extern int mkposcl PROTO((int));
923 extern int mkrep PROTO((int, int, int)); /* make a replicated machine */
925 /* Create a state with a transition on a given symbol. */
926 extern int mkstate PROTO((int));
928 extern void new_rule PROTO((void)); /* initialize for a new rule */
931 /* from file parse.y */
933 /* Build the "<<EOF>>" action for the active start conditions. */
934 extern void build_eof_action PROTO((void));
936 /* Write out a message formatted with one string, pinpointing its location. */
937 extern void format_pinpoint_message PROTO((char[], char[]));
939 /* Write out a message, pinpointing its location. */
940 extern void pinpoint_message PROTO((char[]));
942 /* Write out a warning, pinpointing it at the given line. */
943 extern void line_warning PROTO(( char[], int ));
945 /* Write out a message, pinpointing it at the given line. */
946 extern void line_pinpoint PROTO(( char[], int ));
948 /* Report a formatted syntax error. */
949 extern void format_synerr PROTO((char [], char[]));
950 extern void synerr PROTO((char [])); /* report a syntax error */
951 extern void format_warn PROTO((char [], char[]));
952 extern void warn PROTO((char [])); /* report a warning */
953 extern void yyerror PROTO((char [])); /* report a parse error */
954 extern int yyparse PROTO((void)); /* the YACC parser */
957 /* from file scan.l */
959 /* The Flex-generated scanner for flex. */
960 extern int flexscan PROTO((void));
962 /* Open the given file (if NULL, stdin) for scanning. */
963 extern void set_input_file PROTO((char*));
965 /* Wrapup a file in the lexical analyzer. */
966 extern int yywrap PROTO((void));
969 /* from file sym.c */
971 /* Add symbol and definitions to symbol table. */
972 extern int addsym PROTO((char[], char*, int, hash_table, int));
974 /* Save the text of a character class. */
975 extern void cclinstal PROTO ((Char [], int));
977 /* Lookup the number associated with character class. */
978 extern int ccllookup PROTO((Char []));
980 /* Find symbol in symbol table. */
981 extern struct hash_entry *findsym PROTO((char[], hash_table, int ));
983 extern void ndinstal PROTO((char[], Char[])); /* install a name definition */
984 extern Char *ndlookup PROTO((char[])); /* lookup a name definition */
986 /* Increase maximum number of SC's. */
987 extern void scextend PROTO((void));
988 extern void scinstal PROTO((char[], int)); /* make a start condition */
990 /* Lookup the number associated with a start condition. */
991 extern int sclookup PROTO((char[]));
994 /* from file tblcmp.c */
996 /* Build table entries for dfa state. */
997 extern void bldtbl PROTO((int[], int, int, int, int));
999 extern void cmptmps PROTO((void)); /* compress template table entries */
1000 extern void expand_nxt_chk PROTO((void)); /* increase nxt/chk arrays */
1001 /* Finds a space in the table for a state to be placed. */
1002 extern int find_table_space PROTO((int*, int));
1003 extern void inittbl PROTO((void)); /* initialize transition tables */
1004 /* Make the default, "jam" table entries. */
1005 extern void mkdeftbl PROTO((void));
1007 /* Create table entries for a state (or state fragment) which has
1008 * only one out-transition.
1010 extern void mk1tbl PROTO((int, int, int, int));
1012 /* Place a state into full speed transition table. */
1013 extern void place_state PROTO((int*, int, int));
1015 /* Save states with only one out-transition to be processed later. */
1016 extern void stack1 PROTO((int, int, int, int));
1019 /* from file yylex.c */
1021 extern int yylex PROTO((void));