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 override void Visit(GraphDeclVertexNode node) { _symbolTable.SetCurrentNode(node); foreach (KeyValuePair <string, AbstractNode> item in node.ValueList) { item.Value.Parent = node; item.Value.Accept(this); AllType typeOfKey = _symbolTable.GetAttributeType(item.Key, AllType.VERTEX) ?? AllType.UNKNOWNTYPE; CheckAllowedCast(typeOfKey, item.Value.Type_enum); } }
public override void Visit(GraphDeclVertexNode node) { Debug.Print("GraphDeclVertexNode"); ProgramCode.Append($"{node.Name}("); int i = 0; foreach (KeyValuePair <string, AbstractNode> item in node.ValueList) { InsertComma(ref i); ProgramCode.Append($"{item.Key} = {item.Value}"); } ProgramCode.Append(")"); }
public override void Visit(GraphDeclVertexNode node) { SymbolTable.SetCurrentNode(node); /* Missing the values of the vertex*/ string vertexName = node.Name; if (CheckAlreadyDeclared(node.Name)) { SymbolTable.EnterSymbol(vertexName, AllType.VERTEX); SymbolTable.SetAssigned(vertexName); foreach (var attribute in node.ValueList) { SymbolTable.AttributeDefined(attribute.Key, AllType.VERTEX); } } }
public override AbstractNode VisitVertexDcl([NotNull] GiraphParser.VertexDclContext context) { GraphDeclVertexNode VarNode = new GraphDeclVertexNode(context.Start.Line, context.Start.Column); if (context.GetChild(0).GetText() != "(") { VarNode.Name = context.variable().GetText(); } if (context.assignment() != null) { foreach (var Child in context.assignment()) { VarNode.ValueList.Add(Child.variable().GetText(), Visit(Child.boolCompOrExp())); VarNode.AdoptChildren(Visit(Child)); } } return(VarNode); }
public abstract void Visit(GraphDeclVertexNode node);
public override void Visit(GraphDeclVertexNode node) { throw new Exception("This should be done in the GraphDeclNode"); }