Exemplo n.º 1
0
Statement *ParseSwitchStatement() 
{       
	Statement *snp; 
    Statement *head, *tail; 

	currentFn->UsesPredicate = TRUE;
    snp = NewStatement(st_switch, TRUE);
	snp->predreg = iflevel;
	iflevel++;
    if( expression(&(snp->exp)) == NULL ) 
        error(ERR_EXPREXPECT); 
    needpunc(begin); 
    head = 0; 
    while( lastst != end ) { 
		if( head == NULL )
			head = tail = ParseCaseStatement(); 
		else { 
			tail->next = ParseCaseStatement(); 
			if( tail->next != NULL ) 
				tail = tail->next;
		}
		if (tail==NULL) break;	// end of file in switch
        tail->next = NULL; 
    } 
    snp->s1 = head; 
    NextToken(); 
    if( CheckForDuplicateCases(head) ) 
        error(ERR_DUPCASE); 
	iflevel--;
    return snp; 
} 
Exemplo n.º 2
0
Statement *ParseSwitchStatement() 
{       
	Statement *snp; 
    Statement *head, *tail; 

    snp = NewStatement(st_switch, TRUE);
	iflevel++;
    if( expression(&(snp->exp)) == NULL ) 
        error(ERR_EXPREXPECT); 
    needpunc(begin,36); 
    head = 0; 
    while( lastst != end ) { 
		if( head == (Statement *)NULL ) {
			head = tail = ParseCaseStatement(); 
			if (head)
				head->outer = snp;
		}
		else { 
			tail->next = ParseCaseStatement(); 
			if( tail->next != (Statement *)NULL ) {
				tail->next->outer = snp;
				tail = tail->next;
			}
		}
		if (tail==(Statement *)NULL) break;	// end of file in switch
        tail->next = (Statement *)NULL; 
    } 
    snp->s1 = head; 
    NextToken(); 
    if( CheckForDuplicateCases(head) ) 
        error(ERR_DUPCASE); 
	iflevel--;
    return snp; 
}