// 处理右括号 // parameters: int DoRightBracket() { int nRet; int index; for (; ;) { // 运算符栈顶是否为"("? index = m_OperatorArray.Count - 1; if (index == -1) { return(-1); } Token token = m_OperatorArray[index]; // 运算符栈顶取出 if (token.m_strToken == "(") { m_OperatorArray.RemoveAt(index);// 删除这个运算符栈顶元素 break; } nRet = PutTokenToArray(token.m_strToken, token.m_nType);// 再送入运算符入PL if (nRet == -1) { return(-1); //只要不删数组项,就不必担心delete 问题 } m_OperatorArray.RemoveAt(index); // 删除这个运算符栈顶元素 } return(0); }
public Json(TokenCollection json) { tokens = json; if (tokens[0].Kind == SyntaxKind.OBA && tokens[tokens.Count - 1].Kind == SyntaxKind.CBA) { throw new Exception("Use JsonObjectArray(string json)."); } else if (tokens[0].Kind == SyntaxKind.OB && tokens[tokens.Count - 1].Kind == SyntaxKind.CB) { tokens.RemoveAt(tokens.Count - 1); tokens.RemoveAt(0); } else { throw new Exception("Unknown Json format."); } Parse(); }
public void Trim() { int count = 0; for (count = 0; count < tokenCollection.Count; ++count) { if (tokenCollection[count] != "\n") { break; } } if (count == 0) { return; } for (int i = 0; i < count; ++i) { tokenCollection.RemoveAt(0); } }