void cParser::onError(void) { skipToEnd(); char buffer[256]; sprintf_s(buffer, 256, "行 %d : ",m_curLine+1); m_errorDesc = buffer; if (errorID() == 1) { m_errorDesc += "在尝试赋值的时候,没有得到任何可赋值的变量。"; } else if (errorID() == 2) { m_errorDesc += "同一行上出现了两个变量名 :"; m_errorDesc += m_variable; m_errorDesc += " 和 "; m_errorDesc += m_curVariable; } else if (errorID() == 3) { m_errorDesc += "非法变量名。"; } else { m_errorDesc += "未知错误。"; } testOutput(m_errorDesc); m_curVariable.clear(); m_variable.clear(); setError(0); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void FrameAnimationControl::slotSkipToEnd() { skipToEnd(); }
//Determines if a replacement designator has been passed in and //replases and locates the appropriate list char *getReplacement (int *iPointer, const char *oldLine, int *replacementStatus) { int lineLength = strlen(&oldLine[iPointer[0]]); char *endptr; struct token *listToSearch; int listNum; if (oldLine[iPointer[0]] == '!') { if (!tokenHistory){ if (oldLine[iPointer[0] + 1]) { skipToEnd(oldLine, iPointer); } return NULL; } iPointer[0] += 1; return getTokenSequenceForList (tokenHistory[currentPossition - 1], iPointer, oldLine, replacementStatus); replacementStatus[0] = 1; } else if (oldLine[iPointer[0]] == '-'){ if (lineLength > 1) { if (oldLine[iPointer[0] + 1] >= 48 && oldLine[iPointer[0] + 1] <= 57) { listNum = strtol (&oldLine[iPointer[0] + 1], &endptr, 10); int index = getIndexHistoryPossition (historyTotal + 1 - listNum); int numLength = getIntLength (listNum); iPointer[0] += numLength + 1; if (!tokenHistory){ if (oldLine[iPointer[0] + 1]) { skipToEnd(oldLine, iPointer); } return NULL; } if (index >= 0){ listToSearch = tokenHistory[index]; return getTokenSequenceForList (listToSearch, iPointer, oldLine, replacementStatus); } } } replacementStatus[0] = 1; } else if (oldLine[iPointer[0]] >= 48 && oldLine[iPointer[0]] <= 57) { listNum = strtol (&oldLine[iPointer[0]], &endptr, 10); int index = getIndexHistoryPossition(listNum); int numLength = getIntLength (listNum); iPointer[0] += numLength; if (!tokenHistory){ if (oldLine[iPointer[0] + 1]) { if (oldLine[iPointer[0] + 1] ==':') { iPointer[0] ++; } skipToEnd(oldLine, iPointer); } return NULL; } if (index >= 0){ listToSearch = tokenHistory[index]; return getTokenSequenceForList (listToSearch, iPointer, oldLine, replacementStatus); } replacementStatus[0] = 1; } else if (oldLine[iPointer[0]] == '?') { if (lineLength > 1) { char *searchString = getString (&oldLine[iPointer[0] + 1]); listToSearch = findStringInHistory (searchString); iPointer[0] += strlen(searchString) + 1; if (oldLine[iPointer[0]] == '?'){ iPointer[0] ++; } if (!tokenHistory || !listToSearch){ if (oldLine[iPointer[0] + 1]) { skipToEnd(oldLine, iPointer); } return NULL; } free(searchString); return getTokenSequenceForList (listToSearch, iPointer, oldLine, replacementStatus); } replacementStatus[0] = 1; } if (replacementStatus[0] != 1) { replacementStatus[0] = -1; } return NULL; }