private static bool CheckDeclarationSemantic(StatementToken statement, List <ObjectDescription> descriptions) { ValueToken valueToken = statement.DeclarationToken.ValueToken; List <ObjectPropertyToken> properties = (List <ObjectPropertyToken>)valueToken.Value; VarType objectType = valueToken.Type; if (ProgramContextHolder.GetInstance().Variables.Where(p => string.Equals(p.Name, statement.DeclarationToken.IdentifierToken.Value)).ToList().Count == 0) { MyVariable variable = new MyVariable(statement.DeclarationToken.IdentifierToken.Value, objectType, valueToken); ProgramContextHolder.GetInstance().Variables.Add(variable); } else { throw new Exception("VARIABLE WITH NAME : " + "\" " + statement.DeclarationToken.IdentifierToken.Value + " \" WAS DECLARED"); } for (int field = 0; field < descriptions.Count; field++) { if (descriptions[field].ObjectType == objectType) { ObjectDescription objectDescription = descriptions[field]; for (int i = 0; i < properties.Count; i++) { ObjectField objectField = new ObjectField(properties[i].IdentifierToken.Value, properties[i].Value.Type); if (objectDescription.ObjectsFields.Contains(objectField)) { Console.WriteLine(properties[i].IdentifierToken.Value + " " + properties[i].Value.Type + " correct field"); } else { throw new Exception("Not existed field type in \"" + objectField.Name + "\" according to the :" + objectDescription.ObjectType.ToString() + " structure"); } } break; } } return(true); }
public override bool Equals(object?obj) { ObjectField objectField = (ObjectField)obj; return(obj != null && Name.Equals(objectField.Name) && FieldType == objectField.FieldType); }