示例#1
0
        public override void CheckBodySemantics(TigerScope scope, Report report)
        {
            //Check children
            IdNode.CheckSemantics(scope, report);
            FieldDeclarationNodes.ToList().ForEach(f => f.CheckSemantics(scope, report));

            var usedNames = new List <string>();

            foreach (var f in FieldDeclarationNodes)
            {
                if (usedNames.Contains(f.IdNode.Name))
                {
                    report.AddError(SemanticErrors.DuplicateFieldDeclaration(f, IdNode.Name, f.IdNode.Name));
                }
                usedNames.Add(f.IdNode.Name);
            }

            //If type was not added to scope (if CheckSemantics failed) return
            if (!IsOK || FieldDeclarationNodes.Any(f => !f.IsOK))
            {
                IsOK = false;
                return;
            }

            RecordTigerType = scope.FindType(IdNode.Name) as RecordType;

            IsOK = true;
        }
示例#2
0
        public override void CheckSemantics(TigerScope scope, Report report)
        {
            ContainingScope = scope;

            //Check type existence
            var type = scope.FindType(IdNode.Name);

            //Checking existence of array
            if (type != null)
            {
                TigerType = type is SimpleType ? ((SimpleType)type).ActualType : type;
            }
            else
            {
                report.AddError(SemanticErrors.NonExistentTypeReference(IdNode, IdNode.Name));
            }
        }