[BACK]Return to flexdef.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / lex

Annotation of src/usr.bin/lex/flexdef.h, Revision 1.9

1.9     ! tedu        1: /*     $OpenBSD: flexdef.h,v 1.8 2015/10/10 05:47:54 deraadt Exp $     */
1.2       deraadt     2:
1.1       deraadt     3: /* flexdef - definitions file for flex */
                      4:
1.9     ! tedu        5: /*  Copyright (c) 1990 The Regents of the University of California. */
        !             6: /*  All rights reserved. */
        !             7:
        !             8: /*  This code is derived from software contributed to Berkeley by */
        !             9: /*  Vern Paxson. */
1.1       deraadt    10:
1.9     ! tedu       11: /*  The United States Government has rights in this work pursuant */
        !            12: /*  to contract no. DE-AC03-76SF00098 between the United States */
        !            13: /*  Department of Energy and the University of California. */
        !            14:
        !            15: /*  This file is part of flex. */
        !            16:
        !            17: /*  Redistribution and use in source and binary forms, with or without */
        !            18: /*  modification, are permitted provided that the following conditions */
        !            19: /*  are met: */
        !            20:
        !            21: /*  1. Redistributions of source code must retain the above copyright */
        !            22: /*     notice, this list of conditions and the following disclaimer. */
        !            23: /*  2. Redistributions in binary form must reproduce the above copyright */
        !            24: /*     notice, this list of conditions and the following disclaimer in the */
        !            25: /*     documentation and/or other materials provided with the distribution. */
        !            26:
        !            27: /*  Neither the name of the University nor the names of its contributors */
        !            28: /*  may be used to endorse or promote products derived from this software */
        !            29: /*  without specific prior written permission. */
        !            30:
        !            31: /*  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
        !            32: /*  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
        !            33: /*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
        !            34: /*  PURPOSE. */
1.1       deraadt    35:
1.9     ! tedu       36: #ifndef FLEXDEF_H
        !            37: #define FLEXDEF_H 1
1.1       deraadt    38:
1.9     ! tedu       39: #ifdef HAVE_CONFIG_H
        !            40: #include <config.h>
        !            41: #endif
1.1       deraadt    42:
1.9     ! tedu       43: /* AIX requires this to be the first thing in the file.  */
        !            44: #ifndef __GNUC__
        !            45: # if HAVE_ALLOCA_H
        !            46: #  include <alloca.h>
        !            47: # else
        !            48: #  ifdef _AIX
        !            49:  #pragma alloca
        !            50: #  else
        !            51: #   ifndef alloca /* predefined by HP cc +Olibcalls */
        !            52: char *alloca ();
        !            53: #   endif
        !            54: #  endif
        !            55: # endif
1.1       deraadt    56: #endif
                     57:
1.9     ! tedu       58: #ifdef STDC_HEADERS
        !            59: #include <stdio.h>
        !            60: #include <stdlib.h>
        !            61: #include <stdarg.h>
        !            62: #include <setjmp.h>
        !            63: #include <ctype.h>
1.1       deraadt    64: #include <string.h>
1.9     ! tedu       65: #include <math.h>
        !            66: #endif
        !            67: #ifdef HAVE_ASSERT_H
        !            68: #include <assert.h>
1.1       deraadt    69: #else
1.9     ! tedu       70: #define assert(Pred)
1.1       deraadt    71: #endif
                     72:
1.9     ! tedu       73: #ifdef HAVE_LIMITS_H
        !            74: #include <limits.h>
1.1       deraadt    75: #endif
1.9     ! tedu       76: #ifdef HAVE_UNISTD_H
1.8       deraadt    77: #include <unistd.h>
1.9     ! tedu       78: #endif
        !            79: #ifdef HAVE_NETINET_IN_H
        !            80: #include <netinet/in.h>
        !            81: #endif
        !            82: #ifdef HAVE_SYS_PARAMS_H
        !            83: #include <sys/params.h>
        !            84: #endif
        !            85: #ifdef HAVE_SYS_WAIT_H
        !            86: #include <sys/wait.h>
        !            87: #endif
        !            88: #ifdef HAVE_STDBOOL_H
        !            89: #include <stdbool.h>
1.7       espie      90: #else
1.9     ! tedu       91: #define bool int
        !            92: #define true 1
        !            93: #define false 0
1.1       deraadt    94: #endif
1.9     ! tedu       95: #ifdef HAVE_REGEX_H
        !            96: #include <regex.h>
1.7       espie      97: #endif
1.9     ! tedu       98: #include "flexint.h"
1.1       deraadt    99:
1.9     ! tedu      100: /* We use gettext. So, when we write strings which should be translated, we mark them with _() */
        !           101: #ifdef ENABLE_NLS
        !           102: #ifdef HAVE_LOCALE_H
        !           103: #include <locale.h>
        !           104: #endif /* HAVE_LOCALE_H */
        !           105: #include "gettext.h"
        !           106: #define _(String) gettext (String)
        !           107: #else
        !           108: #define _(STRING) STRING
        !           109: #endif /* ENABLE_NLS */
1.1       deraadt   110:
                    111: /* Always be prepared to generate an 8-bit scanner. */
                    112: #define CSIZE 256
                    113: #define Char unsigned char
                    114:
                    115: /* Size of input alphabet - should be size of ASCII set. */
                    116: #ifndef DEFAULT_CSIZE
                    117: #define DEFAULT_CSIZE 128
                    118: #endif
                    119:
                    120: #ifndef PROTO
1.9     ! tedu      121: #if defined(__STDC__)
1.1       deraadt   122: #define PROTO(proto) proto
                    123: #else
                    124: #define PROTO(proto) ()
                    125: #endif
                    126: #endif
                    127:
                    128: #ifdef VMS
                    129: #ifndef __VMS_POSIX
                    130: #define unlink remove
                    131: #define SHORT_FILE_NAMES
                    132: #endif
                    133: #endif
                    134:
                    135: #ifdef MS_DOS
                    136: #define SHORT_FILE_NAMES
                    137: #endif
                    138:
                    139:
                    140: /* Maximum line length we'll have to deal with. */
                    141: #define MAXLINE 2048
                    142:
                    143: #ifndef MIN
                    144: #define MIN(x,y) ((x) < (y) ? (x) : (y))
                    145: #endif
                    146: #ifndef MAX
                    147: #define MAX(x,y) ((x) > (y) ? (x) : (y))
                    148: #endif
                    149: #ifndef ABS
                    150: #define ABS(x) ((x) < 0 ? -(x) : (x))
                    151: #endif
                    152:
                    153:
                    154: /* ANSI C does not guarantee that isascii() is defined */
                    155: #ifndef isascii
                    156: #define isascii(c) ((c) <= 0177)
                    157: #endif
                    158:
                    159: #define unspecified -1
                    160:
                    161: /* Special chk[] values marking the slots taking by end-of-buffer and action
                    162:  * numbers.
                    163:  */
                    164: #define EOB_POSITION -1
                    165: #define ACTION_POSITION -2
                    166:
                    167: /* Number of data items per line for -f output. */
                    168: #define NUMDATAITEMS 10
                    169:
                    170: /* Number of lines of data in -f output before inserting a blank line for
                    171:  * readability.
                    172:  */
                    173: #define NUMDATALINES 10
                    174:
                    175: /* transition_struct_out() definitions. */
                    176: #define TRANS_STRUCT_PRINT_LENGTH 14
                    177:
                    178: /* Returns true if an nfa state has an epsilon out-transition slot
                    179:  * that can be used.  This definition is currently not used.
                    180:  */
                    181: #define FREE_EPSILON(state) \
                    182:        (transchar[state] == SYM_EPSILON && \
                    183:         trans2[state] == NO_TRANSITION && \
                    184:         finalst[state] != state)
                    185:
                    186: /* Returns true if an nfa state has an epsilon out-transition character
                    187:  * and both slots are free
                    188:  */
                    189: #define SUPER_FREE_EPSILON(state) \
                    190:        (transchar[state] == SYM_EPSILON && \
                    191:         trans1[state] == NO_TRANSITION) \
                    192:
                    193: /* Maximum number of NFA states that can comprise a DFA state.  It's real
                    194:  * big because if there's a lot of rules, the initial state will have a
                    195:  * huge epsilon closure.
                    196:  */
                    197: #define INITIAL_MAX_DFA_SIZE 750
                    198: #define MAX_DFA_SIZE_INCREMENT 750
                    199:
                    200:
                    201: /* A note on the following masks.  They are used to mark accepting numbers
                    202:  * as being special.  As such, they implicitly limit the number of accepting
                    203:  * numbers (i.e., rules) because if there are too many rules the rule numbers
                    204:  * will overload the mask bits.  Fortunately, this limit is \large/ (0x2000 ==
                    205:  * 8192) so unlikely to actually cause any problems.  A check is made in
                    206:  * new_rule() to ensure that this limit is not reached.
                    207:  */
                    208:
                    209: /* Mask to mark a trailing context accepting number. */
                    210: #define YY_TRAILING_MASK 0x2000
                    211:
                    212: /* Mask to mark the accepting number of the "head" of a trailing context
                    213:  * rule.
                    214:  */
                    215: #define YY_TRAILING_HEAD_MASK 0x4000
                    216:
                    217: /* Maximum number of rules, as outlined in the above note. */
                    218: #define MAX_RULE (YY_TRAILING_MASK - 1)
                    219:
                    220:
                    221: /* NIL must be 0.  If not, its special meaning when making equivalence classes
                    222:  * (it marks the representative of a given e.c.) will be unidentifiable.
                    223:  */
                    224: #define NIL 0
                    225:
1.9     ! tedu      226: #define JAM -1                 /* to mark a missing DFA transition */
1.1       deraadt   227: #define NO_TRANSITION NIL
1.9     ! tedu      228: #define UNIQUE -1              /* marks a symbol as an e.c. representative */
        !           229: #define INFINITE_REPEAT -1             /* for x{5,} constructions */
1.1       deraadt   230:
                    231: #define INITIAL_MAX_CCLS 100   /* max number of unique character classes */
                    232: #define MAX_CCLS_INCREMENT 100
                    233:
                    234: /* Size of table holding members of character classes. */
                    235: #define INITIAL_MAX_CCL_TBL_SIZE 500
                    236: #define MAX_CCL_TBL_SIZE_INCREMENT 250
                    237:
                    238: #define INITIAL_MAX_RULES 100  /* default maximum number of rules */
                    239: #define MAX_RULES_INCREMENT 100
                    240:
                    241: #define INITIAL_MNS 2000       /* default maximum number of nfa states */
                    242: #define MNS_INCREMENT 1000     /* amount to bump above by if it's not enough */
                    243:
                    244: #define INITIAL_MAX_DFAS 1000  /* default maximum number of dfa states */
                    245: #define MAX_DFAS_INCREMENT 1000
                    246:
1.9     ! tedu      247: #define JAMSTATE -32766                /* marks a reference to the state that always jams */
1.1       deraadt   248:
                    249: /* Maximum number of NFA states. */
                    250: #define MAXIMUM_MNS 31999
1.9     ! tedu      251: #define MAXIMUM_MNS_LONG 1999999999
1.1       deraadt   252:
                    253: /* Enough so that if it's subtracted from an NFA state number, the result
                    254:  * is guaranteed to be negative.
                    255:  */
1.9     ! tedu      256: #define MARKER_DIFFERENCE (maximum_mns+2)
1.1       deraadt   257:
                    258: /* Maximum number of nxt/chk pairs for non-templates. */
                    259: #define INITIAL_MAX_XPAIRS 2000
                    260: #define MAX_XPAIRS_INCREMENT 2000
                    261:
                    262: /* Maximum number of nxt/chk pairs needed for templates. */
                    263: #define INITIAL_MAX_TEMPLATE_XPAIRS 2500
                    264: #define MAX_TEMPLATE_XPAIRS_INCREMENT 2500
                    265:
                    266: #define SYM_EPSILON (CSIZE + 1)        /* to mark transitions on the symbol epsilon */
                    267:
                    268: #define INITIAL_MAX_SCS 40     /* maximum number of start conditions */
                    269: #define MAX_SCS_INCREMENT 40   /* amount to bump by if it's not enough */
                    270:
                    271: #define ONE_STACK_SIZE 500     /* stack of states with only one out-transition */
1.9     ! tedu      272: #define SAME_TRANS -1          /* transition is the same as "default" entry for state */
1.1       deraadt   273:
                    274: /* The following percentages are used to tune table compression:
                    275:
                    276:  * The percentage the number of out-transitions a state must be of the
                    277:  * number of equivalence classes in order to be considered for table
                    278:  * compaction by using protos.
                    279:  */
                    280: #define PROTO_SIZE_PERCENTAGE 15
                    281:
                    282: /* The percentage the number of homogeneous out-transitions of a state
                    283:  * must be of the number of total out-transitions of the state in order
1.9     ! tedu      284:  * that the state's transition table is first compared with a potential
1.1       deraadt   285:  * template of the most common out-transition instead of with the first
                    286:  * proto in the proto queue.
                    287:  */
                    288: #define CHECK_COM_PERCENTAGE 50
                    289:
                    290: /* The percentage the number of differences between a state's transition
                    291:  * table and the proto it was first compared with must be of the total
                    292:  * number of out-transitions of the state in order to keep the first
                    293:  * proto as a good match and not search any further.
                    294:  */
                    295: #define FIRST_MATCH_DIFF_PERCENTAGE 10
                    296:
                    297: /* The percentage the number of differences between a state's transition
                    298:  * table and the most similar proto must be of the state's total number
                    299:  * of out-transitions to use the proto as an acceptable close match.
                    300:  */
                    301: #define ACCEPTABLE_DIFF_PERCENTAGE 50
                    302:
                    303: /* The percentage the number of homogeneous out-transitions of a state
                    304:  * must be of the number of total out-transitions of the state in order
                    305:  * to consider making a template from the state.
                    306:  */
                    307: #define TEMPLATE_SAME_PERCENTAGE 60
                    308:
                    309: /* The percentage the number of differences between a state's transition
                    310:  * table and the most similar proto must be of the state's total number
                    311:  * of out-transitions to create a new proto from the state.
                    312:  */
                    313: #define NEW_PROTO_DIFF_PERCENTAGE 20
                    314:
                    315: /* The percentage the total number of out-transitions of a state must be
                    316:  * of the number of equivalence classes in order to consider trying to
                    317:  * fit the transition table into "holes" inside the nxt/chk table.
                    318:  */
                    319: #define INTERIOR_FIT_PERCENTAGE 15
                    320:
                    321: /* Size of region set aside to cache the complete transition table of
                    322:  * protos on the proto queue to enable quick comparisons.
                    323:  */
                    324: #define PROT_SAVE_SIZE 2000
                    325:
1.9     ! tedu      326: #define MSP 50                 /* maximum number of saved protos (protos on the proto queue) */
1.1       deraadt   327:
                    328: /* Maximum number of out-transitions a state can have that we'll rummage
                    329:  * around through the interior of the internal fast table looking for a
                    330:  * spot for it.
                    331:  */
                    332: #define MAX_XTIONS_FULL_INTERIOR_FIT 4
                    333:
                    334: /* Maximum number of rules which will be reported as being associated
                    335:  * with a DFA state.
                    336:  */
                    337: #define MAX_ASSOC_RULES 100
                    338:
                    339: /* Number that, if used to subscript an array, has a good chance of producing
                    340:  * an error; should be small enough to fit into a short.
                    341:  */
                    342: #define BAD_SUBSCRIPT -32767
                    343:
                    344: /* Absolute value of largest number that can be stored in a short, with a
                    345:  * bit of slop thrown in for general paranoia.
                    346:  */
                    347: #define MAX_SHORT 32700
                    348:
                    349:
                    350: /* Declarations for global variables. */
                    351:
                    352:
                    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:  * nowarn - if true (-w), do not generate warnings
                    360:  * spprdflt - if true (-s), suppress the default rule
                    361:  * interactive - if true (-I), generate an interactive scanner
                    362:  * lex_compat - if true (-l), maximize compatibility with AT&T lex
1.9     ! tedu      363:  * posix_compat - if true (-X), maximize compatibility with POSIX lex
1.1       deraadt   364:  * do_yylineno - if true, generate code to maintain yylineno
                    365:  * useecs - if true (-Ce flag), use equivalence classes
                    366:  * fulltbl - if true (-Cf flag), don't compress the DFA state table
                    367:  * usemecs - if true (-Cm flag), use meta-equivalence classes
                    368:  * fullspd - if true (-F flag), use Jacobson method of table representation
                    369:  * gen_line_dirs - if true (i.e., no -L flag), generate #line directives
                    370:  * performance_report - if > 0 (i.e., -p flag), generate a report relating
                    371:  *   to scanner performance; if > 1 (-p -p), report on minor performance
                    372:  *   problems, too
                    373:  * backing_up_report - if true (i.e., -b flag), generate "lex.backup" file
                    374:  *   listing backing-up states
                    375:  * C_plus_plus - if true (i.e., -+ flag), generate a C++ scanner class;
                    376:  *   otherwise, a standard C scanner
1.9     ! tedu      377:  * reentrant - if true (-R), generate a reentrant C scanner.
        !           378:  * bison_bridge_lval - if true (--bison-bridge), bison pure calling convention.
        !           379:  * bison_bridge_lloc - if true (--bison-locations), bison yylloc.
1.1       deraadt   380:  * long_align - if true (-Ca flag), favor long-word alignment.
                    381:  * use_read - if true (-f, -F, or -Cr) then use read() for scanner input;
                    382:  *   otherwise, use fread().
                    383:  * yytext_is_array - if true (i.e., %array directive), then declare
                    384:  *   yytext as a array instead of a character pointer.  Nice and inefficient.
                    385:  * do_yywrap - do yywrap() processing on EOF.  If false, EOF treated as
                    386:  *   "no more files".
                    387:  * csize - size of character set for the scanner we're generating;
                    388:  *   128 for 7-bit chars and 256 for 8-bit
                    389:  * yymore_used - if true, yymore() is used in input rules
                    390:  * reject - if true, generate back-up tables for REJECT macro
                    391:  * real_reject - if true, scanner really uses REJECT (as opposed to just
                    392:  *   having "reject" set for variable trailing context)
                    393:  * continued_action - true if this rule's action is to "fall through" to
                    394:  *   the next rule's action (i.e., the '|' action)
                    395:  * in_rule - true if we're inside an individual rule, false if not.
                    396:  * yymore_really_used - whether to treat yymore() as really used, regardless
                    397:  *   of what we think based on references to it in the user's actions.
                    398:  * reject_really_used - same for REJECT
                    399:  */
                    400:
1.9     ! tedu      401: extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn,
        !           402:        spprdflt;
        !           403: extern int interactive, lex_compat, posix_compat, do_yylineno;
1.1       deraadt   404: extern int useecs, fulltbl, usemecs, fullspd;
                    405: extern int gen_line_dirs, performance_report, backing_up_report;
1.9     ! tedu      406: extern int reentrant, bison_bridge_lval, bison_bridge_lloc;
        !           407: extern bool ansi_func_defs, ansi_func_protos;
1.1       deraadt   408: extern int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap;
                    409: extern int csize;
                    410: extern int yymore_used, reject, real_reject, continued_action, in_rule;
                    411:
                    412: extern int yymore_really_used, reject_really_used;
                    413:
                    414:
                    415: /* Variables used in the flex input routines:
                    416:  * datapos - characters on current output line
                    417:  * dataline - number of contiguous lines of data in current data
                    418:  *     statement.  Used to generate readable -f output
                    419:  * linenum - current input line number
                    420:  * skelfile - the skeleton file
                    421:  * skel - compiled-in skeleton array
                    422:  * skel_ind - index into "skel" array, if skelfile is nil
                    423:  * yyin - input file
                    424:  * backing_up_file - file to summarize backing-up states to
                    425:  * infilename - name of input file
                    426:  * outfilename - name of output file
1.9     ! tedu      427:  * headerfilename - name of the .h file to generate
1.1       deraadt   428:  * did_outfilename - whether outfilename was explicitly set
                    429:  * prefix - the prefix used for externally visible names ("yy" by default)
                    430:  * yyclass - yyFlexLexer subclass to use for YY_DECL
                    431:  * do_stdinit - whether to initialize yyin/yyout to stdin/stdout
                    432:  * use_stdout - the -t flag
                    433:  * input_files - array holding names of input files
                    434:  * num_input_files - size of input_files array
1.9     ! tedu      435:  * program_name - name with which program was invoked
1.1       deraadt   436:  *
                    437:  * action_array - array to hold the rule actions
                    438:  * action_size - size of action_array
                    439:  * defs1_offset - index where the user's section 1 definitions start
                    440:  *     in action_array
                    441:  * prolog_offset - index where the prolog starts in action_array
                    442:  * action_offset - index where the non-prolog starts in action_array
                    443:  * action_index - index where the next action should go, with respect
                    444:  *     to "action_array"
                    445:  */
                    446:
1.9     ! tedu      447: extern int datapos, dataline, linenum;
1.1       deraadt   448: extern FILE *skelfile, *yyin, *backing_up_file;
                    449: extern const char *skel[];
                    450: extern int skel_ind;
1.9     ! tedu      451: extern char *infilename, *outfilename, *headerfilename;
1.1       deraadt   452: extern int did_outfilename;
1.9     ! tedu      453: extern char *prefix, *yyclass, *extra_type;
1.1       deraadt   454: extern int do_stdinit, use_stdout;
                    455: extern char **input_files;
                    456: extern int num_input_files;
                    457: extern char *program_name;
                    458:
                    459: extern char *action_array;
                    460: extern int action_size;
                    461: extern int defs1_offset, prolog_offset, action_offset, action_index;
                    462:
                    463:
                    464: /* Variables for stack of states having only one out-transition:
                    465:  * onestate - state number
                    466:  * onesym - transition symbol
                    467:  * onenext - target state
                    468:  * onedef - default base entry
                    469:  * onesp - stack pointer
                    470:  */
                    471:
                    472: extern int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
                    473: extern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
                    474:
                    475:
                    476: /* Variables for nfa machine data:
1.9     ! tedu      477:  * maximum_mns - maximal number of NFA states supported by tables
1.1       deraadt   478:  * current_mns - current maximum on number of NFA states
                    479:  * num_rules - number of the last accepting state; also is number of
                    480:  *     rules created so far
                    481:  * num_eof_rules - number of <<EOF>> rules
                    482:  * default_rule - number of the default rule
                    483:  * current_max_rules - current maximum number of rules
                    484:  * lastnfa - last nfa state number created
                    485:  * firstst - physically the first state of a fragment
                    486:  * lastst - last physical state of fragment
                    487:  * finalst - last logical state of fragment
                    488:  * transchar - transition character
                    489:  * trans1 - transition state
                    490:  * trans2 - 2nd transition state for epsilons
                    491:  * accptnum - accepting number
                    492:  * assoc_rule - rule associated with this NFA state (or 0 if none)
                    493:  * state_type - a STATE_xxx type identifying whether the state is part
                    494:  *     of a normal rule, the leading state in a trailing context
                    495:  *     rule (i.e., the state which marks the transition from
                    496:  *     recognizing the text-to-be-matched to the beginning of
                    497:  *     the trailing context), or a subsequent state in a trailing
                    498:  *     context rule
                    499:  * rule_type - a RULE_xxx type identifying whether this a ho-hum
                    500:  *     normal rule or one which has variable head & trailing
                    501:  *     context
                    502:  * rule_linenum - line number associated with rule
                    503:  * rule_useful - true if we've determined that the rule can be matched
1.9     ! tedu      504:  * rule_has_nl - true if rule could possibly match a newline
        !           505:  * ccl_has_nl - true if current ccl could match a newline
        !           506:  * nlch - default eol char
1.1       deraadt   507:  */
                    508:
1.9     ! tedu      509: extern int maximum_mns, current_mns, current_max_rules;
1.1       deraadt   510: extern int num_rules, num_eof_rules, default_rule, lastnfa;
                    511: extern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
                    512: extern int *accptnum, *assoc_rule, *state_type;
                    513: extern int *rule_type, *rule_linenum, *rule_useful;
1.9     ! tedu      514: extern bool *rule_has_nl, *ccl_has_nl;
        !           515: extern int nlch;
1.1       deraadt   516:
                    517: /* Different types of states; values are useful as masks, as well, for
                    518:  * routines like check_trailing_context().
                    519:  */
                    520: #define STATE_NORMAL 0x1
                    521: #define STATE_TRAILING_CONTEXT 0x2
                    522:
                    523: /* Global holding current type of state we're making. */
                    524:
                    525: extern int current_state_type;
                    526:
                    527: /* Different types of rules. */
                    528: #define RULE_NORMAL 0
                    529: #define RULE_VARIABLE 1
                    530:
                    531: /* True if the input rules include a rule with both variable-length head
                    532:  * and trailing context, false otherwise.
                    533:  */
                    534: extern int variable_trailing_context_rules;
                    535:
                    536:
                    537: /* Variables for protos:
                    538:  * numtemps - number of templates created
                    539:  * numprots - number of protos created
                    540:  * protprev - backlink to a more-recently used proto
                    541:  * protnext - forward link to a less-recently used proto
                    542:  * prottbl - base/def table entry for proto
                    543:  * protcomst - common state of proto
                    544:  * firstprot - number of the most recently used proto
                    545:  * lastprot - number of the least recently used proto
                    546:  * protsave contains the entire state array for protos
                    547:  */
                    548:
                    549: extern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
                    550: extern int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE];
                    551:
                    552:
                    553: /* Variables for managing equivalence classes:
                    554:  * numecs - number of equivalence classes
                    555:  * nextecm - forward link of Equivalence Class members
                    556:  * ecgroup - class number or backward link of EC members
                    557:  * nummecs - number of meta-equivalence classes (used to compress
                    558:  *   templates)
                    559:  * tecfwd - forward link of meta-equivalence classes members
                    560:  * tecbck - backward link of MEC's
                    561:  */
                    562:
                    563: /* Reserve enough room in the equivalence class arrays so that we
                    564:  * can use the CSIZE'th element to hold equivalence class information
                    565:  * for the NUL character.  Later we'll move this information into
                    566:  * the 0th element.
                    567:  */
                    568: extern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs;
                    569:
                    570: /* Meta-equivalence classes are indexed starting at 1, so it's possible
                    571:  * that they will require positions from 1 .. CSIZE, i.e., CSIZE + 1
                    572:  * slots total (since the arrays are 0-based).  nextecm[] and ecgroup[]
                    573:  * don't require the extra position since they're indexed from 1 .. CSIZE - 1.
                    574:  */
                    575: extern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
                    576:
                    577:
                    578: /* Variables for start conditions:
                    579:  * lastsc - last start condition created
                    580:  * current_max_scs - current limit on number of start conditions
                    581:  * scset - set of rules active in start condition
                    582:  * scbol - set of rules active only at the beginning of line in a s.c.
                    583:  * scxclu - true if start condition is exclusive
                    584:  * sceof - true if start condition has EOF rule
                    585:  * scname - start condition name
                    586:  */
                    587:
                    588: extern int lastsc, *scset, *scbol, *scxclu, *sceof;
                    589: extern int current_max_scs;
                    590: extern char **scname;
                    591:
                    592:
                    593: /* Variables for dfa machine data:
                    594:  * current_max_dfa_size - current maximum number of NFA states in DFA
                    595:  * current_max_xpairs - current maximum number of non-template xtion pairs
                    596:  * current_max_template_xpairs - current maximum number of template pairs
                    597:  * current_max_dfas - current maximum number DFA states
                    598:  * lastdfa - last dfa state number created
                    599:  * nxt - state to enter upon reading character
                    600:  * chk - check value to see if "nxt" applies
                    601:  * tnxt - internal nxt table for templates
                    602:  * base - offset into "nxt" for given state
                    603:  * def - where to go if "chk" disallows "nxt" entry
                    604:  * nultrans - NUL transition for each state
                    605:  * NUL_ec - equivalence class of the NUL character
                    606:  * tblend - last "nxt/chk" table entry being used
                    607:  * firstfree - first empty entry in "nxt/chk" table
                    608:  * dss - nfa state set for each dfa
                    609:  * dfasiz - size of nfa state set for each dfa
                    610:  * dfaacc - accepting set for each dfa state (if using REJECT), or accepting
                    611:  *     number, if not
                    612:  * accsiz - size of accepting set for each dfa state
                    613:  * dhash - dfa state hash value
                    614:  * numas - number of DFA accepting states created; note that this
                    615:  *     is not necessarily the same value as num_rules, which is the analogous
                    616:  *     value for the NFA
                    617:  * numsnpairs - number of state/nextstate transition pairs
                    618:  * jambase - position in base/def where the default jam table starts
                    619:  * jamstate - state number corresponding to "jam" state
                    620:  * end_of_buffer_state - end-of-buffer dfa state number
                    621:  */
                    622:
                    623: extern int current_max_dfa_size, current_max_xpairs;
                    624: extern int current_max_template_xpairs, current_max_dfas;
                    625: extern int lastdfa, *nxt, *chk, *tnxt;
1.9     ! tedu      626: extern int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss,
        !           627:        *dfasiz;
        !           628: extern union dfaacc_union {
        !           629:        int    *dfaacc_set;
        !           630:        int     dfaacc_state;
        !           631: }      *dfaacc;
1.1       deraadt   632: extern int *accsiz, *dhash, numas;
                    633: extern int numsnpairs, jambase, jamstate;
                    634: extern int end_of_buffer_state;
                    635:
                    636: /* Variables for ccl information:
                    637:  * lastccl - ccl index of the last created ccl
                    638:  * current_maxccls - current limit on the maximum number of unique ccl's
                    639:  * cclmap - maps a ccl index to its set pointer
                    640:  * ccllen - gives the length of a ccl
                    641:  * cclng - true for a given ccl if the ccl is negated
                    642:  * cclreuse - counts how many times a ccl is re-used
                    643:  * current_max_ccl_tbl_size - current limit on number of characters needed
                    644:  *     to represent the unique ccl's
                    645:  * ccltbl - holds the characters in each ccl - indexed by cclmap
                    646:  */
                    647:
                    648: extern int lastccl, *cclmap, *ccllen, *cclng, cclreuse;
                    649: extern int current_maxccls, current_max_ccl_tbl_size;
                    650: extern Char *ccltbl;
                    651:
                    652:
                    653: /* Variables for miscellaneous information:
                    654:  * nmstr - last NAME scanned by the scanner
                    655:  * sectnum - section number currently being parsed
                    656:  * nummt - number of empty nxt/chk table entries
                    657:  * hshcol - number of hash collisions detected by snstods
                    658:  * dfaeql - number of times a newly created dfa was equal to an old one
                    659:  * numeps - number of epsilon NFA states created
                    660:  * eps2 - number of epsilon states which have 2 out-transitions
                    661:  * num_reallocs - number of times it was necessary to realloc() a group
                    662:  *       of arrays
                    663:  * tmpuses - number of DFA states that chain to templates
                    664:  * totnst - total number of NFA states used to make DFA states
                    665:  * peakpairs - peak number of transition pairs we had to store internally
                    666:  * numuniq - number of unique transitions
                    667:  * numdup - number of duplicate transitions
                    668:  * hshsave - number of hash collisions saved by checking number of states
                    669:  * num_backing_up - number of DFA states requiring backing up
                    670:  * bol_needed - whether scanner needs beginning-of-line recognition
                    671:  */
                    672:
                    673: extern char nmstr[MAXLINE];
                    674: extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
                    675: extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
                    676: extern int num_backing_up, bol_needed;
                    677:
1.9     ! tedu      678: void   *allocate_array PROTO ((int, size_t));
        !           679: void   *reallocate_array PROTO ((void *, int, size_t));
1.1       deraadt   680:
1.9     ! tedu      681: void   *flex_alloc PROTO ((size_t));
        !           682: void   *flex_realloc PROTO ((void *, size_t));
        !           683: void flex_free PROTO ((void *));
1.1       deraadt   684:
                    685: #define allocate_integer_array(size) \
                    686:        (int *) allocate_array( size, sizeof( int ) )
                    687:
                    688: #define reallocate_integer_array(array,size) \
                    689:        (int *) reallocate_array( (void *) array, size, sizeof( int ) )
                    690:
1.9     ! tedu      691: #define allocate_bool_array(size) \
        !           692:        (bool *) allocate_array( size, sizeof( bool ) )
        !           693:
        !           694: #define reallocate_bool_array(array,size) \
        !           695:        (bool *) reallocate_array( (void *) array, size, sizeof( bool ) )
        !           696:
1.1       deraadt   697: #define allocate_int_ptr_array(size) \
                    698:        (int **) allocate_array( size, sizeof( int * ) )
                    699:
                    700: #define allocate_char_ptr_array(size) \
                    701:        (char **) allocate_array( size, sizeof( char * ) )
                    702:
                    703: #define allocate_dfaacc_union(size) \
                    704:        (union dfaacc_union *) \
                    705:                allocate_array( size, sizeof( union dfaacc_union ) )
                    706:
                    707: #define reallocate_int_ptr_array(array,size) \
                    708:        (int **) reallocate_array( (void *) array, size, sizeof( int * ) )
                    709:
                    710: #define reallocate_char_ptr_array(array,size) \
                    711:        (char **) reallocate_array( (void *) array, size, sizeof( char * ) )
                    712:
                    713: #define reallocate_dfaacc_union(array, size) \
                    714:        (union dfaacc_union *) \
                    715:        reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) )
                    716:
                    717: #define allocate_character_array(size) \
                    718:        (char *) allocate_array( size, sizeof( char ) )
                    719:
                    720: #define reallocate_character_array(array,size) \
                    721:        (char *) reallocate_array( (void *) array, size, sizeof( char ) )
                    722:
                    723: #define allocate_Character_array(size) \
                    724:        (Char *) allocate_array( size, sizeof( Char ) )
                    725:
                    726: #define reallocate_Character_array(array,size) \
                    727:        (Char *) reallocate_array( (void *) array, size, sizeof( Char ) )
                    728:
                    729:
                    730: /* Used to communicate between scanner and parser.  The type should really
                    731:  * be YYSTYPE, but we can't easily get our hands on it.
                    732:  */
                    733: extern int yylval;
                    734:
                    735:
                    736: /* External functions that are cross-referenced among the flex source files. */
                    737:
                    738:
                    739: /* from file ccl.c */
                    740:
1.9     ! tedu      741: extern void ccladd PROTO ((int, int)); /* add a single character to a ccl */
        !           742: extern int cclinit PROTO ((void));     /* make an empty ccl */
        !           743: extern void cclnegate PROTO ((int));   /* negate a ccl */
        !           744: extern int ccl_set_diff (int a, int b); /* set difference of two ccls. */
        !           745: extern int ccl_set_union (int a, int b); /* set union of two ccls. */
1.1       deraadt   746:
                    747: /* List the members of a set of characters in CCL form. */
1.9     ! tedu      748: extern void list_character_set PROTO ((FILE *, int[]));
1.1       deraadt   749:
                    750:
                    751: /* from file dfa.c */
                    752:
                    753: /* Check a DFA state for backing up. */
1.9     ! tedu      754: extern void check_for_backing_up PROTO ((int, int[]));
1.1       deraadt   755:
                    756: /* Check to see if NFA state set constitutes "dangerous" trailing context. */
1.9     ! tedu      757: extern void check_trailing_context PROTO ((int *, int, int *, int));
1.1       deraadt   758:
                    759: /* Construct the epsilon closure of a set of ndfa states. */
1.9     ! tedu      760: extern int *epsclosure PROTO ((int *, int *, int[], int *, int *));
1.1       deraadt   761:
                    762: /* Increase the maximum number of dfas. */
1.9     ! tedu      763: extern void increase_max_dfas PROTO ((void));
1.1       deraadt   764:
1.9     ! tedu      765: extern void ntod PROTO ((void));       /* convert a ndfa to a dfa */
1.1       deraadt   766:
                    767: /* Converts a set of ndfa states into a dfa state. */
1.9     ! tedu      768: extern int snstods PROTO ((int[], int, int[], int, int, int *));
1.1       deraadt   769:
                    770:
                    771: /* from file ecs.c */
                    772:
                    773: /* Convert character classes to set of equivalence classes. */
1.9     ! tedu      774: extern void ccl2ecl PROTO ((void));
1.1       deraadt   775:
                    776: /* Associate equivalence class numbers with class members. */
1.9     ! tedu      777: extern int cre8ecs PROTO ((int[], int[], int));
1.1       deraadt   778:
                    779: /* Update equivalence classes based on character class transitions. */
1.9     ! tedu      780: extern void mkeccl PROTO ((Char[], int, int[], int[], int, int));
1.1       deraadt   781:
                    782: /* Create equivalence class for single character. */
1.9     ! tedu      783: extern void mkechar PROTO ((int, int[], int[]));
1.1       deraadt   784:
                    785:
                    786: /* from file gen.c */
                    787:
1.9     ! tedu      788: extern void do_indent PROTO ((void));  /* indent to the current level */
1.1       deraadt   789:
                    790: /* Generate the code to keep backing-up information. */
1.9     ! tedu      791: extern void gen_backing_up PROTO ((void));
1.1       deraadt   792:
                    793: /* Generate the code to perform the backing up. */
1.9     ! tedu      794: extern void gen_bu_action PROTO ((void));
1.1       deraadt   795:
                    796: /* Generate full speed compressed transition table. */
1.9     ! tedu      797: extern void genctbl PROTO ((void));
1.1       deraadt   798:
                    799: /* Generate the code to find the action number. */
1.9     ! tedu      800: extern void gen_find_action PROTO ((void));
1.1       deraadt   801:
1.9     ! tedu      802: extern void genftbl PROTO ((void));    /* generate full transition table */
1.1       deraadt   803:
                    804: /* Generate the code to find the next compressed-table state. */
1.9     ! tedu      805: extern void gen_next_compressed_state PROTO ((char *));
1.1       deraadt   806:
                    807: /* Generate the code to find the next match. */
1.9     ! tedu      808: extern void gen_next_match PROTO ((void));
1.1       deraadt   809:
                    810: /* Generate the code to find the next state. */
1.9     ! tedu      811: extern void gen_next_state PROTO ((int));
1.1       deraadt   812:
                    813: /* Generate the code to make a NUL transition. */
1.9     ! tedu      814: extern void gen_NUL_trans PROTO ((void));
1.1       deraadt   815:
                    816: /* Generate the code to find the start state. */
1.9     ! tedu      817: extern void gen_start_state PROTO ((void));
1.1       deraadt   818:
                    819: /* Generate data statements for the transition tables. */
1.9     ! tedu      820: extern void gentabs PROTO ((void));
1.1       deraadt   821:
                    822: /* Write out a formatted string at the current indentation level. */
1.9     ! tedu      823: extern void indent_put2s PROTO ((const char *, const char *));
1.1       deraadt   824:
                    825: /* Write out a string + newline at the current indentation level. */
1.9     ! tedu      826: extern void indent_puts PROTO ((const char *));
1.1       deraadt   827:
1.9     ! tedu      828: extern void make_tables PROTO ((void));        /* generate transition tables */
1.1       deraadt   829:
                    830:
                    831: /* from file main.c */
                    832:
1.9     ! tedu      833: extern void check_options PROTO ((void));
        !           834: extern void flexend PROTO ((int));
        !           835: extern void usage PROTO ((void));
1.1       deraadt   836:
                    837:
                    838: /* from file misc.c */
                    839:
                    840: /* Add a #define to the action file. */
1.9     ! tedu      841: extern void action_define PROTO ((const char *defname, int value));
1.1       deraadt   842:
                    843: /* Add the given text to the stored actions. */
1.9     ! tedu      844: extern void add_action PROTO ((const char *new_text));
1.1       deraadt   845:
                    846: /* True if a string is all lower case. */
1.9     ! tedu      847: extern int all_lower PROTO ((char *));
1.1       deraadt   848:
                    849: /* True if a string is all upper case. */
1.9     ! tedu      850: extern int all_upper PROTO ((char *));
1.1       deraadt   851:
1.9     ! tedu      852: /* Compare two integers for use by qsort. */
        !           853: extern int intcmp PROTO ((const void *, const void *));
1.1       deraadt   854:
                    855: /* Check a character to make sure it's in the expected range. */
1.9     ! tedu      856: extern void check_char PROTO ((int c));
1.1       deraadt   857:
                    858: /* Replace upper-case letter to lower-case. */
1.9     ! tedu      859: extern Char clower PROTO ((int));
1.1       deraadt   860:
                    861: /* Returns a dynamically allocated copy of a string. */
1.9     ! tedu      862: extern char *copy_string PROTO ((const char *));
1.1       deraadt   863:
                    864: /* Returns a dynamically allocated copy of a (potentially) unsigned string. */
1.9     ! tedu      865: extern Char *copy_unsigned_string PROTO ((Char *));
1.1       deraadt   866:
1.9     ! tedu      867: /* Compare two characters for use by qsort with '\0' sorting last. */
        !           868: extern int cclcmp PROTO ((const void *, const void *));
1.1       deraadt   869:
                    870: /* Finish up a block of data declarations. */
1.9     ! tedu      871: extern void dataend PROTO ((void));
1.1       deraadt   872:
                    873: /* Flush generated data statements. */
1.9     ! tedu      874: extern void dataflush PROTO ((void));
1.1       deraadt   875:
                    876: /* Report an error message and terminate. */
1.9     ! tedu      877: extern void flexerror PROTO ((const char *));
1.1       deraadt   878:
                    879: /* Report a fatal error message and terminate. */
1.9     ! tedu      880: extern void flexfatal PROTO ((const char *));
        !           881:
        !           882: /* Report a fatal error with a pinpoint, and terminate */
        !           883: #if HAVE_DECL___FUNC__
        !           884: #define flex_die(msg) \
        !           885:     do{ \
        !           886:         fprintf (stderr,\
        !           887:                 _("%s: fatal internal error at %s:%d (%s): %s\n"),\
        !           888:                 program_name, __FILE__, (int)__LINE__,\
        !           889:                 __func__,msg);\
        !           890:         FLEX_EXIT(1);\
        !           891:     }while(0)
        !           892: #else /* ! HAVE_DECL___FUNC__ */
        !           893: #define flex_die(msg) \
        !           894:     do{ \
        !           895:         fprintf (stderr,\
        !           896:                 _("%s: fatal internal error at %s:%d %s\n"),\
        !           897:                 program_name, __FILE__, (int)__LINE__,\
        !           898:                 msg);\
        !           899:         FLEX_EXIT(1);\
        !           900:     }while(0)
        !           901: #endif /* ! HAVE_DECL___func__ */
1.1       deraadt   902:
                    903: /* Convert a hexadecimal digit string to an integer value. */
1.9     ! tedu      904: extern int htoi PROTO ((Char[]));
1.1       deraadt   905:
                    906: /* Report an error message formatted with one integer argument. */
1.9     ! tedu      907: extern void lerrif PROTO ((const char *, int));
1.1       deraadt   908:
                    909: /* Report an error message formatted with one string argument. */
1.9     ! tedu      910: extern void lerrsf PROTO ((const char *, const char *));
        !           911:
        !           912: /* Like lerrsf, but also exit after displaying message. */
        !           913: extern void lerrsf_fatal PROTO ((const char *, const char *));
1.1       deraadt   914:
                    915: /* Spit out a "#line" statement. */
1.9     ! tedu      916: extern void line_directive_out PROTO ((FILE *, int));
1.1       deraadt   917:
                    918: /* Mark the current position in the action array as the end of the section 1
                    919:  * user defs.
                    920:  */
1.9     ! tedu      921: extern void mark_defs1 PROTO ((void));
1.1       deraadt   922:
                    923: /* Mark the current position in the action array as the end of the prolog. */
1.9     ! tedu      924: extern void mark_prolog PROTO ((void));
1.1       deraadt   925:
                    926: /* Generate a data statment for a two-dimensional array. */
1.9     ! tedu      927: extern void mk2data PROTO ((int));
1.1       deraadt   928:
1.9     ! tedu      929: extern void mkdata PROTO ((int));      /* generate a data statement */
1.1       deraadt   930:
                    931: /* Return the integer represented by a string of digits. */
1.9     ! tedu      932: extern int myctoi PROTO ((const char *));
1.1       deraadt   933:
                    934: /* Return character corresponding to escape sequence. */
1.9     ! tedu      935: extern Char myesc PROTO ((Char[]));
1.1       deraadt   936:
                    937: /* Convert an octal digit string to an integer value. */
1.9     ! tedu      938: extern int otoi PROTO ((Char[]));
1.1       deraadt   939:
                    940: /* Output a (possibly-formatted) string to the generated scanner. */
1.9     ! tedu      941: extern void out PROTO ((const char *));
        !           942: extern void out_dec PROTO ((const char *, int));
        !           943: extern void out_dec2 PROTO ((const char *, int, int));
        !           944: extern void out_hex PROTO ((const char *, unsigned int));
        !           945: extern void out_str PROTO ((const char *, const char *));
1.1       deraadt   946: extern void out_str3
1.9     ! tedu      947: PROTO ((const char *, const char *, const char *, const char *));
        !           948: extern void out_str_dec PROTO ((const char *, const char *, int));
        !           949: extern void outc PROTO ((int));
        !           950: extern void outn PROTO ((const char *));
        !           951: extern void out_m4_define (const char* def, const char* val);
1.1       deraadt   952:
                    953: /* Return a printable version of the given character, which might be
                    954:  * 8-bit.
                    955:  */
1.9     ! tedu      956: extern char *readable_form PROTO ((int));
1.1       deraadt   957:
                    958: /* Write out one section of the skeleton file. */
1.9     ! tedu      959: extern void skelout PROTO ((void));
1.1       deraadt   960:
                    961: /* Output a yy_trans_info structure. */
1.9     ! tedu      962: extern void transition_struct_out PROTO ((int, int));
1.1       deraadt   963:
                    964: /* Only needed when using certain broken versions of bison to build parse.c. */
1.9     ! tedu      965: extern void *yy_flex_xmalloc PROTO ((int));
1.1       deraadt   966:
                    967: /* Set a region of memory to 0. */
1.9     ! tedu      968: extern void zero_out PROTO ((char *, size_t));
1.1       deraadt   969:
                    970:
                    971: /* from file nfa.c */
                    972:
                    973: /* Add an accepting state to a machine. */
1.9     ! tedu      974: extern void add_accept PROTO ((int, int));
1.1       deraadt   975:
                    976: /* Make a given number of copies of a singleton machine. */
1.9     ! tedu      977: extern int copysingl PROTO ((int, int));
1.1       deraadt   978:
                    979: /* Debugging routine to write out an nfa. */
1.9     ! tedu      980: extern void dumpnfa PROTO ((int));
1.1       deraadt   981:
                    982: /* Finish up the processing for a rule. */
1.9     ! tedu      983: extern void finish_rule PROTO ((int, int, int, int, int));
1.1       deraadt   984:
                    985: /* Connect two machines together. */
1.9     ! tedu      986: extern int link_machines PROTO ((int, int));
1.1       deraadt   987:
                    988: /* Mark each "beginning" state in a machine as being a "normal" (i.e.,
                    989:  * not trailing context associated) state.
                    990:  */
1.9     ! tedu      991: extern void mark_beginning_as_normal PROTO ((int));
1.1       deraadt   992:
                    993: /* Make a machine that branches to two machines. */
1.9     ! tedu      994: extern int mkbranch PROTO ((int, int));
1.1       deraadt   995:
1.9     ! tedu      996: extern int mkclos PROTO ((int));       /* convert a machine into a closure */
        !           997: extern int mkopt PROTO ((int));        /* make a machine optional */
1.1       deraadt   998:
                    999: /* Make a machine that matches either one of two machines. */
1.9     ! tedu     1000: extern int mkor PROTO ((int, int));
1.1       deraadt  1001:
                   1002: /* Convert a machine into a positive closure. */
1.9     ! tedu     1003: extern int mkposcl PROTO ((int));
1.1       deraadt  1004:
1.9     ! tedu     1005: extern int mkrep PROTO ((int, int, int));      /* make a replicated machine */
1.1       deraadt  1006:
                   1007: /* Create a state with a transition on a given symbol. */
1.9     ! tedu     1008: extern int mkstate PROTO ((int));
1.1       deraadt  1009:
1.9     ! tedu     1010: extern void new_rule PROTO ((void));   /* initialize for a new rule */
1.1       deraadt  1011:
                   1012:
                   1013: /* from file parse.y */
                   1014:
                   1015: /* Build the "<<EOF>>" action for the active start conditions. */
1.9     ! tedu     1016: extern void build_eof_action PROTO ((void));
1.1       deraadt  1017:
                   1018: /* Write out a message formatted with one string, pinpointing its location. */
1.9     ! tedu     1019: extern void format_pinpoint_message PROTO ((const char *, const char *));
1.1       deraadt  1020:
                   1021: /* Write out a message, pinpointing its location. */
1.9     ! tedu     1022: extern void pinpoint_message PROTO ((const char *));
1.1       deraadt  1023:
                   1024: /* Write out a warning, pinpointing it at the given line. */
1.9     ! tedu     1025: extern void line_warning PROTO ((const char *, int));
1.1       deraadt  1026:
                   1027: /* Write out a message, pinpointing it at the given line. */
1.9     ! tedu     1028: extern void line_pinpoint PROTO ((const char *, int));
1.1       deraadt  1029:
                   1030: /* Report a formatted syntax error. */
1.9     ! tedu     1031: extern void format_synerr PROTO ((const char *, const char *));
        !          1032: extern void synerr PROTO ((const char *));     /* report a syntax error */
        !          1033: extern void format_warn PROTO ((const char *, const char *));
        !          1034: extern void warn PROTO ((const char *));       /* report a warning */
        !          1035: extern void yyerror PROTO ((const char *));    /* report a parse error */
        !          1036: extern int yyparse PROTO ((void));     /* the YACC parser */
1.1       deraadt  1037:
                   1038:
                   1039: /* from file scan.l */
                   1040:
                   1041: /* The Flex-generated scanner for flex. */
1.9     ! tedu     1042: extern int flexscan PROTO ((void));
1.1       deraadt  1043:
                   1044: /* Open the given file (if NULL, stdin) for scanning. */
1.9     ! tedu     1045: extern void set_input_file PROTO ((char *));
1.1       deraadt  1046:
                   1047: /* Wrapup a file in the lexical analyzer. */
1.9     ! tedu     1048: extern int yywrap PROTO ((void));
1.1       deraadt  1049:
                   1050:
                   1051: /* from file sym.c */
                   1052:
                   1053: /* Save the text of a character class. */
1.9     ! tedu     1054: extern void cclinstal PROTO ((Char[], int));
1.1       deraadt  1055:
                   1056: /* Lookup the number associated with character class. */
1.9     ! tedu     1057: extern int ccllookup PROTO ((Char[]));
1.1       deraadt  1058:
1.9     ! tedu     1059: extern void ndinstal PROTO ((const char *, Char[]));   /* install a name definition */
        !          1060: extern Char *ndlookup PROTO ((const char *));  /* lookup a name definition */
1.1       deraadt  1061:
                   1062: /* Increase maximum number of SC's. */
1.9     ! tedu     1063: extern void scextend PROTO ((void));
        !          1064: extern void scinstal PROTO ((const char *, int));      /* make a start condition */
1.1       deraadt  1065:
                   1066: /* Lookup the number associated with a start condition. */
1.9     ! tedu     1067: extern int sclookup PROTO ((const char *));
1.1       deraadt  1068:
                   1069:
                   1070: /* from file tblcmp.c */
                   1071:
                   1072: /* Build table entries for dfa state. */
1.9     ! tedu     1073: extern void bldtbl PROTO ((int[], int, int, int, int));
        !          1074:
        !          1075: extern void cmptmps PROTO ((void));    /* compress template table entries */
        !          1076: extern void expand_nxt_chk PROTO ((void));     /* increase nxt/chk arrays */
1.1       deraadt  1077:
                   1078: /* Finds a space in the table for a state to be placed. */
1.9     ! tedu     1079: extern int find_table_space PROTO ((int *, int));
        !          1080: extern void inittbl PROTO ((void));    /* initialize transition tables */
        !          1081:
1.1       deraadt  1082: /* Make the default, "jam" table entries. */
1.9     ! tedu     1083: extern void mkdeftbl PROTO ((void));
1.1       deraadt  1084:
                   1085: /* Create table entries for a state (or state fragment) which has
                   1086:  * only one out-transition.
                   1087:  */
1.9     ! tedu     1088: extern void mk1tbl PROTO ((int, int, int, int));
1.1       deraadt  1089:
                   1090: /* Place a state into full speed transition table. */
1.9     ! tedu     1091: extern void place_state PROTO ((int *, int, int));
1.1       deraadt  1092:
                   1093: /* Save states with only one out-transition to be processed later. */
1.9     ! tedu     1094: extern void stack1 PROTO ((int, int, int, int));
1.1       deraadt  1095:
                   1096:
                   1097: /* from file yylex.c */
                   1098:
1.9     ! tedu     1099: extern int yylex PROTO ((void));
        !          1100:
        !          1101: /* A growable array. See buf.c. */
        !          1102: struct Buf {
        !          1103:        void   *elts;           /* elements. */
        !          1104:        int     nelts;          /* number of elements. */
        !          1105:        size_t  elt_size;       /* in bytes. */
        !          1106:        int     nmax;           /* max capacity of elements. */
        !          1107: };
        !          1108:
        !          1109: extern void buf_init PROTO ((struct Buf * buf, size_t elem_size));
        !          1110: extern void buf_destroy PROTO ((struct Buf * buf));
        !          1111: extern struct Buf *buf_append
        !          1112: PROTO ((struct Buf * buf, const void *ptr, int n_elem));
        !          1113: extern struct Buf *buf_concat PROTO((struct Buf* dest, const struct Buf* src));
        !          1114: extern struct Buf *buf_strappend PROTO ((struct Buf *, const char *str));
        !          1115: extern struct Buf *buf_strnappend
        !          1116: PROTO ((struct Buf *, const char *str, int nchars));
        !          1117: extern struct Buf *buf_strdefine
        !          1118: PROTO ((struct Buf * buf, const char *str, const char *def));
        !          1119: extern struct Buf *buf_prints PROTO((struct Buf *buf, const char *fmt, const char* s));
        !          1120: extern struct Buf *buf_m4_define PROTO((struct Buf *buf, const char* def, const char* val));
        !          1121: extern struct Buf *buf_m4_undefine PROTO((struct Buf *buf, const char* def));
        !          1122: extern struct Buf *buf_print_strings PROTO((struct Buf * buf, FILE* out));
        !          1123: extern struct Buf *buf_linedir PROTO((struct Buf *buf, const char* filename, int lineno));
        !          1124:
        !          1125: extern struct Buf userdef_buf; /* a string buffer for #define's generated by user-options on cmd line. */
        !          1126: extern struct Buf defs_buf;    /* a char* buffer to save #define'd some symbols generated by flex. */
        !          1127: extern struct Buf yydmap_buf;  /* a string buffer to hold yydmap elements */
        !          1128: extern struct Buf m4defs_buf;  /* Holds m4 definitions. */
        !          1129: extern struct Buf top_buf;     /* contains %top code. String buffer. */
        !          1130:
        !          1131: /* For blocking out code from the header file. */
        !          1132: #define OUT_BEGIN_CODE() outn("m4_ifdef( [[M4_YY_IN_HEADER]],,[[")
        !          1133: #define OUT_END_CODE()   outn("]])")
        !          1134:
        !          1135: /* For setjmp/longjmp (instead of calling exit(2)). Linkage in main.c */
        !          1136: extern jmp_buf flex_main_jmp_buf;
        !          1137:
        !          1138: #define FLEX_EXIT(status) longjmp(flex_main_jmp_buf,(status)+1)
        !          1139:
        !          1140: /* Removes all \n and \r chars from tail of str. returns str. */
        !          1141: extern char *chomp (char *str);
        !          1142:
        !          1143: /* ctype functions forced to return boolean */
        !          1144: #define b_isalnum(c) (isalnum(c)?true:false)
        !          1145: #define b_isalpha(c) (isalpha(c)?true:false)
        !          1146: #define b_isascii(c) (isascii(c)?true:false)
        !          1147: #define b_isblank(c) (isblank(c)?true:false)
        !          1148: #define b_iscntrl(c) (iscntrl(c)?true:false)
        !          1149: #define b_isdigit(c) (isdigit(c)?true:false)
        !          1150: #define b_isgraph(c) (isgraph(c)?true:false)
        !          1151: #define b_islower(c) (islower(c)?true:false)
        !          1152: #define b_isprint(c) (isprint(c)?true:false)
        !          1153: #define b_ispunct(c) (ispunct(c)?true:false)
        !          1154: #define b_isspace(c) (isspace(c)?true:false)
        !          1155: #define b_isupper(c) (isupper(c)?true:false)
        !          1156: #define b_isxdigit(c) (isxdigit(c)?true:false)
        !          1157:
        !          1158: /* return true if char is uppercase or lowercase. */
        !          1159: bool has_case(int c);
        !          1160:
        !          1161: /* Change case of character if possible. */
        !          1162: int reverse_case(int c);
        !          1163:
        !          1164: /* return false if [c1-c2] is ambiguous for a caseless scanner. */
        !          1165: bool range_covers_case (int c1, int c2);
        !          1166:
        !          1167: /*
        !          1168:  *  From "filter.c"
        !          1169:  */
        !          1170:
        !          1171: /** A single stdio filter to execute.
        !          1172:  *  The filter may be external, such as "sed", or it
        !          1173:  *  may be internal, as a function call.
        !          1174:  */
        !          1175: struct filter {
        !          1176:     int    (*filter_func)(struct filter*); /**< internal filter function */
        !          1177:     void * extra;         /**< extra data passed to filter_func */
        !          1178:        int     argc;         /**< arg count */
        !          1179:        const char ** argv;   /**< arg vector, \0-terminated */
        !          1180:     struct filter * next; /**< next filter or NULL */
        !          1181: };
        !          1182:
        !          1183: /* output filter chain */
        !          1184: extern struct filter * output_chain;
        !          1185: extern struct filter *filter_create_ext PROTO((struct filter * chain, const char *cmd, ...));
        !          1186: struct filter *filter_create_int PROTO((struct filter *chain,
        !          1187:                                  int (*filter_func) (struct filter *),
        !          1188:                   void *extra));
        !          1189: extern bool filter_apply_chain PROTO((struct filter * chain));
        !          1190: extern int filter_truncate (struct filter * chain, int max_len);
        !          1191: extern int filter_tee_header PROTO((struct filter *chain));
        !          1192: extern int filter_fix_linedirs PROTO((struct filter *chain));
        !          1193:
        !          1194:
        !          1195: /*
        !          1196:  * From "regex.c"
        !          1197:  */
        !          1198:
        !          1199: extern regex_t regex_linedir, regex_blank_line;
        !          1200: bool flex_init_regex(void);
        !          1201: void flex_regcomp(regex_t *preg, const char *regex, int cflags);
        !          1202: char   *regmatch_dup (regmatch_t * m, const char *src);
        !          1203: char   *regmatch_cpy (regmatch_t * m, char *dest, const char *src);
        !          1204: int regmatch_len (regmatch_t * m);
        !          1205: int regmatch_strtol (regmatch_t * m, const char *src, char **endptr, int base);
        !          1206: bool regmatch_empty (regmatch_t * m);
        !          1207:
        !          1208: /* From "scanflags.h" */
        !          1209: typedef unsigned int scanflags_t;
        !          1210: extern scanflags_t* _sf_stk;
        !          1211: extern size_t _sf_top_ix, _sf_max; /**< stack of scanner flags. */
        !          1212: #define _SF_CASE_INS   0x0001
        !          1213: #define _SF_DOT_ALL    0x0002
        !          1214: #define _SF_SKIP_WS    0x0004
        !          1215: #define sf_top()           (_sf_stk[_sf_top_ix])
        !          1216: #define sf_case_ins()      (sf_top() & _SF_CASE_INS)
        !          1217: #define sf_dot_all()       (sf_top() & _SF_DOT_ALL)
        !          1218: #define sf_skip_ws()       (sf_top() & _SF_SKIP_WS)
        !          1219: #define sf_set_case_ins(X)      ((X) ? (sf_top() |= _SF_CASE_INS) : (sf_top() &= ~_SF_CASE_INS))
        !          1220: #define sf_set_dot_all(X)       ((X) ? (sf_top() |= _SF_DOT_ALL)  : (sf_top() &= ~_SF_DOT_ALL))
        !          1221: #define sf_set_skip_ws(X)       ((X) ? (sf_top() |= _SF_SKIP_WS)  : (sf_top() &= ~_SF_SKIP_WS))
        !          1222: extern void sf_init(void);
        !          1223: extern void sf_push(void);
        !          1224: extern void sf_pop(void);
        !          1225:
        !          1226:
        !          1227: #endif /* not defined FLEXDEF_H */