Esempio n. 1
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);
        }