예제 #1
0
파일: R1.c 프로젝트: ShaneRyanKelly/R1
//-----------------------------------------
void statement(void)
{
    switch(currentToken -> kind)
    {
      case ID: 
        assignmentStatement(); 
        break;
      case PRINTLN:    
        printlnStatement(); 
        break;
      default:  
        displayErrorLoc();      
        printf("Scanning %s, expecting statement\n",
           currentToken -> image);
        abend();
    }
}
예제 #2
0
void statement (void) {

	//-------------------------------------------------------------------
	// NOTE: Since we currently don't support generic BEGIN/END (compound
	// statement) blocks...
	if ((curToken != TKN_CODE) /*&& (curToken != TKN_BEGIN)*/)
			crunchStatementMarker();
	
	switch (curToken) {
		case TKN_IDENTIFIER: {
			SymTableNodePtr IdPtr = NULL;
			
			//--------------------------------------------------------------
			// First, do we have an assignment statement or a function call?		
			searchAndFindAllSymTables(IdPtr);
		
			if ((IdPtr->defn.key == DFN_FUNCTION)/* || (IdPtr->defn.key == DFN_MODULE)*/) {
				RoutineKey key = IdPtr->defn.info.routine.key;
				if ((key == RTN_ASSERT) || (key == RTN_PRINT) || (key == RTN_CONCAT)) {
					bool uncrunch = ((key == RTN_ASSERT) && !AssertEnabled) ||
									((key == RTN_PRINT) && !PrintEnabled) ||
									((key == RTN_CONCAT) && !StringFunctionsEnabled);
					if (uncrunch) {
						uncrunchStatementMarker();
						Crunch = false;
					}
				}
				crunchSymTableNodePtr(IdPtr);
				if (IdPtr->defn.info.routine.flags & ROUTINE_FLAG_ORDER) {
					if (NumOrderCalls == MAX_ORDERS)
						syntaxError(ABL_ERR_SYNTAX_TOO_MANY_ORDERS);
					crunchByte((unsigned char)(NumOrderCalls / 32));
					crunchByte((unsigned char)(NumOrderCalls % 32));
					NumOrderCalls++;
				}
				getToken();
				SymTableNodePtr thisRoutineIdPtr = CurRoutineIdPtr;
				routineCall(IdPtr, 1);
				CurRoutineIdPtr = thisRoutineIdPtr;
				Crunch = true;
				}
			else
				assignmentStatement(IdPtr);
			}
			break;
		case TKN_REPEAT:
			repeatStatement();
			break;
		case TKN_WHILE:
			whileStatement();
			break;
		case TKN_IF:
			ifStatement();
			break;
		case TKN_FOR:
			forStatement();
			break;
		case TKN_SWITCH:
			switchStatement();
			break;
		case TKN_TRANS:
			transStatement();
			break;
		case TKN_TRANS_BACK:
			transBackStatement();
			break;
	}

	//---------------------------------------------------------------------
	// Now, make sure the statement is closed off with the proper block end
	// statement, if necessary (which is usually the case :).
	synchronize(statementEndList, NULL, NULL);
	if (tokenIn(statementStartList))
		syntaxError(ABL_ERR_SYNTAX_MISSING_SEMICOLON);
}