⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 flexdef.h

📁 C++版 词法分析、语法分析器
💻 H
📖 第 1 页 / 共 3 页
字号:
 * firstfree - first empty entry in "nxt/chk" table
 * dss - nfa state set for each dfa
 * dfasiz - size of nfa state set for each dfa
 * dfaacc - accepting set for each dfa state (or accepting number, if
 *    -r is not given)
 * accsiz - size of accepting set for each dfa state
 * dhash - dfa state hash value
 * numas - number of DFA accepting states created; note that this
 *    is not necessarily the same value as num_rules, which is the analogous
 *    value for the NFA
 * numsnpairs - number of state/nextstate transition pairs
 * jambase - position in base/def where the default jam table starts
 * jamstate - state number corresponding to "jam" state
 * end_of_buffer_state - end-of-buffer dfa state number
 */

extern int current_max_dfa_size, current_max_xpairs;
extern int current_max_template_xpairs, current_max_dfas;
extern int lastdfa, lasttemp, *nxt, *chk, *tnxt;
extern int *base, *def, *nultrans, NUL_ec, tblend, firstfree, **dss, *dfasiz;
extern union dfaacc_union
    {
    int *dfaacc_set;
    int dfaacc_state;
    } *dfaacc;
extern int *accsiz, *dhash, numas;
extern int numsnpairs, jambase, jamstate;
extern int end_of_buffer_state;

/* variables for ccl information:
 * lastccl - ccl index of the last created ccl
 * current_maxccls - current limit on the maximum number of unique ccl's
 * cclmap - maps a ccl index to its set pointer
 * ccllen - gives the length of a ccl
 * cclng - true for a given ccl if the ccl is negated
 * cclreuse - counts how many times a ccl is re-used
 * current_max_ccl_tbl_size - current limit on number of characters needed
 *      to represent the unique ccl's
 * ccltbl - holds the characters in each ccl - indexed by cclmap
 */

extern int lastccl, current_maxccls, *cclmap, *ccllen, *cclng, cclreuse;
extern int current_max_ccl_tbl_size;
extern Char *ccltbl;


/* variables for miscellaneous information:
 * starttime - real-time when we started
 * endtime - real-time when we ended
 * nmstr - last NAME scanned by the scanner
 * sectnum - section number currently being parsed
 * nummt - number of empty nxt/chk table entries
 * hshcol - number of hash collisions detected by snstods
 * dfaeql - number of times a newly created dfa was equal to an old one
 * numeps - number of epsilon NFA states created
 * eps2 - number of epsilon states which have 2 out-transitions
 * num_reallocs - number of times it was necessary to realloc() a group
 *                of arrays
 * tmpuses - number of DFA states that chain to templates
 * totnst - total number of NFA states used to make DFA states
 * peakpairs - peak number of transition pairs we had to store internally
 * numuniq - number of unique transitions
 * numdup - number of duplicate transitions
 * hshsave - number of hash collisions saved by checking number of states
 * num_backtracking - number of DFA states requiring back-tracking
 * bol_needed - whether scanner needs beginning-of-line recognition
 */

extern char *starttime, *endtime, nmstr[MAXLINE];
extern int sectnum, nummt, hshcol, dfaeql, numeps, eps2, num_reallocs;
extern int tmpuses, totnst, peakpairs, numuniq, numdup, hshsave;
extern int num_backtracking, bol_needed;

void *allocate_array(), *reallocate_array();

#define allocate_integer_array(size) \
	(int *) allocate_array( size, sizeof( int ) )

#define reallocate_integer_array(array,size) \
	(int *) reallocate_array( (void *) array, size, sizeof( int ) )

#define allocate_int_ptr_array(size) \
	(int **) allocate_array( size, sizeof( int * ) )

#define allocate_char_ptr_array(size) \
	(char **) allocate_array( size, sizeof( char * ) )

#define allocate_dfaacc_union(size) \
	(union dfaacc_union *) \
		allocate_array( size, sizeof( union dfaacc_union ) )

#define reallocate_int_ptr_array(array,size) \
	(int **) reallocate_array( (void *) array, size, sizeof( int * ) )

#define reallocate_char_ptr_array(array,size) \
	(char **) reallocate_array( (void *) array, size, sizeof( char * ) )

#define reallocate_dfaacc_union(array, size) \
	(union dfaacc_union *) \
	reallocate_array( (void *) array, size, sizeof( union dfaacc_union ) )

#define allocate_character_array(size) \
	(Char *) allocate_array( size, sizeof( Char ) )

#define reallocate_character_array(array,size) \
	(Char *) reallocate_array( (void *) array, size, sizeof( Char ) )


/* used to communicate between scanner and parser.  The type should really
 * be YYSTYPE, but we can't easily get our hands on it.
 */
extern int yylval;


/* external functions that are cross-referenced among the flex source files */


/* from file ccl.c */

extern void ccladd PROTO((int, int));   /* Add a single character to a ccl */
extern int cclinit PROTO(());   /* make an empty ccl */
extern void cclnegate PROTO((int));     /* negate a ccl */

/* list the members of a set of characters in CCL form */
extern void list_character_set PROTO((FILE*, int[]));


/* from file dfa.c */

/* increase the maximum number of dfas */
extern void increase_max_dfas PROTO(());

extern void ntod PROTO(());     /* convert a ndfa to a dfa */


/* from file ecs.c */

/* convert character classes to set of equivalence classes */
extern void ccl2ecl PROTO(());

/* associate equivalence class numbers with class members */
extern int cre8ecs PROTO((int[], int[], int));

/* associate equivalence class numbers using %t table */
extern int ecs_from_xlation PROTO((int[]));

/* update equivalence classes based on character class transitions */
extern void mkeccl PROTO((Char[], int, int[], int[], int, int));

/* create equivalence class for single character */
extern void mkechar PROTO((int, int[], int[]));


/* from file gen.c */

extern void make_tables PROTO(());      /* generate transition tables */


/* from file main.c */

extern void flexend PROTO((int));
/* help on flex */
extern int flexinfo();


/* from file misc.c */

/* write out the actions from the temporary file to lex.yy.c */
extern void action_out PROTO(());

/* true if a string is all lower case */
extern int all_lower PROTO((register Char *));

/* true if a string is all upper case */
extern int all_upper PROTO((register Char *));

/* bubble sort an integer array */
extern void bubble PROTO((int [], int));

/* shell sort a character array */
extern void cshell PROTO((Char [], int, int));

extern void dataend PROTO(());  /* finish up a block of data declarations */

/* report an error message and terminate */
extern void flexerror PROTO((char[]));

/* report a fatal error message and terminate */
extern void flexfatal PROTO((char[]));

/* report an error message formatted with one integer argument */
extern void lerrif PROTO((char[], int));

/* report an error message formatted with one string argument */
extern void lerrsf PROTO((char[], char[]));

/* spit out a "# line" statement */
extern void line_directive_out PROTO((FILE*));

/* generate a data statment for a two-dimensional array */
extern void mk2data PROTO((int));

extern void mkdata PROTO((int));        /* generate a data statement */

/* return the integer represented by a string of digits */
extern int myctoi PROTO((Char []));

/* write out one section of the skeleton files */
extern void any_skelout PROTO((FILE *,FILE *,int *,char *,int,int *));
extern void skelout PROTO(());
extern void header_skeleton_out PROTO(());

/* output a yy_trans_info structure */
extern void transition_struct_out PROTO((int, int));

void set_lexer_name PROTO((char *)) ; /* set lex_name and check redefine */

/* from file nfa.c */

/* add an accepting state to a machine */
extern void add_accept PROTO((int, int));

/* make a given number of copies of a singleton machine */
extern int copysingl PROTO((int, int));

/* debugging routine to write out an nfa */
extern void dumpnfa PROTO((int));

/* finish up the processing for a rule */
extern void finish_rule PROTO((int, int, int, int));

/* connect two machines together */
extern int link_machines PROTO((int, int));

/* mark each "beginning" state in a machine as being a "normal" (i.e.,
 * not trailing context associated) state
 */
extern void mark_beginning_as_normal PROTO((register int));

/* make a machine that branches to two machines */
extern int mkbranch PROTO((int, int));

extern int mkclos PROTO((int)); /* convert a machine into a closure */
extern int mkopt PROTO((int));  /* make a machine optional */

/* make a machine that matches either one of two machines */
extern int mkor PROTO((int, int));

/* convert a machine into a positive closure */
extern int mkposcl PROTO((int));

extern int mkrep PROTO((int, int, int));        /* make a replicated machine */

/* create a state with a transition on a given symbol */
extern int mkstate PROTO((int));

extern void new_rule PROTO(()); /* initialize for a new rule */


/* from file parse.y */

/* write out a message formatted with one string, pinpointing its location */
extern void format_pinpoint_message PROTO((char[], char[]));

/* write out a message, pinpointing its location */
extern void pinpoint_message PROTO((char[]));

extern void synerr PROTO((char []));    /* report a syntax error */
extern int yyparse PROTO(());   /* the YACC parser */


/* from file scan.l */

extern int flexscan PROTO(());  /* the Flex-generated scanner for flex */

/* open the given file (if NULL, stdin) for scanning */
extern void set_input_file PROTO((char*));

extern int yywrap PROTO(());    /* wrapup a file in the lexical analyzer */


/* from file sym.c */

/* save the text of a character class */
extern void cclinstal PROTO ((Char [], int));

/* lookup the number associated with character class */
extern int ccllookup PROTO((Char []));

extern void ndinstal PROTO((char[], Char[]));   /* install a name definition */
extern void scinstal PROTO((char[], int));      /* make a start condition */

/* lookup the number associated with a start condition */
extern int sclookup PROTO((char[]));


/* from file tblcmp.c */

/* build table entries for dfa state */
extern void bldtbl PROTO((int[], int, int, int, int));

extern void cmptmps PROTO(());  /* compress template table entries */
extern void inittbl PROTO(());  /* initialize transition tables */
extern void mkdeftbl PROTO(()); /* make the default, "jam" table entries */

/* create table entries for a state (or state fragment) which has
 * only one out-transition */
extern void mk1tbl PROTO((int, int, int, int));

/* place a state into full speed transition table */
extern void place_state PROTO((int*, int, int));

/* save states with only one out-transition to be processed later */
extern void stack1 PROTO((int, int, int, int));


/* from file yylex.c */

extern int yylex PROTO(());

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -