Exemplo n.º 1
0
        private static SyntaxNode JPair(JSONParser.PairContext pair, Func <ParserRuleContext, Scope, SyntaxNode> continuation, Scope scope)
        {
            string identifier = null;
            var    id         = pair.Identifier();

            if (id != null)
            {
                identifier = id.GetText();
            }
            else
            {
                identifier = pair
                             .StringLiteral()
                             .GetText();

                identifier = identifier.Substring(1, identifier.Length - 2); //traditional jason
            }

            var expr = (ExpressionSyntax)continuation(pair.value(), scope);

            return(CSharp
                   .AnonymousObjectMemberDeclarator(CSharp
                                                    .NameEquals(CSharp
                                                                .IdentifierName(identifier)),
                                                    expr));
        }
Exemplo n.º 2
0
 public DataField VisitPair(JSONParser.PairContext context)
 {
     return(new DataField()
     {
         Text = context.STRING().GetText().Trim('"'),
         Value = new DataValue()
         {
             Text = JToken.Parse(context.value().GetText()).ToString()
         }
     });
 }
Exemplo n.º 3
0
        public override ParserNode VisitPair(JSONParser.PairContext context)
        {
            var node  = GetNode(context, PAIR);
            var str   = context.STRING();
            var isStr = str != null;

            str = str ?? context.NUMBER();
            int start, end;

            str.GetBounds(out start, out end);
            var id = str.GetText();

            if (isStr)
            {
                ++start;
                --end;
                id = id.Substring(1, id.Length - 2);
            }
            node.AddAttr(ID, id, start, end);
            Visit(context.item()).Parent = node;
            return(node);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="JSONParser.pair"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitPair([NotNull] JSONParser.PairContext context)
 {
 }
Exemplo n.º 5
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="JSONParser.pair"/>.
 /// <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 VisitPair([NotNull] JSONParser.PairContext context)
 {
     return(VisitChildren(context));
 }