コード例 #1
0
ファイル: SealedModifier.cs プロジェクト: PetX1996/CODSCRIPT
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            SealedModifier modifier = new SealedModifier(parentInfo.Current);

            parentInfo.Replace(1, modifier);
        }
コード例 #2
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            ConstDef     constDef = new ConstDef(parentInfo.Current.CharIndex, parentInfo.Current.CharLength, parentInfo.Current.LineIndex);
            MemberAccess access   = MemberAccess.Public;
            bool         isSealed = false;

            int      startIndex = parentInfo.CurrentIndex;
            MoveInfo moveInfo   = new MoveInfo(parentInfo);

            // sealed modifier
            SealedModifier trySealed = SealedModifier.GetModifier(moveInfo);

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

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

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

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

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

            // assign
            moveInfo = new MoveInfo(parentInfo);
            IElement nameElem = moveInfo.Current;

            moveInfo.FindNextBlack(SearchDirection.LeftToRight); // =
            moveInfo.FindNextBlack(SearchDirection.LeftToRight); // behind =

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

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

            constDef._compiledContent = exp;

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

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

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

            constDef.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.MoveToIndex(startIndex);
            parentInfo.Replace(length, constDef);

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

            // add const def to list
            parsingInfo.ConstDefList.Add(constDef);

            /*if (scriptInfo.Constants.FindIndex(a => a.Name == name) != -1)
             *  ErrorManager.Semantic("Constant '" + name + "' already defined", new ErrorInfo(parentInfo.ErrorInfo));
             * else
             * {*/
            ConstInfo constInfo = GetInfo(name, access, exp, isSealed, constDef.xmlBlock, parsingInfo, constDef);

            scriptInfo.AddConstant(constInfo);
            constDef._constInfo = constInfo;
            //}
        }