コード例 #1
0
        private static void ParseExtern(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            DelegateDef delegDef = new DelegateDef();

            MoveInfo moveInfo = new MoveInfo(parentInfo);
            Path     path     = Path.Parse(moveInfo, parsingInfo, scriptInfo);

            if (path == null)
            {
                throw new SyntaxException("Bad path", parentInfo.GetErrorInfo());
            }

            delegDef._pathOrUsing = path.ToString();
            delegDef._pathElem    = path;

            // ::
            moveInfo.FindNextBlack(SearchDirection.LeftToRight);
            delegDef._nameSpaceElem = (Token)moveInfo.Current;

            // name
            moveInfo.FindNextBlack(SearchDirection.LeftToRight);
            delegDef._name = moveInfo.Current.ToString();

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

            delegDef.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.Replace(length, delegDef);
        }
コード例 #2
0
        // TODO: dokončiť!
        // zostupne podľa priority vyhľadávania
        // konštanty sa pridružujú k iným operandom a určujú sa podľa kontextu!

        // "string"
        // "string".member
        // "string"[i]

        // &"FILE_LOCALIZED_STRING"

        // 56 | -56 | +56

        // []

        // { 1, 2, 3 }

        // (0,1,2)
        // (0,1,2)[i]

        // (subExpression)
        // (subExpression).member
        // (subExpression)[i]

        // true
        // false
        // undefined

        // thread

        // ::func
        // path::func | path::const

        // var | const
        // var.member
        // var[i]


        // as operators

        // = Expression

        // lastOperand [[delegate]]()
        // lastOperand [[delegate]]().member
        // lastOperand [[delegate]]()[i]

        // lastOperand func()
        // lastOperand func().member
        // lastOperand func()[i]
        // lastOperand path::func()
        // lastOperand path::func().member
        // lastOperand path::func()[i]

        public static bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo, ref bool isSingleOperand, bool isArrayContentDefEnabled, bool isArrayDefEnabled)
        {
            if ((isArrayDefEnabled && (ArrayDef.Check(parentInfo, parsingInfo, scriptInfo))) || // []
                (isArrayContentDefEnabled && ArrayContentDef.Check(parentInfo, parsingInfo, scriptInfo)))    // { 0,1,2 }
            {
                isSingleOperand = IsSingle(parentInfo, parsingInfo);
                return(true);
            }

            if (StringArray.Check(parentInfo, parsingInfo, scriptInfo) || // "str" | "str".member | "str"[]
                LocalizedString.Check(parentInfo, parsingInfo, scriptInfo) || // &"str"
                SignedNumber.Check(parentInfo, parsingInfo, scriptInfo) || // 56 | -56 | +56
                Vector.Check(parentInfo, parsingInfo, scriptInfo) || // (0,1,2) | (0,1,2)[]
                SubExpression.Check(parentInfo, parsingInfo, scriptInfo) || // (exp) | (exp).member* | (exp)[]*
                Literal.Check(parentInfo, parsingInfo, scriptInfo) || // true | false | undefined
                FuncCallModifier.Check(parentInfo, parsingInfo, scriptInfo) || // thread
                DelegateCall.Check(parentInfo, parsingInfo, scriptInfo) || // // [[delegate]](funcArgs) | [[d]]().member* | [[d]]()[]*
                FuncCall.Check(parentInfo, parsingInfo, scriptInfo) || // f() | path::f() | f().member* | f()[i]*
                DelegateDef.Check(parentInfo, parsingInfo, scriptInfo) || // ::func | path::func
                VarName.Check(parentInfo, parsingInfo, scriptInfo)    // var | var.member* | var[i]*
                )
            {
                isSingleOperand = IsSingle(parentInfo, parsingInfo);
                return(true);
            }

            return(false);
        }
コード例 #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);
        }
コード例 #4
0
        public static bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            if (parentInfo.Current.IsTT(TokenType.Word))
            {
                // local function
                MoveInfo localInfo  = new MoveInfo(parentInfo);
                IElement behindName = localInfo.FindNextBlack(SearchDirection.LeftToRight);
                if (behindName is ParenthesesGroup)
                {
                    ParseLocal(parentInfo, parsingInfo, scriptInfo);
                    return(true);
                }

                // extern function
                MoveInfo externInfo = new MoveInfo(parentInfo);
                Path.MoveToEnd(externInfo, SearchDirection.LeftToRight);
                IElement behindPath = externInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible);
                if (behindPath.IsTT(TokenType.Namespace))
                {
                    IElement name = externInfo.FindNextBlack(SearchDirection.LeftToRight);
                    if (name.IsTT(TokenType.Word))
                    {
                        IElement args = externInfo.FindNextBlack(SearchDirection.LeftToRight);
                        if (args is ParenthesesGroup)
                        {
                            ParseExtern(parentInfo, parsingInfo, scriptInfo);
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
コード例 #5
0
ファイル: Statement.cs プロジェクト: PetX1996/CODSCRIPT
 public static void ParseStatementList(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
 {
     while (Check(parentInfo, parsingInfo, scriptInfo))
     {
         parentInfo.Move(SearchDirection.LeftToRight);
     }
 }
コード例 #6
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            WaitStatement waitStatement = new WaitStatement();
            MoveInfo      moveInfo      = new MoveInfo(parentInfo);

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

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

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

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

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

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

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

            waitStatement.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.Replace(length, waitStatement);
        }
コード例 #7
0
        /// <summary>
        /// Vráti path a pridá ho do stromu
        /// Mal by fungovať oboma smermi.
        /// </summary>
        /// <param name="moveInfo"></param>
        /// <param name="dir"></param>
        /// <param name="startIndex"></param>
        /// <param name="length"></param>
        /// <returns></returns>
        public static Path Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo) // TODO: otestovať oboma smermi!
        {
            // TODO: funguješ správne? skontrolovať!
            MoveInfo moveInfo = new MoveInfo(parentInfo);
            IElement next     = moveInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible);

            if (next == null)
            {
                return(null);
            }

            int startIndex = moveInfo.CurrentIndex;

            MoveToEnd(moveInfo, SearchDirection.LeftToRight);

            int length = moveInfo.CurrentIndex - startIndex;

            if (length == 0)
            {
                return(null);
            }

            Path path = new Path(parentInfo.CurrentElements.GetRange(startIndex, length));

            parentInfo.MoveToIndex(startIndex);
            parentInfo.Replace(length, path);
            return(path);
        }
コード例 #8
0
ファイル: XMLBlock.cs プロジェクト: PetX1996/CODSCRIPT
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            MoveInfo        moveInfo = new MoveInfo(parentInfo);
            List <IElement> content  = new List <IElement>();

            IElement cur          = moveInfo.Current;
            int      lastXMLIndex = moveInfo.CurrentIndex;

            do
            {
                if (cur.IsTT(TokenType.XMLComment))
                {
                    lastXMLIndex = moveInfo.CurrentIndex;
                }

                cur = moveInfo.Move(SearchDirection.LeftToRight);
            }while (cur != null && (cur.IsTT(TokenType.XMLComment) || cur.IsTT(TokenType.WhiteSpace)));

            int startIndex = parentInfo.CurrentIndex;
            int length     = (lastXMLIndex + 1) - startIndex;

            // add tokens between first and last xml with its
            content.AddRange(moveInfo.CurrentElements.GetRange(startIndex, length));

            IElement xmlBlock = new XMLBlock(content);

            parentInfo.Replace(length, xmlBlock);
        }
コード例 #9
0
        public static bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            // local
            if (parentInfo.Current.IsTT(TokenType.Namespace))
            {
                MoveInfo localInfo = new MoveInfo(parentInfo);
                IElement next      = localInfo.FindNextBlack(SearchDirection.LeftToRight);
                if (next.IsTT(TokenType.Word))
                {
                    ParseLocal(parentInfo, parsingInfo, scriptInfo);
                    return(true);
                }
            }

            // extern
            if (parentInfo.Current.IsTT(TokenType.Word))
            {
                MoveInfo externInfo = new MoveInfo(parentInfo);
                Path.MoveToEnd(externInfo, SearchDirection.LeftToRight);
                IElement next = externInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible);
                if (next.IsTT(TokenType.Namespace))
                {
                    next = externInfo.FindNextBlack(SearchDirection.LeftToRight);
                    if (next.IsTT(TokenType.Word))
                    {
                        ParseExtern(parentInfo, parsingInfo, scriptInfo);
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #10
0
ファイル: PostfixIncDec.cs プロジェクト: PetX1996/CODSCRIPT
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            PostfixIncDec postfixIncDec = new PostfixIncDec();

            int startIndex = parentInfo.CurrentIndex;
            int length;

            // find operand
            MoveInfo operandInfo = new MoveInfo(parentInfo);
            IElement operand     = operandInfo.FindNextBlack(SearchDirection.RightToLeft);

            if (operand != null && operand is ExpressionOperand)
            {
                startIndex = operandInfo.CurrentIndex;
            }
            else
            {
                throw new SyntaxException("Could not find PostfixIncDec operand", parentInfo.GetErrorInfo());
            }

            // build
            length = (parentInfo.CurrentIndex + 1) - startIndex;
            postfixIncDec.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));

            parentInfo.MoveToIndex(startIndex);
            parentInfo.Replace(length, postfixIncDec);
        }
コード例 #11
0
ファイル: FuncArgs.cs プロジェクト: PetX1996/CODSCRIPT
        private static void CheckOutParam(ParsingInfo parsingInfo, Expression exp, MoveInfo parentInfo)
        {
            if (parsingInfo.OutParamFuncCall != null)
            {
                FuncInfo funcInfo = parsingInfo.OutParamFuncInfo;
                if (parsingInfo.OutParamFuncArgIndex < funcInfo.Parameters.Count)
                {
                    if (funcInfo.Parameters[parsingInfo.OutParamFuncArgIndex].IsOut)
                    {
                        // check exp content
                        List <IElement> expChildren = exp.GetChildren();
                        if (expChildren.Count != 0 && (expChildren[0] is VarName) &&
                            ((VarName)expChildren[0]).GetChildren().Count == 1)
                        {
                            VarName varName    = (VarName)expChildren[0];
                            string  varNameStr = varName.ToString();

                            parsingInfo.CurrentFunc.LocalVars.Add(new LocalVarInfo(parsingInfo.SF, varNameStr, varName.CharIndex, varName.CharLength, null, varName));
                        }
                        else
                        {
                            throw new SyntaxException("Only VarName is allowed as out parameter", parentInfo.GetErrorInfo());
                        }
                    }
                }

                parsingInfo.OutParamFuncArgIndex++;
            }
        }
コード例 #12
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);
        }
コード例 #13
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);
        }
コード例 #14
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            Assign assign = new Assign();

            int startIndex;
            int length;

            // find var define
            MoveInfo varInfo = new MoveInfo(parentInfo);
            IElement var     = varInfo.FindNextBlack(SearchDirection.RightToLeft);

            if (var == null || !(var is ExpressionOperand) || !(var is VarName))
            {
                throw new SyntaxException("Could not parse Assign VarName", parentInfo.GetErrorInfo());
            }

            assign.VarName = (VarName)var;

            startIndex = varInfo.CurrentIndex;

            // parse expression
            MoveInfo moveInfo = new MoveInfo(parentInfo);

            moveInfo.FindNextBlack(SearchDirection.LeftToRight); // move behind =
            Expression exp = Expression.Parse(moveInfo, parsingInfo, scriptInfo, false, true, true);

            if (exp == null)
            {
                throw new SyntaxException("Could not parse Assign Expression", parentInfo.GetErrorInfo());
            }

            assign.Exp = exp;

            // build
            length = (moveInfo.CurrentIndex + 1) - startIndex;
            assign.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));

            parentInfo.MoveToIndex(startIndex);
            parentInfo.Replace(length, assign);

            // add local var def
            IElement baseVar     = ((VarName)var).GetChildren()[0];
            string   baseVarName = baseVar.ToString();

            foreach (string tStr in ScriptManager.GlobalVariables)
            {
                if (baseVarName.EqualCode(tStr))
                {
                    return;
                }
            }

            LocalVarInfo tryVarInfo = parsingInfo.CurrentFunc.LocalVars.Find(a => a.Name.EqualCode(baseVarName)); // there is maybe var with this name...

            if (tryVarInfo == null)
            {
                parsingInfo.CurrentFunc.LocalVars.Add(new LocalVarInfo(parsingInfo.SF, baseVarName, baseVar.CharIndex, baseVar.CharLength, assign, (VarName)var));
            }
        }
コード例 #15
0
ファイル: DelegateCall.cs プロジェクト: PetX1996/CODSCRIPT
 public static bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
 {
     if (parentInfo.Current is DelegateCallGroup)
     {
         Parse(parentInfo, parsingInfo, scriptInfo);
         return(true);
     }
     return(false);
 }
コード例 #16
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);
        }
コード例 #17
0
        private static void ParseUnsigned(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            SignedNumber n = new SignedNumber(new List <IElement>()
            {
                parentInfo.Current
            });

            parentInfo.Replace(1, n);
        }
コード例 #18
0
ファイル: UsingDef.cs プロジェクト: PetX1996/CODSCRIPT
 public static bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
 {
     if (parentInfo.Current.IsTT(TokenType.Word) && parentInfo.Current.ToString().EqualCode("using"))
     {
         Parse(parentInfo, parsingInfo, scriptInfo);
         return(true);
     }
     return(false);
 }
コード例 #19
0
 public static bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
 {
     if (parentInfo.Current is Token && ((Token)parentInfo.Current).Type.SType == TokenType.SymbolType.UnaryOperator)
     {
         Parse(parentInfo, parsingInfo, scriptInfo);
         return(true);
     }
     return(false);
 }
コード例 #20
0
 public static new bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
 {
     if (parentInfo.Current is ScopeGroup)
     {
         Parse(parentInfo, parsingInfo, scriptInfo);
         return(true);
     }
     return(false);
 }
コード例 #21
0
 public static bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
 {
     if (parentInfo.Current.IsTT(TokenType.String))
     {
         Parse(parentInfo, parsingInfo, scriptInfo);
         return(true);
     }
     return(false);
 }
コード例 #22
0
 public static bool IsSingle(MoveInfo parentInfo, ParsingInfo parsingInfo)
 {
     // single operands
     return(parentInfo.Current is ArrayDef ||
            parentInfo.Current is ArrayContentDef
            /*|| parentInfo.Current is DelegateDef*/ // maybe ConsName !!!
            || parentInfo.Current is Assign ||
            parentInfo.Current is PostfixIncDec
            );
 }
コード例 #23
0
        private static void ParseSigned(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            MoveInfo moveInfo = new MoveInfo(parentInfo);

            moveInfo.FindNextBlack(SearchDirection.LeftToRight);

            int          length = ((moveInfo.CurrentIndex + 1) - parentInfo.CurrentIndex);
            SignedNumber n      = new SignedNumber(parentInfo.CurrentElements.GetRange(parentInfo.CurrentIndex, length));

            parentInfo.Replace(length, n);
        }
コード例 #24
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);
        }
コード例 #25
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            BlockStatement bS             = new BlockStatement();
            ScopeGroup     statementGroup = (ScopeGroup)parentInfo.Current;

            MoveInfo groupInfo = new MoveInfo(statementGroup, SearchTree.ContentBlock, 0, parentInfo);

            Statement.ParseStatementList(groupInfo, parsingInfo, scriptInfo);

            bS.AddChildren(statementGroup);
            parentInfo.Replace(1, bS);
        }
コード例 #26
0
ファイル: FuncArgs.cs プロジェクト: PetX1996/CODSCRIPT
        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);
        }
コード例 #27
0
ファイル: BinaryOperator.cs プロジェクト: PetX1996/CODSCRIPT
        public static bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            IElement cur = parentInfo.Current;

            if (cur is Token && ((Token)cur).Type.SType == TokenType.SymbolType.BinaryOperator ||
                cur.IsTT(TokenType.BitAND) || cur.IsTT(TokenType.ADD) || cur.IsTT(TokenType.SUB))
            {
                Parse(parentInfo, parsingInfo, scriptInfo);
                return(true);
            }
            return(false);
        }
コード例 #28
0
        public static void ParseEndRegion(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            MoveInfo        moveInfo = new MoveInfo(parentInfo);
            List <IElement> content  = new List <IElement>(2);

            content.Add(moveInfo.Current);
            content.Add(moveInfo.Move(SearchDirection.LeftToRight));

            IBlock region = new PreProcessorRegion(content);

            parentInfo.Replace(2, region);
        }
コード例 #29
0
 public static bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
 {
     if (parentInfo.Current is Token)
     {
         TokenType tt = ((Token)parentInfo.Current).Type;
         if (tt.SType == TokenType.SymbolType.Assign)
         {
             Parse(parentInfo, parsingInfo, scriptInfo);
             return(true);
         }
     }
     return(false);
 }
コード例 #30
0
 public static new bool Check(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
 {
     if (parentInfo.Current is SQBracketGroup)
     {
         MoveInfo groupInfo = new MoveInfo((SQBracketGroup)parentInfo.Current, SearchTree.ContentBlock, 0, parentInfo);
         IElement first     = groupInfo.Find(SearchDirection.LeftToRight, SearchVisibility.Visible);
         if (first is SQBracketGroup && groupInfo.FindNextBlack(SearchDirection.LeftToRight) == null)
         {
             Parse(parentInfo, parsingInfo, scriptInfo);
             return(true);
         }
     }
     return(false);
 }