亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? yystate.c

?? its about compiler for LL1 and LR
?? C
?? 第 1 頁(yè) / 共 4 頁(yè)
字號(hào):
/*@A (C) 1992 Allen I. Holub                                                */
  /* YYSTATE.C	Routines to manufacture the lr(1) state table.  */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tools/debug.h>
#include <tools/set.h>
#include <tools/hash.h>
#include <tools/compiler.h>
#include <tools/l.h>
#include "parser.h"
#include "llout.h"			/* For _EOI_ definition */

/*----------------------------------------------------------------------*/
					/* For statistics only:		     */
PRIVATE int	Nitems		= 0;	/* number of LR(1) items	     */
PRIVATE int	Npairs		= 0;	/* # of pairs in output tables	     */
PRIVATE int	Ntab_entries	= 0;	/* number of transitions in tables    */
PRIVATE int	Shift_reduce    = 0;	/* number of shift/reduce conflicts  */
PRIVATE int	Reduce_reduce   = 0;	/* number of reduce/reduce conflicts */

#define MAXSTATE   512    /* Max # of LALR(1) states.			*/
#define MAXOBUF	   256    /* Buffer size for various output routines	*/

/*----------------------------------------------------------------------*/

typedef struct _item_		    /* LR(1) item:		   	      */
{
   int		 prod_num;	    /* production number 		      */
   PRODUCTION 	 *prod;		    /* the production itself 		      */
   SYMBOL	 *right_of_dot;     /* symbol to the right of the dot	      */
   unsigned char dot_posn;	    /* offset of dot from start of production */
   SET		 *lookaheads;	    /* set of lookahead symbols for this item */

} ITEM;


#define RIGHT_OF_DOT(p) ( (p)->right_of_dot ? (p)->right_of_dot->val : 0 )

#define MAXKERNEL  32	/* Maximum number of kernel items in a state.	      */
#define MAXCLOSE   128	/* Maximum number of closure items in a state (less   */
			/* the epsilon productions).			      */
#define MAXEPSILON 8	/* Maximum number of epsilon productions that can be  */
			/* in a closure set for any given state.	      */

typedef short STATENUM;


typedef struct _state_			/* LR(1) state			    */
{
   ITEM	 *kernel_items  [MAXKERNEL ];	/* Set of kernel items.		    */
   ITEM	 *epsilon_items [MAXEPSILON];	/* Set of epsilon items.	    */

   unsigned nkitems  : 7 ;		/* # items in kernel_items[].	    */
   unsigned neitems  : 7 ;		/* # items in epsilon_items[].	    */
   unsigned closed   : 1 ;		/* State has had closure performed. */

   STATENUM num;			/* State number (0 is start state). */

} STATE;


typedef struct act_or_goto
{
    int	sym;			/* Given this input symbol, 		   */
    int do_this;		/* do this. >0 == shift, <0 == reduce 	   */
    struct act_or_goto *next;	/* Pointer to next ACT in the linked list. */

} ACT;

typedef ACT GOTO;		/* GOTO is an alias for ACT */

PRIVATE ACT *Actions[MAXSTATE];	/* Array of pointers to the head of the action
			         * chains. Indexed by state number.
			 	 * I'm counting on initialization to NULL here.
			         */
PRIVATE GOTO *Gotos[MAXSTATE]; 	/* Array of pointers to the head of the goto
			 	 * chains.
			 	 */
#define CHUNK	   128		 /* New() gets this many structures at once */
PRIVATE HASH_TAB *States      = NULL;	/* LR(1) states 		 */
PRIVATE int	 Nstates      = 0;	/* Number of states.	 	 */

#define MAX_UNFINISHED	128

typedef struct tnode
{
    STATE	 *state;
    struct tnode *left, *right;

} TNODE;


PRIVATE TNODE	Heap[ MAX_UNFINISHED ]; /* Source of all TNODEs		  */
PRIVATE TNODE	*Next_allocate = Heap ; /* Ptr to next node to allocate   */

PRIVATE TNODE	 *Available  = NULL;	/* Free list of available nodes   */
					/* linked list of TNODES. p->left */
					/* is used as the link.		  */
PRIVATE TNODE	 *Unfinished = NULL;	/* Tree of unfinished states.	  */

PRIVATE ITEM	**State_items;		/* Used to pass info to state_cmp */
PRIVATE int	State_nitems;		/* 		"		  */
PRIVATE int	Sort_by_number = 0;	/*		"		  */

#define NEW	 0			/* Possible return values from 	  */
#define UNCLOSED 1			/* newstate().			  */
#define CLOSED	 2

ITEM	*Recycled_items = NULL;

#define MAX_TOK_PER_LINE  10
PRIVATE int Tokens_printed;	/* Controls number of lookaheads printed */
				/* on a single line of yyout.doc.	 */
#ifdef DEBUG
#ifdef __TURBOC__
#pragma warn -use
#endif
PRIVATE char *strprod       P((PRODUCTION *prod				     ));
#endif
void	add_action	  P(( int state, int input_sym, int do_this	     ));
void	add_goto	  P(( int state, int nonterminal, int go_here	     ));
int	add_lookahead	  P(( SET *dst, SET *src			     ));
void	addreductions	  P(( STATE *state, void *junk			     ));
void	add_unfinished	  P(( STATE *state				     ));
int	closure		  P(( STATE *kernel, ITEM **closure_items, \
					     int maxitems		     ));
int	do_close	  P(( ITEM *item,    ITEM **closure_items, \
					     int *nitems, int *maxitems	     ));
void	freeitem	  P(( ITEM *item				     ));
void	free_recycled_items P(( void 					     ));
STATE	*get_unfinished	  P(( void					     ));
ITEM	*in_closure_items P(( PRODUCTION *production, ITEM **closure_item, \
								int nitems   ));
int	item_cmp	  P(( ITEM **item1p, ITEM **item2p		     ));
int	kclosure	  P(( STATE *kernel, ITEM **closure_items,  \
					     int maxitems, int nclose	     ));
int	lr		  P(( STATE *cur_state				     ));
void	make_yy_lhs	  P(( PRODUCTION **prodtab			     ));
void	make_yy_reduce	  P(( PRODUCTION **prodtab			     ));
void	make_yy_slhs	  P(( PRODUCTION **prodtab			     ));
void	make_yy_srhs	  P(( PRODUCTION **prodtab			     ));
int	merge_lookaheads  P(( ITEM **dst_items, ITEM **src_items, int nitems ));
void	mkprod		  P(( SYMBOL *sym, PRODUCTION **prodtab		     ));
void	movedot		  P(( ITEM *item				     ));
int	move_eps	  P(( STATE *cur_state, ITEM **closure_items, \
						int nclose		     ));
MS  ( void *new )
UNIX( ACT  *new )  	  P(( void 					     ));
ITEM	*newitem	  P(( PRODUCTION *production			     ));
int	newstate	  P(( ITEM **items, int nitems, STATE **statep	     ));
ACT	*p_action	  P(( int state, int input_sym			     ));
void	pclosure	  P(( STATE *kernel, ITEM **closure_items, int nitems));
GOTO	*p_goto		  P(( int state, int nonterminal		     ));
void	print_reductions  P(( void					     ));
void	print_tab	  P(( ACT **table, char *row_name, char *col_name, \
							   int  private      ));
void	 pstate		  P(( STATE *state				     ));
void	 pstate_stdout	  P(( STATE *state				     ));
void	 reduce_one_item  P(( STATE *state, ITEM *item			     ));
void	 reductions	  P(( void					     ));
void	 sprint_tok	  P(( char **bp,     char *format, int arg	     ));
int	 state_cmp	  P(( STATE *new, STATE *tab_node		     ));
unsigned state_hash	  P(( STATE *sym				     ));
char	 *stritem	  P(( ITEM *item,    int lookaheads		     ));


void	lr_stats	  P(( FILE *fp ));			/* public */
int	lr_conflicts	  P(( FILE *fp ));
void	make_parse_tables P(( void     ));


  ANSI( PRIVATE void	*new( void ) )
  KnR ( PRIVATE ACT	*new() 	     )

{
    /* Return an area of memory that can be used as either an ACT or GOTO.
     * These objects cannot be freed.
     */

    static ACT  *eheap;	/* Assuming default initialization to NULL here */
    static ACT	*heap ; /* Ditto.					*/

    if( heap >= eheap )	   /* The > is cheap insurance, == is sufficient */
    {
	if( !(heap = (ACT *) malloc( sizeof(ACT) * CHUNK) ))
	    error( FATAL, "No memory for action or goto\n" );

	eheap = heap + CHUNK ;
    }
    ++Ntab_entries ;
    return heap++  ;
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

PRIVATE ACT	*p_action( state, input_sym )
int state, input_sym;
{
    /* Return a pointer to the existing ACT structure representing the indicated
     * state and input symbol (or NULL if no such symbol exists).
     */

    ACT	*p;

    D( if( state > MAXSTATE )  						)
    D(    error(FATAL, "bad state argument to p_action (%d)\n", state);	)

    for( p = Actions[state]; p ; p = p->next )
	if( p->sym == input_sym )
	    return p;

    return NULL;
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

PRIVATE void	add_action( state, input_sym, do_this )
int state, input_sym, do_this;
{
    /* Add an element to the action part of the parse table. The cell is
     * indexed by the state number and input symbol, and holds do_this.
     */

    ACT	*p;

#ifdef INTERNAL
     if( state > MAXSTATE )
         error(FATAL, "bad state argument to add_action (%d)\n", state );

      if( (p = p_action(state, input_sym)) )
      {
  	error( FATAL,   "Tried to add duplicate action in state %d:\n"
  			"   (1) shift/reduce %d on %s <-existing\n"
  			"   (2) shift/reduce %d on %s <-new\n" ,
  			state, p->do_this, Terms[  p->sym ]->name,
  				  do_this, Terms[input_sym]->name );
     }
#endif

    if( Verbose > 1 )
	printf("Adding shift or reduce action from state %d:  %d on %s\n",
				      state, do_this, Terms[ input_sym ]->name);
    p		   = (ACT *) new();
    p->sym         = input_sym ;
    p->do_this     = do_this ;
    p->next        = Actions[state];
    Actions[state] = p;
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

PRIVATE GOTO	*p_goto( state, nonterminal )
int state, nonterminal;
{
    /* Return a pointer to the existing GOTO structure representing the
     * indicated state and nonterminal (or NULL if no such symbol exists). The
     * value used for the nonterminal is the one in the symbol table; it is
     * adjusted down (so that the smallest nonterminal has the value 0)
     * before doing the table look up, however.
     */

    GOTO   *p;

    nonterminal = ADJ_VAL( nonterminal );

    D( if( nonterminal > NUMNONTERMS ) 			)
    D(    error(FATAL, "bad argument to p_goto\n");	)

    for( p = Gotos[ state ] ; p ; p = p->next )
	if( p->sym == nonterminal )
	    return p;

    return NULL;
}

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

PRIVATE void	add_goto( state, nonterminal, go_here )
int	state, nonterminal, go_here;
{
    /* Add an element to the goto part of the parse table, the cell is indexed
     * by current state number and nonterminal value, and holds go_here. Note
     * that the input nonterminal value is the one that appears in the symbol
     * table. It is adjusted downwards (so that the smallest nonterminal will
     * have the value 0) before being inserted into the table, however.
     */

    GOTO	*p;
    int		unadjusted;		/* Original value of nonterminal   */

    unadjusted  = nonterminal;
    nonterminal = ADJ_VAL( nonterminal );

#ifdef INTERNAL
      if( nonterminal > NUMNONTERMS )
          error(FATAL, "bad argument to add_goto\n");

      if( p = p_goto( state, unadjusted) )
          error(  FATAL,  "Tried to add duplicate goto on nonterminal %s\n"
      			"   (1) goto %3d from %3d <-existing\n"
      			"   (2) goto %3d from %3d <-new\n" ,
  			Terms[unadjusted]->name ,
  			p->go_here, p->state,
  			   go_here,    state );
#endif


    if( Verbose > 1 )
	    printf( "Adding goto from state %d to %d on %s\n",
				      state, go_here, Terms[unadjusted]->name );
    p            = (GOTO *) new();
    p->sym       = nonterminal;
    p->do_this   = go_here;
    p->next      = Gotos[state];
    Gotos[state] = p;
}

PRIVATE int	newstate( items, nitems, statep )
ITEM	**items;
int	nitems;
STATE	**statep;
{
    STATE  *state;
    STATE  *existing;
    int	   state_cmp() ;

    if( nitems > MAXKERNEL )
	error( FATAL, "Kernel of new state %d too large\n", Nstates );


    State_items  = items;	/* set up parameters for state_cmp */
    State_nitems = nitems;	/* and state_hash.		   */

    if( existing = (STATE *) findsym( States, NULL ) )
    {
	/* State exists; by not setting "state" to NULL, we'll recycle	*/
	/* the newly allocated state on the next call.			*/

	*statep = existing;
	if( Verbose > 1 )
	{
	    printf("Using existing state (%sclosed): ",
						existing->closed ? "" : "un" );
	    pstate_stdout( existing );
	}
	return existing->closed ? CLOSED : UNCLOSED ;
    }
    else
    {
	if( Nstates >= MAXSTATE )
	    error(FATAL, "Too many LALR(1) states\n");

	if( !(state = (STATE *) newsym(sizeof(STATE)) ))
	    error( FATAL, "Insufficient memory for states\n" );

	memcpy( state->kernel_items, items, nitems * sizeof(ITEM*) );
	state->nkitems  = nitems;
	state->neitems  = 0;
	state->closed   = 0;
	state->num 	= Nstates++ ;
	*statep 	= state;
	addsym( States, state );

	if( Verbose > 1 )
	{
	    printf("Forming new state:");
	    pstate_stdout( state );
	}

	return NEW;
    }
}

/*----------------------------------------------------------------------*/

PRIVATE void	add_unfinished( state )
STATE	*state;
{
    TNODE **parent, *root;
    int   cmp;

    parent = &Unfinished;
    root   = Unfinished;
    while( root )			/* look for the node in the tree */
    {
	if( (cmp = state->num - root->state->num) == 0 )
	    break;
	else
	{
	    parent = (cmp < 0) ? &root->left : &root->right ;
	    root   = (cmp < 0) ?  root->left :  root->right ;
	}
    }

    if( !root )				      /* Node isn't in tree.         */
    {
	if( Available )			      /* Allocate a new node and      */
	{				      /* put it into the tree.       */
	    *parent   = Available ;	      /* Use node from Available     */
	    Available = Available->left ;     /* list if possible, otherwise */
	}				      /* get the node from the Heap. */
	else
	{
	    if( Next_allocate >= &Heap[ MAX_UNFINISHED ] )
		error(FATAL, "Internal: No memory for unfinished state\n");
	    *parent = Next_allocate++;
	}

	(*parent)->state = state;		      /* initialize the node */
	(*parent)->left  = (*parent)->right = NULL;
    }

    D( printf("\nAdded state %d to unfinished tree:\n", state->num );	)
    D( prnt_unfin( Unfinished );					)
    D( printf("\n");							)
}

/*----------------------------------------------------------------------*/

PRIVATE STATE	*get_unfinished()
{
    /* Returns a pointer to the next unfinished state and deletes that
     * state from the unfinished tree. Returns NULL if the tree is empty.
     */

    TNODE	*root;
    TNODE	**parent;

    if( !Unfinished )
	return NULL;

    parent = &Unfinished;		/* find leftmost node */
    if( root = Unfinished )
    {
	while( root->left )
	{
	    parent = &root->left ;
	    root   = root->left ;
	}
    }

    *parent    = root->right ;	  	/* Unlink node from the tree	*/
    root->left = Available;	  	/* Put it into the free list	*/
    Available  = root;

    D(printf("\nReturning state %d from unfinished tree:\n",root->state->num);)
    D(prnt_unfin( Unfinished );	)
    D(printf("\n");		)

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
在线播放欧美女士性生活| 2021久久国产精品不只是精品| 成人精品视频一区二区三区| 久久精品国产在热久久| 美女诱惑一区二区| 老司机精品视频导航| 精品一二三四在线| 麻豆成人久久精品二区三区红| 青青草国产精品97视觉盛宴| 日本免费在线视频不卡一不卡二| 无码av免费一区二区三区试看| 亚洲一二三区不卡| 日韩黄色免费电影| 美国av一区二区| 国内精品国产成人| 大白屁股一区二区视频| av亚洲精华国产精华精华 | av在线不卡电影| av动漫一区二区| 91啪九色porn原创视频在线观看| 97久久超碰国产精品电影| 91麻豆视频网站| 欧美色精品在线视频| 日韩精品中文字幕一区| 国产日韩v精品一区二区| 亚洲视频免费在线| 91色九色蝌蚪| 欧美日韩国产影片| 精品日韩在线观看| 中文字幕一区在线观看视频| 一区二区三区四区在线| 欧美aaaaa成人免费观看视频| 国产一区二区三区免费观看| 95精品视频在线| 7777精品久久久大香线蕉| 久久亚区不卡日本| 亚洲色图制服丝袜| 午夜精彩视频在线观看不卡| 久久99国产精品尤物| 成人看片黄a免费看在线| 欧美日韩精品免费观看视频| 精品国产一区二区在线观看| 亚洲欧洲日韩综合一区二区| 午夜视频在线观看一区二区 | 欧美又粗又大又爽| 日韩欧美一级二级| 自拍偷拍国产精品| 偷拍一区二区三区| 国产**成人网毛片九色| 欧美电影在线免费观看| 欧美国产精品一区二区| 视频一区二区不卡| 成人av网站免费| 欧美日韩一级黄| 国产精品二三区| 蜜桃精品视频在线观看| 91亚洲精品乱码久久久久久蜜桃| 欧美一级专区免费大片| 18涩涩午夜精品.www| 精品一区二区三区av| 在线看国产一区| 国产精品女主播在线观看| 视频一区二区三区在线| 91麻豆自制传媒国产之光| 亚洲一卡二卡三卡四卡无卡久久| 国产剧情一区二区| 51精品国自产在线| 亚洲男人天堂av| 国产精品一级在线| 欧美一级黄色录像| 亚洲自拍偷拍欧美| 成人国产精品免费| 久久午夜羞羞影院免费观看| 日韩在线观看一区二区| 在线免费观看日韩欧美| 国产色产综合色产在线视频| 久久精品二区亚洲w码| 欧美日韩亚州综合| 亚洲精品成人精品456| 国产成人精品影院| 精品国产乱码久久久久久图片 | 日韩电影一区二区三区四区| 色欲综合视频天天天| 中文字幕一区二区三区蜜月| 国产91对白在线观看九色| 精品国产一区二区精华| 免费人成精品欧美精品| 欧美精品自拍偷拍| 亚洲 欧美综合在线网络| 色国产综合视频| 玉足女爽爽91| 在线这里只有精品| 亚洲精品视频在线观看网站| 色欲综合视频天天天| 亚洲精品日日夜夜| 97久久精品人人爽人人爽蜜臀 | 久久激五月天综合精品| 欧美老肥妇做.爰bbww| 亚洲一区二区三区四区在线观看| 99国产精品久| 亚洲美女电影在线| 色综合久久九月婷婷色综合| 最新久久zyz资源站| 暴力调教一区二区三区| 亚洲图片你懂的| 色综合久久久久网| 亚洲最快最全在线视频| 欧美日韩亚洲国产综合| 日本亚洲三级在线| 日韩欧美色综合| 麻豆一区二区99久久久久| 日韩无一区二区| 另类人妖一区二区av| 久久精子c满五个校花| 国产成人免费视频| 亚洲特级片在线| 欧美人与性动xxxx| 五月婷婷综合激情| 日韩午夜小视频| 精品一区二区久久久| 久久久久成人黄色影片| 成人午夜在线播放| 亚洲欧美乱综合| 欧美精品丝袜中出| 男人的天堂亚洲一区| 欧美成人一级视频| 国产成人免费视频网站| 亚洲欧美日韩人成在线播放| 在线观看视频一区二区| 日韩精品一二区| 久久久亚洲精品一区二区三区| 懂色av中文字幕一区二区三区 | 白白色亚洲国产精品| 一区二区三区中文字幕| 91麻豆精品91久久久久久清纯| 日韩成人免费看| 欧美国产成人在线| 91福利区一区二区三区| 首页亚洲欧美制服丝腿| 久久综合色综合88| 成人av小说网| 视频在线在亚洲| 国产日韩在线不卡| 99久久婷婷国产综合精品 | 成人成人成人在线视频| 亚洲欧美日韩成人高清在线一区| 欧美日韩国产免费| 国产一区二区三区四| 亚洲精品第一国产综合野| 欧美一区二区三区视频在线观看 | 日本精品裸体写真集在线观看| 首页欧美精品中文字幕| 中文字幕av一区二区三区免费看| 欧美日韩在线播| 成人性生交大片免费看视频在线| 午夜精品福利在线| 国产欧美一区二区精品性| 在线观看三级视频欧美| 国产一区二区视频在线播放| 亚洲一区二区三区四区在线| 欧美电影免费观看高清完整版在线观看 | 亚洲女人的天堂| 久久午夜电影网| 欧美日本不卡视频| 97se狠狠狠综合亚洲狠狠| 国产尤物一区二区| 午夜精品久久久久久不卡8050| 日韩一区有码在线| 久久色在线观看| 7799精品视频| 色综合 综合色| 成人aa视频在线观看| 国产在线国偷精品产拍免费yy| 亚洲一区二区欧美| 亚洲欧洲国产日韩| 国产免费成人在线视频| 日韩欧美中文一区二区| 欧美视频第二页| 成人av网在线| 国产伦精品一区二区三区视频青涩 | 人禽交欧美网站| 亚洲一二三区在线观看| 亚洲人亚洲人成电影网站色| 久久精品人人做人人爽97| 欧美大尺度电影在线| 欧美久久久久中文字幕| 在线一区二区三区四区| 99久久婷婷国产综合精品电影| 国产91富婆露脸刺激对白| 韩国女主播一区| 精品中文字幕一区二区小辣椒| 成人听书哪个软件好| 精品系列免费在线观看| 男女男精品视频| 首页欧美精品中文字幕| 亚洲大片免费看| 亚洲国产人成综合网站| 亚洲情趣在线观看| 自拍偷在线精品自拍偷无码专区| 国产欧美一区二区精品久导航|