示例#1
0
        private void CheckParameter([NotNull] ParameterDescriptionEntry parameter, CodeElement ce, ParserRuleContext context, Node node)
        {
            // TCRFUN_LEVEL_88_PARAMETERS
            if (parameter.LevelNumber.Value != 1)
            {
                DiagnosticUtils.AddError(ce, "Condition parameter \"" + parameter.Name + "\" must be subordinate to another parameter.", context);
            }
            if (parameter.DataConditions != null)
            {
                foreach (var condition in parameter.DataConditions)
                {
                    if (condition.LevelNumber.Value != 88)
                    {
                        DiagnosticUtils.AddError(ce, "Condition parameter \"" + condition.Name + "\" must be level 88.");
                    }
                }
            }

            if (parameter.Picture != null)
            {
                Cobol85CompleteASTChecker.CheckPicture(parameter);
            }

            var type = parameter.DataType;

            TypeDefinitionHelper.Check(node, type); //Check if the type exists and is not ambiguous
        }
示例#2
0
        private static void CheckParameter([NotNull] ParameterDescriptionEntry parameter, Node node)
        {
            // TCRFUN_LEVEL_88_PARAMETERS
            if (parameter.LevelNumber?.Value != 1)
            {
                DiagnosticUtils.AddError(node,
                                         "Condition parameter \"" + parameter.Name + "\" must be subordinate to another parameter.");
            }
            if (parameter.DataConditions != null)
            {
                foreach (var condition in parameter.DataConditions)
                {
                    if (condition.LevelNumber?.Value != 88)
                    {
                        DiagnosticUtils.AddError(node,
                                                 "Condition parameter \"" + condition.Name + "\" must be level 88.");
                    }
                    if (condition.LevelNumber?.Value == 88 && parameter.DataType == DataType.Boolean)
                    {
                        DiagnosticUtils.AddError(node,
                                                 "The Level 88 symbol '" + parameter.Name + "' cannot be declared under a BOOL typed symbol");
                    }
                }
            }

            if (parameter.Picture != null)
            {
                CrossCompleteChecker.CheckPicture(node, parameter);
            }

            var            type = parameter.DataType;
            TypeDefinition foundedType;

            TypeDefinitionHelper.Check(node, type, out foundedType); //Check if the type exists and is not ambiguous
        }
示例#3
0
        public static void OnNode(Node node)
        {
            DataDefinition dataDefinition = node as DataDefinition;

            if (dataDefinition == null || node is TypeDefinition)
            {
                return; //not my job
            }

            var data = dataDefinition.CodeElement as DataDescriptionEntry;

            if (data != null && data.UserDefinedDataType != null && data.Picture != null)
            {
                string message = "PICTURE clause incompatible with TYPE clause";
                DiagnosticUtils.AddError(node.CodeElement, message, data.Picture.Token);
            }
            var type = dataDefinition.DataType;

            TypeDefinitionHelper.Check(node, type); //Check if the type exists and is not ambiguous
        }
        public static void OnNode(Node node)
        {
            DataDefinition dataDefinition = node as DataDefinition;

            if (dataDefinition == null || node is TypeDefinition)
            {
                return; //not my job
            }

            var data = dataDefinition.CodeElement as DataDescriptionEntry;

            if (data != null && data.UserDefinedDataType != null && data.Picture != null)
            {
                string message = "PICTURE clause incompatible with TYPE clause";
                DiagnosticUtils.AddError(node, message, data.Picture.Token);
            }

            var            type        = dataDefinition.DataType;
            TypeDefinition foundedType = null;

            TypeDefinitionHelper.Check(node, type, out foundedType); //Check if the type exists and is not ambiguous

            if (foundedType == null || data == null || data.LevelNumber == null)
            {
                return;
            }

            if (data.LevelNumber.Value == 88 || data.LevelNumber.Value == 66)
            {
                DiagnosticUtils.AddError(node,
                                         string.Format("A {0} level variable cannot be typed", data.LevelNumber.Value),
                                         MessageCode.SemanticTCErrorInParser);
            }

            if (data.LevelNumber.Value == 77 && foundedType.Children.Count > 0)
            {
                DiagnosticUtils.AddError(node, "A 77 level variable cannot be typed with a type containing children",
                                         MessageCode.SemanticTCErrorInParser);
            }

            if (data.LevelNumber.Value <= 49)
            {
                browsedTypes.Clear(); //Clear list of browsed types before testing a path
                long simulatedTypeLevel = SimulatedTypeDefLevel(data.LevelNumber.Value, foundedType);
                if (simulatedTypeLevel > 49)
                {
                    var message =
                        string.Format(
                            "Variable '{0}' has to be limited to level {1} because of '{2}' maximum estimated children level",
                            data.Name, data.LevelNumber.Value - (simulatedTypeLevel - 49), foundedType.Name);
                    DiagnosticUtils.AddError(node, message, MessageCode.SemanticTCErrorInParser);
                }
            }

            //Check if initial value equals true/false for boolean TYPEDEF
            if (type == DataType.Boolean && data.InitialValue != null &&
                data.InitialValue.LiteralType != Value.ValueLiteralType.Boolean)
            {
                DiagnosticUtils.AddError(node, "Boolean type requires TRUE/FALSE value clause",
                                         MessageCode.SemanticTCErrorInParser);
            }
        }