private void ParseJson(string input)
        {
            AntlrInputStream stream = new AntlrInputStream(input);
            ITokenSource     lexer  = new JSONLexer(stream);
            ITokenStream     tokens = new CommonTokenStream(lexer);
            JSONParser       parser = new JSONParser(tokens);

            parser.BuildParseTree = true;
            JSONParser.JsonContext tree = parser.json();
            if (tree != null)
            {
                var builder = new TreeBuilder(parser, tree, treeModel);
                builder.Build();
            }
        }
Example #2
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="JSONParser.json"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitJson([NotNull] JSONParser.JsonContext context)
 {
 }
Example #3
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="JSONParser.json"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitJson([NotNull] JSONParser.JsonContext context)
 {
     return(VisitChildren(context));
 }
Example #4
0
 private static SyntaxNode Main(JSONParser.JsonContext json, Func <ParserRuleContext, Scope, SyntaxNode> continuation, Scope scope)
 {
     return(ParsePairs(json.pair(), continuation, scope));
 }
Example #5
0
 public DataItem VisitJson(JSONParser.JsonContext context)
 {
     return(VisitComplex_value(context.complex_value()));
 }
Example #6
0
 public override ParserNode VisitJson(JSONParser.JsonContext context) => GetNode(context, DOC, context.item());