private void CheckTypedef(DataTypeDescriptionEntry typedef, CodeElementsParser.DataDescriptionEntryContext context) { if (typedef == null) { return; } if (typedef.LevelNumber?.Value != 1) { string message = "TYPEDEF clause can only be specified for level 01 entries"; DiagnosticUtils.AddError(typedef, message, context.cobol2002TypedefClause()); } if (typedef.IsExternal) { string message = "EXTERNAL clause cannot be specified with TYPEDEF clause"; foreach (var external in context.externalClause()) { DiagnosticUtils.AddError(typedef, message, external); } } #if EUROINFO_LEGACY_TYPEDEF if (typedef.RestrictionLevel != RestrictionLevel.STRICT) { string message = "Custom EI rule : Only TYPEDEF STRICT is allowed."; DiagnosticUtils.AddError(typedef, message, context.cobol2002TypedefClause()); return; } #endif if (typedef.RestrictionLevel == RestrictionLevel.STRICT) //Manage as a STRICT TYPEDEF { if (typedef.IsSynchronized != null && typedef.IsSynchronized.Value == true) { DiagnosticUtils.AddError(typedef, "SYNC clause cannot be used with a STRICT type definition", context.cobol2002TypedefClause()); } } if (typedef.RestrictionLevel == RestrictionLevel.STRONG) //Manage as a STRONG TYPEDEF { if (typedef.InitialValue != null) { string message = "STRONG TYPEDEF cannot contain VALUE clause:"; foreach (var valeuClause in context.valueClause()) { DiagnosticUtils.AddError(typedef, message, valeuClause); } } if (typedef.Picture != null) { string message = "Elementary TYPEDEF cannot be STRONG"; string rulestack = RuleStackBuilder.GetRuleStack(context.cobol2002TypedefClause()); DiagnosticUtils.AddError(typedef, message, ParseTreeUtils.GetFirstToken(context.cobol2002TypedefClause().STRONG()), rulestack); } } }
internal static void AddError(Node node, string message, Antlr4.Runtime.RuleContext context, MessageCode code = MessageCode.SyntaxErrorInParser) { AddError(node, message, ParseTreeUtils.GetFirstToken(context), RuleStackBuilder.GetRuleStack(context), code); }