示例#1
0
        /// <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>
        public static void Parse(MoveInfo moveInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            int startIndex;
            int length;

            moveInfo.GetGroupCorners(TokenType.SQBracketOpen, TokenType.SQBracketClose,
                                     SearchVisibility.Visible, out startIndex, out length);

            SQBracketGroup group = new SQBracketGroup(moveInfo.CurrentElements.GetRange(startIndex, length));

            moveInfo.Replace(length, group);
        }
示例#2
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            SQBracketGroup group    = (SQBracketGroup)parentInfo.Current;
            MoveInfo       moveInfo = new MoveInfo(group, SearchTree.ContentBlock, 0, parentInfo);

            if (moveInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible) != null)
            {
                throw new SyntaxException("Unknown tokens in ArrayDef", parentInfo.GetErrorInfo());
            }

            ArrayDef arrayDef = new ArrayDef();

            arrayDef.AddChildren(group);
            parentInfo.Replace(1, arrayDef);
        }
示例#3
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            ArrayIndexer aI = new ArrayIndexer();

            SQBracketGroup SQGroup     = (SQBracketGroup)parentInfo.Current;
            MoveInfo       SQGroupInfo = new MoveInfo(SQGroup, SearchTree.ContentBlock, 0, parentInfo);
            Expression     exp         = Expression.Parse(SQGroupInfo, parsingInfo, scriptInfo);

            if (exp == null || SQGroupInfo.FindNextBlack(SearchDirection.LeftToRight) != null)
            {
                throw new SyntaxException("Could not parse array index", parentInfo.GetErrorInfo());
            }

            aI.AddChildren(SQGroup);
            parentInfo.Replace(1, aI);
        }
示例#4
0
 public static bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
 {
     if (parentInfo.Current.IsTT(TokenType.ScopeOpen))
     {
         ScopeGroup.Parse(parentInfo, parsingInfo, scriptInfo);
         return(true);
     }
     else if (parentInfo.Current.IsTT(TokenType.ParenthesesOpen))
     {
         ParenthesesGroup.Parse(parentInfo, parsingInfo, scriptInfo);
         return(true);
     }
     else if (parentInfo.Current.IsTT(TokenType.SQBracketOpen))
     {
         SQBracketGroup.Parse(parentInfo, parsingInfo, scriptInfo);
         return(true);
     }
     return(false);
 }
示例#5
0
        /// <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);
        }
示例#6
0
        public override IElement CreateCopy()
        {
            SQBracketGroup g = new SQBracketGroup(this.CopyChildren());

            return(g);
        }