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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? nfa.c

?? C++版 詞法分析、語法分析器
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* nfa - NFA construction 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++/nfa.c,v 1.1.1.1 2002/04/13 06:01:32 Bear Exp $ (LBL)";
#endif

#include "flexdef.h"


/* declare functions that have forward references */

int dupmachine PROTO((int));
void mkxtion PROTO((int, int));


/* add_accept - add an accepting state to a machine
 *
 * synopsis
 *
 *   add_accept( mach, accepting_number );
 *
 * accepting_number becomes mach's accepting number.
 */

void add_accept( mach, accepting_number )
int mach, accepting_number;

    {
    /* hang the accepting number off an epsilon state.  if it is associated
     * with a state that has a non-epsilon out-transition, then the state
     * will accept BEFORE it makes that transition, i.e., one character
     * too soon
     */

    if ( transchar[finalst[mach]] == SYM_EPSILON )
	accptnum[finalst[mach]] = accepting_number;

    else
	{
	int astate = mkstate( SYM_EPSILON );
	accptnum[astate] = accepting_number;
	mach = link_machines( mach, astate );
	}
    }


/* copysingl - make a given number of copies of a singleton machine
 *
 * synopsis
 *
 *   newsng = copysingl( singl, num );
 *
 *     newsng - a new singleton composed of num copies of singl
 *     singl  - a singleton machine
 *     num    - the number of copies of singl to be present in newsng
 */

int copysingl( singl, num )
int singl, num;

    {
    int copy, i;

    copy = mkstate( SYM_EPSILON );

    for ( i = 1; i <= num; ++i )
	copy = link_machines( copy, dupmachine( singl ) );

    return ( copy );
    }


/* dumpnfa - debugging routine to write out an nfa
 *
 * synopsis
 *    int state1;
 *    dumpnfa( state1 );
 */

void dumpnfa( state1 )
int state1;

    {
    int sym, tsp1, tsp2, anum, ns;

    fprintf( stderr, "\n\n********** beginning dump of nfa with start state %d\n",
	     state1 );

    /* we probably should loop starting at firstst[state1] and going to
     * lastst[state1], but they're not maintained properly when we "or"
     * all of the rules together.  So we use our knowledge that the machine
     * starts at state 1 and ends at lastnfa.
     */

    /* for ( ns = firstst[state1]; ns <= lastst[state1]; ++ns ) */
    for ( ns = 1; ns <= lastnfa; ++ns )
	{
	fprintf( stderr, "state # %4d\t", ns );

	sym = transchar[ns];
	tsp1 = trans1[ns];
	tsp2 = trans2[ns];
	anum = accptnum[ns];

	fprintf( stderr, "%3d:  %4d, %4d", sym, tsp1, tsp2 );

	if ( anum != NIL )
	    fprintf( stderr, "  [%d]", anum );

	fprintf( stderr, "\n" );
	}

    fprintf( stderr, "********** end of dump\n" );
    }


/* dupmachine - make a duplicate of a given machine
 *
 * synopsis
 *
 *   copy = dupmachine( mach );
 *
 *     copy - holds duplicate of mach
 *     mach - machine to be duplicated
 *
 * note that the copy of mach is NOT an exact duplicate; rather, all the
 * transition states values are adjusted so that the copy is self-contained,
 * as the original should have been.
 *
 * also note that the original MUST be contiguous, with its low and high
 * states accessible by the arrays firstst and lastst
 */

int dupmachine( mach )
int mach;

    {
    int i, init, state_offset;
    int state = 0;
    int last = lastst[mach];

    for ( i = firstst[mach]; i <= last; ++i )
	{
	state = mkstate( transchar[i] );

	if ( trans1[i] != NO_TRANSITION )
	    {
	    mkxtion( finalst[state], trans1[i] + state - i );

	    if ( transchar[i] == SYM_EPSILON && trans2[i] != NO_TRANSITION )
		mkxtion( finalst[state], trans2[i] + state - i );
	    }

	accptnum[state] = accptnum[i];
	}

    if ( state == 0 )
	flexfatal( "empty machine in dupmachine()" );

    state_offset = state - i + 1;

    init = mach + state_offset;
    firstst[init] = firstst[mach] + state_offset;
    finalst[init] = finalst[mach] + state_offset;
    lastst[init] = lastst[mach] + state_offset;

    return ( init );
    }


/* finish_rule - finish up the processing for a rule
 *
 * synopsis
 *
 *   finish_rule( mach, variable_trail_rule, headcnt, trailcnt );
 *
 * An accepting number is added to the given machine.  If variable_trail_rule
 * is true then the rule has trailing context and both the head and trail
 * are variable size.  Otherwise if headcnt or trailcnt is non-zero then
 * the machine recognizes a pattern with trailing context and headcnt is
 * the number of characters in the matched part of the pattern, or zero
 * if the matched part has variable length.  trailcnt is the number of
 * trailing context characters in the pattern, or zero if the trailing
 * context has variable length.
 */

void finish_rule( mach, variable_trail_rule, headcnt, trailcnt )
int mach, variable_trail_rule, headcnt, trailcnt;

    {
    add_accept( mach, num_rules );

    /* we did this in new_rule(), but it often gets the wrong
     * number because we do it before we start parsing the current rule
     */
    rule_linenum[num_rules] = linenum;

    /* if this is a continued action, then the line-number has
     * already been updated, giving us the wrong number
     */
    if ( continued_action )
	--rule_linenum[num_rules];

    fprintf( temp_action_file, "case %d:\n", num_rules );

    if ( variable_trail_rule )
	{
	rule_type[num_rules] = RULE_VARIABLE;

	if ( performance_report )
	    fprintf( stderr, "Variable trailing context rule at line %d\n",
		     rule_linenum[num_rules] );

	variable_trailing_context_rules = true;
	}

    else
	{
	rule_type[num_rules] = RULE_NORMAL;

	if ( headcnt > 0 || trailcnt > 0 )
	    {
	    /* do trailing context magic to not match the trailing characters */
	    char *scanner_cp = "yy_c_buf_p = yy_cp";
	    char *scanner_bp = "yy_bp";

	    fprintf( temp_action_file,
	"*yy_cp = yy_hold_char; /* undo effects of setting up yytext */\n" );

	    if ( headcnt > 0 )
		fprintf( temp_action_file, "%s = %s + %d;\n",
			 scanner_cp, scanner_bp, headcnt );

	    else
		fprintf( temp_action_file,
			 "%s -= %d;\n", scanner_cp, trailcnt );
	
	    fprintf( temp_action_file,
		     "YY_DO_BEFORE_ACTION; /* set up yytext again */\n" );
	    }
	}

    line_directive_out( temp_action_file );
    }


/* link_machines - connect two machines together
 *
 * synopsis
 *
 *   new = link_machines( first, last );
 *
 *     new    - a machine constructed by connecting first to last
 *     first  - the machine whose successor is to be last
 *     last   - the machine whose predecessor is to be first
 *
 * note: this routine concatenates the machine first with the machine
 *  last to produce a machine new which will pattern-match first first
 *  and then last, and will fail if either of the sub-patterns fails.
 *  FIRST is set to new by the operation.  last is unmolested.
 */

int link_machines( first, last )
int first, last;

    {
    if ( first == NIL )
	return ( last );

    else if ( last == NIL )
	return ( first );

    else
	{
	mkxtion( finalst[first], last );
	finalst[first] = finalst[last];
	lastst[first] = max( lastst[first], lastst[last] );
	firstst[first] = min( firstst[first], firstst[last] );

	return ( first );
	}
    }


/* mark_beginning_as_normal - mark each "beginning" state in a machine
 *                            as being a "normal" (i.e., not trailing context-
 *                            associated) states
 *
 * synopsis
 *
 *   mark_beginning_as_normal( mach )
 *
 *     mach - machine to mark
 *
 * The "beginning" states are the epsilon closure of the first state
 */

void mark_beginning_as_normal( mach )
register int mach;

    {
    switch ( state_type[mach] )
	{
	case STATE_NORMAL:
	    /* oh, we've already visited here */
	    return;

	case STATE_TRAILING_CONTEXT:
	    state_type[mach] = STATE_NORMAL;

	    if ( transchar[mach] == SYM_EPSILON )
		{
		if ( trans1[mach] != NO_TRANSITION )
		    mark_beginning_as_normal( trans1[mach] );

		if ( trans2[mach] != NO_TRANSITION )
		    mark_beginning_as_normal( trans2[mach] );
		}
	    break;

	default:
	    flexerror( "bad state type in mark_beginning_as_normal()" );
	    break;
	}
    }


/* mkbranch - make a machine that branches to two machines
 *
 * synopsis
 *
 *   branch = mkbranch( first, second );

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线麻豆精品观看| 日韩一二三区不卡| 国产在线观看一区二区| 日本中文在线一区| 免费欧美日韩国产三级电影| 天堂资源在线中文精品| 亚洲国产综合91精品麻豆| 亚洲精品欧美在线| 亚洲r级在线视频| 亚洲成人免费av| 午夜激情久久久| 日本伊人色综合网| 国产精品一区二区在线看| 国产精品一区一区三区| 国产成人av电影在线| 99在线视频精品| 欧美三级日韩在线| 日韩精品最新网址| 欧美精品一区在线观看| 国产精品久久久久久久久快鸭 | 欧美伊人久久久久久久久影院 | 欧美激情综合在线| 欧美国产精品一区| 国产精品久久影院| 亚洲午夜免费电影| 久久丁香综合五月国产三级网站| 韩国午夜理伦三级不卡影院| 国产91在线看| 欧美少妇一区二区| 久久―日本道色综合久久| 亚洲图片另类小说| 日韩黄色片在线观看| 国产精品2024| 五月天激情小说综合| 精品一区二区在线观看| 91蜜桃在线免费视频| 欧美欧美午夜aⅴ在线观看| 久久亚洲精品国产精品紫薇| 日韩美女视频一区二区 | 亚洲欧美二区三区| 老司机午夜精品99久久| 波多野结衣一区二区三区| 欧美一级黄色片| 亚洲精品五月天| 日本午夜一区二区| 色呦呦一区二区三区| 精品少妇一区二区三区视频免付费| 亚洲四区在线观看| 国产永久精品大片wwwapp| 在线观看亚洲成人| 亚洲国产经典视频| 国产在线不卡一区| 91精品国产一区二区三区香蕉| 亚洲欧洲精品一区二区三区| 韩国女主播一区| 在线播放中文字幕一区| 一区二区三区四区亚洲| 国产成人av一区二区三区在线| 欧美男人的天堂一二区| 亚洲欧美日韩人成在线播放| 国产一区二区三区蝌蚪| 国产精品77777| 一区二区三区四区国产精品| 国内外成人在线| 91精品国产麻豆| 亚洲午夜激情av| 91一区二区在线观看| 亚洲色图一区二区| aa级大片欧美| 18涩涩午夜精品.www| 成人精品免费看| 国产精品欧美久久久久无广告| 久久精品国产精品亚洲红杏| 51午夜精品国产| 五月婷婷色综合| 91福利国产精品| 夜夜夜精品看看| 欧美三级电影网| 午夜日韩在线电影| 日韩一级高清毛片| 精品一区免费av| 国产亚洲福利社区一区| 粉嫩绯色av一区二区在线观看| 久久久久亚洲蜜桃| 国产成人精品午夜视频免费| 国产精品久久久久影院亚瑟 | 久久精品国产亚洲aⅴ| 欧美精三区欧美精三区| 日本三级亚洲精品| 欧美成人乱码一区二区三区| 精品一区二区久久| 国产欧美日韩另类一区| 91在线播放网址| 亚洲尤物视频在线| 欧美一区在线视频| 经典三级视频一区| 中文字幕一区二区视频| 欧美日韩一卡二卡三卡| 蜜乳av一区二区三区| 国产丝袜欧美中文另类| 99精品在线观看视频| 亚洲国产综合在线| 日韩欧美亚洲国产精品字幕久久久| 国产在线播放一区| 国产精品久久毛片av大全日韩| 欧洲激情一区二区| 日韩电影免费在线观看网站| 久久久久久免费网| 91国偷自产一区二区三区成为亚洲经典 | 蜜臀a∨国产成人精品| 久久一区二区三区四区| 国产福利电影一区二区三区| 亚洲成人777| 久久综合久久久久88| 91美女在线看| 久久99精品国产麻豆婷婷洗澡| 中文字幕一区在线观看视频| 欧美肥妇毛茸茸| 处破女av一区二区| 视频一区视频二区中文| 欧美激情一区二区三区在线| 欧美调教femdomvk| 成人动漫一区二区在线| 午夜电影网一区| 国产精品第13页| 日韩一区二区三区四区五区六区| av电影天堂一区二区在线| 久久精品国产第一区二区三区| 亚洲激情自拍偷拍| 国产日本亚洲高清| 91麻豆精品国产自产在线 | 久久久精品综合| 欧美私人免费视频| 波多野结衣视频一区| 国产一区二区不卡在线| 日日骚欧美日韩| 亚洲一区二区三区不卡国产欧美| 久久九九影视网| 日韩欧美电影在线| 日韩一卡二卡三卡| 欧美亚洲动漫精品| 色妞www精品视频| 成人福利电影精品一区二区在线观看| 蜜臀av性久久久久蜜臀aⅴ四虎| 一区二区三区在线播放| 一区二区三区鲁丝不卡| 中文字幕在线一区二区三区| 久久久久久99精品| 久久久久久免费毛片精品| 日韩精品一区国产麻豆| 日韩一区二区三区三四区视频在线观看| 在线中文字幕一区二区| 色国产精品一区在线观看| 色综合天天综合网天天看片| 99久久免费视频.com| 91香蕉视频黄| 在线视频观看一区| 欧洲av在线精品| 欧美日韩一区二区在线观看| 欧美日韩国产在线播放网站| 在线精品国精品国产尤物884a| 91久久一区二区| 欧美三级中文字幕在线观看| 欧美日韩一区在线| 欧美zozo另类异族| 久久精品一区二区三区不卡牛牛| 亚洲精品一区二区三区福利| 久久久久88色偷偷免费| 国产精品女人毛片| 亚洲欧美日韩国产中文在线| 亚洲理论在线观看| 午夜私人影院久久久久| 日本亚洲一区二区| 国产一区欧美二区| 99国产精品久| 91精品国产品国语在线不卡| 久久综合成人精品亚洲另类欧美| 国产欧美在线观看一区| 中文字幕亚洲综合久久菠萝蜜| 亚洲一区二区视频在线| 日韩不卡手机在线v区| 国产精品1024久久| 色素色在线综合| 久久人人97超碰com| 亚洲码国产岛国毛片在线| 午夜精品久久久久久| 国产精品一区二区三区四区| 99免费精品在线| 精品少妇一区二区三区| 国产精品高潮呻吟| 日韩精品一二三四| 成人综合婷婷国产精品久久蜜臀 | 从欧美一区二区三区| 欧美熟乱第一页| 久久久久久久久久久黄色| 成人免费在线视频| 国产精品资源在线看| 欧美日韩免费高清一区色橹橹| 久久精品综合网| 亚洲www啪成人一区二区麻豆|