Пример #1
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            SubExpression subExp = new SubExpression();

            ParenthesesGroup group     = (ParenthesesGroup)parentInfo.Current;
            MoveInfo         groupInfo = new MoveInfo(group, SearchTree.ContentBlock, 0, parentInfo);
            Expression       exp       = Expression.Parse(groupInfo, parsingInfo, scriptInfo);

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

            int startIndex = parentInfo.CurrentIndex;
            int length     = 1;

            MoveInfo moveInfo = new MoveInfo(parentInfo);
            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)));

            subExp.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.Replace(length, subExp);
        }
Пример #2
0
        public override IElement CreateCopy()
        {
            ArrayIndexer e = new ArrayIndexer();

            e.AddChildren(this.CopyChildren());
            return(e);
        }
Пример #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
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            StringArray strArray = new StringArray();

            MoveInfo moveInfo = new MoveInfo(parentInfo);
            IElement next     = moveInfo.FindNextBlack(SearchDirection.LeftToRight);

            int length = 1;

            if (next != null &&
                (ArrayIndexer.Check(moveInfo, parsingInfo, scriptInfo) ||
                 DataMember.Check(moveInfo, parsingInfo, scriptInfo)))
            {
                length = (moveInfo.CurrentIndex + 1) - parentInfo.CurrentIndex;
            }

            strArray.AddChildren(parentInfo.CurrentElements.GetRange(parentInfo.CurrentIndex, length));
            parentInfo.Replace(length, strArray);
        }
Пример #5
0
        public static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            VarName varName = new VarName();

            MoveInfo moveInfo = new MoveInfo(parentInfo);

            int startIndex = parentInfo.CurrentIndex;
            int length;

            // 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)));

            varName.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.Replace(length, varName);
        }
Пример #6
0
        public static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            Vector vec = new Vector();

            ParenthesesGroup group     = (ParenthesesGroup)parentInfo.Current;
            MoveInfo         groupInfo = new MoveInfo(group, SearchTree.ContentBlock, 0, parentInfo);

            for (int i = 0; i < 3; i++)
            {
                Expression exp  = Expression.Parse(groupInfo, parsingInfo, scriptInfo);
                IElement   next = groupInfo.FindNextBlack(SearchDirection.LeftToRight);
                if ((i < 2 && !next.IsTT(TokenType.Comma)) ||
                    (i == 2 && next != null))
                {
                    throw new SyntaxException("Could not parse vector " + (i + 1) + " expression", parentInfo.GetErrorInfo());
                }

                if (i != 2) // move behind ,
                {
                    groupInfo.Move(SearchDirection.LeftToRight);
                }
            }

            int startIndex = parentInfo.CurrentIndex;
            int length     = 1;

            MoveInfo moveInfo = new MoveInfo(parentInfo);

            moveInfo.FindNextBlack(SearchDirection.LeftToRight);
            if (moveInfo.Current != null && ArrayIndexer.Check(moveInfo, parsingInfo, scriptInfo))
            {
                length = (moveInfo.CurrentIndex + 1) - startIndex;
            }

            vec.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.Replace(length, vec);
        }
Пример #7
0
        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);
        }
Пример #8
0
        private static void ParseLocal(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            FuncCall funcCall = new FuncCall();

            MoveInfo moveInfo = new MoveInfo(parentInfo);

            funcCall._nameElem = (Token)moveInfo.Current;
            funcCall._name     = moveInfo.Current.ToString();

            #region ParsingInfo Args
            FuncInfo tryOutFuncInfo = scriptInfo.FindGlobalsFunc(funcCall._name);
            if (tryOutFuncInfo != null && tryOutFuncInfo.HasOutParams)
            {
                parsingInfo.OutParamFuncCall     = funcCall;
                parsingInfo.OutParamFuncInfo     = tryOutFuncInfo;
                parsingInfo.OutParamFuncArgIndex = 0;
            }

            object lastCall         = parsingInfo.CurrentCall;
            int?   lastCallArgIndex = parsingInfo.CurrentCallArgIndex;
            parsingInfo.CurrentCall         = funcCall;
            parsingInfo.CurrentCallArgIndex = 0;
            #endregion

            // args
            moveInfo.FindNextBlack(SearchDirection.LeftToRight);
            if (!FuncArgs.Check(moveInfo, parsingInfo, scriptInfo))
            {
                throw new SyntaxException("Could not parse funcArgs", parentInfo.GetErrorInfo());
            }

            #region ParsingInfo Args
            if (parsingInfo.OutParamFuncCall != null)
            {
                parsingInfo.OutParamFuncCall = null;
            }

            parsingInfo.CurrentCall         = lastCall;
            parsingInfo.CurrentCallArgIndex = lastCallArgIndex;
            #endregion

            int startIndex = parentInfo.CurrentIndex;
            int length;

            // 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
            funcCall.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.MoveToIndex(startIndex);
            parentInfo.Replace(length, funcCall);
        }