// FILE DESCRIPTION ENTRY //////////////////////////// public override void EnterFileDescriptionEntry(CodeElementsParser.FileDescriptionEntryContext context) { var entry = new FileDescriptionEntry(); if (context.FD() != null) entry.LevelIndicator = new SyntaxProperty<FileDescriptionType>(FileDescriptionType.File, ParseTreeUtils.GetFirstToken(context.FD())); else if (context.SD() != null) entry.LevelIndicator = new SyntaxProperty<FileDescriptionType>(FileDescriptionType.SortMergeFile, ParseTreeUtils.GetFirstToken(context.SD())); entry.FileName = CobolWordsBuilder.CreateFileNameReference(context.fileNameReference()); if (context.externalClause() != null && context.externalClause().Length > 0) { var externalClauseContext = context.externalClause()[0]; entry.IsExternal = new SyntaxProperty<bool>(true, ParseTreeUtils.GetFirstToken(externalClauseContext.EXTERNAL())); } if (context.globalClause() != null && context.globalClause().Length > 0) { var globalClauseContext = context.globalClause()[0]; entry.IsGlobal = new SyntaxProperty<bool>(true, ParseTreeUtils.GetFirstToken(globalClauseContext.GLOBAL())); } if (context.blockContainsClause() != null && context.blockContainsClause().Length > 0) { var blockContainsClauseContext = context.blockContainsClause()[0]; entry.MaxBlockSize = CobolWordsBuilder.CreateIntegerValue(blockContainsClauseContext.maxNumberOfBytes); if (blockContainsClauseContext.minNumberOfBytes != null) { entry.MinBlockSize = CobolWordsBuilder.CreateIntegerValue(blockContainsClauseContext.minNumberOfBytes); } if (blockContainsClauseContext.CHARACTERS() != null) { entry.BlockSizeUnit = new SyntaxProperty<BlockSizeUnit>(BlockSizeUnit.Characters, ParseTreeUtils.GetFirstToken(blockContainsClauseContext.CHARACTERS())); } else if (blockContainsClauseContext.RECORDS() != null) { entry.BlockSizeUnit = new SyntaxProperty<BlockSizeUnit>(BlockSizeUnit.Records, ParseTreeUtils.GetFirstToken(blockContainsClauseContext.RECORDS())); } } if (context.recordClause() != null && context.recordClause().Length > 0) { var recordClauseContext = context.recordClause()[0]; if (recordClauseContext.numberOfBytes != null) { entry.MinRecordSize = CobolWordsBuilder.CreateIntegerValue(recordClauseContext.numberOfBytes); entry.MaxRecordSize = entry.MinRecordSize; } else if (recordClauseContext.minNumberOfBytes != null) { entry.MinRecordSize = CobolWordsBuilder.CreateIntegerValue(recordClauseContext.minNumberOfBytes); entry.MaxRecordSize = CobolWordsBuilder.CreateIntegerValue(recordClauseContext.maxNumberOfBytes); } else if (recordClauseContext.VARYING() != null) { if (recordClauseContext.fromNumberOfBytes != null) entry.MinRecordSize = CobolWordsBuilder.CreateIntegerValue(recordClauseContext.fromNumberOfBytes); if (recordClauseContext.toNumberOfBytes != null) entry.MaxRecordSize = CobolWordsBuilder.CreateIntegerValue(recordClauseContext.toNumberOfBytes); if (recordClauseContext.dataNameReference() != null) entry.RecordSizeDependingOn = CobolWordsBuilder.CreateDataNameReference(recordClauseContext.dataNameReference()); } } if (context.labelRecordsClause() != null && context.labelRecordsClause().Length > 0) { var labelRecordClauseContext = context.labelRecordsClause()[0]; if (labelRecordClauseContext.STANDARD() != null) { entry.LabelRecordType = new SyntaxProperty<LabelRecordType>(LabelRecordType.StandardLabels, ParseTreeUtils.GetFirstToken(labelRecordClauseContext.STANDARD())); } if (labelRecordClauseContext.OMITTED() != null) { entry.LabelRecordType = new SyntaxProperty<LabelRecordType>(LabelRecordType.Omitted, ParseTreeUtils.GetFirstToken(labelRecordClauseContext.OMITTED())); } else if (labelRecordClauseContext.dataNameReference() != null && labelRecordClauseContext.dataNameReference().Length > 0) { entry.LabelRecords = new SymbolReference[labelRecordClauseContext.dataNameReference().Length]; for (int i = 0; i < labelRecordClauseContext.dataNameReference().Length; i++) entry.LabelRecords[i] = CobolWordsBuilder.CreateDataNameReference(labelRecordClauseContext.dataNameReference()[i]); } } if (context.valueOfClause() != null && context.valueOfClause().Length > 0) { var valueOfClauseContext = context.valueOfClause()[0]; entry.ValueOfLabelRecords = new Dictionary<SymbolReference, Variable>(); for (int i = 0; i < valueOfClauseContext.qualifiedDataName().Length; i++) { entry.ValueOfLabelRecords.Add( CobolWordsBuilder.CreateQualifiedDataName(valueOfClauseContext.qualifiedDataName()[i]), CobolExpressionsBuilder.CreateVariable(valueOfClauseContext.variable5()[i])); } } if (context.dataRecordsClause() != null && context.dataRecordsClause().Length > 0) { var dataRecordClauseContext = context.dataRecordsClause()[0]; entry.DataRecords = new SymbolReference[dataRecordClauseContext.dataNameReference().Length]; for (int i = 0; i < dataRecordClauseContext.dataNameReference().Length; i++) entry.DataRecords[i] = CobolWordsBuilder.CreateDataNameReference(dataRecordClauseContext.dataNameReference()[i]); } if (context.linageClause() != null && context.linageClause().Length > 0) { var linageClauseContext = context.linageClause()[0]; if (linageClauseContext.numberOfLinesInPage != null) entry.LogicalPageBodyLineCount = CobolExpressionsBuilder.CreateIntegerVariable(linageClauseContext.numberOfLinesInPage); if (linageClauseContext.firstLineNumberOfFootingArea != null) entry.LogicalPageFootingLineNumber = CobolExpressionsBuilder.CreateIntegerVariable(linageClauseContext.firstLineNumberOfFootingArea); if (linageClauseContext.numberOfLinesInTopMargin != null) entry.LogicalPageTopMarginLineCount = CobolExpressionsBuilder.CreateIntegerVariable(linageClauseContext.numberOfLinesInTopMargin); if (linageClauseContext.numberOfLinesInBottomMargin != null) entry.LogicalPageBottomMarginLineCount = CobolExpressionsBuilder.CreateIntegerVariable(linageClauseContext.numberOfLinesInBottomMargin); } if (context.recordingModeClause() != null && context.recordingModeClause().Length > 0) { var recordingModeClauseContext = context.recordingModeClause()[0]; entry.RecordingMode = CobolWordsBuilder.CreateRecordingMode(recordingModeClauseContext.recordingMode()); } Context = context; CodeElement = entry; }
// - 2. Special registers (allocate a storage area on reference) - internal StorageArea CreateLinageCounterSpecialRegister(CodeElementsParser.LinageCounterSpecialRegisterContext context) { return new FilePropertySpecialRegister( ParseTreeUtils.GetFirstToken(context.LINAGE_COUNTER()), CobolWordsBuilder.CreateFileNameReference(context.fileNameReference())); }
internal UseAfterIOExceptionStatement CreateUseStatementForExceptionDeclarative(CodeElementsParser.UseStatementForExceptionDeclarativeContext context) { var statement = new UseAfterIOExceptionStatement(); if (context.GLOBAL() != null) statement.IsGlobal = new SyntaxProperty<bool>(true, ParseTreeUtils.GetFirstToken(context.GLOBAL())); if (context.fileNameReference() != null && context.fileNameReference().Length > 0) { statement.FileNames = new SymbolReference[context.fileNameReference().Length]; for (int i = 0; i < context.fileNameReference().Length; i++) statement.FileNames[i] = CobolWordsBuilder.CreateFileNameReference(context.fileNameReference()[i]); } statement.OpenMode = CreateOpenMode(context); return statement; }
// - 2. Special registers (allocate a storage area on reference) - internal StorageArea CreateLinageCounterSpecialRegister(CodeElementsParser.LinageCounterSpecialRegisterContext context) { var specialRegister = new FilePropertySpecialRegister( ParseTreeUtils.GetFirstToken(context.LINAGE_COUNTER()), CobolWordsBuilder.CreateFileNameReference(context.fileNameReference())); if(specialRegister.DataDescriptionEntry != null) { var dataDescription = specialRegister.DataDescriptionEntry; CobolWordsBuilder.symbolInformationForTokens[specialRegister.DataDescriptionEntry.DataName.NameLiteral.Token] = specialRegister.DataDescriptionEntry.DataName; } if (specialRegister.SymbolReference != null) { CobolWordsBuilder.symbolInformationForTokens[specialRegister.SymbolReference.NameLiteral.Token] = specialRegister.SymbolReference; } return specialRegister; }