Exemple #1
0
        internal void ParseRoute(string routeString, out IMessageSource messageSource, out string condition, out Endpoint endpoint)
        {
            var errorListener = new ErrorListener();
            var input         = new AntlrInputStream(routeString);
            var lexer         = new RouteLexer(input);
            var tokens        = new CommonTokenStream(lexer);
            var parser        = new RouteParser(tokens);

            parser.RemoveErrorListeners();
            parser.AddErrorListener(errorListener);
            IParseTree tree = parser.route();

            errorListener.Validate();

            var walker   = new ParseTreeWalker();
            var listener = new RouteParserListener(this.endpointFactory);

            walker.Walk(listener, tree);

            condition     = listener.Condition ?? DefaultCondition;
            messageSource = CustomMessageSource.Create(listener.Source);
            endpoint      = listener.Endpoint;
        }