public override void CheckSemantic(Scope scope, IErrorReporter logger)
        {
            base.CheckSemantic(scope, logger);

            var childScope = GetScope(scope);

            foreach (var message in InnerMessages)
            {
                message.CheckSemantic(childScope, logger);
            }

            foreach (var e in Enums)
            {
                e.CheckSemantic(childScope, logger);
            }

            foreach (var f in Fields)
            {
                f.Message = this;
                f.CheckSemantic(childScope, logger);
            }

            if (Fields.ToLookup(x => x.Number).Any(x => x.Count() > 1))
            {
                logger.AddError($"Duplicated fields numbers in {Name} ({ string.Join(",", Fields.ToLookup(x => x.Number).Where(x => x.Count() > 1).Select(x => string.Join(",", x) +"="+ x.Key)) }) , {Line},{Column}");
            }

            if (Fields.ToLookup(x => x.Name).Any(x => x.Count() > 1))
            {
                logger.AddError($"Duplicated fields names in {Name} ({ string.Join(",", Fields.ToLookup(x => x.Name).Where(x => x.Count() > 1).Select(x => string.Join(",", x) + "=" + x.Key)) }) , {Line},{Column}");
            }
        }
Esempio n. 2
0
        public override void CheckSemantic(Scope scope, IErrorReporter logger)
        {
            TypeDeclaration = scope.GetDeclaration(Name);
            if (TypeDeclaration == null)
            {
                logger.AddError($"Type {Name} is not defined at {Name.Line},{Name.Column}");
            }

            if (GenericArgs != null)
            {
                foreach (var genParameter in GenericArgs)
                {
                    genParameter.CheckSemantic(scope, logger);
                    if (genParameter.TypeDeclaration == PrimitiveType.Void)
                    {
                        logger.AddError($"Type void is not supported as a generic argument in {genParameter.Line},{genParameter.Column}");
                    }
                }
            }
        }
Esempio n. 3
0
        public override void CheckSemantic(Scope scope, IErrorReporter logger)
        {
            base.CheckSemantic(scope, logger);

            Type.CheckSemantic(scope, logger);

            if (FieldType == PrimitiveType.Void)
            {
                logger.AddError($"Type void is not supported as a field type in {Line},{Column}");
            }
        }
        public override void CheckSemantic(Scope scope, IErrorReporter logger)
        {
            base.CheckSemantic(scope, logger);

            Request.CheckSemantic(scope, logger);
            Response.CheckSemantic(scope, logger);

            RequestType  = scope.GetDeclaration(Request);
            ResponseType = scope.GetDeclaration(Response);

            if (RequestType == null)
            {
                logger.AddError($"Type {RequestType} is not defined at {Line},{Column}");
            }

            if (ResponseType == null)
            {
                logger.AddError($"Type {ResponseType} is not defined at {Line},{Column}");
            }
        }
Esempio n. 5
0
        public static void AddError(IErrorReporter reporter, ICharRange token, string text)
        {
            var fromPos = token.FromPos;
            var toPos   = token.ToPos;

            reporter.AddError(
                fromPos.LineNo,
                fromPos.CharNo,
                toPos.LineNo,
                toPos.CharNo,
                text);
        }
        public override void CheckSemantic(Scope scope, IErrorReporter logger)
        {
            base.CheckSemantic(scope, logger);

            if (Rpcs.ToLookup(x => x.Name).Any(x => x.Count() > 1))
            {
                logger.AddError($"Duplicated fields numbers in {Name} ({ string.Join(",", Rpcs.ToLookup(x => x.Name).Where(x => x.Count() > 1).Select(x => string.Join(",", x) + "=" + x.Key)) }) , {Line},{Column}");
            }

            foreach (var item in Rpcs)
            {
                item.CheckSemantic(scope, logger);
            }
        }
        public override void CheckSemantic(Scope scope, IErrorReporter logger)
        {
            Name.CheckSemantic(scope, logger);

            var enumDecl = scope.GetDeclaration(Name.Left) as EnumDeclaration;

            if (enumDecl == null)
            {
                logger.AddError($"Missing Declaration {Name.Left}");
            }

            var field = enumDecl.Members.Find(x => x.Name == Name.Id);

            Value = field.Value;
        }