public override void Visit(AddQueryNode node) { _symbolTable.SetCurrentNode(node); checkCollectionFollowsCollection(node.ToVariable); if (node.IsGraph) { //control statement for input to graphs AllType?TypeOfTargetCollection = _symbolTable.RetrieveSymbol(node.ToVariable, out bool isCollectionTargetColl, false); node.Type = TypeOfTargetCollection.ToString(); bool IsGraphVertexCollection = TypeOfTargetCollection == AllType.VERTEX && isCollectionTargetColl; bool isGraphEdgeCollection = TypeOfTargetCollection == AllType.EDGE && isCollectionTargetColl; bool isPreDefVerOrEdgeCollInGraph = TypeOfTargetCollection == AllType.GRAPH; if (isPreDefVerOrEdgeCollInGraph) { //if declarations are added to the graph. foreach (AbstractNode edgeOrVertexdcl in node.Dcls) { edgeOrVertexdcl.Accept(this); } } else if (IsGraphVertexCollection || isGraphEdgeCollection) { //if declarations is added to an extended collection on graph - NOT LEGAL foreach (AbstractNode vertexOrEdgedcl in node.Dcls) { if (vertexOrEdgedcl is GraphDeclVertexNode || vertexOrEdgedcl is GraphDeclEdgeNode) { break; } } } } //if the ToVariable is a collection: else if (node.IsColl) { AllType?TypeOfTargetCollection = _symbolTable.RetrieveSymbol(node.ToVariable, out bool isCollectionTargetColl, false); node.Type = TypeOfTargetCollection.ToString(); AllType?typeOfVar = null; foreach (var item in node.TypeOrVariable) { item.Accept(this); AbstractNode expressionToAdd = item; if ((expressionToAdd is BoolComparisonNode) && expressionToAdd.Children[0] is ExpressionNode) { typeOfVar = (expressionToAdd.Children[0] as ExpressionNode).OverAllType; } else if (expressionToAdd is ExpressionNode) { typeOfVar = (expressionToAdd as ExpressionNode).OverAllType; } else { typeOfVar = expressionToAdd.Type_enum; } bool targetIsGraph = TypeOfTargetCollection == AllType.GRAPH; if (isCollectionTargetColl) { //non-declarations are added to an extended collection on graph, or simply a collection. bool AllowedCast = TypeOfTargetCollection == AllType.DECIMAL && typeOfVar == AllType.INT; CheckAllowedCast(TypeOfTargetCollection ?? AllType.UNKNOWNTYPE, typeOfVar ?? AllType.UNKNOWNTYPE); } else if (targetIsGraph) { //if variables are added to the graph. bool varIsVertex = typeOfVar == AllType.VERTEX; bool varIsEdge = typeOfVar == AllType.EDGE; if (varIsEdge || varIsVertex) { //only edge and vertex variables can be added to a graph. } else { _symbolTable.WrongTypeError(node.TypeOrVariable.ToString(), node.ToVariable); } } else { _symbolTable.TargetIsNotCollError(node.ToVariable); } } } else { Console.WriteLine("Is neither collection or Graph. This should not be possible"); } }