public DefaultParseConfig()
 {
     MainMethodName = "main";
     ArgsPattern    = new TokensBlockWithExcludePatternBuilder()
                      .Reset()
                      .StartWith(TokenType.ARGS_OPEN)
                      .ExceptRange(
         Enum.GetValues(typeof(TokenType))
         .Cast <TokenType>()
         .Where(t => t.IsOperatorToken())
         .ToList())
                      .Except(TokenType.ACCESS_MODIFICATOR)
                      .EndWith(TokenType.ARGS_CLOSE)
                      .Build();
     MethodDefPattern = new StrictComboPatternBuilder()
                        .Reset()
                        .NextPattern(new SingleTokenPattern(TokenType.IDENTIFIER))
                        .NextPattern(ArgsPattern)
                        .NextPattern(TokensBlockPattern.BracketBlock)
                        .Build();
 }
Exemple #2
0
        public CppTokenFilterChain()
        {
            var argsBlock = new TokensBlockWithExcludePatternBuilder()
                            .Reset()
                            .StartWith(TokenType.ARGS_OPEN)
                            .ExceptRange(
                Enum.GetValues(typeof(TokenType))
                .Cast <TokenType>()
                .Where(t => t.IsOperatorToken())
                .ToList())
                            .Except(TokenType.ACCESS_MODIFICATOR)
                            .EndWith(TokenType.ARGS_CLOSE)
                            .Build();

            var gotoLabelPattern = TokenSequencePatternBuilder
                                   .Reset()
                                   .Then(TokenType.IDENTIFIER)
                                   .Then(TokenType.DOUBLE_DOT)
                                   .Build();
            var gotoConstructionPattern = new StartEndTokensPattern(
                TokenType.RESERVE_5,
                TokenType.LINE_END);
            var accessModificatorPattern = TokenSequencePatternBuilder
                                           .Reset()
                                           .Then(TokenType.ACCESS_MODIFICATOR)
                                           .Then(TokenType.DOUBLE_DOT)
                                           .Build();
            var classQualifierPattern = TokenSequencePatternBuilder
                                        .Reset()
                                        .Then(TokenType.IDENTIFIER)
                                        .Then(TokenType.DOUBLE_DOT)
                                        .Then(TokenType.DOUBLE_DOT)
                                        .Build();
            var throwLinePattern = new StartEndTokensPattern(
                TokenType.THROW_OPERATOR,
                TokenType.LINE_END);
            var emptyObjVarsPattern = TokenSequencePatternBuilder
                                      .Reset()
                                      .Then(TokenType.IDENTIFIER)
                                      .Then(TokenType.IDENTIFIER)
                                      .Then(TokenType.LINE_END)
                                      .Build();
            var varDefPattern = TokenSequencePatternBuilder
                                .Reset()
                                .Then(TokenType.IDENTIFIER)
                                .Then(TokenType.LINE_END)
                                .Build();
            var castPattern = TokenSequencePatternBuilder
                              .Reset()
                              .Then(TokenType.ARGS_OPEN)
                              .Then(TokenType.IDENTIFIER)
                              .Then(TokenType.ARGS_CLOSE)
                              .Build();

            var catchBlockPattern = StrictPatternBuilder
                                    .Reset()
                                    .NextPattern(new SingleTokenPattern(TokenType.CATCH_OPERATOR))
                                    .NextPattern(argsBlock)
                                    .NextPattern(TokensBlockPattern.BracketBlock)
                                    .Build();

            var structDefPattern = StrictPatternBuilder
                                   .Reset()
                                   .NextPattern(TokenSequencePatternBuilder
                                                .Reset()
                                                .Then(TokenType.RESERVE_1)
                                                .Then(TokenType.IDENTIFIER)
                                                .Build())
                                   .NextPattern(TokensBlockPattern.BracketBlock)
                                   .Build();

            var structVarInitComboPattern = StrictPatternBuilder
                                            .Reset()
                                            .NextPattern(TokenSequencePatternBuilder
                                                         .Reset()
                                                         .Then(TokenType.IDENTIFIER)
                                                         .Then(TokenType.IDENTIFIER)
                                                         .Then(TokenType.EQUAL_ACTION)
                                                         .Build())
                                            .NextPattern(TokensBlockPattern.BracketBlock)
                                            .Build();

            Filters.AddRange(new List <TokenFilter>()
            {
                new RemoveTokensFilter(gotoLabelPattern, TokenFilter.HighestPriority),
                new RemoveTokensFilter(gotoConstructionPattern, TokenFilter.HighestPriority),
                new RemoveTokensFilter(catchBlockPattern, TokenFilter.HighestPriority),
                new RemoveTokensFilter(structDefPattern, TokenFilter.HighestPriority),
                new RemoveTokensFilter(structVarInitComboPattern, TokenFilter.HighestPriority),
                new RemoveTokensFilter(accessModificatorPattern, TokenFilter.HighestPriority),
                new RemoveTokensFilter(classQualifierPattern, TokenFilter.HighestPriority),

                new EditTokensFilter(FilterTryBlock, TokenFilter.PreHighestPriority),
                new EditTokensFilter(ClassFilter, TokenFilter.PreHighestPriority),

                new RemoveTokensFilter(throwLinePattern),
                new RemoveTokensFilter(castPattern),

                new RemoveTokensFilter(emptyObjVarsPattern, TokenFilter.LowestPriority),
                new RemoveTokensFilter(varDefPattern, TokenFilter.LowestPriority)
            });
        }