/// <summary> /// Vytvorí grupu s obsahom [[ ]] a prepíše ju v strome. /// </summary> /// <param name="moveInfo"></param> /// <param name="dir"></param> /// <param name="startIndex"></param> /// <param name="length"></param> /// <returns></returns> private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo) { SQBracketGroup outerGroup = (SQBracketGroup)parentInfo.Current; List <IElement> outerGroupChildren = outerGroup.GetChildren(); MoveInfo outerGroupInfo = new MoveInfo(outerGroup, SearchTree.ContentBlock, 0, parentInfo); SQBracketGroup innerGroup = (SQBracketGroup)outerGroupInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible); List <IElement> innerGroupChildren = innerGroup.GetChildren(); int startElemsCount = outerGroupChildren.IndexOf(innerGroup) + 1; int endElemsCount = outerGroupChildren.Count - startElemsCount + 1; outerGroupInfo.Replace(1, innerGroupChildren); List <IElement> children = outerGroup.GetChildren(); DelegateCallGroup delegateCall = new DelegateCallGroup(children, startElemsCount, endElemsCount); parentInfo.Replace(1, delegateCall); }
public override IElement CreateCopy() { DelegateCallGroup g = new DelegateCallGroup(this.CopyChildren(), this.startElemCount, this.endElemCount); return(g); }
private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo) { DelegateCall delegCall = new DelegateCall(); MoveInfo moveInfo = new MoveInfo(parentInfo); DelegateCallGroup group = (DelegateCallGroup)parentInfo.Current; MoveInfo groupInfo = new MoveInfo(group, SearchTree.ContentBlock, 0, parentInfo); Expression deleg = Expression.Parse(groupInfo, parsingInfo, scriptInfo); if (deleg == null || groupInfo.FindNextBlack(SearchDirection.LeftToRight) != null) { throw new SyntaxException("Could not parse delegate", parentInfo.GetErrorInfo()); } #region ParsingInfo Args object lastCall = parsingInfo.CurrentCall; int? lastCallArgIndex = parsingInfo.CurrentCallArgIndex; parsingInfo.CurrentCall = delegCall; parsingInfo.CurrentCallArgIndex = 0; #endregion // find args moveInfo.FindNextBlack(SearchDirection.LeftToRight); if (!FuncArgs.Check(moveInfo, parsingInfo, scriptInfo)) { throw new SyntaxException("Could not find delegate funcArgs", parentInfo.GetErrorInfo()); } int startIndex = parentInfo.CurrentIndex; int length; #region ParsingInfo Args parsingInfo.CurrentCall = lastCall; parsingInfo.CurrentCallArgIndex = lastCallArgIndex; #endregion // find self and modifiers MoveInfo selfInfo = new MoveInfo(parentInfo); IElement self = selfInfo.FindNextBlack(SearchDirection.RightToLeft); if (self != null && self is ExpressionOperand) // self is self or FuncCallModifier { startIndex = selfInfo.CurrentIndex; if (self is FuncCallModifier) // self is FuncCallModifier -> find self { self = selfInfo.FindNextBlack(SearchDirection.RightToLeft); if (self != null && self is ExpressionOperand) { startIndex = selfInfo.CurrentIndex; } } } // find members and arrayIndexers IElement next = null; do { length = (moveInfo.CurrentIndex + 1) - startIndex; next = moveInfo.FindNextBlack(SearchDirection.LeftToRight); }while (next != null && (ArrayIndexer.Check(moveInfo, parsingInfo, scriptInfo) || DataMember.Check(moveInfo, parsingInfo, scriptInfo))); // build delegCall.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length)); parentInfo.MoveToIndex(startIndex); parentInfo.Replace(length, delegCall); }