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); } } }
private static Nodes.TypeDefinition CreateBase(DataType type) { var entry = new DataTypeDescriptionEntry(); entry.LevelNumber = new GeneratedIntegerValue(1); entry.DataName = new SymbolDefinition(new GeneratedAlphanumericValue(type.Name), SymbolType.DataName); entry.DataType = type; return(new Nodes.TypeDefinition(entry)); }
public virtual void StartTypeDefinitionEntry(DataTypeDescriptionEntry typedef) { SetCurrentNodeToTopLevelItem(typedef.LevelNumber); var node = new TypeDefinition(typedef); Enter(node); // TCTYPE_GLOBAL_TYPEDEF var table = node.SymbolTable.GetTableFromScope(node.CodeElement().IsGlobal ? SymbolTable.Scope.Global : SymbolTable.Scope.Declarations); table.AddType(node); _CurrentTypeDefinition = node; AnalyticsWrapper.Telemetry.TrackEvent(EventType.TypeDeclared, node.Name, LogType.TypeCobolUsage); }
private static Nodes.TypeDefinition CreateCurrency() { var entry = new DataTypeDescriptionEntry(); entry.LevelNumber = new GeneratedIntegerValue(1); entry.DataName = new SymbolDefinition(new GeneratedAlphanumericValue("CURRENCY"), SymbolType.DataName); entry.Picture = new GeneratedAlphanumericValue(string.Format("{0}({1})", 'X', 3)); entry.DataType = DataType.Currency; var tokenLine = TokensLine.CreateVirtualLineForInsertedToken(entry.Line, "01 CURRENCY TYPEDEF STRICT PUBLIC PIC X(03)."); entry.ConsumedTokens.Add(new Token(TokenType.LevelNumber, 0, 1, tokenLine)); entry.ConsumedTokens.Add(new Token(TokenType.UserDefinedWord, 3, 10, tokenLine)); entry.ConsumedTokens.Add(new Token(TokenType.TYPEDEF, 12, 18, tokenLine)); entry.ConsumedTokens.Add(new Token(TokenType.STRICT, 20, 25, tokenLine)); entry.ConsumedTokens.Add(new Token(TokenType.PUBLIC, 27, 32, tokenLine)); entry.ConsumedTokens.Add(new Token(TokenType.PIC, 34, 36, tokenLine)); entry.ConsumedTokens.Add(new Token(TokenType.PictureCharacterString, 38, 42, tokenLine)); entry.ConsumedTokens.Add(new Token(TokenType.PeriodSeparator, 43, 43, tokenLine)); return(new Nodes.TypeDefinition(entry)); }
public virtual void StartTypeDefinitionEntry(DataTypeDescriptionEntry typedef) { SetCurrentNodeToTopLevelItem(typedef.LevelNumber); var node = new TypeDefinition(typedef); Enter(node); SymbolTable table; if (node.CodeElement().IsGlobal) // TCTYPE_GLOBAL_TYPEDEF { table = node.SymbolTable.GetTableFromScope(SymbolTable.Scope.Global); } else { table = node.SymbolTable.GetTableFromScope(SymbolTable.Scope.Declarations); } table.AddType(node); AnalyticsWrapper.Telemetry.TrackEvent("[Type-Declared] " + node.Name, EventType.TypeCobolUsage); }
public virtual bool Visit(DataTypeDescriptionEntry dataTypeDescriptionEntry) { return(true); }