Blame src/flexdef.h

Packit f00812
Packit f00812
/* flexdef - definitions file for flex */
Packit f00812
Packit f00812
/*  Copyright (c) 1990 The Regents of the University of California. */
Packit f00812
/*  All rights reserved. */
Packit f00812
Packit f00812
/*  This code is derived from software contributed to Berkeley by */
Packit f00812
/*  Vern Paxson. */
Packit f00812
Packit f00812
/*  The United States Government has rights in this work pursuant */
Packit f00812
/*  to contract no. DE-AC03-76SF00098 between the United States */
Packit f00812
/*  Department of Energy and the University of California. */
Packit f00812
Packit f00812
/*  This file is part of flex. */
Packit f00812
Packit f00812
/*  Redistribution and use in source and binary forms, with or without */
Packit f00812
/*  modification, are permitted provided that the following conditions */
Packit f00812
/*  are met: */
Packit f00812
Packit f00812
/*  1. Redistributions of source code must retain the above copyright */
Packit f00812
/*     notice, this list of conditions and the following disclaimer. */
Packit f00812
/*  2. Redistributions in binary form must reproduce the above copyright */
Packit f00812
/*     notice, this list of conditions and the following disclaimer in the */
Packit f00812
/*     documentation and/or other materials provided with the distribution. */
Packit f00812
Packit f00812
/*  Neither the name of the University nor the names of its contributors */
Packit f00812
/*  may be used to endorse or promote products derived from this software */
Packit f00812
/*  without specific prior written permission. */
Packit f00812
Packit f00812
/*  THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR */
Packit f00812
/*  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED */
Packit f00812
/*  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR */
Packit f00812
/*  PURPOSE. */
Packit f00812
Packit f00812
#ifndef FLEXDEF_H
Packit f00812
#define FLEXDEF_H 1
Packit f00812
Packit f00812
#ifdef HAVE_CONFIG_H
Packit f00812
#include <config.h>
Packit f00812
#endif
Packit f00812
Packit f00812
#include <stdio.h>
Packit f00812
#include <stdlib.h>
Packit f00812
#include <stdarg.h>
Packit f00812
#include <setjmp.h>
Packit f00812
#include <ctype.h>
Packit f00812
#include <libgen.h> /* for XPG version of basename(3) */
Packit f00812
#include <string.h>
Packit f00812
#include <math.h>
Packit f00812
Packit f00812
#ifdef HAVE_ASSERT_H
Packit f00812
#include <assert.h>
Packit f00812
#else
Packit f00812
#define assert(Pred)
Packit f00812
#endif
Packit f00812
Packit f00812
#ifdef HAVE_LIMITS_H
Packit f00812
#include <limits.h>
Packit f00812
#endif
Packit f00812
#ifdef HAVE_UNISTD_H
Packit f00812
#include <unistd.h>
Packit f00812
#endif
Packit f00812
#ifdef HAVE_NETINET_IN_H
Packit f00812
#include <netinet/in.h>
Packit f00812
#endif
Packit f00812
#ifdef HAVE_SYS_PARAMS_H
Packit f00812
#include <sys/params.h>
Packit f00812
#endif
Packit f00812
#ifdef HAVE_SYS_STAT_H
Packit f00812
#include <sys/stat.h>
Packit f00812
#endif
Packit f00812
#include <sys/wait.h>
Packit f00812
#include <stdbool.h>
Packit f00812
#ifdef HAVE_REGEX_H
Packit f00812
#include <regex.h>
Packit f00812
#endif
Packit f00812
#include "flexint.h"
Packit f00812
Packit f00812
/* We use gettext. So, when we write strings which should be translated, we mark them with _() */
Packit f00812
#ifdef ENABLE_NLS
Packit f00812
#ifdef HAVE_LOCALE_H
Packit f00812
#include <locale.h>
Packit f00812
#endif /* HAVE_LOCALE_H */
Packit f00812
#include "gettext.h"
Packit f00812
#define _(String) gettext (String)
Packit f00812
#else
Packit f00812
#define _(STRING) STRING
Packit f00812
#endif /* ENABLE_NLS */
Packit f00812
Packit f00812
/* Always be prepared to generate an 8-bit scanner. */
Packit f00812
#define CSIZE 256
Packit f00812
Packit f00812
/* Size of input alphabet - should be size of ASCII set. */
Packit f00812
#ifndef DEFAULT_CSIZE
Packit f00812
#define DEFAULT_CSIZE 128
Packit f00812
#endif
Packit f00812
Packit f00812
/* Maximum line length we'll have to deal with. */
Packit f00812
#define MAXLINE 2048
Packit f00812
Packit f00812
#ifndef MIN
Packit f00812
#define MIN(x,y) ((x) < (y) ? (x) : (y))
Packit f00812
#endif
Packit f00812
#ifndef MAX
Packit f00812
#define MAX(x,y) ((x) > (y) ? (x) : (y))
Packit f00812
#endif
Packit f00812
#ifndef ABS
Packit f00812
#define ABS(x) ((x) < 0 ? -(x) : (x))
Packit f00812
#endif
Packit f00812
Packit f00812
Packit f00812
#define unspecified -1
Packit f00812
Packit f00812
/* Special chk[] values marking the slots taking by end-of-buffer and action
Packit f00812
 * numbers.
Packit f00812
 */
Packit f00812
#define EOB_POSITION -1
Packit f00812
#define ACTION_POSITION -2
Packit f00812
Packit f00812
/* Number of data items per line for -f output. */
Packit f00812
#define NUMDATAITEMS 10
Packit f00812
Packit f00812
/* Number of lines of data in -f output before inserting a blank line for
Packit f00812
 * readability.
Packit f00812
 */
Packit f00812
#define NUMDATALINES 10
Packit f00812
Packit f00812
/* transition_struct_out() definitions. */
Packit f00812
#define TRANS_STRUCT_PRINT_LENGTH 14
Packit f00812
Packit f00812
/* Returns true if an nfa state has an epsilon out-transition slot
Packit f00812
 * that can be used.  This definition is currently not used.
Packit f00812
 */
Packit f00812
#define FREE_EPSILON(state) \
Packit f00812
	(transchar[state] == SYM_EPSILON && \
Packit f00812
	 trans2[state] == NO_TRANSITION && \
Packit f00812
	 finalst[state] != state)
Packit f00812
Packit f00812
/* Returns true if an nfa state has an epsilon out-transition character
Packit f00812
 * and both slots are free
Packit f00812
 */
Packit f00812
#define SUPER_FREE_EPSILON(state) \
Packit f00812
	(transchar[state] == SYM_EPSILON && \
Packit f00812
	 trans1[state] == NO_TRANSITION) \
Packit f00812
Packit f00812
/* Maximum number of NFA states that can comprise a DFA state.  It's real
Packit f00812
 * big because if there's a lot of rules, the initial state will have a
Packit f00812
 * huge epsilon closure.
Packit f00812
 */
Packit f00812
#define INITIAL_MAX_DFA_SIZE 750
Packit f00812
#define MAX_DFA_SIZE_INCREMENT 750
Packit f00812
Packit f00812
Packit f00812
/* A note on the following masks.  They are used to mark accepting numbers
Packit f00812
 * as being special.  As such, they implicitly limit the number of accepting
Packit f00812
 * numbers (i.e., rules) because if there are too many rules the rule numbers
Packit f00812
 * will overload the mask bits.  Fortunately, this limit is \large/ (0x2000 ==
Packit f00812
 * 8192) so unlikely to actually cause any problems.  A check is made in
Packit f00812
 * new_rule() to ensure that this limit is not reached.
Packit f00812
 */
Packit f00812
Packit f00812
/* Mask to mark a trailing context accepting number. */
Packit f00812
#define YY_TRAILING_MASK 0x2000
Packit f00812
Packit f00812
/* Mask to mark the accepting number of the "head" of a trailing context
Packit f00812
 * rule.
Packit f00812
 */
Packit f00812
#define YY_TRAILING_HEAD_MASK 0x4000
Packit f00812
Packit f00812
/* Maximum number of rules, as outlined in the above note. */
Packit f00812
#define MAX_RULE (YY_TRAILING_MASK - 1)
Packit f00812
Packit f00812
Packit f00812
/* NIL must be 0.  If not, its special meaning when making equivalence classes
Packit f00812
 * (it marks the representative of a given e.c.) will be unidentifiable.
Packit f00812
 */
Packit f00812
#define NIL 0
Packit f00812
Packit f00812
#define JAM -1			/* to mark a missing DFA transition */
Packit f00812
#define NO_TRANSITION NIL
Packit f00812
#define UNIQUE -1		/* marks a symbol as an e.c. representative */
Packit f00812
#define INFINITE_REPEAT -1		/* for x{5,} constructions */
Packit f00812
Packit f00812
#define INITIAL_MAX_CCLS 100	/* max number of unique character classes */
Packit f00812
#define MAX_CCLS_INCREMENT 100
Packit f00812
Packit f00812
/* Size of table holding members of character classes. */
Packit f00812
#define INITIAL_MAX_CCL_TBL_SIZE 500
Packit f00812
#define MAX_CCL_TBL_SIZE_INCREMENT 250
Packit f00812
Packit f00812
#define INITIAL_MAX_RULES 100	/* default maximum number of rules */
Packit f00812
#define MAX_RULES_INCREMENT 100
Packit f00812
Packit f00812
#define INITIAL_MNS 2000	/* default maximum number of nfa states */
Packit f00812
#define MNS_INCREMENT 1000	/* amount to bump above by if it's not enough */
Packit f00812
Packit f00812
#define INITIAL_MAX_DFAS 1000	/* default maximum number of dfa states */
Packit f00812
#define MAX_DFAS_INCREMENT 1000
Packit f00812
Packit f00812
#define JAMSTATE -32766		/* marks a reference to the state that always jams */
Packit f00812
Packit f00812
/* Maximum number of NFA states. */
Packit f00812
#define MAXIMUM_MNS 31999
Packit f00812
#define MAXIMUM_MNS_LONG 1999999999
Packit f00812
Packit f00812
/* Enough so that if it's subtracted from an NFA state number, the result
Packit f00812
 * is guaranteed to be negative.
Packit f00812
 */
Packit f00812
#define MARKER_DIFFERENCE (maximum_mns+2)
Packit f00812
Packit f00812
/* Maximum number of nxt/chk pairs for non-templates. */
Packit f00812
#define INITIAL_MAX_XPAIRS 2000
Packit f00812
#define MAX_XPAIRS_INCREMENT 2000
Packit f00812
Packit f00812
/* Maximum number of nxt/chk pairs needed for templates. */
Packit f00812
#define INITIAL_MAX_TEMPLATE_XPAIRS 2500
Packit f00812
#define MAX_TEMPLATE_XPAIRS_INCREMENT 2500
Packit f00812
Packit f00812
#define SYM_EPSILON (CSIZE + 1)	/* to mark transitions on the symbol epsilon */
Packit f00812
Packit f00812
#define INITIAL_MAX_SCS 40	/* maximum number of start conditions */
Packit f00812
#define MAX_SCS_INCREMENT 40	/* amount to bump by if it's not enough */
Packit f00812
Packit f00812
#define ONE_STACK_SIZE 500	/* stack of states with only one out-transition */
Packit f00812
#define SAME_TRANS -1		/* transition is the same as "default" entry for state */
Packit f00812
Packit f00812
/* The following percentages are used to tune table compression:
Packit f00812
Packit f00812
 * The percentage the number of out-transitions a state must be of the
Packit f00812
 * number of equivalence classes in order to be considered for table
Packit f00812
 * compaction by using protos.
Packit f00812
 */
Packit f00812
#define PROTO_SIZE_PERCENTAGE 15
Packit f00812
Packit f00812
/* The percentage the number of homogeneous out-transitions of a state
Packit f00812
 * must be of the number of total out-transitions of the state in order
Packit f00812
 * that the state's transition table is first compared with a potential
Packit f00812
 * template of the most common out-transition instead of with the first
Packit f00812
 * proto in the proto queue.
Packit f00812
 */
Packit f00812
#define CHECK_COM_PERCENTAGE 50
Packit f00812
Packit f00812
/* The percentage the number of differences between a state's transition
Packit f00812
 * table and the proto it was first compared with must be of the total
Packit f00812
 * number of out-transitions of the state in order to keep the first
Packit f00812
 * proto as a good match and not search any further.
Packit f00812
 */
Packit f00812
#define FIRST_MATCH_DIFF_PERCENTAGE 10
Packit f00812
Packit f00812
/* The percentage the number of differences between a state's transition
Packit f00812
 * table and the most similar proto must be of the state's total number
Packit f00812
 * of out-transitions to use the proto as an acceptable close match.
Packit f00812
 */
Packit f00812
#define ACCEPTABLE_DIFF_PERCENTAGE 50
Packit f00812
Packit f00812
/* The percentage the number of homogeneous out-transitions of a state
Packit f00812
 * must be of the number of total out-transitions of the state in order
Packit f00812
 * to consider making a template from the state.
Packit f00812
 */
Packit f00812
#define TEMPLATE_SAME_PERCENTAGE 60
Packit f00812
Packit f00812
/* The percentage the number of differences between a state's transition
Packit f00812
 * table and the most similar proto must be of the state's total number
Packit f00812
 * of out-transitions to create a new proto from the state.
Packit f00812
 */
Packit f00812
#define NEW_PROTO_DIFF_PERCENTAGE 20
Packit f00812
Packit f00812
/* The percentage the total number of out-transitions of a state must be
Packit f00812
 * of the number of equivalence classes in order to consider trying to
Packit f00812
 * fit the transition table into "holes" inside the nxt/chk table.
Packit f00812
 */
Packit f00812
#define INTERIOR_FIT_PERCENTAGE 15
Packit f00812
Packit f00812
/* Size of region set aside to cache the complete transition table of
Packit f00812
 * protos on the proto queue to enable quick comparisons.
Packit f00812
 */
Packit f00812
#define PROT_SAVE_SIZE 2000
Packit f00812
Packit f00812
#define MSP 50			/* maximum number of saved protos (protos on the proto queue) */
Packit f00812
Packit f00812
/* Maximum number of out-transitions a state can have that we'll rummage
Packit f00812
 * around through the interior of the internal fast table looking for a
Packit f00812
 * spot for it.
Packit f00812
 */
Packit f00812
#define MAX_XTIONS_FULL_INTERIOR_FIT 4
Packit f00812
Packit f00812
/* Maximum number of rules which will be reported as being associated
Packit f00812
 * with a DFA state.
Packit f00812
 */
Packit f00812
#define MAX_ASSOC_RULES 100
Packit f00812
Packit f00812
/* Number that, if used to subscript an array, has a good chance of producing
Packit f00812
 * an error; should be small enough to fit into a short.
Packit f00812
 */
Packit f00812
#define BAD_SUBSCRIPT -32767
Packit f00812
Packit f00812
/* Absolute value of largest number that can be stored in a short, with a
Packit f00812
 * bit of slop thrown in for general paranoia.
Packit f00812
 */
Packit f00812
#define MAX_SHORT 32700
Packit f00812
Packit f00812
Packit f00812
/* Declarations for global variables. */
Packit f00812
Packit f00812
Packit f00812
/* Variables for flags:
Packit f00812
 * printstats - if true (-v), dump statistics
Packit f00812
 * syntaxerror - true if a syntax error has been found
Packit f00812
 * eofseen - true if we've seen an eof in the input file
Packit f00812
 * ddebug - if true (-d), make a "debug" scanner
Packit f00812
 * trace - if true (-T), trace processing
Packit f00812
 * nowarn - if true (-w), do not generate warnings
Packit f00812
 * spprdflt - if true (-s), suppress the default rule
Packit f00812
 * interactive - if true (-I), generate an interactive scanner
Packit f00812
 * lex_compat - if true (-l), maximize compatibility with AT&T lex
Packit f00812
 * posix_compat - if true (-X), maximize compatibility with POSIX lex
Packit f00812
 * do_yylineno - if true, generate code to maintain yylineno
Packit f00812
 * useecs - if true (-Ce flag), use equivalence classes
Packit f00812
 * fulltbl - if true (-Cf flag), don't compress the DFA state table
Packit f00812
 * usemecs - if true (-Cm flag), use meta-equivalence classes
Packit f00812
 * fullspd - if true (-F flag), use Jacobson method of table representation
Packit f00812
 * gen_line_dirs - if true (i.e., no -L flag), generate #line directives
Packit f00812
 * performance_report - if > 0 (i.e., -p flag), generate a report relating
Packit f00812
 *   to scanner performance; if > 1 (-p -p), report on minor performance
Packit f00812
 *   problems, too
Packit f00812
 * backing_up_report - if true (i.e., -b flag), generate "lex.backup" file
Packit f00812
 *   listing backing-up states
Packit f00812
 * C_plus_plus - if true (i.e., -+ flag), generate a C++ scanner class;
Packit f00812
 *   otherwise, a standard C scanner
Packit f00812
 * reentrant - if true (-R), generate a reentrant C scanner.
Packit f00812
 * bison_bridge_lval - if true (--bison-bridge), bison pure calling convention.
Packit f00812
 * bison_bridge_lloc - if true (--bison-locations), bison yylloc.
Packit f00812
 * long_align - if true (-Ca flag), favor long-word alignment.
Packit f00812
 * use_read - if true (-f, -F, or -Cr) then use read() for scanner input;
Packit f00812
 *   otherwise, use fread().
Packit f00812
 * yytext_is_array - if true (i.e., %array directive), then declare
Packit f00812
 *   yytext as a array instead of a character pointer.  Nice and inefficient.
Packit f00812
 * do_yywrap - do yywrap() processing on EOF.  If false, EOF treated as
Packit f00812
 *   "no more files".
Packit f00812
 * csize - size of character set for the scanner we're generating;
Packit f00812
 *   128 for 7-bit chars and 256 for 8-bit
Packit f00812
 * yymore_used - if true, yymore() is used in input rules
Packit f00812
 * reject - if true, generate back-up tables for REJECT macro
Packit f00812
 * real_reject - if true, scanner really uses REJECT (as opposed to just
Packit f00812
 *   having "reject" set for variable trailing context)
Packit f00812
 * continued_action - true if this rule's action is to "fall through" to
Packit f00812
 *   the next rule's action (i.e., the '|' action)
Packit f00812
 * in_rule - true if we're inside an individual rule, false if not.
Packit f00812
 * yymore_really_used - whether to treat yymore() as really used, regardless
Packit f00812
 *   of what we think based on references to it in the user's actions.
Packit f00812
 * reject_really_used - same for REJECT
Packit f00812
 * trace_hex - use hexadecimal numbers in trace/debug outputs instead of octals
Packit f00812
 */
Packit f00812
Packit f00812
extern int printstats, syntaxerror, eofseen, ddebug, trace, nowarn,
Packit f00812
	spprdflt;
Packit f00812
extern int interactive, lex_compat, posix_compat, do_yylineno;
Packit f00812
extern int useecs, fulltbl, usemecs, fullspd;
Packit f00812
extern int gen_line_dirs, performance_report, backing_up_report;
Packit f00812
extern int reentrant, bison_bridge_lval, bison_bridge_lloc;
Packit f00812
extern bool ansi_func_defs, ansi_func_protos;
Packit f00812
extern int C_plus_plus, long_align, use_read, yytext_is_array, do_yywrap;
Packit f00812
extern int csize;
Packit f00812
extern int yymore_used, reject, real_reject, continued_action, in_rule;
Packit f00812
Packit f00812
extern int yymore_really_used, reject_really_used;
Packit f00812
extern int trace_hex;
Packit f00812
Packit f00812
/* Variables used in the flex input routines:
Packit f00812
 * datapos - characters on current output line
Packit f00812
 * dataline - number of contiguous lines of data in current data
Packit f00812
 * 	statement.  Used to generate readable -f output
Packit f00812
 * linenum - current input line number
Packit f00812
 * skelfile - the skeleton file
Packit f00812
 * skel - compiled-in skeleton array
Packit f00812
 * skel_ind - index into "skel" array, if skelfile is nil
Packit f00812
 * yyin - input file
Packit f00812
 * backing_up_file - file to summarize backing-up states to
Packit f00812
 * infilename - name of input file
Packit f00812
 * outfilename - name of output file
Packit f00812
 * headerfilename - name of the .h file to generate
Packit f00812
 * did_outfilename - whether outfilename was explicitly set
Packit f00812
 * prefix - the prefix used for externally visible names ("yy" by default)
Packit f00812
 * yyclass - yyFlexLexer subclass to use for YY_DECL
Packit f00812
 * do_stdinit - whether to initialize yyin/yyout to stdin/stdout
Packit f00812
 * use_stdout - the -t flag
Packit f00812
 * input_files - array holding names of input files
Packit f00812
 * num_input_files - size of input_files array
Packit f00812
 * program_name - name with which program was invoked
Packit f00812
 *
Packit f00812
 * action_array - array to hold the rule actions
Packit f00812
 * action_size - size of action_array
Packit f00812
 * defs1_offset - index where the user's section 1 definitions start
Packit f00812
 *	in action_array
Packit f00812
 * prolog_offset - index where the prolog starts in action_array
Packit f00812
 * action_offset - index where the non-prolog starts in action_array
Packit f00812
 * action_index - index where the next action should go, with respect
Packit f00812
 * 	to "action_array"
Packit f00812
 */
Packit f00812
Packit f00812
extern int datapos, dataline, linenum;
Packit f00812
extern FILE *skelfile, *backing_up_file;
Packit f00812
extern const char *skel[];
Packit f00812
extern int skel_ind;
Packit f00812
extern char *infilename, *outfilename, *headerfilename;
Packit f00812
extern int did_outfilename;
Packit f00812
extern char *prefix, *yyclass, *extra_type;
Packit f00812
extern int do_stdinit, use_stdout;
Packit f00812
extern char **input_files;
Packit f00812
extern int num_input_files;
Packit f00812
extern char *program_name;
Packit f00812
Packit f00812
extern char *action_array;
Packit f00812
extern int action_size;
Packit f00812
extern int defs1_offset, prolog_offset, action_offset, action_index;
Packit f00812
Packit f00812
Packit f00812
/* Variables for stack of states having only one out-transition:
Packit f00812
 * onestate - state number
Packit f00812
 * onesym - transition symbol
Packit f00812
 * onenext - target state
Packit f00812
 * onedef - default base entry
Packit f00812
 * onesp - stack pointer
Packit f00812
 */
Packit f00812
Packit f00812
extern int onestate[ONE_STACK_SIZE], onesym[ONE_STACK_SIZE];
Packit f00812
extern int onenext[ONE_STACK_SIZE], onedef[ONE_STACK_SIZE], onesp;
Packit f00812
Packit f00812
Packit f00812
/* Variables for nfa machine data:
Packit f00812
 * maximum_mns - maximal number of NFA states supported by tables
Packit f00812
 * current_mns - current maximum on number of NFA states
Packit f00812
 * num_rules - number of the last accepting state; also is number of
Packit f00812
 * 	rules created so far
Packit f00812
 * num_eof_rules - number of <<EOF>> rules
Packit f00812
 * default_rule - number of the default rule
Packit f00812
 * current_max_rules - current maximum number of rules
Packit f00812
 * lastnfa - last nfa state number created
Packit f00812
 * firstst - physically the first state of a fragment
Packit f00812
 * lastst - last physical state of fragment
Packit f00812
 * finalst - last logical state of fragment
Packit f00812
 * transchar - transition character
Packit f00812
 * trans1 - transition state
Packit f00812
 * trans2 - 2nd transition state for epsilons
Packit f00812
 * accptnum - accepting number
Packit f00812
 * assoc_rule - rule associated with this NFA state (or 0 if none)
Packit f00812
 * state_type - a STATE_xxx type identifying whether the state is part
Packit f00812
 * 	of a normal rule, the leading state in a trailing context
Packit f00812
 * 	rule (i.e., the state which marks the transition from
Packit f00812
 * 	recognizing the text-to-be-matched to the beginning of
Packit f00812
 * 	the trailing context), or a subsequent state in a trailing
Packit f00812
 * 	context rule
Packit f00812
 * rule_type - a RULE_xxx type identifying whether this a ho-hum
Packit f00812
 * 	normal rule or one which has variable head & trailing
Packit f00812
 * 	context
Packit f00812
 * rule_linenum - line number associated with rule
Packit f00812
 * rule_useful - true if we've determined that the rule can be matched
Packit f00812
 * rule_has_nl - true if rule could possibly match a newline
Packit f00812
 * ccl_has_nl - true if current ccl could match a newline
Packit f00812
 * nlch - default eol char
Packit f00812
 */
Packit f00812
Packit f00812
extern int maximum_mns, current_mns, current_max_rules;
Packit f00812
extern int num_rules, num_eof_rules, default_rule, lastnfa;
Packit f00812
extern int *firstst, *lastst, *finalst, *transchar, *trans1, *trans2;
Packit f00812
extern int *accptnum, *assoc_rule, *state_type;
Packit f00812
extern int *rule_type, *rule_linenum, *rule_useful;
Packit f00812
extern bool *rule_has_nl, *ccl_has_nl;
Packit f00812
extern int nlch;
Packit f00812
Packit f00812
/* Different types of states; values are useful as masks, as well, for
Packit f00812
 * routines like check_trailing_context().
Packit f00812
 */
Packit f00812
#define STATE_NORMAL 0x1
Packit f00812
#define STATE_TRAILING_CONTEXT 0x2
Packit f00812
Packit f00812
/* Global holding current type of state we're making. */
Packit f00812
Packit f00812
extern int current_state_type;
Packit f00812
Packit f00812
/* Different types of rules. */
Packit f00812
#define RULE_NORMAL 0
Packit f00812
#define RULE_VARIABLE 1
Packit f00812
Packit f00812
/* True if the input rules include a rule with both variable-length head
Packit f00812
 * and trailing context, false otherwise.
Packit f00812
 */
Packit f00812
extern int variable_trailing_context_rules;
Packit f00812
Packit f00812
Packit f00812
/* Variables for protos:
Packit f00812
 * numtemps - number of templates created
Packit f00812
 * numprots - number of protos created
Packit f00812
 * protprev - backlink to a more-recently used proto
Packit f00812
 * protnext - forward link to a less-recently used proto
Packit f00812
 * prottbl - base/def table entry for proto
Packit f00812
 * protcomst - common state of proto
Packit f00812
 * firstprot - number of the most recently used proto
Packit f00812
 * lastprot - number of the least recently used proto
Packit f00812
 * protsave contains the entire state array for protos
Packit f00812
 */
Packit f00812
Packit f00812
extern int numtemps, numprots, protprev[MSP], protnext[MSP], prottbl[MSP];
Packit f00812
extern int protcomst[MSP], firstprot, lastprot, protsave[PROT_SAVE_SIZE];
Packit f00812
Packit f00812
Packit f00812
/* Variables for managing equivalence classes:
Packit f00812
 * numecs - number of equivalence classes
Packit f00812
 * nextecm - forward link of Equivalence Class members
Packit f00812
 * ecgroup - class number or backward link of EC members
Packit f00812
 * nummecs - number of meta-equivalence classes (used to compress
Packit f00812
 *   templates)
Packit f00812
 * tecfwd - forward link of meta-equivalence classes members
Packit f00812
 * tecbck - backward link of MEC's
Packit f00812
 */
Packit f00812
Packit f00812
/* Reserve enough room in the equivalence class arrays so that we
Packit f00812
 * can use the CSIZE'th element to hold equivalence class information
Packit f00812
 * for the NUL character.  Later we'll move this information into
Packit f00812
 * the 0th element.
Packit f00812
 */
Packit f00812
extern int numecs, nextecm[CSIZE + 1], ecgroup[CSIZE + 1], nummecs;
Packit f00812
Packit f00812
/* Meta-equivalence classes are indexed starting at 1, so it's possible
Packit f00812
 * that they will require positions from 1 .. CSIZE, i.e., CSIZE + 1
Packit f00812
 * slots total (since the arrays are 0-based).  nextecm[] and ecgroup[]
Packit f00812
 * don't require the extra position since they're indexed from 1 .. CSIZE - 1.
Packit f00812
 */
Packit f00812
extern int tecfwd[CSIZE + 1], tecbck[CSIZE + 1];
Packit f00812
Packit f00812
Packit f00812
/* Variables for start conditions:
Packit f00812
 * lastsc - last start condition created
Packit f00812
 * current_max_scs - current limit on number of start conditions
Packit f00812
 * scset - set of rules active in start condition
Packit f00812
 * scbol - set of rules active only at the beginning of line in a s.c.
Packit f00812
 * scxclu - true if start condition is exclusive
Packit f00812
 * sceof - true if start condition has EOF rule
Packit f00812
 * scname - start condition name
Packit f00812
 */
Packit f00812
Packit f00812
extern int lastsc, *scset, *scbol, *scxclu, *sceof;
Packit f00812
extern int current_max_scs;
Packit f00812
extern char **scname;
Packit f00812
Packit f00812
Packit f00812
/* Variables for dfa machine data:
Packit f00812
 * current_max_dfa_size - current maximum number of NFA states in DFA
Packit f00812
 * current_max_xpairs - current maximum number of non-template xtion pairs
Packit f00812
 * current_max_template_xpairs - current maximum number of template pairs
Packit f00812
 * current_max_dfas - current maximum number DFA states
Packit f00812
 * lastdfa - last dfa state number created
Packit f00812
 * nxt - state to enter upon reading character
Packit f00812
 * chk - check value to see if "nxt" applies
Packit f00812
 * tnxt - internal nxt table for templates
Packit f00812
 * base - offset into "nxt" for given state
Packit f00812
 * def - where to go if "chk" disallows "nxt" entry
Packit f00812
 * nultrans - NUL transition for each state
Packit f00812
 * NUL_ec - equivalence class of the NUL character
Packit f00812
 * tblend - last "nxt/chk" table entry being used
Packit f00812
 * firstfree - first empty entry in "nxt/chk" table
Packit f00812
 * dss - nfa state set for each dfa
Packit f00812
 * dfasiz - size of nfa state set for each dfa
Packit f00812
 * dfaacc - accepting set for each dfa state (if using REJECT), or accepting
Packit f00812
 *	number, if not
Packit f00812
 * accsiz - size of accepting set for each dfa state
Packit f00812
 * dhash - dfa state hash value
Packit f00812
 * numas - number of DFA accepting states created; note that this
Packit f00812
 *	is not necessarily the same value as num_rules, which is the analogous
Packit f00812
 *	value for the NFA
Packit f00812
 * numsnpairs - number of state/nextstate transition pairs
Packit f00812
 * jambase - position in base/def where the default jam table starts
Packit f00812
 * jamstate - state number corresponding to "jam" state
Packit f00812
 * end_of_buffer_state - end-of-buffer dfa state number
Packit f00812
 */
Packit f00812
Packit f00812
extern int current_max_dfa_size, current_max_xpairs;
Packit f00812
extern int current_max_template_xpairs, current_max_dfas;
Packit f00812
extern int lastdfa, *nxt, *chk, *tnxt;
Packit f00812
extern int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss,
Packit f00812
	*dfasiz;
Packit f00812
extern union dfaacc_union {
Packit f00812
	int    *dfaacc_set;
Packit f00812
	int     dfaacc_state;
Packit f00812
}      *dfaacc;
Packit f00812
extern int *accsiz, *dhash, numas;
Packit f00812
extern int numsnpairs, jambase, jamstate;
Packit f00812
extern int end_of_buffer_state;
Packit f00812
Packit f00812
/* Variables for ccl information:
Packit f00812
 * lastccl - ccl index of the last created ccl
Packit f00812
 * current_maxccls - current limit on the maximum number of unique ccl's
Packit f00812
 * cclmap - maps a ccl index to its set pointer
Packit f00812
 * ccllen - gives the length of a ccl
Packit f00812
 * cclng - true for a given ccl if the ccl is negated
Packit f00812
 * cclreuse - counts how many times a ccl is re-used
Packit f00812
 * current_max_ccl_tbl_size - current limit on number of characters needed
Packit f00812
 *	to represent the unique ccl's
Packit f00812
 * ccltbl - holds the characters in each ccl - indexed by cclmap
Packit f00812
 */
Packit f00812
Packit f00812
extern int lastccl, *cclmap, *ccllen, *cclng, cclreuse;
Packit f00812
extern int current_maxccls, current_max_ccl_tbl_size;
Packit f00812
extern unsigned char *ccltbl;
Packit f00812
Packit f00812
Packit f00812
/* Variables for miscellaneous information:
Packit f00812
 * nmstr - last NAME scanned by the scanner
Packit f00812
 * sectnum - section number currently being parsed
Packit f00812
 * nummt - number of empty nxt/chk table entries
Packit f00812
 * hshcol - number of hash collisions detected by snstods
Packit f00812
 * dfaeql - number of times a newly created dfa was equal to an old one
Packit f00812
 * numeps - number of epsilon NFA states created
Packit f00812
 * eps2 - number of epsilon states which have 2 out-transitions
Packit f00812
 * num_reallocs - number of times it was necessary to realloc() a group
Packit f00812
 *	  of arrays
Packit f00812
 * tmpuses - number of DFA states that chain to templates
Packit f00812
 * totnst - total number of NFA states used to make DFA states
Packit f00812
 * peakpairs - peak number of transition pairs we had to store internally
Packit f00812
 * numuniq - number of unique transitions
Packit f00812
 * numdup - number of duplicate transitions
Packit f00812
 * hshsave - number of hash collisions saved by checking number of states
Packit f00812
 * num_backing_up - number of DFA states requiring backing up
Packit f00812
 * bol_needed - whether scanner needs beginning-of-line recognition
Packit f00812
 */
Packit f00812
Packit f00812
extern char nmstr[MAXLINE];
Packit f00812
extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
Packit f00812
extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
Packit f00812
extern int num_backing_up, bol_needed;
Packit f00812
Packit f00812
#ifndef HAVE_REALLOCARRAY
Packit f00812
void *reallocarray(void *, size_t, size_t);
Packit f00812
#endif
Packit f00812
Packit f00812
void   *allocate_array(int, size_t);
Packit f00812
void   *reallocate_array(void *, int, size_t);
Packit f00812
Packit f00812
#define allocate_integer_array(size) \
Packit f00812
	allocate_array(size, sizeof(int))
Packit f00812
Packit f00812
#define reallocate_integer_array(array,size) \
Packit f00812
	reallocate_array((void *) array, size, sizeof(int))
Packit f00812
Packit f00812
#define allocate_bool_array(size) \
Packit f00812
	allocate_array(size, sizeof(bool))
Packit f00812
Packit f00812
#define reallocate_bool_array(array,size) \
Packit f00812
	reallocate_array((void *) array, size, sizeof(bool))
Packit f00812
Packit f00812
#define allocate_int_ptr_array(size) \
Packit f00812
	allocate_array(size, sizeof(int *))
Packit f00812
Packit f00812
#define allocate_char_ptr_array(size) \
Packit f00812
	allocate_array(size, sizeof(char *))
Packit f00812
Packit f00812
#define allocate_dfaacc_union(size) \
Packit f00812
	allocate_array(size, sizeof(union dfaacc_union))
Packit f00812
Packit f00812
#define reallocate_int_ptr_array(array,size) \
Packit f00812
	reallocate_array((void *) array, size, sizeof(int *))
Packit f00812
Packit f00812
#define reallocate_char_ptr_array(array,size) \
Packit f00812
	reallocate_array((void *) array, size, sizeof(char *))
Packit f00812
Packit f00812
#define reallocate_dfaacc_union(array, size) \
Packit f00812
	reallocate_array((void *) array, size, sizeof(union dfaacc_union))
Packit f00812
Packit f00812
#define allocate_character_array(size) \
Packit f00812
	allocate_array( size, sizeof(char))
Packit f00812
Packit f00812
#define reallocate_character_array(array,size) \
Packit f00812
	reallocate_array((void *) array, size, sizeof(char))
Packit f00812
Packit f00812
#define allocate_Character_array(size) \
Packit f00812
	allocate_array(size, sizeof(unsigned char))
Packit f00812
Packit f00812
#define reallocate_Character_array(array,size) \
Packit f00812
	reallocate_array((void *) array, size, sizeof(unsigned char))
Packit f00812
Packit f00812
Packit f00812
/* External functions that are cross-referenced among the flex source files. */
Packit f00812
Packit f00812
Packit f00812
/* from file ccl.c */
Packit f00812
Packit f00812
extern void ccladd(int, int);	/* add a single character to a ccl */
Packit f00812
extern int cclinit(void);	/* make an empty ccl */
Packit f00812
extern void cclnegate(int);	/* negate a ccl */
Packit f00812
extern int ccl_set_diff (int a, int b); /* set difference of two ccls. */
Packit f00812
extern int ccl_set_union (int a, int b); /* set union of two ccls. */
Packit f00812
Packit f00812
/* List the members of a set of characters in CCL form. */
Packit f00812
extern void list_character_set(FILE *, int[]);
Packit f00812
Packit f00812
Packit f00812
/* from file dfa.c */
Packit f00812
Packit f00812
/* Check a DFA state for backing up. */
Packit f00812
extern void check_for_backing_up(int, int[]);
Packit f00812
Packit f00812
/* Check to see if NFA state set constitutes "dangerous" trailing context. */
Packit f00812
extern void check_trailing_context(int *, int, int *, int);
Packit f00812
Packit f00812
/* Construct the epsilon closure of a set of ndfa states. */
Packit f00812
extern int *epsclosure(int *, int *, int[], int *, int *);
Packit f00812
Packit f00812
/* Increase the maximum number of dfas. */
Packit f00812
extern void increase_max_dfas(void);
Packit f00812
Packit f00812
extern void ntod(void);	/* convert a ndfa to a dfa */
Packit f00812
Packit f00812
/* Converts a set of ndfa states into a dfa state. */
Packit f00812
extern int snstods(int[], int, int[], int, int, int *);
Packit f00812
Packit f00812
Packit f00812
/* from file ecs.c */
Packit f00812
Packit f00812
/* Convert character classes to set of equivalence classes. */
Packit f00812
extern void ccl2ecl(void);
Packit f00812
Packit f00812
/* Associate equivalence class numbers with class members. */
Packit f00812
extern int cre8ecs(int[], int[], int);
Packit f00812
Packit f00812
/* Update equivalence classes based on character class transitions. */
Packit f00812
extern void mkeccl(unsigned char[], int, int[], int[], int, int);
Packit f00812
Packit f00812
/* Create equivalence class for single character. */
Packit f00812
extern void mkechar(int, int[], int[]);
Packit f00812
Packit f00812
Packit f00812
/* from file gen.c */
Packit f00812
Packit f00812
extern void do_indent(void);	/* indent to the current level */
Packit f00812
Packit f00812
/* Generate the code to keep backing-up information. */
Packit f00812
extern void gen_backing_up(void);
Packit f00812
Packit f00812
/* Generate the code to perform the backing up. */
Packit f00812
extern void gen_bu_action(void);
Packit f00812
Packit f00812
/* Generate full speed compressed transition table. */
Packit f00812
extern void genctbl(void);
Packit f00812
Packit f00812
/* Generate the code to find the action number. */
Packit f00812
extern void gen_find_action(void);
Packit f00812
Packit f00812
extern void genftbl(void);	/* generate full transition table */
Packit f00812
Packit f00812
/* Generate the code to find the next compressed-table state. */
Packit f00812
extern void gen_next_compressed_state(char *);
Packit f00812
Packit f00812
/* Generate the code to find the next match. */
Packit f00812
extern void gen_next_match(void);
Packit f00812
Packit f00812
/* Generate the code to find the next state. */
Packit f00812
extern void gen_next_state(int);
Packit f00812
Packit f00812
/* Generate the code to make a NUL transition. */
Packit f00812
extern void gen_NUL_trans(void);
Packit f00812
Packit f00812
/* Generate the code to find the start state. */
Packit f00812
extern void gen_start_state(void);
Packit f00812
Packit f00812
/* Generate data statements for the transition tables. */
Packit f00812
extern void gentabs(void);
Packit f00812
Packit f00812
/* Write out a formatted string at the current indentation level. */
Packit f00812
extern void indent_put2s(const char *, const char *);
Packit f00812
Packit f00812
/* Write out a string + newline at the current indentation level. */
Packit f00812
extern void indent_puts(const char *);
Packit f00812
Packit f00812
extern void make_tables(void);	/* generate transition tables */
Packit f00812
Packit f00812
Packit f00812
/* from file main.c */
Packit f00812
Packit f00812
extern void check_options(void);
Packit f00812
extern void flexend(int);
Packit f00812
extern void usage(void);
Packit f00812
Packit f00812
Packit f00812
/* from file misc.c */
Packit f00812
Packit f00812
/* Add a #define to the action file. */
Packit f00812
extern void action_define(const char *defname, int value);
Packit f00812
Packit f00812
/* Add the given text to the stored actions. */
Packit f00812
extern void add_action(const char *new_text);
Packit f00812
Packit f00812
/* True if a string is all lower case. */
Packit f00812
extern int all_lower(char *);
Packit f00812
Packit f00812
/* True if a string is all upper case. */
Packit f00812
extern int all_upper(char *);
Packit f00812
Packit f00812
/* Compare two integers for use by qsort. */
Packit f00812
extern int intcmp(const void *, const void *);
Packit f00812
Packit f00812
/* Check a character to make sure it's in the expected range. */
Packit f00812
extern void check_char(int c);
Packit f00812
Packit f00812
/* Replace upper-case letter to lower-case. */
Packit f00812
extern unsigned char clower(int);
Packit f00812
Packit f00812
/* strdup() that fails fatally on allocation failures. */
Packit f00812
extern char *xstrdup(const char *);
Packit f00812
Packit f00812
/* Compare two characters for use by qsort with '\0' sorting last. */
Packit f00812
extern int cclcmp(const void *, const void *);
Packit f00812
Packit f00812
/* Finish up a block of data declarations. */
Packit f00812
extern void dataend(void);
Packit f00812
Packit f00812
/* Flush generated data statements. */
Packit f00812
extern void dataflush(void);
Packit f00812
Packit f00812
/* Report an error message and terminate. */
Packit f00812
extern void flexerror(const char *);
Packit f00812
Packit f00812
/* Report a fatal error message and terminate. */
Packit f00812
extern void flexfatal(const char *);
Packit f00812
Packit f00812
/* Report a fatal error with a pinpoint, and terminate */
Packit f00812
#if HAVE_DECL___FUNC__
Packit f00812
#define flex_die(msg) \
Packit f00812
    do{ \
Packit f00812
        fprintf (stderr,\
Packit f00812
                _("%s: fatal internal error at %s:%d (%s): %s\n"),\
Packit f00812
                program_name, __FILE__, (int)__LINE__,\
Packit f00812
                __func__,msg);\
Packit f00812
        FLEX_EXIT(1);\
Packit f00812
    }while(0)
Packit f00812
#else /* ! HAVE_DECL___FUNC__ */
Packit f00812
#define flex_die(msg) \
Packit f00812
    do{ \
Packit f00812
        fprintf (stderr,\
Packit f00812
                _("%s: fatal internal error at %s:%d %s\n"),\
Packit f00812
                program_name, __FILE__, (int)__LINE__,\
Packit f00812
                msg);\
Packit f00812
        FLEX_EXIT(1);\
Packit f00812
    }while(0)
Packit f00812
#endif /* ! HAVE_DECL___func__ */
Packit f00812
Packit f00812
/* Convert a hexadecimal digit string to an integer value. */
Packit f00812
extern int htoi(unsigned char[]);
Packit f00812
Packit f00812
/* Report an error message formatted  */
Packit f00812
extern void lerr(const char *, ...)
Packit f00812
#if defined(__GNUC__) && __GNUC__ >= 3
Packit f00812
    __attribute__((__format__(__printf__, 1, 2)))
Packit f00812
#endif
Packit f00812
;
Packit f00812
Packit f00812
/* Like lerr, but also exit after displaying message. */
Packit f00812
extern void lerr_fatal(const char *, ...)
Packit f00812
#if defined(__GNUC__) && __GNUC__ >= 3
Packit f00812
    __attribute__((__format__(__printf__, 1, 2)))
Packit f00812
#endif
Packit f00812
;
Packit f00812
Packit f00812
/* Spit out a "#line" statement. */
Packit f00812
extern void line_directive_out(FILE *, int);
Packit f00812
Packit f00812
/* Mark the current position in the action array as the end of the section 1
Packit f00812
 * user defs.
Packit f00812
 */
Packit f00812
extern void mark_defs1(void);
Packit f00812
Packit f00812
/* Mark the current position in the action array as the end of the prolog. */
Packit f00812
extern void mark_prolog(void);
Packit f00812
Packit f00812
/* Generate a data statment for a two-dimensional array. */
Packit f00812
extern void mk2data(int);
Packit f00812
Packit f00812
extern void mkdata(int);	/* generate a data statement */
Packit f00812
Packit f00812
/* Return the integer represented by a string of digits. */
Packit f00812
extern int myctoi(const char *);
Packit f00812
Packit f00812
/* Return character corresponding to escape sequence. */
Packit f00812
extern unsigned char myesc(unsigned char[]);
Packit f00812
Packit f00812
/* Convert an octal digit string to an integer value. */
Packit f00812
extern int otoi(unsigned char[]);
Packit f00812
Packit f00812
/* Output a (possibly-formatted) string to the generated scanner. */
Packit f00812
extern void out(const char *);
Packit f00812
extern void out_dec(const char *, int);
Packit f00812
extern void out_dec2(const char *, int, int);
Packit f00812
extern void out_hex(const char *, unsigned int);
Packit f00812
extern void out_str(const char *, const char *);
Packit f00812
extern void out_str3(const char *, const char *, const char *, const char *);
Packit f00812
extern void out_str_dec(const char *, const char *, int);
Packit f00812
extern void outc(int);
Packit f00812
extern void outn(const char *);
Packit f00812
extern void out_m4_define(const char* def, const char* val);
Packit f00812
Packit f00812
/* Return a printable version of the given character, which might be
Packit f00812
 * 8-bit.
Packit f00812
 */
Packit f00812
extern char *readable_form(int);
Packit f00812
Packit f00812
/* Write out one section of the skeleton file. */
Packit f00812
extern void skelout(void);
Packit f00812
Packit f00812
/* Output a yy_trans_info structure. */
Packit f00812
extern void transition_struct_out(int, int);
Packit f00812
Packit f00812
/* Only needed when using certain broken versions of bison to build parse.c. */
Packit f00812
extern void *yy_flex_xmalloc(int);
Packit f00812
Packit f00812
Packit f00812
/* from file nfa.c */
Packit f00812
Packit f00812
/* Add an accepting state to a machine. */
Packit f00812
extern void add_accept(int, int);
Packit f00812
Packit f00812
/* Make a given number of copies of a singleton machine. */
Packit f00812
extern int copysingl(int, int);
Packit f00812
Packit f00812
/* Debugging routine to write out an nfa. */
Packit f00812
extern void dumpnfa(int);
Packit f00812
Packit f00812
/* Finish up the processing for a rule. */
Packit f00812
extern void finish_rule(int, int, int, int, int);
Packit f00812
Packit f00812
/* Connect two machines together. */
Packit f00812
extern int link_machines(int, int);
Packit f00812
Packit f00812
/* Mark each "beginning" state in a machine as being a "normal" (i.e.,
Packit f00812
 * not trailing context associated) state.
Packit f00812
 */
Packit f00812
extern void mark_beginning_as_normal(int);
Packit f00812
Packit f00812
/* Make a machine that branches to two machines. */
Packit f00812
extern int mkbranch(int, int);
Packit f00812
Packit f00812
extern int mkclos(int);	/* convert a machine into a closure */
Packit f00812
extern int mkopt(int);	/* make a machine optional */
Packit f00812
Packit f00812
/* Make a machine that matches either one of two machines. */
Packit f00812
extern int mkor(int, int);
Packit f00812
Packit f00812
/* Convert a machine into a positive closure. */
Packit f00812
extern int mkposcl(int);
Packit f00812
Packit f00812
extern int mkrep(int, int, int);	/* make a replicated machine */
Packit f00812
Packit f00812
/* Create a state with a transition on a given symbol. */
Packit f00812
extern int mkstate(int);
Packit f00812
Packit f00812
extern void new_rule(void);	/* initialize for a new rule */
Packit f00812
Packit f00812
Packit f00812
/* from file parse.y */
Packit f00812
Packit f00812
/* Build the "<<EOF>>" action for the active start conditions. */
Packit f00812
extern void build_eof_action(void);
Packit f00812
Packit f00812
/* Write out a message formatted with one string, pinpointing its location. */
Packit f00812
extern void format_pinpoint_message(const char *, const char *);
Packit f00812
Packit f00812
/* Write out a message, pinpointing its location. */
Packit f00812
extern void pinpoint_message(const char *);
Packit f00812
Packit f00812
/* Write out a warning, pinpointing it at the given line. */
Packit f00812
extern void line_warning(const char *, int);
Packit f00812
Packit f00812
/* Write out a message, pinpointing it at the given line. */
Packit f00812
extern void line_pinpoint(const char *, int);
Packit f00812
Packit f00812
/* Report a formatted syntax error. */
Packit f00812
extern void format_synerr(const char *, const char *);
Packit f00812
extern void synerr(const char *);	/* report a syntax error */
Packit f00812
extern void format_warn(const char *, const char *);
Packit f00812
extern void warn(const char *);	/* report a warning */
Packit f00812
extern void yyerror(const char *);	/* report a parse error */
Packit f00812
Packit f00812
Packit f00812
/* from file scan.l */
Packit f00812
Packit f00812
/* The Flex-generated scanner for flex. */
Packit f00812
extern int flexscan(void);
Packit f00812
Packit f00812
/* Open the given file (if NULL, stdin) for scanning. */
Packit f00812
extern void set_input_file(char *);
Packit f00812
Packit f00812
Packit f00812
/* from file sym.c */
Packit f00812
Packit f00812
/* Save the text of a character class. */
Packit f00812
extern void cclinstal(char[], int);
Packit f00812
Packit f00812
/* Lookup the number associated with character class. */
Packit f00812
extern int ccllookup(char[]);
Packit f00812
Packit f00812
extern void ndinstal(const char *, char[]);	/* install a name definition */
Packit f00812
extern char *ndlookup(const char *);	/* lookup a name definition */
Packit f00812
Packit f00812
/* Increase maximum number of SC's. */
Packit f00812
extern void scextend(void);
Packit f00812
extern void scinstal(const char *, int);	/* make a start condition */
Packit f00812
Packit f00812
/* Lookup the number associated with a start condition. */
Packit f00812
extern int sclookup(const char *);
Packit f00812
Packit f00812
Packit f00812
/* from file tblcmp.c */
Packit f00812
Packit f00812
/* Build table entries for dfa state. */
Packit f00812
extern void bldtbl(int[], int, int, int, int);
Packit f00812
Packit f00812
extern void cmptmps(void);	/* compress template table entries */
Packit f00812
extern void expand_nxt_chk(void);	/* increase nxt/chk arrays */
Packit f00812
Packit f00812
/* Finds a space in the table for a state to be placed. */
Packit f00812
extern int find_table_space(int *, int);
Packit f00812
extern void inittbl(void);	/* initialize transition tables */
Packit f00812
Packit f00812
/* Make the default, "jam" table entries. */
Packit f00812
extern void mkdeftbl(void);
Packit f00812
Packit f00812
/* Create table entries for a state (or state fragment) which has
Packit f00812
 * only one out-transition.
Packit f00812
 */
Packit f00812
extern void mk1tbl(int, int, int, int);
Packit f00812
Packit f00812
/* Place a state into full speed transition table. */
Packit f00812
extern void place_state(int *, int, int);
Packit f00812
Packit f00812
/* Save states with only one out-transition to be processed later. */
Packit f00812
extern void stack1(int, int, int, int);
Packit f00812
Packit f00812
Packit f00812
/* from file yylex.c */
Packit f00812
Packit f00812
extern int yylex(void);
Packit f00812
Packit f00812
/* A growable array. See buf.c. */
Packit f00812
struct Buf {
Packit f00812
	void   *elts;		/* elements. */
Packit f00812
	int     nelts;		/* number of elements. */
Packit f00812
	size_t  elt_size;	/* in bytes. */
Packit f00812
	int     nmax;		/* max capacity of elements. */
Packit f00812
};
Packit f00812
Packit f00812
extern void buf_init(struct Buf * buf, size_t elem_size);
Packit f00812
extern void buf_destroy(struct Buf * buf);
Packit f00812
extern struct Buf *buf_append(struct Buf * buf, const void *ptr, int n_elem);
Packit f00812
extern struct Buf *buf_concat(struct Buf* dest, const struct Buf* src);
Packit f00812
extern struct Buf *buf_strappend(struct Buf *, const char *str);
Packit f00812
extern struct Buf *buf_strnappend(struct Buf *, const char *str, int nchars);
Packit f00812
extern struct Buf *buf_strdefine(struct Buf * buf, const char *str, const char *def);
Packit f00812
extern struct Buf *buf_prints(struct Buf *buf, const char *fmt, const char* s);
Packit f00812
extern struct Buf *buf_m4_define(struct Buf *buf, const char* def, const char* val);
Packit f00812
extern struct Buf *buf_m4_undefine(struct Buf *buf, const char* def);
Packit f00812
extern struct Buf *buf_print_strings(struct Buf * buf, FILE* out);
Packit f00812
extern struct Buf *buf_linedir(struct Buf *buf, const char* filename, int lineno);
Packit f00812
Packit f00812
extern struct Buf userdef_buf; /* a string buffer for #define's generated by user-options on cmd line. */
Packit f00812
extern struct Buf defs_buf;    /* a char* buffer to save #define'd some symbols generated by flex. */
Packit f00812
extern struct Buf yydmap_buf;  /* a string buffer to hold yydmap elements */
Packit f00812
extern struct Buf m4defs_buf;  /* Holds m4 definitions. */
Packit f00812
extern struct Buf top_buf;     /* contains %top code. String buffer. */
Packit f00812
Packit f00812
/* For blocking out code from the header file. */
Packit f00812
#define OUT_BEGIN_CODE() outn("m4_ifdef( [[M4_YY_IN_HEADER]],,[[")
Packit f00812
#define OUT_END_CODE()   outn("]])")
Packit f00812
Packit f00812
/* For setjmp/longjmp (instead of calling exit(2)). Linkage in main.c */
Packit f00812
extern jmp_buf flex_main_jmp_buf;
Packit f00812
Packit f00812
#define FLEX_EXIT(status) longjmp(flex_main_jmp_buf,(status)+1)
Packit f00812
Packit f00812
/* Removes all \n and \r chars from tail of str. returns str. */
Packit f00812
extern char *chomp (char *str);
Packit f00812
Packit f00812
/* ctype functions forced to return boolean */
Packit f00812
#define b_isalnum(c) (isalnum(c)?true:false)
Packit f00812
#define b_isalpha(c) (isalpha(c)?true:false)
Packit f00812
#define b_isascii(c) (isascii(c)?true:false)
Packit f00812
#define b_isblank(c) (isblank(c)?true:false)
Packit f00812
#define b_iscntrl(c) (iscntrl(c)?true:false)
Packit f00812
#define b_isdigit(c) (isdigit(c)?true:false)
Packit f00812
#define b_isgraph(c) (isgraph(c)?true:false)
Packit f00812
#define b_islower(c) (islower(c)?true:false)
Packit f00812
#define b_isprint(c) (isprint(c)?true:false)
Packit f00812
#define b_ispunct(c) (ispunct(c)?true:false)
Packit f00812
#define b_isspace(c) (isspace(c)?true:false)
Packit f00812
#define b_isupper(c) (isupper(c)?true:false)
Packit f00812
#define b_isxdigit(c) (isxdigit(c)?true:false)
Packit f00812
Packit f00812
/* return true if char is uppercase or lowercase. */
Packit f00812
bool has_case(int c);
Packit f00812
Packit f00812
/* Change case of character if possible. */
Packit f00812
int reverse_case(int c);
Packit f00812
Packit f00812
/* return false if [c1-c2] is ambiguous for a caseless scanner. */
Packit f00812
bool range_covers_case (int c1, int c2);
Packit f00812
Packit f00812
/*
Packit f00812
 *  From "filter.c"
Packit f00812
 */
Packit f00812
Packit f00812
/** A single stdio filter to execute.
Packit f00812
 *  The filter may be external, such as "sed", or it
Packit f00812
 *  may be internal, as a function call.
Packit f00812
 */
Packit f00812
struct filter {
Packit f00812
    int    (*filter_func)(struct filter*); /**< internal filter function */
Packit f00812
    void * extra;         /**< extra data passed to filter_func */
Packit f00812
	int     argc;         /**< arg count */
Packit f00812
	const char ** argv;   /**< arg vector, \0-terminated */
Packit f00812
    struct filter * next; /**< next filter or NULL */
Packit f00812
};
Packit f00812
Packit f00812
/* output filter chain */
Packit f00812
extern struct filter * output_chain;
Packit f00812
extern struct filter *filter_create_ext (struct filter * chain, const char *cmd, ...);
Packit f00812
struct filter *filter_create_int(struct filter *chain,
Packit f00812
				  int (*filter_func) (struct filter *),
Packit f00812
                  void *extra);
Packit f00812
extern bool filter_apply_chain(struct filter * chain);
Packit f00812
extern int filter_truncate(struct filter * chain, int max_len);
Packit f00812
extern int filter_tee_header(struct filter *chain);
Packit f00812
extern int filter_fix_linedirs(struct filter *chain);
Packit f00812
Packit f00812
Packit f00812
/*
Packit f00812
 * From "regex.c"
Packit f00812
 */
Packit f00812
Packit f00812
extern regex_t regex_linedir, regex_blank_line;
Packit f00812
bool flex_init_regex(void);
Packit f00812
void flex_regcomp(regex_t *preg, const char *regex, int cflags);
Packit f00812
char   *regmatch_dup (regmatch_t * m, const char *src);
Packit f00812
char   *regmatch_cpy (regmatch_t * m, char *dest, const char *src);
Packit f00812
int regmatch_len (regmatch_t * m);
Packit f00812
int regmatch_strtol (regmatch_t * m, const char *src, char **endptr, int base);
Packit f00812
bool regmatch_empty (regmatch_t * m);
Packit f00812
Packit f00812
/* From "scanflags.h" */
Packit f00812
typedef unsigned int scanflags_t;
Packit f00812
extern scanflags_t* _sf_stk;
Packit f00812
extern size_t _sf_top_ix, _sf_max; /**< stack of scanner flags. */
Packit f00812
#define _SF_CASE_INS   ((scanflags_t) 0x0001)
Packit f00812
#define _SF_DOT_ALL    ((scanflags_t) 0x0002)
Packit f00812
#define _SF_SKIP_WS    ((scanflags_t) 0x0004)
Packit f00812
#define sf_top()           (_sf_stk[_sf_top_ix])
Packit f00812
#define sf_case_ins()      (sf_top() & _SF_CASE_INS)
Packit f00812
#define sf_dot_all()       (sf_top() & _SF_DOT_ALL)
Packit f00812
#define sf_skip_ws()       (sf_top() & _SF_SKIP_WS)
Packit f00812
#define sf_set_case_ins(X)      ((X) ? (sf_top() |= _SF_CASE_INS) : (sf_top() &= ~_SF_CASE_INS))
Packit f00812
#define sf_set_dot_all(X)       ((X) ? (sf_top() |= _SF_DOT_ALL)  : (sf_top() &= ~_SF_DOT_ALL))
Packit f00812
#define sf_set_skip_ws(X)       ((X) ? (sf_top() |= _SF_SKIP_WS)  : (sf_top() &= ~_SF_SKIP_WS))
Packit f00812
extern void sf_init(void);
Packit f00812
extern void sf_push(void);
Packit f00812
extern void sf_pop(void);
Packit f00812
Packit f00812
Packit f00812
#endif /* not defined FLEXDEF_H */