Beispiel #1
0
Statement *ParseStatement() 
{
	Statement *snp; 
    switch( lastst ) { 
    case semicolon: 
        NextToken(); 
        snp = NULL; 
        break; 
    case begin: 
		NextToken(); 
        snp = ParseCompoundStatement();
        return snp; 
    case kw_if: snp = ParseIfStatement(); break; 
    case kw_while: snp = ParseWhileStatement(); break; 
    case kw_until: snp = ParseUntilStatement(); break; 
    case kw_for:   snp = ParseForStatement();   break; 
    case kw_forever: snp = ParseForeverStatement(); break; 
    case kw_firstcall: snp = ParseFirstcallStatement(); break; 
    case kw_return: snp = ParseReturnStatement(); break; 
    case kw_break: snp = ParseBreakStatement(); break; 
    case kw_goto: snp = ParseGotoStatement(); break; 
    case kw_continue: snp = ParseContinueStatement(); break; 
    case kw_do:
	case kw_loop: snp = ParseDoStatement(); break; 
    case kw_switch: snp = ParseSwitchStatement(); break;
	case kw_try: snp = ParseTryStatement(); break;
	case kw_throw: snp = ParseThrowStatement(); break;
	case kw_vortex:
			snp = vortex_stmt();
			break;
	case kw_intoff: snp = ParseIntoffStatement(); break;
	case kw_inton: snp = ParseIntonStatement(); break;
	case kw_stop: snp = ParseStopStatement(); break;
	case kw_asm:
		snp = ParseAsmStatement(); break;
	case kw_critical: snp = ParseCriticalStatement(); break;
	case kw_spinlock: snp = ParseSpinlockStatement(); break;
	case kw_spinunlock: snp = ParseSpinunlockStatement(); break;
    case id:
			SkipSpaces();
            if( lastch == ':' ) 
                return ParseLabelStatement(); 
            // else fall through to parse expression
    default: 
            snp = ParseExpressionStatement(); 
            break; 
    } 
    if( snp != NULL ) 
        snp->next = NULL;
    return snp; 
} 
Sentencia* Sintactico::ParseIterationStatement()
{
	//Utilizamos Primeros
	if ( proximo_token.GetTipo() == kw_for )
	{
		return ParseForStatement();
	}
	else if ( proximo_token.GetTipo() == kw_repeat )
	{
		return ParseRepeatStatement();
	}
	else if ( proximo_token.GetTipo() == kw_while )
	{
		return ParseWhileStatement();
	}
	else
		throw SyntaxException("No se encontro token valido",analizador_lexico->GetLineaActual() );
}