/// <summary> /// 重新构造二叉树 /// </summary> /// <param name="strExpression">表达式</param> public void ChangeExpression(string strExpression) { _Expression = strExpression; _Tree = null; _Position = 0; _Identifiers = null; _CurrentIdentifier = null; _ParentIdentifier = null; if (strExpression != string.Empty) { try { _ExpressionChars = new Char[strExpression.Length + 1]; strExpression.CopyTo(0, _ExpressionChars, 0, strExpression.Length); _ExpressionChars[strExpression.Length] = '\0'; _Tree = DoExpression(); if (_ExpressionChars[_Position] != '\0') { throw ParsingException.NewParsingException(Parse_Error.peSyntaxError, _Position); } } finally { _CurrentIdentifier = null; _ParentIdentifier = null; } } }
//私有方法 /// <summary> /// 顺序输出标识符 /// </summary> /// <param name="oID"></param> /// <param name="strID"></param> /// <param name="nPos"></param> private void OutputID(Operation_IDs oID, string strID, int nPos) { if (OutputIdentifiers) { ParseIdentifier pi = new ParseIdentifier(oID, strID, nPos, _CurrentIdentifier); if (_CurrentIdentifier == null) { if (_ParentIdentifier == null) { _Identifiers = pi; } else { _ParentIdentifier._SubIdentifier = pi; } } else { _CurrentIdentifier._NextIdentifier = pi; } pi._ParentIdentifier = _ParentIdentifier; _CurrentIdentifier = pi; } }
public ParseIdentifier(Operation_IDs oID, string strID, int nPos, ParseIdentifier prev) { _OperationID = oID; _Identifier = strID; _Position = nPos; _PrevIdentifier = prev; }
private void OutputIDToParentLevel() { if (_ParentIdentifier != null) { _CurrentIdentifier = _ParentIdentifier; _ParentIdentifier = _ParentIdentifier._ParentIdentifier; } }
private void OutputIDToSubLevel() { _ParentIdentifier = _CurrentIdentifier; _CurrentIdentifier = null; }