[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.11

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