public IfBranchVariable CreateElseBranchVariable(IEnumerable <Token> tokens, Token token, ICollection <Variable> variables, int i)
        {
            var branchVariable = new IfBranchVariable
            {
                Value = token.Flag
            };

            ICollection <Token> subTokens = new List <Token>();

            Util.CollectionTokens(tokens, subTokens, i + 1, Strings.StartFlag2, Strings.EndFlag2, true);
            var count = subTokens.Count();

            ICollection <Variable> bodyVariables = new List <Variable>();

            branchVariable.Variables = bodyVariables;

            for (var a = 0; a < count; a++)
            {
                var subToken = subTokens.ElementAt(a);
                var handler  = VariableHandleFactory.Create(subToken.Flag);
                a = handler.TryAddVariable(subTokens, subToken, bodyVariables, a);
            }

            branchVariable.TokenCount = count;
            return(branchVariable);
        }
        private static IEnumerable <CaseVariable> GetCaseVariables(ICollection <Token> tokens)
        {
            var n = tokens.Count();
            ICollection <CaseVariable> caseVariables = new List <CaseVariable>();
            ICollection <Variable>     variables     = new List <Variable>();
            CaseVariable lastCaseVariable            = null;

            for (var a = 0; a < n; a++)
            {
                var token = tokens.ElementAt(a);
                var flag  = token.Flag;
                if (flag == Break)
                {
                    lastCaseVariable.Variables = variables.ToArray();
                    variables.Clear();
                    lastCaseVariable = null;
                    continue;
                }
                else if (flag != Case && flag != DefaultStr)
                {
                    var handler = VariableHandleFactory.Create(flag);
                    a = handler.TryAddVariable(tokens, token, variables, a);
                    continue;
                }

                if (lastCaseVariable == null)
                {
                    lastCaseVariable = new CaseVariable();
                    caseVariables.Add(lastCaseVariable);
                }

                if (flag == DefaultStr)
                {
                    lastCaseVariable.Default = true;
                    if (tokens.ElementAt(a + 1).Flag != Strings.Colon)
                    {
                        throw new ArgumentException("switch 语法错误");
                    }

                    a += 1;
                    continue;
                }

                var nextFlag = tokens.ElementAt(a + 1).Flag;
                var result   = DefaultVariableHandler.CreateVariable(tokens, nextFlag, a + 1);
                lastCaseVariable.ConstVariable.Add(result.Item1);
                var nextSplitFlag = tokens.ElementAt(result.Item2 + 1).Flag;
                if (nextSplitFlag != Strings.Colon)
                {
                    throw new ArgumentException("switch 语法错误");
                }

                a += 2;
            }

            return(caseVariables);
        }