Exemple #1
0
        public override AbstractNode VisitGraphInitDcl([NotNull] GiraphParser.GraphInitDclContext context)
        {
            GraphNode GNode = new GraphNode(context.Start.Line, context.Start.Column);

            GNode.Name = context.variable().GetText();
            // Handle all VetexDcl's and add them to the list in the GraphNode
            foreach (var Child in context.graphDclBlock().vertexDcls())
            {
                foreach (var NestedChild in Child.vertexDcl())
                {
                    GraphDeclVertexNode VNode = new GraphDeclVertexNode(context.Start.Line, context.Start.Column);
                    if (NestedChild.variable() != null)
                    {
                        VNode.Name = NestedChild.variable().GetText();
                    }
                    if (NestedChild.assignment() != null)
                    {
                        foreach (var Attribute in NestedChild.assignment())
                        {
                            VNode.ValueList.Add(Attribute.variable().GetText(), Visit(Attribute.boolCompOrExp()));
                        }
                    }
                    GNode.Vertices.Add(VNode);
                }
            }
            // Handle all edgeDcl's and add them to the list in the GraphNode
            foreach (var Child in context.graphDclBlock().edgeDcls())
            {
                foreach (var NestedChild in Child.edgeDcl())
                {
                    GraphDeclEdgeNode ENode = new GraphDeclEdgeNode(context.Start.Line, context.Start.Column);
                    // If there is a name for the Edge
                    if (NestedChild.variable().GetLength(0) > 2)
                    {
                        ENode.Name           = NestedChild.variable(0).GetText();               // Edge Name
                        ENode.VertexNameFrom = NestedChild.variable(1).GetText();               // Vertex From
                        ENode.VertexNameTo   = NestedChild.variable(2).GetText();               // Vertex To
                    }
                    else
                    {
                        ENode.VertexNameFrom = NestedChild.variable(0).GetText();                       // Vertex From
                        ENode.VertexNameTo   = NestedChild.variable(1).GetText();                       // Vertex To
                    }
                    // Checks if there are any assignments
                    if (NestedChild.assignment() != null)
                    {
                        foreach (var Attribute in NestedChild.assignment())
                        {
                            // This is in order to ignore the attributes that are without
                            if (Attribute.variable() != null)
                            {
                                ENode.ValueList.Add(Attribute.variable().GetText(), Visit(Attribute.boolCompOrExp()));
                            }
                        }
                    }
                    GNode.Edges.Add(ENode);
                }
            }
            return(GNode);
        }
 public ProjectedNestedChild(ClassWithNestedObservableCollection parent, NestedChild child)
 {
     Parent = parent;
     Child  = child;
 }