예제 #1
0
파일: parser.c 프로젝트: apason/tiralabra
static stmt_node *statement(void){
    stmt_node *stmtn = newStmtNode();
    
    if(match(TOKEN_IDENTIFIER,   NO_CONSUME) ||
       match(TOKEN_SCOL,         NO_CONSUME)){
	if((stmtn->assn = assignment()) != NULL)
	    return stmtn;
    }
    else if(match(TOKEN_TYPEKEY, NO_CONSUME)){
	if((stmtn->decn = declaration()) != NULL)
	    return stmtn;
    }
    else if(match(TOKEN_IFKEY,   NO_CONSUME)){
	if((stmtn->ifn = if_()) != NULL)
	    return stmtn;
    }
    else if(match(TOKEN_WHILEKEY,NO_CONSUME)){
	if((stmtn->whilen = while_()) != NULL)
	    return stmtn;
    }
    else if(match(TOKEN_FORKEY,  NO_CONSUME)){
	if((stmtn->forn = for_()) != NULL)
	    return stmtn;
    }
    else if((stmtn->lCur = match(TOKEN_LCUR, CONSUME)) != NULL){
	if((stmtn->sln = statement_list()) != error)
	    if((stmtn->rCur = match(TOKEN_RCUR, CONSUME)) != NULL)
		return stmtn;
    }
    else if((stmtn->ins = match(TOKEN_INSTRUCTION, CONSUME)) != NULL)
	return stmtn;


    freeStmt(stmtn);
    return NULL;
}
예제 #2
0
lint combination(lint n, lint m) {
	lint res = 1;
	if (2 * m > n) m = n - m;
	for_(i,0,m) res = res * (n - i) / (i + 1);
	return res;
}