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 with or without
15 * modification are permitted provided that: (1) source distributions retain
16 * this entire copyright notice and comment, and (2) distributions including
17 * binaries display the following acknowledgement: ``This product includes
18 * software developed by the University of California, Berkeley and its
19 * contributors'' in the documentation or other materials provided with the
20 * distribution and in all advertising materials mentioning features or use
21 * of this software. Neither the name of the University nor the names of
22 * its contributors may be used to endorse or promote products derived from
23 * this software without 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$ (LBL) */
37 #define HAVE_STRING_H 1
56 #ifdef HAVE_SYS_TYPES_H
57 #include <sys/types.h>
68 /* As an aid for the internationalization patch to flex, which
69 * is maintained outside this distribution for copyright reasons.
71 #define _(String) (String)
73 /* Always be prepared to generate an 8-bit scanner. */
75 #define Char unsigned char
77 /* Size of input alphabet - should be size of ASCII set. */
79 #define DEFAULT_CSIZE 128
84 #define PROTO(proto) proto
86 #define PROTO(proto) ()
93 #define SHORT_FILE_NAMES
98 #define SHORT_FILE_NAMES
102 /* Maximum line length we'll have to deal with. */
106 #define MIN(x,y) ((x) < (y) ? (x) : (y))
109 #define MAX(x,y) ((x) > (y) ? (x) : (y))
112 #define ABS(x) ((x) < 0 ? -(x) : (x))
116 /* ANSI C does not guarantee that isascii() is defined */
118 #define isascii(c) ((c) <= 0177)
124 #define unspecified -1
127 /* Special chk[] values marking the slots taking by end-of-buffer and action
130 #define EOB_POSITION -1
131 #define ACTION_POSITION -2
133 /* Number of data items per line for -f output. */
134 #define NUMDATAITEMS 10
136 /* Number of lines of data in -f output before inserting a blank line for
139 #define NUMDATALINES 10
141 /* transition_struct_out() definitions. */
142 #define TRANS_STRUCT_PRINT_LENGTH 14
144 /* Returns true if an nfa state has an epsilon out-transition slot
145 * that can be used. This definition is currently not used.
147 #define FREE_EPSILON(state) \
148 (transchar[state] == SYM_EPSILON && \
149 trans2[state] == NO_TRANSITION && \
150 finalst[state] != state)
152 /* Returns true if an nfa state has an epsilon out-transition character
153 * and both slots are free
155 #define SUPER_FREE_EPSILON(state) \
156 (transchar[state] == SYM_EPSILON && \
157 trans1[state] == NO_TRANSITION) \
159 /* Maximum number of NFA states that can comprise a DFA state. It's real
160 * big because if there's a lot of rules, the initial state will have a
161 * huge epsilon closure.
163 #define INITIAL_MAX_DFA_SIZE 750
164 #define MAX_DFA_SIZE_INCREMENT 750
167 /* A note on the following masks. They are used to mark accepting numbers
168 * as being special. As such, they implicitly limit the number of accepting
169 * numbers (i.e., rules) because if there are too many rules the rule numbers
170 * will overload the mask bits. Fortunately, this limit is \large/ (0x2000 ==
171 * 8192) so unlikely to actually cause any problems. A check is made in
172 * new_rule() to ensure that this limit is not reached.
175 /* Mask to mark a trailing context accepting number. */
176 #define YY_TRAILING_MASK 0x2000
178 /* Mask to mark the accepting number of the "head" of a trailing context
181 #define YY_TRAILING_HEAD_MASK 0x4000
183 /* Maximum number of rules, as outlined in the above note. */
184 #define MAX_RULE (YY_TRAILING_MASK - 1)
187 /* NIL must be 0. If not, its special meaning when making equivalence classes
188 * (it marks the representative of a given e.c.) will be unidentifiable.
192 #define JAM -1 /* to mark a missing DFA transition */
193 #define NO_TRANSITION NIL
194 #define UNIQUE -1 /* marks a symbol as an e.c. representative */
195 #define INFINITY -1 /* for x{5,} constructions */
197 #define INITIAL_MAX_CCLS 100 /* max number of unique character classes */
198 #define MAX_CCLS_INCREMENT 100
200 /* Size of table holding members of character classes. */
201 #define INITIAL_MAX_CCL_TBL_SIZE 500
202 #define MAX_CCL_TBL_SIZE_INCREMENT 250
204 #define INITIAL_MAX_RULES 100 /* default maximum number of rules */
205 #define MAX_RULES_INCREMENT 100
207 #define INITIAL_MNS 2000 /* default maximum number of nfa states */
208 #define MNS_INCREMENT 1000 /* amount to bump above by if it's not enough */
210 #define INITIAL_MAX_DFAS 1000 /* default maximum number of dfa states */
211 #define MAX_DFAS_INCREMENT 1000
213 #define JAMSTATE -32766 /* marks a reference to the state that always jams */
215 /* Maximum number of NFA states. */
216 #define MAXIMUM_MNS 31999
218 /* Enough so that if it's subtracted from an NFA state number, the result
219 * is guaranteed to be negative.
221 #define MARKER_DIFFERENCE (MAXIMUM_MNS+2)
223 /* Maximum number of nxt/chk pairs for non-templates. */
224 #define INITIAL_MAX_XPAIRS 2000
225 #define MAX_XPAIRS_INCREMENT 2000
227 /* Maximum number of nxt/chk pairs needed for templates. */
228 #define INITIAL_MAX_TEMPLATE_XPAIRS 2500
229 #define MAX_TEMPLATE_XPAIRS_INCREMENT 2500
231 #define SYM_EPSILON (CSIZE + 1) /* to mark transitions on the symbol epsilon */
233 #define INITIAL_MAX_SCS 40 /* maximum number of start conditions */
234 #define MAX_SCS_INCREMENT 40 /* amount to bump by if it's not enough */
236 #define ONE_STACK_SIZE 500 /* stack of states with only one out-transition */
237 #define SAME_TRANS -1 /* transition is the same as "default" entry for state */
239 /* The following percentages are used to tune table compression:
241 * The percentage the number of out-transitions a state must be of the
242 * number of equivalence classes in order to be considered for table
243 * compaction by using protos.
245 #define PROTO_SIZE_PERCENTAGE 15
247 /* The percentage the number of homogeneous out-transitions of a state
248 * must be of the number of total out-transitions of the state in order
249 * that the state's transition table is first compared with a potential
250 * template of the most common out-transition instead of with the first
251 * proto in the proto queue.
253 #define CHECK_COM_PERCENTAGE 50
255 /* The percentage the number of differences between a state's transition
256 * table and the proto it was first compared with must be of the total
257 * number of out-transitions of the state in order to keep the first
258 * proto as a good match and not search any further.
260 #define FIRST_MATCH_DIFF_PERCENTAGE 10
262 /* The percentage the number of differences between a state's transition
263 * table and the most similar proto must be of the state's total number
264 * of out-transitions to use the proto as an acceptable close match.
266 #define ACCEPTABLE_DIFF_PERCENTAGE 50
268 /* The percentage the number of homogeneous out-transitions of a state
269 * must be of the number of total out-transitions of the state in order
270 * to consider making a template from the state.
272 #define TEMPLATE_SAME_PERCENTAGE 60
274 /* The percentage the number of differences between a state's transition
275 * table and the most similar proto must be of the state's total number
276 * of out-transitions to create a new proto from the state.
278 #define NEW_PROTO_DIFF_PERCENTAGE 20
280 /* The percentage the total number of out-transitions of a state must be
281 * of the number of equivalence classes in order to consider trying to
282 * fit the transition table into "holes" inside the nxt/chk table.
284 #define INTERIOR_FIT_PERCENTAGE 15
286 /* Size of region set aside to cache the complete transition table of
287 * protos on the proto queue to enable quick comparisons.
289 #define PROT_SAVE_SIZE 2000
291 #define MSP 50 /* maximum number of saved protos (protos on the proto queue) */
293 /* Maximum number of out-transitions a state can have that we'll rummage
294 * around through the interior of the internal fast table looking for a
297 #define MAX_XTIONS_FULL_INTERIOR_FIT 4
299 /* Maximum number of rules which will be reported as being associated
302 #define MAX_ASSOC_RULES 100
304 /* Number that, if used to subscript an array, has a good chance of producing
305 * an error; should be small enough to fit into a short.
307 #define BAD_SUBSCRIPT -32767
309 /* Absolute value of largest number that can be stored in a short, with a
310 * bit of slop thrown in for general paranoia.
312 #define MAX_SHORT 32700
315 /* Declarations for global variables. */
317 /* Variables for symbol tables:
318 * sctbl - start-condition symbol table
319 * ndtbl - name-definition symbol table
320 * ccltab - character class text symbol table
325 struct hash_entry
*prev
, *next
;
331 typedef struct hash_entry
**hash_table
;
333 #define NAME_TABLE_HASH_SIZE 101
334 #define START_COND_HASH_SIZE 101
335 #define CCL_HASH_SIZE 101
337 extern struct hash_entry
*ndtbl
[NAME_TABLE_HASH_SIZE
];
338 extern struct hash_entry
*sctbl
[START_COND_HASH_SIZE
];
339 extern struct hash_entry
*ccltab
[CCL_HASH_SIZE
];
342 /* Variables for flags:
343 * printstats - if true (-v), dump statistics
344 * syntaxerror - true if a syntax error has been found
345 * eofseen - true if we've seen an eof in the input file
346 * ddebug - if true (-d), make a "debug" scanner
347 * trace - if true (-T), trace processing
348 * nowarn - if true (-w), do not generate warnings
349 * spprdflt - if true (-s), suppress the default rule
350 * interactive - if true (-I), generate an interactive scanner
351 * caseins - if true (-i), generate a case-insensitive scanner
352 * lex_compat - if true (-l), maximize compatibility with AT&T lex
353 * do_yylineno - if true, generate code to maintain yylineno
354 * useecs - if true (-Ce flag), use equivalence classes
355 * fulltbl - if true (-Cf flag), don't compress the DFA state table
356 * usemecs - if true (-Cm flag), use meta-equivalence classes
357 * fullspd - if true (-F flag), use Jacobson method of table representation
358 * gen_line_dirs - if true (i.e., no -L flag), generate #line directives
359 * performance_report - if > 0 (i.e., -p flag), generate a report relating
360 * to scanner performance; if > 1 (-p -p), report on minor performance
362 * backing_up_report - if true (i.e., -b flag), generate "lex.backup" file
363 * listing backing-up states
364 * C_plus_plus - if true (i.e., -+ flag), generate a C++ scanner class;
365 * otherwise, a standard C scanner
366 * long_align - if true (-Ca flag), favor long-word alignment.
367 * use_read - if true (-f, -F, or -Cr) then use read() for scanner input;
368 * otherwise, use fread().
369 * yytext_is_array - if true (i.e., %array directive), then declare
370 * yytext as a array instead of a character pointer. Nice and inefficient.
371 * do_yywrap - do yywrap() processing on EOF. If false, EOF treated as
373 * csize - size of character set for the scanner we're generating;
374 * 128 for 7-bit chars and 256 for 8-bit
375 * yymore_used - if true, yymore() is used in input rules
376 * reject - if true, generate back-up tables for REJECT macro
377 * real_reject - if true, scanner really uses REJECT (as opposed to just
378 * having "reject" set for variable trailing context)
379 * continued_action - true if this rule's action is to "fall through" to
380 * the next rule's action (i.e., the '|' action)
381 * in_rule - true if we're inside an individual rule, false if not.
382 * yymore_really_used - whether to treat yymore() as really used, regardless
383 * of what we think based on references to it in the user's actions.
384 * reject_really_used - same for REJECT
387 extern int printstats
, syntaxerror
, eofseen
, ddebug
, trace
, nowarn
, spprdflt
;
388 extern int interactive
, caseins
, lex_compat
, do_yylineno
;
389 extern int useecs
, fulltbl
, usemecs
, fullspd
;
390 extern int gen_line_dirs
, performance_report
, backing_up_report
;
391 extern int C_plus_plus
, long_align
, use_read
, yytext_is_array
, do_yywrap
;
393 extern int yymore_used
, reject
, real_reject
, continued_action
, in_rule
;
395 extern int yymore_really_used
, reject_really_used
;
398 /* Variables used in the flex input routines:
399 * datapos - characters on current output line
400 * dataline - number of contiguous lines of data in current data
401 * statement. Used to generate readable -f output
402 * linenum - current input line number
403 * out_linenum - current output line number
404 * skelfile - the skeleton file
405 * skel - compiled-in skeleton array
406 * skel_ind - index into "skel" array, if skelfile is nil
408 * backing_up_file - file to summarize backing-up states to
409 * infilename - name of input file
410 * outfilename - name of output file
411 * did_outfilename - whether outfilename was explicitly set
412 * prefix - the prefix used for externally visible names ("yy" by default)
413 * yyclass - yyFlexLexer subclass to use for YY_DECL
414 * do_stdinit - whether to initialize yyin/yyout to stdin/stdout
415 * use_stdout - the -t flag
416 * input_files - array holding names of input files
417 * num_input_files - size of input_files array
418 * program_name - name with which program was invoked
420 * action_array - array to hold the rule actions
421 * action_size - size of action_array
422 * defs1_offset - index where the user's section 1 definitions start
424 * prolog_offset - index where the prolog starts in action_array
425 * action_offset - index where the non-prolog starts in action_array
426 * action_index - index where the next action should go, with respect
430 extern int datapos
, dataline
, linenum
, out_linenum
;
431 extern FILE *skelfile
, *yyin
, *backing_up_file
;
432 extern const char *skel
[];
434 extern char *infilename
, *outfilename
;
435 extern int did_outfilename
;
436 extern char *prefix
, *yyclass
;
437 extern int do_stdinit
, use_stdout
;
438 extern char **input_files
;
439 extern int num_input_files
;
440 extern char *program_name
;
442 extern char *action_array
;
443 extern int action_size
;
444 extern int defs1_offset
, prolog_offset
, action_offset
, action_index
;
447 /* Variables for stack of states having only one out-transition:
448 * onestate - state number
449 * onesym - transition symbol
450 * onenext - target state
451 * onedef - default base entry
452 * onesp - stack pointer
455 extern int onestate
[ONE_STACK_SIZE
], onesym
[ONE_STACK_SIZE
];
456 extern int onenext
[ONE_STACK_SIZE
], onedef
[ONE_STACK_SIZE
], onesp
;
459 /* Variables for nfa machine data:
460 * current_mns - current maximum on number of NFA states
461 * num_rules - number of the last accepting state; also is number of
462 * rules created so far
463 * num_eof_rules - number of <<EOF>> rules
464 * default_rule - number of the default rule
465 * current_max_rules - current maximum number of rules
466 * lastnfa - last nfa state number created
467 * firstst - physically the first state of a fragment
468 * lastst - last physical state of fragment
469 * finalst - last logical state of fragment
470 * transchar - transition character
471 * trans1 - transition state
472 * trans2 - 2nd transition state for epsilons
473 * accptnum - accepting number
474 * assoc_rule - rule associated with this NFA state (or 0 if none)
475 * state_type - a STATE_xxx type identifying whether the state is part
476 * of a normal rule, the leading state in a trailing context
477 * rule (i.e., the state which marks the transition from
478 * recognizing the text-to-be-matched to the beginning of
479 * the trailing context), or a subsequent state in a trailing
481 * rule_type - a RULE_xxx type identifying whether this a ho-hum
482 * normal rule or one which has variable head & trailing
484 * rule_linenum - line number associated with rule
485 * rule_useful - true if we've determined that the rule can be matched
488 extern int current_mns
, current_max_rules
;
489 extern int num_rules
, num_eof_rules
, default_rule
, lastnfa
;
490 extern int *firstst
, *lastst
, *finalst
, *transchar
, *trans1
, *trans2
;
491 extern int *accptnum
, *assoc_rule
, *state_type
;
492 extern int *rule_type
, *rule_linenum
, *rule_useful
;
494 /* Different types of states; values are useful as masks, as well, for
495 * routines like check_trailing_context().
497 #define STATE_NORMAL 0x1
498 #define STATE_TRAILING_CONTEXT 0x2
500 /* Global holding current type of state we're making. */
502 extern int current_state_type
;
504 /* Different types of rules. */
505 #define RULE_NORMAL 0
506 #define RULE_VARIABLE 1
508 /* True if the input rules include a rule with both variable-length head
509 * and trailing context, false otherwise.
511 extern int variable_trailing_context_rules
;
514 /* Variables for protos:
515 * numtemps - number of templates created
516 * numprots - number of protos created
517 * protprev - backlink to a more-recently used proto
518 * protnext - forward link to a less-recently used proto
519 * prottbl - base/def table entry for proto
520 * protcomst - common state of proto
521 * firstprot - number of the most recently used proto
522 * lastprot - number of the least recently used proto
523 * protsave contains the entire state array for protos
526 extern int numtemps
, numprots
, protprev
[MSP
], protnext
[MSP
], prottbl
[MSP
];
527 extern int protcomst
[MSP
], firstprot
, lastprot
, protsave
[PROT_SAVE_SIZE
];
530 /* Variables for managing equivalence classes:
531 * numecs - number of equivalence classes
532 * nextecm - forward link of Equivalence Class members
533 * ecgroup - class number or backward link of EC members
534 * nummecs - number of meta-equivalence classes (used to compress
536 * tecfwd - forward link of meta-equivalence classes members
537 * tecbck - backward link of MEC's
540 /* Reserve enough room in the equivalence class arrays so that we
541 * can use the CSIZE'th element to hold equivalence class information
542 * for the NUL character. Later we'll move this information into
545 extern int numecs
, nextecm
[CSIZE
+ 1], ecgroup
[CSIZE
+ 1], nummecs
;
547 /* Meta-equivalence classes are indexed starting at 1, so it's possible
548 * that they will require positions from 1 .. CSIZE, i.e., CSIZE + 1
549 * slots total (since the arrays are 0-based). nextecm[] and ecgroup[]
550 * don't require the extra position since they're indexed from 1 .. CSIZE - 1.
552 extern int tecfwd
[CSIZE
+ 1], tecbck
[CSIZE
+ 1];
555 /* Variables for start conditions:
556 * lastsc - last start condition created
557 * current_max_scs - current limit on number of start conditions
558 * scset - set of rules active in start condition
559 * scbol - set of rules active only at the beginning of line in a s.c.
560 * scxclu - true if start condition is exclusive
561 * sceof - true if start condition has EOF rule
562 * scname - start condition name
565 extern int lastsc
, *scset
, *scbol
, *scxclu
, *sceof
;
566 extern int current_max_scs
;
567 extern char **scname
;
570 /* Variables for dfa machine data:
571 * current_max_dfa_size - current maximum number of NFA states in DFA
572 * current_max_xpairs - current maximum number of non-template xtion pairs
573 * current_max_template_xpairs - current maximum number of template pairs
574 * current_max_dfas - current maximum number DFA states
575 * lastdfa - last dfa state number created
576 * nxt - state to enter upon reading character
577 * chk - check value to see if "nxt" applies
578 * tnxt - internal nxt table for templates
579 * base - offset into "nxt" for given state
580 * def - where to go if "chk" disallows "nxt" entry
581 * nultrans - NUL transition for each state
582 * NUL_ec - equivalence class of the NUL character
583 * tblend - last "nxt/chk" table entry being used
584 * firstfree - first empty entry in "nxt/chk" table
585 * dss - nfa state set for each dfa
586 * dfasiz - size of nfa state set for each dfa
587 * dfaacc - accepting set for each dfa state (if using REJECT), or accepting
589 * accsiz - size of accepting set for each dfa state
590 * dhash - dfa state hash value
591 * numas - number of DFA accepting states created; note that this
592 * is not necessarily the same value as num_rules, which is the analogous
594 * numsnpairs - number of state/nextstate transition pairs
595 * jambase - position in base/def where the default jam table starts
596 * jamstate - state number corresponding to "jam" state
597 * end_of_buffer_state - end-of-buffer dfa state number
600 extern int current_max_dfa_size
, current_max_xpairs
;
601 extern int current_max_template_xpairs
, current_max_dfas
;
602 extern int lastdfa
, *nxt
, *chk
, *tnxt
;
603 extern int *base
, *def
, *nultrans
, NUL_ec
, tblend
, firstfree
, **dss
, *dfasiz
;
604 extern union dfaacc_union
609 extern int *accsiz
, *dhash
, numas
;
610 extern int numsnpairs
, jambase
, jamstate
;
611 extern int end_of_buffer_state
;
613 /* Variables for ccl information:
614 * lastccl - ccl index of the last created ccl
615 * current_maxccls - current limit on the maximum number of unique ccl's
616 * cclmap - maps a ccl index to its set pointer
617 * ccllen - gives the length of a ccl
618 * cclng - true for a given ccl if the ccl is negated
619 * cclreuse - counts how many times a ccl is re-used
620 * current_max_ccl_tbl_size - current limit on number of characters needed
621 * to represent the unique ccl's
622 * ccltbl - holds the characters in each ccl - indexed by cclmap
625 extern int lastccl
, *cclmap
, *ccllen
, *cclng
, cclreuse
;
626 extern int current_maxccls
, current_max_ccl_tbl_size
;
630 /* Variables for miscellaneous information:
631 * nmstr - last NAME scanned by the scanner
632 * sectnum - section number currently being parsed
633 * nummt - number of empty nxt/chk table entries
634 * hshcol - number of hash collisions detected by snstods
635 * dfaeql - number of times a newly created dfa was equal to an old one
636 * numeps - number of epsilon NFA states created
637 * eps2 - number of epsilon states which have 2 out-transitions
638 * num_reallocs - number of times it was necessary to realloc() a group
640 * tmpuses - number of DFA states that chain to templates
641 * totnst - total number of NFA states used to make DFA states
642 * peakpairs - peak number of transition pairs we had to store internally
643 * numuniq - number of unique transitions
644 * numdup - number of duplicate transitions
645 * hshsave - number of hash collisions saved by checking number of states
646 * num_backing_up - number of DFA states requiring backing up
647 * bol_needed - whether scanner needs beginning-of-line recognition
650 extern char nmstr
[MAXLINE
];
651 extern int sectnum
, nummt
, hshcol
, dfaeql
, numeps
, eps2
, num_reallocs
;
652 extern int tmpuses
, totnst
, peakpairs
, numuniq
, numdup
, hshsave
;
653 extern int num_backing_up
, bol_needed
;
655 void *allocate_array
PROTO((int, size_t));
656 void *reallocate_array
PROTO((void*, int, size_t));
658 void *flex_alloc
PROTO((size_t));
659 void *flex_realloc
PROTO((void*, size_t));
660 void flex_free
PROTO((void*));
662 #define allocate_integer_array(size) \
663 (int *) allocate_array( size, sizeof( int ) )
665 #define reallocate_integer_array(array,size) \
666 (int *) reallocate_array( (void *) array, size, sizeof( int ) )
668 #define allocate_int_ptr_array(size) \
669 (int **) allocate_array( size, sizeof( int * ) )
671 #define allocate_char_ptr_array(size) \
672 (char **) allocate_array( size, sizeof( char * ) )
674 #define allocate_dfaacc_union(size) \
675 (union dfaacc_union *) \
676 allocate_array( size, sizeof( union dfaacc_union ) )
678 #define reallocate_int_ptr_array(array,size) \
679 (int **) reallocate_array( (void *) array, size, sizeof( int * ) )
681 #define reallocate_char_ptr_array(array,size) \
682 (char **) reallocate_array( (void *) array, size, sizeof( char * ) )
684 #define reallocate_dfaacc_union(array, size) \
685 (union dfaacc_union *) \
686 reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) )
688 #define allocate_character_array(size) \
689 (char *) allocate_array( size, sizeof( char ) )
691 #define reallocate_character_array(array,size) \
692 (char *) reallocate_array( (void *) array, size, sizeof( char ) )
694 #define allocate_Character_array(size) \
695 (Char *) allocate_array( size, sizeof( Char ) )
697 #define reallocate_Character_array(array,size) \
698 (Char *) reallocate_array( (void *) array, size, sizeof( Char ) )
701 /* Used to communicate between scanner and parser. The type should really
702 * be YYSTYPE, but we can't easily get our hands on it.
707 /* External functions that are cross-referenced among the flex source files. */
710 /* from file ccl.c */
712 extern void ccladd
PROTO((int, int)); /* add a single character to a ccl */
713 extern int cclinit
PROTO((void)); /* make an empty ccl */
714 extern void cclnegate
PROTO((int)); /* negate a ccl */
716 /* List the members of a set of characters in CCL form. */
717 extern void list_character_set
PROTO((FILE*, int[]));
720 /* from file dfa.c */
722 /* Check a DFA state for backing up. */
723 extern void check_for_backing_up
PROTO((int, int[]));
725 /* Check to see if NFA state set constitutes "dangerous" trailing context. */
726 extern void check_trailing_context
PROTO((int*, int, int*, int));
728 /* Construct the epsilon closure of a set of ndfa states. */
729 extern int *epsclosure
PROTO((int*, int*, int[], int*, int*));
731 /* Increase the maximum number of dfas. */
732 extern void increase_max_dfas
PROTO((void));
734 extern void ntod
PROTO((void)); /* convert a ndfa to a dfa */
736 /* Converts a set of ndfa states into a dfa state. */
737 extern int snstods
PROTO((int[], int, int[], int, int, int*));
740 /* from file ecs.c */
742 /* Convert character classes to set of equivalence classes. */
743 extern void ccl2ecl
PROTO((void));
745 /* Associate equivalence class numbers with class members. */
746 extern int cre8ecs
PROTO((int[], int[], int));
748 /* Update equivalence classes based on character class transitions. */
749 extern void mkeccl
PROTO((Char
[], int, int[], int[], int, int));
751 /* Create equivalence class for single character. */
752 extern void mkechar
PROTO((int, int[], int[]));
755 /* from file gen.c */
757 extern void do_indent
PROTO((void)); /* indent to the current level */
759 /* Generate the code to keep backing-up information. */
760 extern void gen_backing_up
PROTO((void));
762 /* Generate the code to perform the backing up. */
763 extern void gen_bu_action
PROTO((void));
765 /* Generate full speed compressed transition table. */
766 extern void genctbl
PROTO((void));
768 /* Generate the code to find the action number. */
769 extern void gen_find_action
PROTO((void));
771 extern void genftbl
PROTO((void)); /* generate full transition table */
773 /* Generate the code to find the next compressed-table state. */
774 extern void gen_next_compressed_state
PROTO((char*));
776 /* Generate the code to find the next match. */
777 extern void gen_next_match
PROTO((void));
779 /* Generate the code to find the next state. */
780 extern void gen_next_state
PROTO((int));
782 /* Generate the code to make a NUL transition. */
783 extern void gen_NUL_trans
PROTO((void));
785 /* Generate the code to find the start state. */
786 extern void gen_start_state
PROTO((void));
788 /* Generate data statements for the transition tables. */
789 extern void gentabs
PROTO((void));
791 /* Write out a formatted string at the current indentation level. */
792 extern void indent_put2s
PROTO((char[], char[]));
794 /* Write out a string + newline at the current indentation level. */
795 extern void indent_puts
PROTO((char[]));
797 extern void make_tables
PROTO((void)); /* generate transition tables */
800 /* from file main.c */
802 extern void check_options
PROTO((void));
803 extern void flexend
PROTO((int));
804 extern void usage
PROTO((void));
807 /* from file misc.c */
809 /* Add a #define to the action file. */
810 extern void action_define
PROTO(( char *defname
, int value
));
812 /* Add the given text to the stored actions. */
813 extern void add_action
PROTO(( char *new_text
));
815 /* True if a string is all lower case. */
816 extern int all_lower
PROTO((register char *));
818 /* True if a string is all upper case. */
819 extern int all_upper
PROTO((register char *));
821 /* Bubble sort an integer array. */
822 extern void bubble
PROTO((int [], int));
824 /* Check a character to make sure it's in the expected range. */
825 extern void check_char
PROTO((int c
));
827 /* Replace upper-case letter to lower-case. */
828 extern Char clower
PROTO((int));
830 /* Returns a dynamically allocated copy of a string. */
831 extern char *copy_string
PROTO((register const char *));
833 /* Returns a dynamically allocated copy of a (potentially) unsigned string. */
834 extern Char
*copy_unsigned_string
PROTO((register Char
*));
836 /* Shell sort a character array. */
837 extern void cshell
PROTO((Char
[], int, int));
839 /* Finish up a block of data declarations. */
840 extern void dataend
PROTO((void));
842 /* Flush generated data statements. */
843 extern void dataflush
PROTO((void));
845 /* Report an error message and terminate. */
846 extern void flexerror
PROTO((const char[]));
848 /* Report a fatal error message and terminate. */
849 extern void flexfatal
PROTO((const char[]));
851 /* Convert a hexadecimal digit string to an integer value. */
852 extern int htoi
PROTO((Char
[]));
854 /* Report an error message formatted with one integer argument. */
855 extern void lerrif
PROTO((const char[], int));
857 /* Report an error message formatted with one string argument. */
858 extern void lerrsf
PROTO((const char[], const char[]));
860 /* Spit out a "#line" statement. */
861 extern void line_directive_out
PROTO((FILE*, int));
863 /* Mark the current position in the action array as the end of the section 1
866 extern void mark_defs1
PROTO((void));
868 /* Mark the current position in the action array as the end of the prolog. */
869 extern void mark_prolog
PROTO((void));
871 /* Generate a data statment for a two-dimensional array. */
872 extern void mk2data
PROTO((int));
874 extern void mkdata
PROTO((int)); /* generate a data statement */
876 /* Return the integer represented by a string of digits. */
877 extern int myctoi
PROTO((char []));
879 /* Return character corresponding to escape sequence. */
880 extern Char myesc
PROTO((Char
[]));
882 /* Convert an octal digit string to an integer value. */
883 extern int otoi
PROTO((Char
[] ));
885 /* Output a (possibly-formatted) string to the generated scanner. */
886 extern void out
PROTO((const char []));
887 extern void out_dec
PROTO((const char [], int));
888 extern void out_dec2
PROTO((const char [], int, int));
889 extern void out_hex
PROTO((const char [], unsigned int));
890 extern void out_line_count
PROTO((const char []));
891 extern void out_str
PROTO((const char [], const char []));
893 PROTO((const char [], const char [], const char [], const char []));
894 extern void out_str_dec
PROTO((const char [], const char [], int));
895 extern void outc
PROTO((int));
896 extern void outn
PROTO((const char []));
898 /* Return a printable version of the given character, which might be
901 extern char *readable_form
PROTO((int));
903 /* Write out one section of the skeleton file. */
904 extern void skelout
PROTO((void));
906 /* Output a yy_trans_info structure. */
907 extern void transition_struct_out
PROTO((int, int));
909 /* Only needed when using certain broken versions of bison to build parse.c. */
910 extern void *yy_flex_xmalloc
PROTO(( int ));
912 /* Set a region of memory to 0. */
913 extern void zero_out
PROTO((char *, size_t));
916 /* from file nfa.c */
918 /* Add an accepting state to a machine. */
919 extern void add_accept
PROTO((int, int));
921 /* Make a given number of copies of a singleton machine. */
922 extern int copysingl
PROTO((int, int));
924 /* Debugging routine to write out an nfa. */
925 extern void dumpnfa
PROTO((int));
927 /* Finish up the processing for a rule. */
928 extern void finish_rule
PROTO((int, int, int, int));
930 /* Connect two machines together. */
931 extern int link_machines
PROTO((int, int));
933 /* Mark each "beginning" state in a machine as being a "normal" (i.e.,
934 * not trailing context associated) state.
936 extern void mark_beginning_as_normal
PROTO((register int));
938 /* Make a machine that branches to two machines. */
939 extern int mkbranch
PROTO((int, int));
941 extern int mkclos
PROTO((int)); /* convert a machine into a closure */
942 extern int mkopt
PROTO((int)); /* make a machine optional */
944 /* Make a machine that matches either one of two machines. */
945 extern int mkor
PROTO((int, int));
947 /* Convert a machine into a positive closure. */
948 extern int mkposcl
PROTO((int));
950 extern int mkrep
PROTO((int, int, int)); /* make a replicated machine */
952 /* Create a state with a transition on a given symbol. */
953 extern int mkstate
PROTO((int));
955 extern void new_rule
PROTO((void)); /* initialize for a new rule */
958 /* from file parse.y */
960 /* Build the "<<EOF>>" action for the active start conditions. */
961 extern void build_eof_action
PROTO((void));
963 /* Write out a message formatted with one string, pinpointing its location. */
964 extern void format_pinpoint_message
PROTO((char[], char[]));
966 /* Write out a message, pinpointing its location. */
967 extern void pinpoint_message
PROTO((char[]));
969 /* Write out a warning, pinpointing it at the given line. */
970 extern void line_warning
PROTO(( char[], int ));
972 /* Write out a message, pinpointing it at the given line. */
973 extern void line_pinpoint
PROTO(( char[], int ));
975 /* Report a formatted syntax error. */
976 extern void format_synerr
PROTO((char [], char[]));
977 extern void synerr
PROTO((char [])); /* report a syntax error */
978 extern void format_warn
PROTO((char [], char[]));
979 extern void warn
PROTO((char [])); /* report a warning */
980 extern void yyerror
PROTO((char [])); /* report a parse error */
981 extern int yyparse
PROTO((void)); /* the YACC parser */
984 /* from file scan.l */
986 /* The Flex-generated scanner for flex. */
987 extern int flexscan
PROTO((void));
989 /* Open the given file (if NULL, stdin) for scanning. */
990 extern void set_input_file
PROTO((char*));
992 /* Wrapup a file in the lexical analyzer. */
993 extern int yywrap
PROTO((void));
996 /* from file sym.c */
998 /* Add symbol and definitions to symbol table. */
999 extern int addsym
PROTO((register char[], char*, int, hash_table
, int));
1001 /* Save the text of a character class. */
1002 extern void cclinstal
PROTO ((Char
[], int));
1004 /* Lookup the number associated with character class. */
1005 extern int ccllookup
PROTO((Char
[]));
1007 /* Find symbol in symbol table. */
1008 extern struct hash_entry
*findsym
PROTO((register char[], hash_table
, int ));
1010 extern void ndinstal
PROTO((char[], Char
[])); /* install a name definition */
1011 extern Char
*ndlookup
PROTO((char[])); /* lookup a name definition */
1013 /* Increase maximum number of SC's. */
1014 extern void scextend
PROTO((void));
1015 extern void scinstal
PROTO((char[], int)); /* make a start condition */
1017 /* Lookup the number associated with a start condition. */
1018 extern int sclookup
PROTO((char[]));
1021 /* from file tblcmp.c */
1023 /* Build table entries for dfa state. */
1024 extern void bldtbl
PROTO((int[], int, int, int, int));
1026 extern void cmptmps
PROTO((void)); /* compress template table entries */
1027 extern void expand_nxt_chk
PROTO((void)); /* increase nxt/chk arrays */
1028 /* Finds a space in the table for a state to be placed. */
1029 extern int find_table_space
PROTO((int*, int));
1030 extern void inittbl
PROTO((void)); /* initialize transition tables */
1031 /* Make the default, "jam" table entries. */
1032 extern void mkdeftbl
PROTO((void));
1034 /* Create table entries for a state (or state fragment) which has
1035 * only one out-transition.
1037 extern void mk1tbl
PROTO((int, int, int, int));
1039 /* Place a state into full speed transition table. */
1040 extern void place_state
PROTO((int*, int, int));
1042 /* Save states with only one out-transition to be processed later. */
1043 extern void stack1
PROTO((int, int, int, int));
1046 /* from file yylex.c */
1048 extern int yylex
PROTO((void));