public override void Visit(ExtractMinQueryNode node) { _symbolTable.SetCurrentNode(node); checkCollectionFollowsCollection(node.Variable); AllType collectionNameType = _symbolTable.RetrieveSymbol(node.Variable, out bool isCollectionInQuery, false) ?? AllType.UNKNOWNTYPE; /*if (_symbolTable.IsClass(collectionNameType)) { * _symbolTable.CollectionOfClasses(); * return; * }*/ if (isCollectionInQuery) { node.Type = collectionNameType.ToString().ToLower(); if (!_symbolTable.IsClass(node.Type_enum) && node.Attribute != null && node.Attribute != "") { _symbolTable.AttributeUsedOnNonClass(); } } else { _symbolTable.NotCollection(node.Variable); } if (node.WhereCondition != null) { node.WhereCondition.Accept(this); } }
public override string ToString() { string collection = IsCollection ? "COLLECTION" : ""; string colName; colName = collection; return(colName + " " + Type.ToString() + "|Depth:" + Depth + "|Reach:" + Reachable.ToString()); }
public override void Visit(DequeueQueryNode node) { _symbolTable.SetCurrentNode(node); AllType CollectionType = _symbolTable.RetrieveSymbol(node.Variable, out bool isCollection) ?? AllType.UNKNOWNTYPE; if (!isCollection) { _symbolTable.ExpectedCollection(); return; } node.Type = CollectionType.ToString().ToLower(); }
/// <summary> /// Retrieves the type from classes. /// </summary> /// <returns>The type from classes.</returns> /// <param name="names">Names.</param> /// <param name="type">Type.</param> /// <param name="IsCollection">If set to <c>true</c> is collection.</param> /// <param name="ShowErrors">If set to <c>true</c> show errors.</param> private AllType?RetrieveTypeFromClasses(List <string> names, AllType type, out bool IsCollection, bool ShowErrors = true) { // [GRAPH/VERTEX/EDGE]-><KEYS>->ClassEntry string name = names[0]; // Check if the class contains a variable with the name given if (_classesTable[type].ContainsKey(name)) { var entry = _classesTable[type][name]; // Check if the type on the names place, is a class type if (IsClass(entry.Type)) { // Check how many names are left to handle, its its more then 1, continue if (names.Count > 1) { // Remove the first name, since its no longer needed names.RemoveAt(0); // Call RetriveTypeFromClasses recursively until the final type is determined return(RetrieveTypeFromClasses(names, entry.Type, out IsCollection, ShowErrors)); } else { // If this is the last name, return the type of it. IsCollection = entry.Collection; return(entry.Type); } } // If its not a class, just return the type else { IsCollection = entry.Collection; return(_classesTable[type][name].Type); } } else { if (ShowErrors) { Console.WriteLine(name + " is undeclared in the class " + type.ToString()); } IsCollection = false; return(null); } }