Example #1
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            DoWhileStatement doWhileStatement = new DoWhileStatement();
            MoveInfo         moveInfo         = new MoveInfo(parentInfo);

            doWhileStatement._doKeyword = (Token)moveInfo.Current;

            // statement
            moveInfo.FindNextBlack(SearchDirection.LeftToRight);
            if (!Statement.Check(moveInfo, parsingInfo, scriptInfo))
            {
                throw new SyntaxException("Could not parse do-while statement", parentInfo.GetErrorInfo());
            }

            doWhileStatement._statement = (Statement)moveInfo.Current;

            // while
            IElement tryWhile = moveInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (tryWhile == null || !tryWhile.IsTT(TokenType.Word) || !tryWhile.ToString().EqualCode("while"))
            {
                throw new SyntaxException("Could not find do-while while part", parentInfo.GetErrorInfo());
            }

            doWhileStatement._whileKeyword = (Token)tryWhile;

            // expression
            IElement tryExpGroup = moveInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (tryExpGroup == null || !(tryExpGroup is ParenthesesGroup))
            {
                throw new SyntaxException("Could not find do-while expression", parentInfo.GetErrorInfo());
            }

            ParenthesesGroup expGroup     = (ParenthesesGroup)tryExpGroup;
            MoveInfo         expGroupInfo = new MoveInfo(expGroup, SearchTree.ContentBlock, 0, parentInfo);
            Expression       exp          = Expression.Parse(expGroupInfo, parsingInfo, scriptInfo);

            if (exp == null || expGroupInfo.FindNextBlack(SearchDirection.LeftToRight) != null)
            {
                throw new SyntaxException("Could not parse do-while expression", parentInfo.GetErrorInfo());
            }

            doWhileStatement._expParentGroup = expGroup;

            // terminal
            IElement tryTerminal = moveInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (tryTerminal == null || !tryTerminal.IsTT(TokenType.SemiColon))
            {
                throw new SyntaxException("Missing directive ';'?", parentInfo.GetErrorInfo());
            }

            // build
            int startIndex = parentInfo.CurrentIndex;
            int length     = (moveInfo.CurrentIndex + 1) - startIndex;

            doWhileStatement.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.Replace(length, doWhileStatement);
        }
Example #2
0
        public static bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            if (parentInfo.Current is ParenthesesGroup)
            {
                ParenthesesGroup group    = (ParenthesesGroup)parentInfo.Current;
                MoveInfo         moveInfo = new MoveInfo(group, SearchTree.ContentBlock, 0, parentInfo);

                int i;
                for (i = 0; i < 2; i++)
                {
                    IElement next = moveInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible, a => a.IsTT(TokenType.Comma));
                    if (next == null)
                    {
                        break;
                    }

                    moveInfo.Move(SearchDirection.LeftToRight);
                }

                if (i == 0)
                {
                    return(false);
                }
                else if (i == 2)
                {
                    Parse(parentInfo, parsingInfo, scriptInfo);
                    return(true);
                }
                else
                {
                    throw new SyntaxException("Only 3D vector is allowed", parentInfo.GetErrorInfo());
                }
            }
            return(false);
        }
Example #3
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);
        }
Example #4
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            IfElseStatement ifElse = new IfElseStatement();

            MoveInfo moveInfo = new MoveInfo(parentInfo);

            IElement expTry = moveInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (expTry == null || !(expTry is ParenthesesGroup))
            {
                throw new SyntaxException("Could not find if expression", parentInfo.GetErrorInfo());
            }

            ParenthesesGroup expGroup = (ParenthesesGroup)expTry;
            MoveInfo         expInfo  = new MoveInfo(expGroup, SearchTree.ContentBlock, 0, moveInfo);

            Expression exp = Expression.Parse(expInfo, parsingInfo, scriptInfo);

            if (exp == null)
            {
                throw new SyntaxException("Could not find if expression", parentInfo.GetErrorInfo());
            }

            if (expInfo.FindNextBlack(SearchDirection.LeftToRight) != null)
            {
                throw new SyntaxException("Could not parse if expression", parentInfo.GetErrorInfo());
            }

            moveInfo.Move(SearchDirection.LeftToRight);

            if (!Statement.Check(moveInfo, parsingInfo, scriptInfo))
            {
                throw new SyntaxException("Could not find statement", parentInfo.GetErrorInfo());
            }

            int endIndex = moveInfo.CurrentIndex;

            IElement tryElse = moveInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (tryElse != null && tryElse.IsTT(TokenType.Word) && moveInfo.Current.ToString() == "else")
            {
                moveInfo.Move(SearchDirection.LeftToRight);
                if (!Statement.Check(moveInfo, parsingInfo, scriptInfo))
                {
                    throw new SyntaxException("Could not find statement", parentInfo.GetErrorInfo());
                }

                endIndex = moveInfo.CurrentIndex;
            }

            int             totalLength = (endIndex + 1) - parentInfo.CurrentIndex;
            List <IElement> children    = parentInfo.CurrentElements.GetRange(parentInfo.CurrentIndex, totalLength);

            ifElse.AddChildren(children);

            parentInfo.Replace(totalLength, ifElse);
        }
Example #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>
        public static void Parse(MoveInfo moveInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            int startIndex;
            int length;

            moveInfo.GetGroupCorners(TokenType.ParenthesesOpen, TokenType.ParenthesesClose,
                                     SearchVisibility.Visible, out startIndex, out length);

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

            moveInfo.Replace(length, group);
        }
Example #6
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            FuncArgs funcArgs = new FuncArgs();

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

            IElement next = groupInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible);

            while (next != null)
            {
                Expression exp = Expression.Parse(groupInfo, parsingInfo, scriptInfo);
                next = groupInfo.FindNextBlack(SearchDirection.LeftToRight); // jump behind funcArg
                if (exp == null ||
                    (next != null && !next.IsTT(TokenType.Comma)))
                {
                    throw new SyntaxException("Could not parse funcArg", parentInfo.GetErrorInfo());
                }

                if (next != null)
                {
                    next = groupInfo.FindNextBlack(SearchDirection.LeftToRight); // jump behind ,
                    if (next == null)
                    {
                        throw new SyntaxException("Could not parse funcArg", parentInfo.GetErrorInfo());
                    }
                }

                CheckOutParam(parsingInfo, exp, parentInfo);

                if (parsingInfo.CurrentCall != null &&
                    parsingInfo.CurrentCallArgIndex != null)
                {
                    if (parsingInfo.CurrentCall is FuncCall)
                    {
                        ((FuncCall)parsingInfo.CurrentCall).Arguments.Add(exp);
                        parsingInfo.CurrentCallArgIndex++;
                    }
                    else if (parsingInfo.CurrentCall is DelegateCall)
                    {
                        ((DelegateCall)parsingInfo.CurrentCall).Arguments.Add(exp);
                        parsingInfo.CurrentCallArgIndex++;
                    }
                    else
                    {
                        throw new ArgumentException("parsingInfo.CurrentCall");
                    }
                }
            }

            funcArgs.AddChildren(group);
            parentInfo.Replace(1, funcArgs);
        }
Example #7
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);
 }
Example #8
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);
        }
Example #9
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            WhileStatement whileStatement = new WhileStatement();
            MoveInfo       moveInfo       = new MoveInfo(parentInfo);

            // expression
            IElement expGroupTry = moveInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (expGroupTry == null || !(expGroupTry is ParenthesesGroup))
            {
                throw new SyntaxException("Could not find while expression", parentInfo.GetErrorInfo());
            }

            ParenthesesGroup expGroup     = (ParenthesesGroup)expGroupTry;
            MoveInfo         expGroupInfo = new MoveInfo(expGroup, SearchTree.ContentBlock, 0, parentInfo);
            Expression       exp          = Expression.Parse(expGroupInfo, parsingInfo, scriptInfo);

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

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

            // build
            int startIndex = parentInfo.CurrentIndex;
            int length     = (moveInfo.CurrentIndex + 1) - startIndex;

            whileStatement.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.Replace(length, whileStatement);
        }
Example #10
0
        public override IElement CreateCopy()
        {
            ParenthesesGroup g = new ParenthesesGroup(this.CopyChildren());

            return(g);
        }
Example #11
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            ForStatement forStatement = new ForStatement();
            MoveInfo     moveInfo     = new MoveInfo(parentInfo);

            // expGroup
            IElement tryExpGroup = moveInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (tryExpGroup == null || !(tryExpGroup is ParenthesesGroup))
            {
                throw new SyntaxException("Could not find for expressions", parentInfo.GetErrorInfo());
            }

            ParenthesesGroup expGroup     = (ParenthesesGroup)tryExpGroup;
            MoveInfo         expGroupInfo = new MoveInfo(expGroup, SearchTree.ContentBlock, 0, parentInfo);

            // initializer
            IElement tryInitializer = expGroupInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible);

            if (tryInitializer == null)
            {
                throw new SyntaxException("Could not parse for initializer", parentInfo.GetErrorInfo());
            }

            if (!tryInitializer.IsTT(TokenType.SemiColon))
            {
                if (!ExpressionStatement.Check(expGroupInfo, parsingInfo, scriptInfo, false))
                {
                    throw new SyntaxException("Could not parse for initializer", parentInfo.GetErrorInfo());
                }

                expGroupInfo.FindNextBlack(SearchDirection.LeftToRight);
            }

            if (expGroupInfo.Current == null || !expGroupInfo.Current.IsTT(TokenType.SemiColon))
            {
                throw new SyntaxException("Missing for first directive ';'?", parentInfo.GetErrorInfo());
            }

            // expression
            IElement tryExpression = expGroupInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (tryExpression == null)
            {
                throw new SyntaxException("Could not parse for expression", parentInfo.GetErrorInfo());
            }

            if (!tryExpression.IsTT(TokenType.SemiColon))
            {
                Expression exp = Expression.Parse(expGroupInfo, parsingInfo, scriptInfo);
                if (exp == null)
                {
                    throw new SyntaxException("Could not parse for expression", parentInfo.GetErrorInfo());
                }

                expGroupInfo.FindNextBlack(SearchDirection.LeftToRight);
            }

            if (expGroupInfo.Current == null || !expGroupInfo.Current.IsTT(TokenType.SemiColon))
            {
                throw new SyntaxException("Missing for second directive ';'?", parentInfo.GetErrorInfo());
            }

            // iterator
            IElement tryIterator = expGroupInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (tryIterator != null)
            {
                if (!ExpressionStatement.Check(expGroupInfo, parsingInfo, scriptInfo, false))
                {
                    throw new SyntaxException("Could not parse for iterator", parentInfo.GetErrorInfo());
                }

                IElement end = expGroupInfo.FindNextBlack(SearchDirection.LeftToRight);
                if (end != null)
                {
                    throw new SyntaxException("Could not parse for iterator", parentInfo.GetErrorInfo());
                }
            }

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

            // build
            int startIndex = parentInfo.CurrentIndex;
            int length     = (moveInfo.CurrentIndex + 1) - startIndex;

            forStatement.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.Replace(length, forStatement);
        }
Example #12
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            ForEachStatement foreachStatement = new ForEachStatement();
            MoveInfo         moveInfo         = new MoveInfo(parentInfo);

            foreachStatement._foreachKeyword = (Token)moveInfo.Current;

            // expression
            IElement expGroupTry = moveInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (expGroupTry == null || !(expGroupTry is ParenthesesGroup))
            {
                throw new SyntaxException("Could not find foreach expression", parentInfo.GetErrorInfo());
            }

            ParenthesesGroup expGroup     = (ParenthesesGroup)expGroupTry;
            MoveInfo         expGroupInfo = new MoveInfo(expGroup, SearchTree.ContentBlock, 0, parentInfo);

            foreachStatement._foreachGroup = expGroup;

            // var define
            IElement tryVar = expGroupInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible);

            if (tryVar == null || !tryVar.IsTT(TokenType.Word))
            {
                throw new SyntaxException("Could not parse foreach var", parentInfo.GetErrorInfo());
            }

            VarName.Parse(expGroupInfo, parsingInfo, scriptInfo);
            VarName varName = (VarName)expGroupInfo.Current;

            LocalVarInfo localVar = parsingInfo.CurrentFunc.LocalVars.Find(a => a.Name.EqualCode(tryVar.ToString()));     // there is already var with this name...

            if (localVar == null)
            {
                parsingInfo.CurrentFunc.LocalVars.Add(new LocalVarInfo(scriptInfo.SF, tryVar.ToString(), tryVar.CharIndex, tryVar.CharLength, null, varName));
            }

            foreachStatement._currentVar = varName;

            // in keyword
            IElement tryIn = expGroupInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (tryIn == null || !tryIn.IsTT(TokenType.Word) || !tryIn.ToString().EqualCode("in"))
            {
                throw new SyntaxException("Could not find foreach 'in'", parentInfo.GetErrorInfo());
            }

            // array
            IElement   tryArray    = expGroupInfo.FindNextBlack(SearchDirection.LeftToRight);
            Expression tryArrayExp = Expression.Parse(expGroupInfo, parsingInfo, scriptInfo);

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

            foreachStatement._array = tryArrayExp;

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

            foreachStatement._statement = (Statement)moveInfo.Current;

            // build
            int startIndex = parentInfo.CurrentIndex;
            int length     = (moveInfo.CurrentIndex + 1) - startIndex;

            foreachStatement.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.Replace(length, foreachStatement);
        }
Example #13
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            SwitchStatement switchStatement = new SwitchStatement();
            MoveInfo        moveInfo        = new MoveInfo(parentInfo);

            // expression
            IElement tryExpGroup = moveInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (!(tryExpGroup is ParenthesesGroup))
            {
                throw new SyntaxException("Could not find switch expression", parentInfo.GetErrorInfo());
            }

            ParenthesesGroup expGroup = (ParenthesesGroup)tryExpGroup;

            MoveInfo   expGroupInfo = new MoveInfo(expGroup, SearchTree.ContentBlock, 0, parentInfo);
            Expression exp          = Expression.Parse(expGroupInfo, parsingInfo, scriptInfo);

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

            // scope group
            IElement tryScopeGroup = moveInfo.FindNextBlack(SearchDirection.LeftToRight);

            if (!(tryScopeGroup is ScopeGroup))
            {
                throw new SyntaxException("Could not find switch ScopeGroup", parentInfo.GetErrorInfo());
            }

            ScopeGroup scopeGroup = (ScopeGroup)tryScopeGroup;

            MoveInfo scopeGroupInfo = new MoveInfo(scopeGroup, SearchTree.ContentBlock, 0, parentInfo);
            IElement nextCase       = scopeGroupInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible);

            if (nextCase == null)
            {
                throw new SyntaxException("Could not find any switch case", parentInfo.GetErrorInfo());
            }

            while (nextCase != null)
            {
                if (!(
                        DefaultSwitchStatement.Check(scopeGroupInfo, parsingInfo, scriptInfo, true) ||
                        CaseSwitchStatement.Check(scopeGroupInfo, parsingInfo, scriptInfo, true)
                        ))
                {
                    throw new SyntaxException("Could not parse switch case/default", parentInfo.GetErrorInfo());
                }

                nextCase = scopeGroupInfo.FindNextBlack(SearchDirection.LeftToRight);
            }

            // build
            int startIndex = parentInfo.CurrentIndex;
            int length     = (moveInfo.CurrentIndex + 1) - startIndex;

            switchStatement.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.Replace(length, switchStatement);
        }
Example #14
0
        public static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            FuncDef function = new FuncDef(parentInfo.Current.CharIndex, parentInfo.Current.CharLength, parentInfo.Current.LineIndex, parsingInfo.SF);

            // začiatok názvu
            MoveInfo moveInfo = new MoveInfo(parentInfo);

            int startIndex = parentInfo.CurrentIndex;

            // modifier
            MemberAccess   access;
            AccessModifier modifier = AccessModifier.GetModifier(moveInfo, out access);

            if (modifier != null)
            {
                startIndex = moveInfo.CurrentIndex;
            }
            else
            {
                moveInfo = new MoveInfo(parentInfo);
            }

            // xml
            XMLBlock xml = XMLBlock.GetXMLSummary(moveInfo);

            function.xmlBlock = xml;
            if (xml != null)
            {
                startIndex = moveInfo.CurrentIndex;
            }

            // začiatok názvu
            moveInfo = new MoveInfo(parentInfo);
            IElement nameElem = moveInfo.Current;

            moveInfo.Move(SearchDirection.LeftToRight);

            // parametry
            IElement paramsTry = moveInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible);

            if (!(paramsTry is ParenthesesGroup))
            {
                throw new SyntaxException("Could not find FuncDef parameters", parentInfo.GetErrorInfo());
            }

            ParenthesesGroup paramsGroup = (ParenthesesGroup)paramsTry;
            // získaj zoznam parametrov
            MoveInfo            paramsMoveInfo = new MoveInfo(paramsGroup, SearchTree.ContentBlock, 0, moveInfo);
            List <FuncDefParam> defParams      = GetParameterList(paramsMoveInfo, parsingInfo, scriptInfo);

            // pridaj zoznam parametrov do stromu a posuň sa zaň
            moveInfo.Move(SearchDirection.LeftToRight);

            // body
            IElement bodyTry = moveInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible);

            if (!(bodyTry is ScopeGroup))
            {
                throw new SyntaxException("Could not find FuncDef body", parentInfo.GetErrorInfo());
            }

            ScopeGroup      bodyGroup         = (ScopeGroup)bodyTry;
            List <IElement> bodyGroupChildren = bodyGroup.GetChildren();

            moveInfo.Move(SearchDirection.LeftToRight); // skoč za telo

            // add func to tree
            int             totalLength = moveInfo.CurrentIndex - startIndex;
            List <IElement> children    = parentInfo.CurrentElements.GetRange(startIndex, totalLength);

            function.AddChildren(children);


            foreach (FuncDefParam p in defParams)
            {
                function.LocalVars.Add(new LocalVarInfo(parsingInfo.SF, p.Name, (int)function.ImportantCharIndex, (int)function.ImportantCharLength, null, p.VarName)); // it must be after function.AddChildren() !!
            }
            parentInfo.MoveToIndex(startIndex);
            parentInfo.Replace(totalLength, function);

            // set current function
            parsingInfo.CurrentFunc = function;
            parsingInfo.FuncDefList.Add(function);

            // go inside body
            MoveInfo bodyInfo = new MoveInfo(bodyGroup, SearchTree.ContentBlock, 0, parentInfo);

            Statement.ParseStatementList(bodyInfo, parsingInfo, scriptInfo);

            // info
            string name = nameElem.ToString();

            /*if (scriptInfo.)
             * if (scriptInfo.Functions.FindIndex(a => a.Name.EqualCode(name)) != -1)
             * {
             *  ErrorManager.Semantic("Function '" + name + "' already defined", new ErrorInfo(parentInfo.ErrorInfo));
             *  return;
             * }*/

            FuncInfo funcInfo = GetInfo(name, access, defParams, xml, parsingInfo, function);

            scriptInfo.AddFunction(funcInfo);

            function.funcInfo = funcInfo;
        }