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

📄 flexdef.h

📁 C++版 词法分析、语法分析器
💻 H
📖 第 1 页 / 共 3 页
字号:
/* flexdef - definitions file for flex */

/*-
 * Copyright (c) 1990 The Regents of the University of California.
 * All rights reserved.
 *
 * This code is derived from software contributed to Berkeley by
 * Vern Paxson.
 * 
 * The United States Government has rights in this work pursuant
 * to contract no. DE-AC03-76SF00098 between the United States
 * Department of Energy and the University of California.
 *
 * Redistribution and use in source and binary forms are permitted provided
 * that: (1) source distributions retain this entire copyright notice and
 * comment, and (2) distributions including binaries display the following
 * acknowledgement:  ``This product includes software developed by the
 * University of California, Berkeley and its contributors'' in the
 * documentation or other materials provided with the distribution and in
 * all advertising materials mentioning features or use of this software.
 * Neither the name of the University nor the names of its contributors may
 * be used to endorse or promote products derived from this software without
 * specific prior written permission.
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

/* @(#) $Header: c:\\program\040files\\development\\cvs\040repository/flex++/flexdef.h,v 1.2 2002/04/13 18:34:29 Bear Exp $ (LBL) */

#ifdef	WIN32
	#include <Windows.h>
#endif

#ifndef FILE
#include <stdio.h>
#endif

/* always be prepared to generate an 8-bit scanner */
#define FLEX_8_BIT_CHARS

#ifdef FLEX_8_BIT_CHARS
#define CSIZE 256
#define Char unsigned char
#else
#define Char char
#define CSIZE 128
#endif

/* size of input alphabet - should be size of ASCII set */
#ifndef DEFAULT_CSIZE
#define DEFAULT_CSIZE 128
#endif

#ifndef PROTO
#ifdef __STDC__
#define PROTO(proto) proto
#else
#define PROTO(proto) ()
#endif
#endif

#ifndef MS_DOS
#ifdef  MSDOS
#define MS_DOS
#else
#ifdef _MSDOS
#define MS_DOS
#endif
#endif
#endif

#ifdef USG
#define SYS_V
#endif

#ifdef MS_DOS
/* read' : unresolved external  */
/* #define fileno _fileno' : unresolved external */
#include <io.h>
#include <string.h>
#define mktemp _mktemp
#define unlink remove
#define read _read
#define fileno _fileno
#else
/* The Unix kernel calls used here */
extern int read PROTO((int, char*, int));
extern int unlink PROTO((char*));
extern int write PROTO((int, char*, int));
#endif

#ifdef SYS_V
	#include <string.h>
#elif WIN32
	#include <string.h>
	#include <math.h>
	#include <process.h>
	#include <malloc.h>
	#define __STDC__ 1
#else
	#ifndef _MSDOS
		#include <strings.h>
	#endif /* end _MSDOS */
	#ifdef lint
		char *sprintf(); /* keep lint happy */
	#endif
	#ifdef SCO_UNIX
		void *memset();
	#else
		#if defined(ATARI) || defined(TURBO)
			char *memset();
		#endif
	#endif
#endif

#ifdef ATARI
#define SYS_V
#define abs(x) ((x) < 0 ? -(x) : (x))
#define SHORT_FILE_NAMES
#ifdef TURBO
#define SHORT_EXTERNAL_NAMES
#endif
#endif

#ifdef AMIGA
#define bzero(s, n) setmem((char *)(s), n, '\0')
#ifndef abs
#define abs(x) ((x) < 0 ? -(x) : (x))
#endif
#else
#define bzero(s, n) (void) memset((char *)(s), '\0', n)
#endif

#ifdef VMS
#define unlink delete
#define SHORT_FILE_NAMES
#endif

#ifdef __STDC__

#ifdef __GNUC__
#include <stddef.h>
void *malloc( size_t );
void free( void* );
#else
#include <stdlib.h>
#endif

#else   /* ! __STDC__ */
char *malloc(), *realloc();
#endif


/* maximum line length we'll have to deal with */
#define MAXLINE BUFSIZ

/* maximum size of file name */
#define FILENAMESIZE 1024

#ifndef min
#define min(x,y) ((x) < (y) ? (x) : (y))
#endif
#ifndef max
#define max(x,y) ((x) > (y) ? (x) : (y))
#endif

#ifdef MS_DOS
#ifndef abs
#define abs(x) ((x) < 0 ? -(x) : (x))
#endif
#define SHORT_FILE_NAMES
#endif

#define true 1
#define false 0


#ifndef DEFAULT_SKELETON_FILE
#define DEFAULT_SKELETON_FILE "flexskel.cc"
#endif
#ifndef DEFAULT_SKELETONHEADER_FILE
#define DEFAULT_SKELETONHEADER_FILE "flexskel.h"
#endif

#ifdef SHORT_EXTERNAL_NAMES
/* avoid long external names that are ambiguous within the first 8 characters */
#define current_mns                 c__mns
#define current_max_rules           c__max_rules
#define current_max_state_type      c__max_state_type
#define current_max_scs             c__max_scs
#define current_max_dfa_size        c__max__size
#define current_max_xpairs          c__max_xpairs
#define current_max_template_xpairs c__max_template_xpairs
#define current_max_dfas            c__max_dfas
#define current_maxccls             c__maxccles
#define current_max_ccl_tbl_size    c__max_ccl_tbl_size
#define indent_puts                 ind_puts
#define indent_put2s                ind_put2s
#define gen_next_compressed_state   gen_n_comressed_state
#define gen_next_match              gen_n_match
#define gen_next_state              gen_n_state
#define variable_trailing_context_rules  var_tr_context_rules
#define variable_trailing_rule           var_tr_rule
#define backtrack_report            backtr_report
#define backtrack_file              backtr_file
#define skelheaderfilename          sk_hfname
#define skelheaderfile      sk_hf
#endif


/* special chk[] values marking the slots taking by end-of-buffer and action
 * numbers
 */
#define EOB_POSITION -1
#define ACTION_POSITION -2

/* number of data items per line for -f output */
#define NUMDATAITEMS 10

/* number of lines of data in -f output before inserting a blank line for
 * readability.
 */
#define NUMDATALINES 10

/* transition_struct_out() definitions */
#define TRANS_STRUCT_PRINT_LENGTH 15

/* returns true if an nfa state has an epsilon out-transition slot
 * that can be used.  This definition is currently not used.
 */
#define FREE_EPSILON(state) \
	(transchar[state] == SYM_EPSILON && \
	 trans2[state] == NO_TRANSITION && \
	 finalst[state] != state)

/* returns true if an nfa state has an epsilon out-transition character
 * and both slots are free
 */
#define SUPER_FREE_EPSILON(state) \
	(transchar[state] == SYM_EPSILON && \
	 trans1[state] == NO_TRANSITION) \

/* maximum number of NFA states that can comprise a DFA state.  It's real
 * big because if there's a lot of rules, the initial state will have a
 * huge epsilon closure.
 */
#define INITIAL_MAX_DFA_SIZE 750
#define MAX_DFA_SIZE_INCREMENT 750


/* a note on the following masks.  They are used to mark accepting numbers
 * as being special.  As such, they implicitly limit the number of accepting
 * numbers (i.e., rules) because if there are too many rules the rule numbers
 * will overload the mask bits.  Fortunately, this limit is \large/ (0x2000 ==
 * 8192) so unlikely to actually cause any problems.  A check is made in
 * new_rule() to ensure that this limit is not reached.
 */

/* mask to mark a trailing context accepting number */
#define YY_TRAILING_MASK 0x2000

/* mask to mark the accepting number of the "head" of a trailing context rule */
#define YY_TRAILING_HEAD_MASK 0x4000

/* maximum number of rules, as outlined in the above note */
#define MAX_RULE (YY_TRAILING_MASK - 1)


/* NIL must be 0.  If not, its special meaning when making equivalence classes
 * (it marks the representative of a given e.c.) will be unidentifiable
 */
#define NIL 0

#define JAM -1  /* to mark a missing DFA transition */
#define NO_TRANSITION NIL
#define UNIQUE -1       /* marks a symbol as an e.c. representative */
#define INFINITY -1     /* for x{5,} constructions */

#define INITIAL_MAX_CCLS 100    /* max number of unique character classes */
#define MAX_CCLS_INCREMENT 100

/* size of table holding members of character classes */
#define INITIAL_MAX_CCL_TBL_SIZE 500
#define MAX_CCL_TBL_SIZE_INCREMENT 250

#define INITIAL_MAX_RULES 100   /* default maximum number of rules */
#define MAX_RULES_INCREMENT 100

#define INITIAL_MNS 2000        /* default maximum number of nfa states */
#define MNS_INCREMENT 1000      /* amount to bump above by if it's not enough */

#define INITIAL_MAX_DFAS 1000   /* default maximum number of dfa states */
#define MAX_DFAS_INCREMENT 1000

#define JAMSTATE -32766 /* marks a reference to the state that always jams */

/* enough so that if it's subtracted from an NFA state number, the result
 * is guaranteed to be negative
 */
#define MARKER_DIFFERENCE 32000
#define MAXIMUM_MNS 31999

/* maximum number of nxt/chk pairs for non-templates */
#define INITIAL_MAX_XPAIRS 2000
#define MAX_XPAIRS_INCREMENT 2000

/* maximum number of nxt/chk pairs needed for templates */
#define INITIAL_MAX_TEMPLATE_XPAIRS 2500
#define MAX_TEMPLATE_XPAIRS_INCREMENT 2500

#define SYM_EPSILON (CSIZE + 1) /* to mark transitions on the symbol epsilon */

#define INITIAL_MAX_SCS 40      /* maximum number of start conditions */
#define MAX_SCS_INCREMENT 40    /* amount to bump by if it's not enough */

#define ONE_STACK_SIZE 500      /* stack of states with only one out-transition */
#define SAME_TRANS -1   /* transition is the same as "default" entry for state */

/* the following percentages are used to tune table compression:

⌨️ 快捷键说明

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