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); } } }
public static void OnCodeElement(DataDescriptionEntry data, CodeElementsParser.DataDescriptionEntryContext context) { var external = GetContext(data, context?.externalClause()); var global = GetContext(data, context?.globalClause()); if (data.DataName == null) { if (!data.IsFiller) { DiagnosticUtils.AddError(data, "Data name or FILLER expected", context?.dataNameDefinition()); } if (data.IsExternal) { DiagnosticUtils.AddError(data, "Data name must be specified for any entry containing the EXTERNAL clause", external); } if (data.IsGlobal) { DiagnosticUtils.AddError(data, "Data name must be specified for any entry containing the GLOBAL clause", global); } } else { if (data.LevelNumber != null && data.IsExternal && data.LevelNumber.Value != 01) { DiagnosticUtils.AddError(data, "External is only allowed for level 01", external); } if (data.LevelNumber != null && !((data.LevelNumber.Value >= 01 && data.LevelNumber.Value <= 49) || data.LevelNumber.Value == 66 || data.LevelNumber.Value == 77 || data.LevelNumber.Value == 88)) { DiagnosticUtils.AddError(data, "Data must be declared between level 01 to 49, or equals to 66, 77, 88", context?.dataNameDefinition()); } } }