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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tblcmp.c

?? C++版 詞法分析、語法分析器
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* tblcmp - table compression routines */

/*-
 * 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.
 */

#ifndef lint
static char rcsid[] =
    "@(#) $Header: c:\\program\040files\\development\\cvs\040repository/flex++/tblcmp.c,v 1.1.1.1 2002/04/13 06:01:33 Bear Exp $ (LBL)";
#endif

#include "flexdef.h"


/* declarations for functions that have forward references */

void mkentry PROTO((register int*, int, int, int, int));
void mkprot PROTO((int[], int, int));
void mktemplate PROTO((int[], int, int));
void mv2front PROTO((int));
int tbldiff PROTO((int[], int, int[]));


/* bldtbl - build table entries for dfa state
 *
 * synopsis
 *   int state[numecs], statenum, totaltrans, comstate, comfreq;
 *   bldtbl( state, statenum, totaltrans, comstate, comfreq );
 *
 * State is the statenum'th dfa state.  It is indexed by equivalence class and
 * gives the number of the state to enter for a given equivalence class.
 * totaltrans is the total number of transitions out of the state.  Comstate
 * is that state which is the destination of the most transitions out of State.
 * Comfreq is how many transitions there are out of State to Comstate.
 *
 * A note on terminology:
 *    "protos" are transition tables which have a high probability of
 * either being redundant (a state processed later will have an identical
 * transition table) or nearly redundant (a state processed later will have
 * many of the same out-transitions).  A "most recently used" queue of
 * protos is kept around with the hope that most states will find a proto
 * which is similar enough to be usable, and therefore compacting the
 * output tables.
 *    "templates" are a special type of proto.  If a transition table is
 * homogeneous or nearly homogeneous (all transitions go to the same
 * destination) then the odds are good that future states will also go
 * to the same destination state on basically the same character set.
 * These homogeneous states are so common when dealing with large rule
 * sets that they merit special attention.  If the transition table were
 * simply made into a proto, then (typically) each subsequent, similar
 * state will differ from the proto for two out-transitions.  One of these
 * out-transitions will be that character on which the proto does not go
 * to the common destination, and one will be that character on which the
 * state does not go to the common destination.  Templates, on the other
 * hand, go to the common state on EVERY transition character, and therefore
 * cost only one difference.
 */

void bldtbl( state, statenum, totaltrans, comstate, comfreq )
int state[], statenum, totaltrans, comstate, comfreq;

    {
    int extptr, extrct[2][CSIZE + 1];
    int mindiff, minprot, i, d;
    int checkcom;

    /* If extptr is 0 then the first array of extrct holds the result of the
     * "best difference" to date, which is those transitions which occur in
     * "state" but not in the proto which, to date, has the fewest differences
     * between itself and "state".  If extptr is 1 then the second array of
     * extrct hold the best difference.  The two arrays are toggled
     * between so that the best difference to date can be kept around and
     * also a difference just created by checking against a candidate "best"
     * proto.
     */

    extptr = 0;

    /* if the state has too few out-transitions, don't bother trying to
     * compact its tables
     */

    if ( (totaltrans * 100) < (numecs * PROTO_SIZE_PERCENTAGE) )
	mkentry( state, numecs, statenum, JAMSTATE, totaltrans );

    else
	{
	/* checkcom is true if we should only check "state" against
	 * protos which have the same "comstate" value
	 */

	checkcom = comfreq * 100 > totaltrans * CHECK_COM_PERCENTAGE;

	minprot = firstprot;
	mindiff = totaltrans;

	if ( checkcom )
	    {
	    /* find first proto which has the same "comstate" */
	    for ( i = firstprot; i != NIL; i = protnext[i] )
		if ( protcomst[i] == comstate )
		    {
		    minprot = i;
		    mindiff = tbldiff( state, minprot, extrct[extptr] );
		    break;
		    }
	    }

	else
	    {
	    /* since we've decided that the most common destination out
	     * of "state" does not occur with a high enough frequency,
	     * we set the "comstate" to zero, assuring that if this state
	     * is entered into the proto list, it will not be considered
	     * a template.
	     */
	    comstate = 0;

	    if ( firstprot != NIL )
		{
		minprot = firstprot;
		mindiff = tbldiff( state, minprot, extrct[extptr] );
		}
	    }

	/* we now have the first interesting proto in "minprot".  If
	 * it matches within the tolerances set for the first proto,
	 * we don't want to bother scanning the rest of the proto list
	 * to see if we have any other reasonable matches.
	 */

	if ( mindiff * 100 > totaltrans * FIRST_MATCH_DIFF_PERCENTAGE )
	    { /* not a good enough match.  Scan the rest of the protos */
	    for ( i = minprot; i != NIL; i = protnext[i] )
		{
		d = tbldiff( state, i, extrct[1 - extptr] );
		if ( d < mindiff )
		    {
		    extptr = 1 - extptr;
		    mindiff = d;
		    minprot = i;
		    }
		}
	    }

	/* check if the proto we've decided on as our best bet is close
	 * enough to the state we want to match to be usable
	 */

	if ( mindiff * 100 > totaltrans * ACCEPTABLE_DIFF_PERCENTAGE )
	    {
	    /* no good.  If the state is homogeneous enough, we make a
	     * template out of it.  Otherwise, we make a proto.
	     */

	    if ( comfreq * 100 >= totaltrans * TEMPLATE_SAME_PERCENTAGE )
		mktemplate( state, statenum, comstate );

	    else
		{
		mkprot( state, statenum, comstate );
		mkentry( state, numecs, statenum, JAMSTATE, totaltrans );
		}
	    }

	else
	    { /* use the proto */
	    mkentry( extrct[extptr], numecs, statenum,
		     prottbl[minprot], mindiff );

	    /* if this state was sufficiently different from the proto
	     * we built it from, make it, too, a proto
	     */

	    if ( mindiff * 100 >= totaltrans * NEW_PROTO_DIFF_PERCENTAGE )
		mkprot( state, statenum, comstate );

	    /* since mkprot added a new proto to the proto queue, it's possible
	     * that "minprot" is no longer on the proto queue (if it happened
	     * to have been the last entry, it would have been bumped off).
	     * If it's not there, then the new proto took its physical place
	     * (though logically the new proto is at the beginning of the
	     * queue), so in that case the following call will do nothing.
	     */

	    mv2front( minprot );
	    }
	}
    }


/* cmptmps - compress template table entries
 *
 * synopsis
 *    cmptmps();
 *
 *  template tables are compressed by using the 'template equivalence
 *  classes', which are collections of transition character equivalence
 *  classes which always appear together in templates - really meta-equivalence
 *  classes.  until this point, the tables for templates have been stored
 *  up at the top end of the nxt array; they will now be compressed and have
 *  table entries made for them.
 */

void cmptmps()

    {
    int tmpstorage[CSIZE + 1];
    register int *tmp = tmpstorage, i, j;
    int totaltrans, trans;

    peakpairs = numtemps * numecs + tblend;

    if ( usemecs )
	{
	/* create equivalence classes base on data gathered on template
	 * transitions
	 */

	nummecs = cre8ecs( tecfwd, tecbck, numecs );
	}
    
    else
	nummecs = numecs;

    if ( lastdfa + numtemps + 1 >= current_max_dfas )
	increase_max_dfas();

    /* loop through each template */

    for ( i = 1; i <= numtemps; ++i )
	{
	totaltrans = 0;	/* number of non-jam transitions out of this template */

	for ( j = 1; j <= numecs; ++j )
	    {
	    trans = tnxt[numecs * i + j];

	    if ( usemecs )
		{
		/* the absolute value of tecbck is the meta-equivalence class
		 * of a given equivalence class, as set up by cre8ecs
		 */
		if ( tecbck[j] > 0 )
		    {
		    tmp[tecbck[j]] = trans;

		    if ( trans > 0 )
			++totaltrans;
		    }
		}

	    else
		{
		tmp[j] = trans;

		if ( trans > 0 )
		    ++totaltrans;
		}
	    }

	/* it is assumed (in a rather subtle way) in the skeleton that
	 * if we're using meta-equivalence classes, the def[] entry for
	 * all templates is the jam template, i.e., templates never default
	 * to other non-jam table entries (e.g., another template)
	 */

	/* leave room for the jam-state after the last real state */
	mkentry( tmp, nummecs, lastdfa + i + 1, JAMSTATE, totaltrans );
	}
    }



/* expand_nxt_chk - expand the next check arrays */

void expand_nxt_chk()

    {
    register int old_max = current_max_xpairs;

    current_max_xpairs += MAX_XPAIRS_INCREMENT;

    ++num_reallocs;

    nxt = reallocate_integer_array( nxt, current_max_xpairs );
    chk = reallocate_integer_array( chk, current_max_xpairs );

    bzero( (char *) (chk + old_max),
	   MAX_XPAIRS_INCREMENT * sizeof( int ) / sizeof( char ) );
    }


/* find_table_space - finds a space in the table for a state to be placed
 *
 * synopsis
 *     int *state, numtrans, block_start;
 *     int find_table_space();
 *
 *     block_start = find_table_space( state, numtrans );
 *
 * State is the state to be added to the full speed transition table.
 * Numtrans is the number of out-transitions for the state.
 *
 * find_table_space() returns the position of the start of the first block (in
 * chk) able to accommodate the state
 *
 * In determining if a state will or will not fit, find_table_space() must take
 * into account the fact that an end-of-buffer state will be added at [0],
 * and an action number will be added in [-1].
 */

int find_table_space( state, numtrans )
int *state, numtrans;
    
    {
    /* firstfree is the position of the first possible occurrence of two
     * consecutive unused records in the chk and nxt arrays
     */
    register int i;
    register int *state_ptr, *chk_ptr;
    register int *ptr_to_last_entry_in_state;

    /* if there are too many out-transitions, put the state at the end of
     * nxt and chk
     */
    if ( numtrans > MAX_XTIONS_FULL_INTERIOR_FIT )
	{
	/* if table is empty, return the first available spot in chk/nxt,
	 * which should be 1
	 */
	if ( tblend < 2 )
	    return ( 1 );

	i = tblend - numecs;	/* start searching for table space near the
				 * end of chk/nxt arrays
				 */
	}

    else
	i = firstfree;		/* start searching for table space from the
				 * beginning (skipping only the elements
				 * which will definitely not hold the new
				 * state)
				 */

    while ( 1 )		/* loops until a space is found */
	{
	if ( i + numecs >= current_max_xpairs )
	    expand_nxt_chk();

	/* loops until space for end-of-buffer and action number are found */
	while ( 1 )
	    {
	    if ( chk[i - 1] == 0 )	/* check for action number space */
		{
		if ( chk[i] == 0 )	/* check for end-of-buffer space */
		    break;

		else
		    i += 2;	/* since i != 0, there is no use checking to
				 * see if (++i) - 1 == 0, because that's the
				 * same as i == 0, so we skip a space
				 */
		}

	    else
		++i;

	    if ( i + numecs >= current_max_xpairs )
		expand_nxt_chk();
	    }

	/* if we started search from the beginning, store the new firstfree for
	 * the next call of find_table_space()
	 */
	if ( numtrans <= MAX_XTIONS_FULL_INTERIOR_FIT )
	    firstfree = i + 1;

	/* check to see if all elements in chk (and therefore nxt) that are
	 * needed for the new state have not yet been taken
	 */

	state_ptr = &state[1];
	ptr_to_last_entry_in_state = &chk[i + numecs + 1];

	for ( chk_ptr = &chk[i + 1]; chk_ptr != ptr_to_last_entry_in_state;
	      ++chk_ptr )
	    if ( *(state_ptr++) != 0 && *chk_ptr != 0 )
		break;

	if ( chk_ptr == ptr_to_last_entry_in_state )
	    return ( i );

	else
	    ++i;
	}
    }


/* inittbl - initialize transition tables
 *
 * synopsis
 *   inittbl();
 *
 * Initializes "firstfree" to be one beyond the end of the table.  Initializes
 * all "chk" entries to be zero.  Note that templates are built in their
 * own tbase/tdef tables.  They are shifted down to be contiguous
 * with the non-template entries during table generation.
 */
void inittbl()

    {
    register int i;

    bzero( (char *) chk, current_max_xpairs * sizeof( int ) / sizeof( char ) );

    tblend = 0;
    firstfree = tblend + 1;
    numtemps = 0;

    if ( usemecs )
	{
	/* set up doubly-linked meta-equivalence classes
	 * these are sets of equivalence classes which all have identical
	 * transitions out of TEMPLATES
	 */

	tecbck[1] = NIL;

	for ( i = 2; i <= numecs; ++i )
	    {
	    tecbck[i] = i - 1;
	    tecfwd[i - 1] = i;
	    }

	tecfwd[numecs] = NIL;
	}
    }


/* mkdeftbl - make the default, "jam" table entries

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人动漫在线观看| 成人美女在线观看| 五月天视频一区| 亚洲午夜一区二区三区| 亚洲图片欧美一区| 婷婷中文字幕一区三区| 婷婷中文字幕一区三区| 日韩激情一二三区| 首页国产丝袜综合| 免费高清成人在线| 麻豆成人免费电影| 韩国午夜理伦三级不卡影院| 激情久久久久久久久久久久久久久久| 久久99最新地址| 国产资源精品在线观看| 国产成人av电影在线播放| 成人丝袜18视频在线观看| 成人国产亚洲欧美成人综合网| 99久久综合精品| 色婷婷久久综合| 3d动漫精品啪啪1区2区免费 | 国产亚洲视频系列| 日本一区二区电影| 1000部国产精品成人观看| 亚洲欧美日韩电影| 婷婷久久综合九色国产成人| 蜜桃一区二区三区四区| 国产酒店精品激情| 99久久婷婷国产综合精品电影 | 日韩欧美成人一区二区| 欧美变态口味重另类| 日本一区二区三级电影在线观看| 中文字幕一区二区在线播放| 一区二区国产视频| 奇米777欧美一区二区| 国产一区在线不卡| 91在线观看污| 51精品秘密在线观看| 国产午夜精品久久久久久免费视| 国产精品久久久久久久久免费樱桃 | 国产传媒欧美日韩成人| 91蜜桃在线免费视频| 欧美一区二区在线看| 亚洲国产电影在线观看| 亚洲一级在线观看| 国产美女精品一区二区三区| 99久免费精品视频在线观看| 欧美一级高清大全免费观看| 国产精品污网站| 图片区小说区国产精品视频| 国产麻豆视频一区| 欧美系列日韩一区| 久久综合五月天婷婷伊人| 亚洲欧美日韩国产手机在线 | 国产成人三级在线观看| 欧美视频一二三区| 久久久99精品免费观看| 亚洲一区二区三区不卡国产欧美| 激情偷乱视频一区二区三区| 色嗨嗨av一区二区三区| 337p日本欧洲亚洲大胆精品| 亚洲色图欧美偷拍| 国产精品综合av一区二区国产馆| 91福利视频网站| 久久久精品中文字幕麻豆发布| 亚洲男人的天堂av| 欧美日韩一本到| www久久精品| 亚洲gay无套男同| 91免费看片在线观看| 精品国产第一区二区三区观看体验| 亚洲女人小视频在线观看| 国内精品伊人久久久久影院对白| 欧美性生活一区| 国产网站一区二区| 麻豆成人久久精品二区三区小说| 91成人免费网站| 国产精品毛片高清在线完整版 | 在线观看不卡视频| 欧美激情自拍偷拍| 久久爱www久久做| 欧美人与禽zozo性伦| 亚洲情趣在线观看| 国产精品一区二区久久精品爱涩 | 久久亚洲私人国产精品va媚药| 亚洲一二三四在线观看| av一区二区三区| 国产三级欧美三级| 蜜臀av一区二区在线免费观看 | 日韩一区二区免费视频| 亚洲综合免费观看高清完整版在线 | 久久久www成人免费毛片麻豆| 五月婷婷综合网| 在线观看三级视频欧美| 亚洲欧美自拍偷拍| caoporn国产一区二区| 欧美激情在线看| 国产一区二区三区在线观看精品| 日韩视频一区在线观看| 日韩精品一级中文字幕精品视频免费观看 | 日韩一区二区免费在线电影 | 欧美色手机在线观看| 亚洲色图视频网| 91蝌蚪porny九色| 综合网在线视频| 91首页免费视频| 亚洲欧美综合在线精品| 91亚洲国产成人精品一区二区三 | 国产在线精品免费av| 欧美成人精品1314www| 久久精品久久精品| 精品人伦一区二区色婷婷| 久久不见久久见免费视频1| xnxx国产精品| 国产精品小仙女| 国产精品嫩草99a| 92精品国产成人观看免费| 亚洲欧美影音先锋| 色女孩综合影院| 亚洲成人福利片| 日韩视频一区二区在线观看| 国产在线精品一区二区夜色 | 亚洲欧美日韩在线不卡| 在线观看视频91| 秋霞午夜av一区二区三区| 精品久久久久久久一区二区蜜臀| 国内偷窥港台综合视频在线播放| 国产欧美日韩另类视频免费观看| 丁香天五香天堂综合| 最新不卡av在线| 欧美伦理电影网| 九九精品视频在线看| 国产精品久久久一本精品| 91毛片在线观看| 石原莉奈在线亚洲二区| 欧美精品一区二区三| 成人免费毛片高清视频| 一区二区免费视频| 日韩精品在线网站| 成人精品免费视频| 亚洲五月六月丁香激情| 精品国内二区三区| 99久久99久久精品国产片果冻| 一区二区三区不卡视频在线观看| 91精品麻豆日日躁夜夜躁| 国产精品一区二区在线观看网站| 国产精品麻豆视频| 欧美视频精品在线观看| 韩国毛片一区二区三区| 亚洲精品一二三区| 日韩一级二级三级| 99麻豆久久久国产精品免费优播| 日韩在线卡一卡二| 国产精品久久久久一区二区三区 | 99久久综合狠狠综合久久| 亚洲国产精品久久久久秋霞影院 | 亚洲欧洲日韩综合一区二区| 欧美日韩国产另类一区| 国产东北露脸精品视频| 亚洲高清久久久| 中文无字幕一区二区三区| 欧美日本国产视频| 成人高清视频在线观看| 日韩成人免费看| 亚洲男同性视频| 久久久.com| 4hu四虎永久在线影院成人| 成人精品一区二区三区四区| 日韩中文字幕不卡| 综合电影一区二区三区| 精品国产污污免费网站入口| 色狠狠色狠狠综合| 成人一区二区三区中文字幕| 婷婷丁香久久五月婷婷| 中文字幕一区二区三中文字幕| 欧美zozo另类异族| 欧美电影影音先锋| 91亚洲精品久久久蜜桃网站| 国产激情视频一区二区三区欧美| 亚洲国产日产av| 中文字幕一区二区三| 久久久亚洲午夜电影| 91麻豆精品久久久久蜜臀| 91视频国产资源| 国产成人av影院| 久久国产生活片100| 亚洲bt欧美bt精品| 一区二区三区国产精华| 国产精品国产三级国产aⅴ入口| 精品久久久久久最新网址| 欧美乱熟臀69xxxxxx| 在线观看日产精品| 91免费在线视频观看| 福利电影一区二区| 激情av综合网| 激情综合色综合久久| 免费国产亚洲视频| 日日摸夜夜添夜夜添精品视频 | 91蜜桃网址入口| 9久草视频在线视频精品|