/** * Entry function which will process the assembled code and perform the required actions */ void processAssembledCode(char * assembled, unsigned int length, unsigned short numberSymbols, int coreId, int numberActiveCores, int baseHostPid) { stopInterpreter=0; currentSymbolEntries=0; localCoreId=coreId; numActiveCores=numberActiveCores; symbolTable=initialiseSymbolTable(numberSymbols); hostCoresBasePid=baseHostPid; unsigned int i; for (i=0;i<length;) { unsigned short command=getUShort(&assembled[i]); i+=sizeof(unsigned short); if (command == LET_TOKEN) i=handleLet(assembled, i); if (command == ARRAYSET_TOKEN) i=handleArraySet(assembled, i); if (command == DIMARRAY_TOKEN) i=handleDimArray(assembled, i, 0); if (command == DIMSHAREDARRAY_TOKEN) i=handleDimArray(assembled, i, 1); if (command == PRINT_TOKEN) i=handlePrint(assembled, i); if (command == STOP_TOKEN) return; if (command == SYNC_TOKEN) i=handleSync(assembled, i); if (command == IF_TOKEN) i=handleIf(assembled, i); if (command == IFELSE_TOKEN) i=handleIf(assembled, i); if (command == FOR_TOKEN) i=handleFor(assembled, i); if (command == GOTO_TOKEN) i=handleGoto(assembled, i); if (command == INPUT_TOKEN) i=handleInput(assembled, i); if (command == INPUT_STRING_TOKEN) i=handleInputWithString(assembled, i); if (command == SEND_TOKEN) i=handleSend(assembled, i); if (command == RECV_TOKEN) i=handleRecv(assembled, i); if (command == RECVTOARRAY_TOKEN) i=handleRecvToArray(assembled, i); if (command == SENDRECV_TOKEN) i=handleSendRecv(assembled, i); if (command == SENDRECVARRAY_TOKEN) i=handleSendRecvArray(assembled, i); if (command == BCAST_TOKEN) i=handleBcast(assembled, i); if (command == REDUCTION_TOKEN) i=handleReduction(assembled, i); if (stopInterpreter) return; } }
bool LRParser::performAction(std::pair<EAction, std::string> action) { switch (action.first) { case shift: // push the token on the stack. stack_.push(action.second); //std::cout << *this << std::endl; break; case reduction: // Replace the body of the production rule by the head. handleReduction(action.second); break; case accept: // EMPTY STACK //std::cout << *this << std::endl; while (!stack_.empty()) { stack_.pop(); } return true; break; case jump: // Pretty much the same thing as a shift. stack_.push(action.second); break; case error: return false; break; case blank: return false; break; default: return false; break; } // Error, did not enter switch. return true; }