Beispiel #1
0
        public override IElement CreateCopy()
        {
            DefaultSwitchStatement e = new DefaultSwitchStatement();

            e.AddChildren(this.CopyChildren());
            return(e);
        }
Beispiel #2
0
        private static void Parse(MoveInfo parentInfo, ParsingInfo parsingInfo, ScriptInfo scriptInfo)
        {
            DefaultSwitchStatement defaultSwitch = new DefaultSwitchStatement();
            MoveInfo moveInfo = new MoveInfo(parentInfo);

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

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

            // statements
            IElement nextStatement = moveInfo.FindNextBlack(SearchDirection.LeftToRight);

            while (nextStatement != null) // end of switch
            {
                if (CaseSwitchStatement.Check(moveInfo, parsingInfo, scriptInfo, false) ||
                    DefaultSwitchStatement.Check(moveInfo, parsingInfo, scriptInfo, false))
                {
                    break;
                }

                Statement.Check(moveInfo, parsingInfo, scriptInfo);

                nextStatement = moveInfo.FindNextBlack(SearchDirection.LeftToRight);
            }

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

            defaultSwitch.AddChildren(parentInfo.CurrentElements.GetRange(startIndex, length));
            parentInfo.Replace(length, defaultSwitch);
        }