Пример #1
0
        /// <summary>
        /// Parses the specified JSON input.
        /// </summary>
        public Node Parse(String input)
        {
            Assume.NotNull(input, nameof(input));

            var stream = new AntlrInputStream(input);
            ITokenSource lexer = new JsonLexer(stream);
            ITokenStream tokens = new CommonTokenStream(lexer);
            var parser = new JsonParser(tokens) {
                BuildParseTree = true
            };

            var tree = parser.start();

            var treeFactory = new StandardJsonSyntaxTreeFactory();
            var syntaxBuilder = new StandardJsonSyntaxTreeBuilder(treeFactory);

            return syntaxBuilder.Visit(input, tree);
        }
Пример #2
0
        /// <summary>
        /// Parses the specified JSON input.
        /// </summary>
        public Node Parse(String input)
        {
            Assume.NotNull(input, nameof(input));

            var          stream = new AntlrInputStream(input);
            ITokenSource lexer  = new JsonLexer(stream);
            ITokenStream tokens = new CommonTokenStream(lexer);
            var          parser = new JsonParser(tokens)
            {
                BuildParseTree = true
            };

            var tree = parser.start();

            var treeFactory   = new StandardJsonSyntaxTreeFactory();
            var syntaxBuilder = new StandardJsonSyntaxTreeBuilder(treeFactory);

            return(syntaxBuilder.Visit(input, tree));
        }