コード例 #1
0
ファイル: eval_3.c プロジェクト: hansongjing/Old-Projects
void exec(char *str)
{
	char *lhs = (char *) news(strlen(str));
	char *rhs = (char *) news(strlen(str));
	char *sptr = NULL;

	/* here the rhs & lhs are obtained */
	for(sptr=lhs;*str!='\0'&&*str!='=';str++)
	*sptr++ = *str;
	*sptr = '\0';
	if(*str=='=')
	for(sptr=rhs,str++;*str!='\0';str++) {
    *sptr++ = *str;
	*sptr = '\0'; }
	else *rhs = '\0';

	if(rhs=='\0') /* no assignment involved */
	{
		//
	}
	else
	{
		//
	}

	printf("%s\n%s",lhs,rhs);
	free(lhs);
	free(rhs);
}
コード例 #2
0
ファイル: SearchQueue.C プロジェクト: arne-cl/turian-parser
/// Add a new ParseState with its associated Cost to the queue.
void SearchQueue::add(const ParseState& state, const Cost& cost) {
    _addcnt++;

    // If this is a final state...
    if (state.is_final()) {
        StateCost news(state, cost);

        // And the new state is better than the current best state
        // FIXME: Don't switch >, < convention?
        if (_best.empty() || news > _best) {
            _best = news;
            assert(_best.is_final());
            Debug::log(3) << "Current best final cost <- " << _best.cost().to_string() << " (popped " << _popcnt << ", skipped " << _skipcnt << ")\n";
            Debug::log(3) << this->stats();
            Debug::log(3) << stats::resource_usage() << "\n";
        }
    } else {
        // If we don't have room for this state, then just return.
        if (!this->can_add(cost)) return;

        StateCost news(state, cost);

        if (!this->can_explore(news)) return;
        _q.push(news);
    }
}
コード例 #3
0
ファイル: Fl_Image.cpp プロジェクト: edeproject/efltk
Fl_Image *Fl_Image::scale(int W, int H)
{
    Fl_Image *ret = new Fl_Image(W, H, bitspp());
    ret->format()->copy(format());

    Fl_Rect olds(0,0,width(),height()); Fl_Rect news(0,0,W,H);
    bool success = Fl_Renderer::stretch(m_data, bytespp(), pitch(), &olds,
                                        ret->data(), bytespp(), ret->pitch(), &news);
    if(!success) {
        delete ret;
        ret = 0;
    }
    return ret;
}
コード例 #4
0
ファイル: tweenhi.c プロジェクト: AnimatorPro/Animator-Pro
static Errcode ld_tween(char *name, Tween_state *ts)
{
	Errcode err;
	XFILE *xf;
	Tween_file_header tfh;
	Tween_link *newl;
	long i;

	err = xffopen(name, &xf, XREADONLY);
	if (err < Success)
		return err;

	err = xffread(xf, &tfh, sizeof(tfh));
	if (err < Success)
		goto cleanup;

	if (tfh.magic != TWEEN_MAGIC) {
		err = Err_bad_magic;
		goto cleanup;
	}

	for (i = 0; i < tfh.link_count; i++) {
		err = news(newl);
		if (err < Success)
			goto cleanup;

		err = xffread(xf, &newl->start, 2*sizeof(newl->start));
		if (err < Success)
			goto cleanup;

		add_tail(&ts->links,&newl->node);
	}

	err = ld_poly(xf, &ts->p0);
	if (err < Success)
		goto cleanup;

	err = ld_poly(xf, &ts->p1);
	if (err < Success)
		goto cleanup;

cleanup:
	xffclose(&xf);
	return err;
}
コード例 #5
0
ファイル: battlestar.c プロジェクト: AhmadTux/DragonFlyBSD
int
main(int argc, char **argv)
{
	char mainbuf[LINELENGTH];
	char *next;

	/* Open the score file then revoke setgid privileges */
	open_score_file();
	setgid(getgid());

	initialize(argc < 2 || strcmp(argv[1], "-r"));
start:
	news();
	beenthere[position]++;
	if (notes[LAUNCHED])
		crash();	/* decrements fuel & crash */
	if (matchlight) {
		puts("Your match splutters out.");
		matchlight = 0;
	}
	if (!notes[CANTSEE] || testbit(inven, LAMPON) ||
	    testbit(location[position].objects, LAMPON)) {
		writedes();
		printobjs();
	} else
		puts("It's too dark to see anything in here!");
	whichway(location[position]);
run:
	next = getcom(mainbuf, sizeof mainbuf, ">-: ",
	    "Please type in something.");
	for (wordcount = 0; next && wordcount < 20; wordcount++)
		next = getword(next, words[wordcount], -1);
	parse();
	switch (cypher()) {
	case -1:
		goto run;
	case 0:
		goto start;
	default:
		exit(1); /* Shouldn't happen */
	}
	return (1);
}
コード例 #6
0
ファイル: String.cpp プロジェクト: dadaa/gecko-dev
JSFlatString*
NewStringCopyNDontDeflate(ExclusiveContext* cx, const CharT* s, size_t n)
{
    if (JSInlineString::lengthFits<CharT>(n))
        return NewInlineString<allowGC>(cx, mozilla::Range<const CharT>(s, n));

    ScopedJSFreePtr<CharT> news(cx->pod_malloc<CharT>(n + 1));
    if (!news)
        return nullptr;

    PodCopy(news.get(), s, n);
    news[n] = 0;

    JSFlatString* str = JSFlatString::new_<allowGC>(cx, news.get(), n);
    if (!str)
        return nullptr;

    news.forget();
    return str;
}
コード例 #7
0
ファイル: com1.c プロジェクト: Freeaqingme/OpenBSD
void
newlocation(void)
{
	news();
	if (beenthere[position] <= ROOMDESC)
	     beenthere[position]++;
	if (notes[LAUNCHED])
		crash();	/* decrements fuel & crash */
	if (matchlight) {
		puts("Your match splutters out.");
		matchlight = 0;
	}
	if (!notes[CANTSEE] || TestBit(inven, LAMPON) ||
	    TestBit(location[position].objects, LAMPON)) {
		writedes();
		printobjs();
	} else
		puts("It's too dark to see anything in here!");
	whichway(location[position]);
}
コード例 #8
0
ファイル: mainwindow.cpp プロジェクト: teodorxxx/test
void MainWindow::createFileActions()
{
	m_NewAction = new QAction(QIcon(":/icons/icons/new.png"), tr("&Nowy"), this);
	m_NewAction->setStatusTip(tr("Nowy plik"));
	m_NewAction->setShortcut(QKeySequence::New);
	connect (m_NewAction, SIGNAL(triggered()), this, SLOT(news()));

	m_OpenAction = new QAction(QIcon(":/icons/icons/open.png"), tr("&Otwórz"), this);
	m_OpenAction->setStatusTip(tr("Otwórz istniejący plik"));
	m_OpenAction->setShortcut(QKeySequence::Open);
	connect (m_OpenAction, SIGNAL(triggered()), this, SLOT(open()));

	m_SaveAction = new QAction(QIcon(":/icons/icons/save.png"), tr("&Zapisz"), this);
	m_SaveAction->setStatusTip(tr("Zapisz plik"));
	m_SaveAction->setShortcut(QKeySequence::Save);
	connect (m_SaveAction, SIGNAL(triggered()), this, SLOT(save()));

	m_QuitAction = new QAction(QIcon(":/icons/icons/quit.png"), tr("&Wyjście"), this);
	m_QuitAction->setStatusTip(tr("Wyjdź z programu"));
	m_QuitAction->setShortcut(Qt::CTRL + Qt::Key_Q);
	connect (m_QuitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
}
コード例 #9
0
ファイル: menu.cpp プロジェクト: opieproject/qte-opie
MenuExample::MenuExample( QWidget *parent, const char *name )
    : QWidget( parent, name )
{
    QPixmap p1( p1_xpm );
    QPixmap p2( p2_xpm );
    QPixmap p3( p3_xpm );

    QPopupMenu *print = new QPopupMenu( this );
    CHECK_PTR( print );
    print->insertTearOffHandle();
    print->insertItem( "&Print to printer", this, SLOT(printer()) );
    print->insertItem( "Print to &file", this, SLOT(file()) );
    print->insertItem( "Print to fa&x", this, SLOT(fax()) );
    print->insertSeparator();
    print->insertItem( "Printer &Setup", this, SLOT(printerSetup()) );

    QPopupMenu *file = new QPopupMenu( this );
    CHECK_PTR( file );
    file->insertItem( p1, "&Open",  this, SLOT(open()), CTRL+Key_O );
    file->insertItem( p2, "&New", this, SLOT(news()), CTRL+Key_N );
    file->insertItem( p3, "&Save", this, SLOT(save()), CTRL+Key_S );
    file->insertItem( "&Close", this, SLOT(closeDoc()), CTRL+Key_W );
    file->insertSeparator();
    file->insertItem( "&Print", print, CTRL+Key_P );
    file->insertSeparator();
    file->insertItem( "E&xit",  qApp, SLOT(quit()), CTRL+Key_Q );

    QPopupMenu *edit = new QPopupMenu( this );
    CHECK_PTR( edit );
    int undoID = edit->insertItem( "&Undo", this, SLOT(undo()) );
    int redoID = edit->insertItem( "&Redo", this, SLOT(redo()) );
    edit->setItemEnabled( undoID, FALSE );
    edit->setItemEnabled( redoID, FALSE );

    QPopupMenu* options = new QPopupMenu( this );
    CHECK_PTR( options );
    options->insertTearOffHandle();
    options->setCaption("Options");
    options->insertItem( "&Normal Font", this, SLOT(normal()) );
    options->insertSeparator();

    options->polish(); // adjust system settings
    QFont f = options->font();
    f.setBold( TRUE );
    boldID = options->insertItem( new MyMenuItem( "Bold", f ) );
    options->setAccel( CTRL+Key_B, boldID );
    options->connectItem( boldID, this, SLOT(bold()) );
    f = font();
    f.setUnderline( TRUE );
    underlineID = options->insertItem( new MyMenuItem( "Underline", f ) );
    options->setAccel( CTRL+Key_U, underlineID );
    options->connectItem( underlineID, this, SLOT(underline()) );

    isBold = FALSE;
    isUnderline = FALSE;
    options->setCheckable( TRUE );


    QPopupMenu *help = new QPopupMenu( this );
    CHECK_PTR( help );
    help->insertItem( "&About", this, SLOT(about()), CTRL+Key_H );
    help->insertItem( "About &Qt", this, SLOT(aboutQt()) );

    menu = new QMenuBar( this );
    CHECK_PTR( menu );
    menu->insertItem( "&File", file );
    menu->insertItem( "&Edit", edit );
    menu->insertItem( "&Options", options );
    menu->insertSeparator();
    menu->insertItem( "&Help", help );
    menu->setSeparator( QMenuBar::InWindowsStyle );

    label = new QLabel( this );
    CHECK_PTR( label );
    label->setGeometry( 20, rect().center().y()-20, width()-40, 40 );
    label->setFrameStyle( QFrame::Box | QFrame::Raised );
    label->setLineWidth( 1 );
    label->setAlignment( AlignCenter );

    connect( this,  SIGNAL(explain(const QString&)),
             label, SLOT(setText(const QString&)) );

    setMinimumSize( 100, 80 );
}
コード例 #10
0
ファイル: y.tab.c プロジェクト: 8l/inferno
int
yyparse(void)
{
	struct
	{
		YYSTYPE	yyv;
		int	yys;
	} yys[YYMAXDEPTH], *yyp, *yypt;
	short *yyxi;
	int yyj, yym, yystate, yyn, yyg;
	long yychar;
	YYSTYPE save1, save2;
	int save3, save4;

	save1 = yylval;
	save2 = yyval;
	save3 = yynerrs;
	save4 = yyerrflag;

	yystate = 0;
	yychar = -1;
	yynerrs = 0;
	yyerrflag = 0;
	yyp = &yys[-1];
	goto yystack;

ret0:
	yyn = 0;
	goto ret;

ret1:
	yyn = 1;
	goto ret;

ret:
	yylval = save1;
	yyval = save2;
	yynerrs = save3;
	yyerrflag = save4;
	return yyn;

yystack:
	/* put a state and value onto the stack */
	if(yydebug >= 4)
		fprint(2, "char %s in %s", yytokname(yychar), yystatname(yystate));

	yyp++;
	if(yyp >= &yys[YYMAXDEPTH]) {
		yyerror("yacc stack overflow");
		goto ret1;
	}
	yyp->yys = yystate;
	yyp->yyv = yyval;

yynewstate:
	yyn = yypact[yystate];
	if(yyn <= YYFLAG)
		goto yydefault; /* simple state */
	if(yychar < 0)
		yychar = yylex1();
	yyn += yychar;
	if(yyn < 0 || yyn >= YYLAST)
		goto yydefault;
	yyn = yyact[yyn];
	if(yychk[yyn] == yychar) { /* valid shift */
		yychar = -1;
		yyval = yylval;
		yystate = yyn;
		if(yyerrflag > 0)
			yyerrflag--;
		goto yystack;
	}

yydefault:
	/* default state action */
	yyn = yydef[yystate];
	if(yyn == -2) {
		if(yychar < 0)
			yychar = yylex1();

		/* look through exception table */
		for(yyxi=yyexca;; yyxi+=2)
			if(yyxi[0] == -1 && yyxi[1] == yystate)
				break;
		for(yyxi += 2;; yyxi += 2) {
			yyn = yyxi[0];
			if(yyn < 0 || yyn == yychar)
				break;
		}
		yyn = yyxi[1];
		if(yyn < 0)
			goto ret0;
	}
	if(yyn == 0) {
		/* error ... attempt to resume parsing */
		switch(yyerrflag) {
		case 0:   /* brand new error */
			yyerror("syntax error");
			yynerrs++;
			if(yydebug >= 1) {
				fprint(2, "%s", yystatname(yystate));
				fprint(2, "saw %s\n", yytokname(yychar));
			}

		case 1:
		case 2: /* incompletely recovered error ... try again */
			yyerrflag = 3;

			/* find a state where "error" is a legal shift action */
			while(yyp >= yys) {
				yyn = yypact[yyp->yys] + YYERRCODE;
				if(yyn >= 0 && yyn < YYLAST) {
					yystate = yyact[yyn];  /* simulate a shift of "error" */
					if(yychk[yystate] == YYERRCODE)
						goto yystack;
				}

				/* the current yyp has no shift onn "error", pop stack */
				if(yydebug >= 2)
					fprint(2, "error recovery pops state %d, uncovers %d\n",
						yyp->yys, (yyp-1)->yys );
				yyp--;
			}
			/* there is no state on the stack with an error shift ... abort */
			goto ret1;

		case 3:  /* no shift yet; clobber input char */
			if(yydebug >= 2)
				fprint(2, "error recovery discards %s\n", yytokname(yychar));
			if(yychar == YYEOFCODE)
				goto ret1;
			yychar = -1;
			goto yynewstate;   /* try again in the same state */
		}
	}

	/* reduction by production yyn */
	if(yydebug >= 2)
		fprint(2, "reduce %d in:\n\t%s", yyn, yystatname(yystate));

	yypt = yyp;
	yyp -= yyr2[yyn];
	yyval = (yyp+1)->yyv;
	yym = yyn;

	/* consult goto table to find next state */
	yyn = yyr1[yyn];
	yyg = yypgo[yyn];
	yyj = yyg + yyp->yys + 1;

	if(yyj >= YYLAST || yychk[yystate=yyact[yyj]] != -yyn)
		yystate = yyact[yyg];
	switch(yym) {
		
case 1:
#line	41	"asm.y"
{
		assem(yypt[-0].yyv.inst);
	} break;
case 2:
#line	47	"asm.y"
{ yyval.inst = nil; } break;
case 3:
#line	49	"asm.y"
{
		if(yypt[-0].yyv.inst != nil) {
			yypt[-0].yyv.inst->link = yypt[-1].yyv.inst;
			yyval.inst = yypt[-0].yyv.inst;
		}
		else
			yyval.inst = yypt[-1].yyv.inst;
	} break;
case 4:
#line	60	"asm.y"
{
		yypt[-0].yyv.inst->sym = yypt[-2].yyv.sym;
		yyval.inst = yypt[-0].yyv.inst;
	} break;
case 5:
#line	65	"asm.y"
{
		heap(yypt[-3].yyv.ival, yypt[-1].yyv.ival, yypt[-0].yyv.string);
		yyval.inst = nil;
	} break;
case 6:
#line	70	"asm.y"
{
		yyval.inst = nil;
	} break;
case 8:
#line	77	"asm.y"
{
		yyval.ival = yypt[-0].yyv.ival;
	} break;
case 9:
#line	81	"asm.y"
{
		yypt[-0].yyv.sym->value = heapid++;
		yyval.ival = yypt[-0].yyv.sym->value;
	} break;
case 10:
#line	88	"asm.y"
{ yyval.string = nil; } break;
case 11:
#line	90	"asm.y"
{
		yyval.string = yypt[-0].yyv.string;
	} break;
case 12:
#line	96	"asm.y"
{
		yyval.list = newi(yypt[-0].yyv.ival, nil);
	} break;
case 13:
#line	100	"asm.y"
{
		yyval.list = newi(yypt[-0].yyv.ival, yypt[-2].yyv.list);
	} break;
case 14:
#line	106	"asm.y"
{
		yyval.inst = ai(yypt[-3].yyv.ival);
		yyval.inst->src = yypt[-2].yyv.addr;
		yyval.inst->dst = yypt[-0].yyv.addr;
	} break;
case 15:
#line	112	"asm.y"
{
		yyval.inst = ai(yypt[-5].yyv.ival);
		yyval.inst->src = yypt[-4].yyv.addr;
		yyval.inst->reg = yypt[-2].yyv.addr;
		yyval.inst->dst = yypt[-0].yyv.addr;
	} break;
case 16:
#line	119	"asm.y"
{
		yyval.inst = ai(yypt[-3].yyv.ival);
		yyval.inst->src = yypt[-2].yyv.addr;
		yyval.inst->dst = yypt[-0].yyv.addr;
	} break;
case 17:
#line	125	"asm.y"
{
		yyval.inst = ai(yypt[-1].yyv.ival);
		yyval.inst->dst = yypt[-0].yyv.addr;
	} break;
case 18:
#line	130	"asm.y"
{
		yyval.inst = ai(yypt[-0].yyv.ival);
	} break;
case 19:
#line	136	"asm.y"
{
		data(DEFB, yypt[-2].yyv.ival, yypt[-0].yyv.list);
	} break;
case 20:
#line	140	"asm.y"
{
		data(DEFW, yypt[-2].yyv.ival, yypt[-0].yyv.list);
	} break;
case 21:
#line	144	"asm.y"
{
		data(DEFL, yypt[-2].yyv.ival, yypt[-0].yyv.list);
	} break;
case 22:
#line	148	"asm.y"
{
		data(DEFF, yypt[-2].yyv.ival, newi(dtocanon((double)yypt[-0].yyv.ival), nil));
	} break;
case 23:
#line	152	"asm.y"
{
		data(DEFF, yypt[-2].yyv.ival, newi(dtocanon(yypt[-0].yyv.fval), nil));
	} break;
case 24:
#line	156	"asm.y"
{
		if(strcmp(yypt[-0].yyv.sym->name, "Inf") == 0 || strcmp(yypt[-0].yyv.sym->name, "Infinity") == 0) {
			u.l = (uvlong)0x7ff00000<<32;
			data(DEFF, yypt[-2].yyv.ival, newi(dtocanon(u.d), nil));
		} else if(strcmp(yypt[-0].yyv.sym->name, "NaN") == 0) {
			u.l = ((uvlong)0x7fffffff<<32) | (uvlong)0xffffffffUL;
			data(DEFF, yypt[-2].yyv.ival, newi(dtocanon(u.d), nil));
		} else
			diag("bad value for real: %s", yypt[-0].yyv.sym->name);
	} break;
case 25:
#line	167	"asm.y"
{
		data(DEFF, yypt[-3].yyv.ival, newi(dtocanon(-(double)yypt[-0].yyv.ival), nil));
	} break;
case 26:
#line	171	"asm.y"
{
		data(DEFF, yypt[-3].yyv.ival, newi(dtocanon(-yypt[-0].yyv.fval), nil));
	} break;
case 27:
#line	175	"asm.y"
{
		if(strcmp(yypt[-0].yyv.sym->name, "Inf") == 0 || strcmp(yypt[-0].yyv.sym->name, "Infinity") == 0) {
			u.l = (uvlong)0xfff00000<<32;
			data(DEFF, yypt[-3].yyv.ival, newi(dtocanon(u.d), nil));
		} else
			diag("bad value for real: %s", yypt[-0].yyv.sym->name);
	} break;
case 28:
#line	183	"asm.y"
{
		data(DEFS, yypt[-2].yyv.ival, news(yypt[-0].yyv.string, nil));
	} break;
case 29:
#line	187	"asm.y"
{
		if(yypt[-2].yyv.sym->ds != 0)
			diag("%s declared twice", yypt[-2].yyv.sym->name);
		yypt[-2].yyv.sym->ds = yypt[-0].yyv.ival;
		yypt[-2].yyv.sym->value = dseg;
		dseg += yypt[-0].yyv.ival;
	} break;
case 30:
#line	195	"asm.y"
{
		ext(yypt[-4].yyv.ival, yypt[-2].yyv.ival, yypt[-0].yyv.string);
	} break;
case 31:
#line	199	"asm.y"
{
		mklink(yypt[-6].yyv.ival, yypt[-4].yyv.ival, yypt[-2].yyv.ival, yypt[-0].yyv.string);
	} break;
case 32:
#line	203	"asm.y"
{
		if(module != nil)
			diag("this module already defined as %s", yypt[-0].yyv.sym->name);
		else
			module = yypt[-0].yyv.sym;
	} break;
case 33:
#line	210	"asm.y"
{
		if(pcentry >= 0)
			diag("this module already has entry point %d, %d" , pcentry, dentry);
		pcentry = yypt[-2].yyv.ival;
		dentry = yypt[-0].yyv.ival;
	} break;
case 34:
#line	217	"asm.y"
{
		data(DEFA, yypt[-4].yyv.ival, newa(yypt[-2].yyv.ival, yypt[-0].yyv.ival));
	} break;
case 35:
#line	221	"asm.y"
{
		data(DIND, yypt[-2].yyv.ival, newa(yypt[-0].yyv.ival, 0));
	} break;
case 36:
#line	225	"asm.y"
{
		data(DAPOP, 0, newa(0, 0));
	} break;
case 37:
#line	229	"asm.y"
{
		ldts(yypt[-0].yyv.ival);
	} break;
case 38:
#line	233	"asm.y"
{
		excs(yypt[-0].yyv.ival);
	} break;
case 39:
#line	237	"asm.y"
{
		exc(yypt[-10].yyv.ival, yypt[-8].yyv.ival, yypt[-6].yyv.ival, yypt[-4].yyv.ival, yypt[-2].yyv.ival, yypt[-0].yyv.ival);
	} break;
case 40:
#line	241	"asm.y"
{
		etab(yypt[-2].yyv.string, yypt[-0].yyv.ival);
	} break;
case 41:
#line	245	"asm.y"
{
		etab(nil, yypt[-0].yyv.ival);
	} break;
case 42:
#line	249	"asm.y"
{
		source(yypt[-0].yyv.string);
	} break;
case 43:
#line	255	"asm.y"
{
		yyval.addr = aa(yypt[-0].yyv.ival);
		yyval.addr->mode = AXIMM;
		if(yyval.addr->val > 0x7FFF || yyval.addr->val < -0x8000)
			diag("immediate %d too large for middle operand", yyval.addr->val);
	} break;
case 44:
#line	262	"asm.y"
{
		if(yypt[-0].yyv.addr->mode == AMP)
			yypt[-0].yyv.addr->mode = AXINM;
		else
			yypt[-0].yyv.addr->mode = AXINF;
		if(yypt[-0].yyv.addr->mode == AXINM && (ulong)yypt[-0].yyv.addr->val > 0xFFFF)
			diag("register offset %d(mp) too large", yypt[-0].yyv.addr->val);
		if(yypt[-0].yyv.addr->mode == AXINF && (ulong)yypt[-0].yyv.addr->val > 0xFFFF)
			diag("register offset %d(fp) too large", yypt[-0].yyv.addr->val);
		yyval.addr = yypt[-0].yyv.addr;
	} break;
case 45:
#line	276	"asm.y"
{
		yyval.addr = aa(yypt[-0].yyv.ival);
		yyval.addr->mode = AIMM;
	} break;
case 46:
#line	281	"asm.y"
{
		yyval.addr = aa(0);
		yyval.addr->sym = yypt[-0].yyv.sym;
	} break;
case 48:
#line	289	"asm.y"
{
		yypt[-0].yyv.addr->mode |= AIND;
		yyval.addr = yypt[-0].yyv.addr;
	} break;
case 49:
#line	294	"asm.y"
{
		yypt[-1].yyv.addr->mode |= AIND;
		if(yypt[-1].yyv.addr->val & 3)
			diag("indirect offset must be word size");
		if(yypt[-1].yyv.addr->mode == (AMP|AIND) && ((ulong)yypt[-1].yyv.addr->val > 0xFFFF || (ulong)yypt[-3].yyv.ival > 0xFFFF))
			diag("indirect offset %d(%d(mp)) too large", yypt[-3].yyv.ival, yypt[-1].yyv.addr->val);
		if(yypt[-1].yyv.addr->mode == (AFP|AIND) && ((ulong)yypt[-1].yyv.addr->val > 0xFFFF || (ulong)yypt[-3].yyv.ival > 0xFFFF))
			diag("indirect offset %d(%d(fp)) too large", yypt[-3].yyv.ival, yypt[-1].yyv.addr->val);
		yypt[-1].yyv.addr->off = yypt[-1].yyv.addr->val;
		yypt[-1].yyv.addr->val = yypt[-3].yyv.ival;
		yyval.addr = yypt[-1].yyv.addr;
	} break;
case 51:
#line	310	"asm.y"
{
		yyval.addr = aa(yypt[-3].yyv.ival);
		yyval.addr->mode = AMP;
	} break;
case 52:
#line	315	"asm.y"
{
		yyval.addr = aa(yypt[-3].yyv.ival);
		yyval.addr->mode = AFP;
	} break;
case 54:
#line	323	"asm.y"
{
		yyval.ival = yypt[-0].yyv.sym->value;
	} break;
case 55:
#line	327	"asm.y"
{
		yyval.ival = -yypt[-0].yyv.ival;
	} break;
case 56:
#line	331	"asm.y"
{
		yyval.ival = yypt[-0].yyv.ival;
	} break;
case 57:
#line	335	"asm.y"
{
		yyval.ival = ~yypt[-0].yyv.ival;
	} break;
case 58:
#line	339	"asm.y"
{
		yyval.ival = yypt[-1].yyv.ival;
	} break;
case 60:
#line	346	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival + yypt[-0].yyv.ival;
	} break;
case 61:
#line	350	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival - yypt[-0].yyv.ival;
	} break;
case 62:
#line	354	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival * yypt[-0].yyv.ival;
	} break;
case 63:
#line	358	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival / yypt[-0].yyv.ival;
	} break;
case 64:
#line	362	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival % yypt[-0].yyv.ival;
	} break;
case 65:
#line	366	"asm.y"
{
		yyval.ival = yypt[-3].yyv.ival << yypt[-0].yyv.ival;
	} break;
case 66:
#line	370	"asm.y"
{
		yyval.ival = yypt[-3].yyv.ival >> yypt[-0].yyv.ival;
	} break;
case 67:
#line	374	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival & yypt[-0].yyv.ival;
	} break;
case 68:
#line	378	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival ^ yypt[-0].yyv.ival;
	} break;
case 69:
#line	382	"asm.y"
{
		yyval.ival = yypt[-2].yyv.ival | yypt[-0].yyv.ival;
	} break;
	}
	goto yystack;  /* stack new state and value */
}
コード例 #11
0
//****************************************对抽取的语料库按类别进行分类****************************************
void corpus_category(string filename_path, string path_read, string path_write) //参数1:文件名列表路径 参数2:读取文件的目录 参数3:写入文件的目录
{

	string file_name;    //存储读取的各个文件的名字
	ifstream read_filename(filename_path);  //从LIST.TXT读取文件名
	ofstream sports(path_write+"sports.txt");//属于sport类的存放在sport.txt文件中
	ofstream house(path_write+"house.txt");
	ofstream it(path_write+"it.txt");
	ofstream test_2008(path_write+"2008.txt");
	ofstream news(path_write+"news.txt");
	ofstream yule(path_write+"yule.txt");
	ofstream business(path_write+"business.txt");
	ofstream travel(path_write+"travel.txt");
	ofstream mil_news(path_write+"mil.news.txt");
	ofstream women(path_write+"women.txt");
	ofstream health(path_write+"health.txt");
	ofstream test_auto(path_write+"auto.txt");
	ofstream cul(path_write+"cul.txt");
	ofstream learning(path_write+"learning.txt");
	ofstream test_else(path_write+"else.txt");
	string path_in, str_line,cut_str;//path_in:存放读文件路径 str_line:读取的一行文件 cut_str:存放截取的字符串
	string::size_type pos1, pos2;
	int number = 0;
	while (getline(read_filename, file_name))
	{
		number++;
		cout << number << endl;
		path_in = path_read + file_name;
		ifstream infile(path_in);
		while (getline(infile, str_line))              //读取各个文件的每一行字符串
		{
			pos1 = 0;
			pos2 = str_line.find("####");
			cut_str = str_line.substr(pos1, pos2 - pos1);
			if (string(cut_str) == string("sports"))         //字符串匹配  是否为sports类
			{
				sports << str_line << endl;                  //如果是sports类就把该行输出到sports.txt文件
			}
			else if (cut_str == "house")
			{
				house << str_line << endl;
			}
			else if (cut_str == "it")
			{
				it << str_line << endl;
			}
			else if (cut_str == "2008")
			{
				test_2008 << str_line << endl;
			}
			else if (cut_str == "news")
			{
				news << str_line << endl;
			}
			else if (cut_str == "yule")
			{
				yule << str_line << endl;
			}
			else if (cut_str == "business")
			{
				business << str_line << endl;
			}
			else if (cut_str == "travel")
			{
				travel << str_line << endl;
			}
			else if (cut_str == "mil.news")
			{
				mil_news << str_line << endl;
			}
			else if (cut_str == "women")
			{
				women << str_line << endl;
			}
			else if (cut_str == "health")
			{
				health << str_line << endl;
			}
			else if (cut_str == "auto")
			{
				test_auto << str_line << endl;
			}
			else if (cut_str == "cul")
			{
				cul << str_line << endl;
			}
			else if (cut_str == "learning")
			{
				learning << str_line << endl;
			}
			else
			{
				test_else << str_line << endl;
			}
		}
		infile.close();   //每次结束都得关闭文件.
	}
}