@ibm/ibmi-eventf-parser 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/MapTable.d.ts +2 -2
- package/dist/src/ProcessorBlock.d.ts +2 -2
- package/dist/src/index.d.ts +2 -0
- package/dist/src/record/ErrorInformationRecord.d.ts +18 -34
- package/dist/src/record/ExpansionRecord.d.ts +9 -55
- package/dist/src/record/FeedbackCodeRecord.d.ts +5 -14
- package/dist/src/record/FileEndRecord.d.ts +5 -27
- package/dist/src/record/FileIDRecord.d.ts +11 -15
- package/dist/src/record/IRecord.d.ts +10 -0
- package/dist/src/record/MapDefineRecord.d.ts +6 -40
- package/dist/src/record/MapEndRecord.d.ts +6 -34
- package/dist/src/record/MapStartRecord.d.ts +5 -27
- package/dist/src/record/ProcessorRecord.d.ts +5 -27
- package/dist/src/record/ProgramRecord.d.ts +4 -20
- package/dist/src/record/TimestampRecord.d.ts +3 -19
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,3 +1,53 @@
|
|
|
1
1
|
# ibmi-eventf-parser
|
|
2
2
|
Parses the event files that are placed into the EVFEVENT SRC-PF by IBM i compilers. Provides a call back interface to allow any other tools to process compiler errors.
|
|
3
3
|
The eventf format is described in this [IBM documentation](https://www.ibm.com/docs/en/rdfi/9.6.0?topic=reference-events-file-format)
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
This parser is available as an NPM module and can be installed as a dependency using:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @ibm/ibmi-eventf-parser
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## Example
|
|
16
|
+
|
|
17
|
+
The API to use this parser is illustrated in the [vitest/files.test.ts](./vitest/files.test.ts) examples:
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
const parser = new Parser();
|
|
21
|
+
const markers: MarkerCreator = new MarkerCreator();
|
|
22
|
+
parser.parseFile(`${TEST_DIR}/SQLRPGLE.PGM.evfevent`, markers);
|
|
23
|
+
|
|
24
|
+
assert.ok(markers.equals(0, '/home/REINHARD/builds/hll/sqlrpgle.pgm.sqlrpgle', 328, 'Precompile option COMMIT changed by SET OPTION statement.'));
|
|
25
|
+
assert.ok(markers.equals(1, '/home/REINHARD/builds/hll/includes/familly.rpgleinc', 23, 'The Definition-Type entry is not valid; defaults to parameter definition.'));
|
|
26
|
+
assert.ok(markers.equals(60, '/home/REINHARD/builds/hll/sqlrpgle.pgm.sqlrpgle', 0, 'Compilation stopped. Severity 30 errors found in program.'));
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
In the simplest method, create a class that implements the `IMarkerCreator` interface and then pass an instance into the `parseFile` method on the `Parser` class.
|
|
34
|
+
|
|
35
|
+
For every error logged in the eventf, the following callback function will be called:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
public createMarker(record: ErrorInformationRecord, fileLocation: string, isReadOnly: string) {
|
|
39
|
+
//...
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
where the `ErrorInformationRecord` has all the information about the error included the original line and column range in the original source that this error was encountered in. The value is that the parser is able to interpret all of the expansion events from precompilers and includes to determine accurate token locations in the origination source file whose path is provided in the `fileLocation`.
|
|
44
|
+
|
|
45
|
+
If the eventf is not stored in a local file, using the more general `ISequentialFileReader` on the general `parser.parse(fileReader: ISequentialFileReader, markerCreator?: IMarkerCreator)` method. The `readNextLine()` method can use sockets, read from an array, or any arbitrary mechanism to get the contents of the eventf, one record at a time.
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
export interface ISequentialFileReader {
|
|
49
|
+
readNextLine(): string | undefined;
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
For full access to every record that was parsed in the eventf, set an implementation of `IProcessor` on the parser using the `parser.setProcessor()` method.
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";var t={322:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExpansionProcessor=void 0;const i=s(153);e.ExpansionProcessor=class{constructor(){this.PRE_COMPILE_PROCESSOR_ID="999",this.postProcessingNeeded=!0,this._noProcessorEventsYet=!0,this._containsPreCompileProcessorBlocks=!1}processErrorRecord(t){this.currentProcessor.addErrorInformation(t)}processExpansionRecord(t){this.currentProcessor.setContainsExpansionEvents(!0),this.currentProcessor.getMappingTable().addExpansionRecord(t)}processFeedbackCodeRecord(t){}processFileEndRecord(t){try{this.currentProcessor.closeFile(t)}catch(t){throw this.postProcessingNeeded=!1,new Error(t.message?t.message:t)}}processFileIDRecord(t){try{const e=parseInt(t.getSourceId());if(this.currentProcessor.isProcessorIDZero())1!==e||this.currentProcessor.getInputFile()||this.currentProcessor.setInputFile(t),this.currentProcessor.getMappingTable().addFileToFileTable(t);else{if(e>1){if(!this.currentProcessor.getOutputFile())return void this.currentProcessor.setOutputFile(t)}else 1!==e||this.currentProcessor.getInputFile()||this.currentProcessor.setInputFile(t);this.currentProcessor.addFile(t)}}catch(t){throw this.postProcessingNeeded=!1,new Error(t.message?t.message:t)}}processMapDefineRecord(t){}processMapEndRecord(t){}processMapStartRecord(t){}processProcessorRecord(t){this._containsPreCompileProcessorBlocks||t.getOutputId()!==this.PRE_COMPILE_PROCESSOR_ID||(this._containsPreCompileProcessorBlocks=!0);try{this.currentProcessor&&this.currentProcessor.processorEnded()}catch(t){throw this.postProcessingNeeded=!1,new Error(t.message?t.message:t)}const e=this.constructEventsFileProcessorBlock(t);this._noProcessorEventsYet&&(e.setFirstInEventsFile(!0),this._noProcessorEventsYet=!1),e.setPreviousProcessor(this.currentProcessor),this.currentProcessor=e}constructEventsFileProcessorBlock(t){return new i.ProcessorBlock(t)}processProgramRecord(t){}processTimestampRecord(t){this._noProcessorEventsYet=!0}doPreProcessing(){return!1}doPostProcessing(){return!(this.postProcessingNeeded&&this._containsPreCompileProcessorBlocks&&this.determineAndSetMappingSupport(this.currentProcessor)&&(this.currentProcessor.resolveFileNamesForAllErrors(),1))}determineAndSetMappingSupport(t){let e=!1,s=t;for(;s;){const t=this.isMappingSupportedByCurrentEventsFile(s);for(this.setMappingSupportForCurrentEventsFile(s,t),!e&&t&&(e=!0);s&&!s.getIsFirstInEventsFile();)s=s.getPreviousProcessorBlock();s&&(s=s.getPreviousProcessorBlock())}return e}setMappingSupportForCurrentEventsFile(t,e){let s=t;for(;s;)s.setMappingSupported(e),s=s.getIsFirstInEventsFile()?void 0:s.getPreviousProcessorBlock()}isMappingSupportedByCurrentEventsFile(t){let e;e=t.getOutputFile()?!!t.getContainsExpansionEvents()||0!==t.getTotalNumberOfLinesInOutputFile()&&t.getTotalNumberOfLinesInOutputFile()===t.getTotalNumberOfLinesInInputFiles():!(!t.getPreviousProcessorBlock()||t.getIsFirstInEventsFile());const s=t.getPreviousProcessorBlock();return s&&!t.getIsFirstInEventsFile()&&(e=e&&this.isMappingSupportedByCurrentEventsFile(s)),e}getAllErrors(){return this.currentProcessor?this.currentProcessor.getAllProcessorErrors():[]}getAllFileIDRecords(){return this.currentProcessor?this.currentProcessor.getMappingTable().getAllFileIDRecords():[]}}},232:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MapTable=void 0;class s{constructor(t,e){this.inputStartLine=0,this.inputEndLine=-1,this.inputFileID="",this.outputStartLine=0,this.outputEndLine=-1,e&&(this.inputStartLine=e.getInputStartLine(),this.inputEndLine=e.getInputEndLine(),this.inputFileID=e.getInputFileID(),this.outputStartLine=e.getOutputStartLine(),this.outputEndLine=e.getOutputEndLine()),t&&(this.inputFileID=t)}getInputEndLine(){return this.inputEndLine}setInputEndLine(t){this.inputEndLine=t}getInputFileID(){return this.inputFileID}setInputFileID(t){this.inputFileID=t}getInputStartLine(){return this.inputStartLine}setInputStartLine(t){this.inputStartLine=t}getOutputEndLine(){return this.outputEndLine}setOutputEndLine(t){this.outputEndLine=t}getOutputStartLine(){return this.outputStartLine}setOutputStartLine(t){this.outputStartLine=t}shiftOutputLines(t){this.outputStartLine+=t,this.outputEndLine>0&&(this.outputEndLine+=t)}containsOutputLine(t){return-1===this.outputEndLine?t>=this.outputStartLine:t>=this.outputStartLine&&t<=this.outputEndLine}containsInputLine(t,e){return-1===this.inputEndLine?t>=this.inputStartLine&&e===this.inputFileID:t>=this.inputStartLine&&t<=this.inputEndLine&&e===this.inputFileID}fixInputRangeBasedOnOutputRange(){this.inputEndLine=this.outputEndLine-this.outputStartLine+this.inputStartLine}fixOutputRangeBasedOnInputRange(){this.outputEndLine=this.inputEndLine-this.inputStartLine+this.outputStartLine}}class i{constructor(t){this.ID=t,this.lines=0}getID(){return this.ID}getLinesProcessed(){return this.lines}increaseLinesProcessed(t){this.lines+=t}}e.MapTable=class{constructor(){this.map=[],this.queueExpansion=[],this.files=new r,this.lookupIndex=0,this.fileTable=new Map}addFileInformation(t){const e=this.createOpenEndedSourceLineRange(t),s=new i(t.getSourceId());if(!this.files.isEmpty()){const t=this.files.peek(),s=this.map[this.map.length-1];s.getOutputStartLine()===e.getOutputStartLine()?this.map.pop():(s.setOutputEndLine(e.getOutputStartLine()-1),s.setInputEndLine(s.getOutputEndLine()-s.getOutputStartLine()+s.getInputStartLine()),t?.increaseLinesProcessed(s.getInputEndLine()-s.getInputStartLine()+1))}this.map.push(e),this.files.push(s),this.fileTable.set(t.getSourceId(),t)}addFileToFileTable(t){this.fileTable.set(t.getSourceId(),t)}closeFile(t){if(this.files.isEmpty())throw new Error(`A FILEEND event does not have a matching FILEID.\nFaulty event: ${t.toString()}`);const e=this.files.pop();if(e?.getID()!==t.getFileId())throw new Error(`The ID field of the FILEEND event does not match the ID field of the last FILEID event.\nMismatched IDs: \t FILEID: ${e?.getID()}\t FILEEND: ${t.toString()}`);const i=this.map[this.map.length-1];if(i.getInputFileID()!==t.getFileId())throw new Error(`The ID field of the FILEEND event does not match the ID field of the last SourceLineRange.\nMismatched IDs: \t FILEID: ${i.getInputFileID()}\t FILEEND: ${t.toString()}`);let r=0;try{r=parseInt(t.getExpansion())}catch(e){throw new Error(`Unable to parse the expansion field of the FILEEND record to an integer\nFaulty record: ${t.toString()}`)}if(0!==r){if(i.setInputEndLine(i.getInputStartLine()+r-e.getLinesProcessed()-1),i.setOutputEndLine(i.getOutputStartLine()+r-e.getLinesProcessed()-1),this.files.isEmpty())return;const t=this.files.peek(),n=new s(t.getID());n.setInputStartLine(t.getLinesProcessed()+1),n.setOutputStartLine(i.getOutputEndLine()+1),this.map.push(n)}else{if(i.setInputEndLine(i.getInputStartLine()),i.setOutputStartLine(i.getOutputStartLine()-1),i.setOutputEndLine(i.getOutputStartLine()),this.files.isEmpty())return;const t=this.files.peek(),e=new s(t.getID());e.setInputStartLine(t.getLinesProcessed()+1),e.setOutputStartLine(i.getOutputStartLine()+1),this.map.push(e)}}createOpenEndedSourceLineRange(t){let e=1;try{e=parseInt(t.getLine())}catch(e){throw new Error(`Unable to parse the line field of the FILEID record to an integer\nFaulty record: ${t.toString()}`)}const i=new s(t.getSourceId());if(i.setInputStartLine(1),this.files.isEmpty())i.setOutputStartLine(1);else{const t=this.map[this.map.length-1],s=this.files.peek();s&&i.setOutputStartLine(t.getOutputStartLine()+e-s.getLinesProcessed())}return i}addExpansionRecord(t){this.queueExpansion.push(t)}getSourceLineRangeForOutputLine(t){for(const e of this.map)if(e.containsOutputLine(t))return e}optimizedSourceLineRangeLookup(t){for(let e=this.lookupIndex;e<this.map.length;e++){const s=this.map[e];if(s.containsOutputLine(t))return this.lookupIndex=e,s}for(let e=0;e<this.lookupIndex&&e<this.map.length;e++){const s=this.map[e];if(s.containsOutputLine(t))return this.lookupIndex=e,s}}getSourceLineRangeForInputLine(t,e){for(const s of this.map)if(s.containsInputLine(t,e))return s}shiftRangesBy(t,e){for(let s=e;s<this.map.length;s++)this.map[s].shiftOutputLines(t)}handleExpansion(t){const e=this.createSourceLineRange(t);let s;if(e.getOutputStartLine()-this.map[this.map.length-1].getOutputEndLine()==1){if(e.getInputStartLine()===e.getInputEndLine())return void this.map.push(e)}else s=e.getInputStartLine()!==e.getInputEndLine()||0===e.getOutputStartLine()&&0===e.getOutputEndLine()?this.getSourceLineRangeForInputLine(e.getInputStartLine(),e.getInputFileID()):this.getSourceLineRangeForOutputLine(e.getOutputStartLine());this.splitExpandedSourceLineRange(e,s)}splitExpandedSourceLineRange(t,e){const i=this.map.indexOf(e),r=0===t.getOutputStartLine()&&0===t.getOutputEndLine(),n=r?t.getInputStartLine()-t.getInputEndLine()-1:t.getOutputEndLine()-t.getOutputStartLine()+1;if(r)if(t.getInputStartLine()===e.getInputStartLine()&&t.getInputEndLine()===e.getInputEndLine())this.map.splice(i,1),this.shiftRangesBy(n,i);else if(t.getInputStartLine()===e.getInputStartLine())e.setInputStartLine(t.getInputEndLine()+1),e.setOutputStartLine(e.getOutputStartLine()+Math.abs(n)),this.shiftRangesBy(n,i);else if(t.getInputEndLine()===e.getInputEndLine())e.setInputEndLine(t.getInputStartLine()-1),e.setOutputEndLine(e.getOutputEndLine()-Math.abs(n)),this.shiftRangesBy(n,i+1);else{const r=new s(void 0,e);e.setInputEndLine(t.getInputStartLine()-1),e.fixOutputRangeBasedOnInputRange(),r.setInputStartLine(t.getInputEndLine()+1),r.setOutputStartLine(e.getOutputEndLine()+Math.abs(n)+1),this.map.splice(i+1,0,r),this.shiftRangesBy(n,i+1)}else if(e.getOutputStartLine()===t.getOutputStartLine())t.getInputStartLine()===t.getInputEndLine()&&(this.map.splice(i,0,t),this.shiftRangesBy(n,i+1));else{const r=new s(void 0,e);e.setOutputEndLine(t.getOutputStartLine()-1),e.fixInputRangeBasedOnOutputRange(),this.map.splice(i+1,0,t),r.setInputStartLine(e.getInputEndLine()+1),r.setOutputStartLine(e.getOutputEndLine()+1),this.map.splice(i+2,0,r),this.shiftRangesBy(n,i+2)}}createSourceLineRange(t){const e=new s(t.getInputFileID());let i=0,r=0,n=0,o=0;try{i=parseInt(t.getInputLineStart()),r=parseInt(t.getInputLineEnd()),n=parseInt(t.getOutputLineStart()),o=parseInt(t.getOutputLineEnd())}catch(e){throw new Error(`Unable to parse the fields of the EXPANSION record to integers\nFaulty record: ${t.toString()}`)}return e.setInputStartLine(i),e.setInputEndLine(r),e.setOutputStartLine(n),e.setOutputEndLine(o),e}getFileIDRecordForFileID(t){return this.fileTable.get(t)}getFileLocationForFileID(t){const e=this.getFileIDRecordForFileID(t);if(e)return e.getFilename()}modifyErrorInformation(t){const e=parseInt(t.getStmtLine()),s=this.optimizedSourceLineRangeLookup(e);if(!s)throw new Error(`The line number on which ERROR occurs could not be found in the map.\nFaulty event: ${t.toString()}`);try{t.setStmtLine(this.getLineFromSourceLineRange(s,e).toString()),t.setFileId(s.getInputFileID());const i=parseInt(t.getStartErrLine());t.setStartErrLine(this.getLineFromSourceLineRange(s,i).toString());const r=parseInt(t.getEndErrLine());t.setEndErrLine(this.getLineFromSourceLineRange(s,r).toString()),t.setFileName(this.fileTable.get(s.getInputFileID()).getFilename())}catch(e){throw new Error(`Unable to parse the line fields of the ERROR record to integers\nFaulty record: ${t.toString()}`)}}getLineFromSourceLineRange(t,e){return t?t.getInputEndLine()-t.getInputStartLine()==t.getOutputEndLine()-t.getOutputStartLine()||-1===t.getInputEndLine()&&-1===t.getOutputEndLine()?e-t.getOutputStartLine()+t.getInputStartLine():t.getInputStartLine():e}finalizeMap(){if(!this.files.isEmpty())throw new Error(`One or more FILEID records do not have matching FILEEND records\nList of outstanding FILEID records: ${JSON.stringify(this.files)}`);this.queueExpansion.forEach((t=>{this.handleExpansion(t)}));const t=new s("001");t.setInputStartLine(0),t.setInputEndLine(0),t.setOutputStartLine(0),t.setOutputEndLine(0),this.map.unshift(t)}toString(){let t="";return this.map.forEach((e=>{t+=`${e.getInputFileID()}: [${e.getInputStartLine()},${e.getInputEndLine()}]--\x3e[${e.getOutputStartLine()},${e.getOutputEndLine()}]\n`})),t}getAllFileIDRecords(){if(!this.fileTable||0===this.fileTable.size)return[];const t=new Set;for(let e of this.fileTable.keys()){const s=this.fileTable.get(e);t.add(s)}return Array.from(t.values())}};class r{constructor(){this.stack=[]}push(t){this.stack.push(t)}pop(){return this.stack.pop()}peek(){return this.stack[this.stack.length-1]}isEmpty(){return 0===this.stack.length}size(){return this.stack.length}}},387:function(t,e,s){var i=this&&this.__createBinding||(Object.create?function(t,e,s,i){void 0===i&&(i=s);var r=Object.getOwnPropertyDescriptor(e,s);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[s]}}),Object.defineProperty(t,i,r)}:function(t,e,s,i){void 0===i&&(i=s),t[i]=e[s]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)"default"!==s&&Object.prototype.hasOwnProperty.call(t,s)&&i(e,t,s);return r(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.Parser=void 0;const o=n(s(17)),u=s(768),a=s(477),p=s(130),l=s(253),c=s(1),h=s(884),d=s(618),g=s(322),I=s(147);class E{constructor(t,e){this.location=t,this.browseMode=e}getLocation(){return this.location}isReadOnly(){return this.browseMode.toString()}setReadOnly(t){this.browseMode=t}}class L{constructor(t){this.iSequentialFileReader=t}readNextLine(){if(this.peakLine){const t=this.peakLine;return this.peakLine=void 0,t}return this.iSequentialFileReader.readNextLine()}peakNextRecordType(){return this.peakLine=this.iSequentialFileReader.readNextLine(),this.peakLine?.split(/\s+/).filter((t=>""!==t))[0]}}e.Parser=class{constructor(){this.sourceTable=new Map}getUntilTheEndOfTheLine(t,e){let s=e[t++];for(;t<e.length;){s=s.concat(" ");let i=e[t++];s=s.concat(i)}return s}log(t){process.env.DEBUG&&console.log(t)}parseFile(t,e){this.parse(new F(t),e)}parse(t,e){let s,i;this.processor||(this.processor=new g.ExpansionProcessor),this.processor?.doPreProcessing();const r=new L(t);let n=r.readNextLine();for(;n;){let t=n.split(/\s+/).filter((t=>""!==t)),e=0;for(;e<t.length;){if(s=t[e++],s===u.IRecordT.ERROR_INFORMATION){const s=t[e++];i=t[e++];let r=this.sourceTable.get(i);if(!r)if("000"===i){r=this.sourceTable.get("001")||new E("",!1)}else r=new E("",!1);const n=t[e++],o=t[e++],u=t[e++],a=t[e++],p=t[e++],l=t[e++],h=t[e++],d=t[e++],g=t[e++],I=t[e++],L=this.getUntilTheEndOfTheLine(e,t),F=new c.ErrorInformationRecord(s,i,n,o,u,a,p,l,h,d,g,I,L);F.setFileName(r.getLocation()),this.processor&&this.processor.processErrorRecord(F);break}if(s===u.IRecordT.FILE_ID){let s=!1;const o=t[e++];i=t[e++];const a=t[e++],p=parseInt(t[e++]);let c=n.substring(28);this.log(`EventsFileParser: location from line 1 = ${c}`);let h=r.peakNextRecordType();for(;h===u.IRecordT.FILE_CONT;){if(n=r.readNextLine(),!n)throw new Error("Events file has incorrect format. End of file encountered before location length satisfied.");t=n.split(" "),c+=n.substring(28),this.log(`EventsFileParser: location from line 1 = ${c}`),h=r.peakNextRecordType()}let d=c.substring(c.length-16,c.length-2);try{parseInt(d)}catch(t){d=""}const g=c.charAt(c.length-1),I=" "===c.charAt(c.length-2);s=!("1"!==g||!I),c=c.substring(0,c.length-17),c=this.resolveRelativePath(c);const L=new E(c,s);if((this.lastOutputFile&&c===this.lastOutputFile.getLocation()||this.currentOutputFile&&c===this.currentOutputFile.getLocation())&&L.setReadOnly(!0),"999"===i&&(this.lastOutputFile?(this.lastOutputFile=this.currentOutputFile,this.currentOutputFile=L):this.lastOutputFile=this.currentOutputFile=L),this.sourceTable.set(i,L),this.processor){const t=new l.FileIDRecord(o,i,a,p.toString(),c,d.toString(),g);try{this.processor.processFileIDRecord(t)}catch(t){const e=t.message?t.message:t;this.log(e),this.exception=new Error(e)}}break}if(s===u.IRecordT.FILE_END){if(this.processor){const s=t[e++],i=t[e++],r=t[e++],n=new h.FileEndRecord(s,i,r);try{this.processor?.processFileEndRecord(n)}catch(t){const e=t.message?t.message:t;this.log(e),this.exception=new Error(e)}}break}if(s===u.IRecordT.EXPANSION){if(this.processor){const s=new d.ExpansionRecord(t[e++],t[e++],t[e++],t[e++],t[e++],t[e++],t[e++]);this.processor?.processExpansionRecord(s)}break}if(s===u.IRecordT.TIMESTAMP){if(this.processor){let s=new a.TimestampRecord(t[e++],t[e++]);this.processor?.processTimestampRecord(s)}break}if(s===u.IRecordT.PROCESSOR){if(this.processor){let s=new p.ProcessorRecord(t[e++],t[e++],t[e++]);try{this.processor?.processProcessorRecord(s)}catch(t){const e=t.message?t.message:t;this.log(e),this.exception=new Error(e)}}break}if(s===u.IRecordT.PROGRAM||s===u.IRecordT.MAP_DEFINE||s===u.IRecordT.MAP_END||s===u.IRecordT.MAP_START||s===u.IRecordT.FEEDBACK_CODE||0===s.trim().length)break;throw new Error(`Events file has incorrect format. Unexpected line type. LT=${n}`)}n&&(n=r.readNextLine())}if(this.processor)try{this.processor?.doPostProcessing()}catch(t){this.exception=new Error(t.message?t.message:t)}e&&this.getAllErrors().forEach((t=>{const s=this.sourceTable.get(t.getFileId());s&&e.createMarker(t,t.getFileName(),s.isReadOnly())}))}resolveRelativePath(t){return(t=o.normalize(t).toString()).replace(/\\/g,"/")}getException(){return this.exception}setProcessor(t){this.processor=t}getAllErrors(){if(this.processor){const t=this.processor?.getAllErrors();let e=[];return e=e.concat(...t),e}return[]}getAllFileIDRecords(){return this.processor?this.processor.getAllFileIDRecords():[]}};class F{constructor(t){this.currLineNum=0,this.file=(0,I.readFileSync)(t,"utf-8"),this.linesArray=this.file.split(/\r?\n/)}readNextLine(){let t;return this.currLineNum<this.linesArray.length?(t=this.linesArray[this.currLineNum],this.currLineNum++):t=void 0,t}}e.default=F},153:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ProcessorBlock=void 0;const i=s(232);e.ProcessorBlock=class{constructor(t){this.INPUT_FILE_ID="001",this.containsExpansionEvents=!1,this.isFirstInEventsFile=!1,this.mappingSupported=!1,this.totalNumberOfLinesInOutputFile=0,this.totalNumberOfLinesInInputFiles=0,this.currentProcessor=t,this.mappingTable=new i.MapTable,this.errors=[]}getInputFile(){return this.inputFile}getInitialInputFile(){return this.previousProcessorBlock&&!this.getIsFirstInEventsFile()?this.previousProcessorBlock.getInitialInputFile():this.getInputFile()}setInputFile(t){this.inputFile=t}addFile(t){this.mappingTable.addFileInformation(t)}closeFile(t){if(this.outputFile){if(t.getFileId()===this.outputFile.getSourceId())return void this.setTotalNumberOfLinesInOutputFile(parseInt(t.getExpansion()));this.increaseTotalNumberOfLinesInInputFiles(parseInt(t.getExpansion())),this.mappingTable.closeFile(t)}}getOutputFile(){return this.outputFile}setOutputFile(t){this.outputFile=t}getMappingTable(){return this.mappingTable}isProcessorIDZero(){return 0===parseInt(this.currentProcessor.getOutputId())}addErrorInformation(t){this.errors.push(t)}processorEnded(){this.mappingTable.finalizeMap()}setPreviousProcessor(t){this.previousProcessorBlock=t}setContainsExpansionEvents(t){this.containsExpansionEvents=t}getContainsExpansionEvents(){return this.containsExpansionEvents}increaseTotalNumberOfLinesInInputFiles(t){this.totalNumberOfLinesInInputFiles+=t}getTotalNumberOfLinesInInputFiles(){return this.totalNumberOfLinesInInputFiles}setTotalNumberOfLinesInOutputFile(t){this.totalNumberOfLinesInOutputFile=t}getTotalNumberOfLinesInOutputFile(){return this.totalNumberOfLinesInOutputFile}getPreviousProcessorBlock(){return this.previousProcessorBlock}modifyErrorInformation(t){this.mappingTable.modifyErrorInformation(t);let e="",s="";const i=this.getInputFile();i&&(e=i.getFilename(),s=i.getSourceId()),!this.previousProcessorBlock||this.getIsFirstInEventsFile()||!this.isMappingSupported()||t.getFileId()!==s&&t.getFileId()!==e||this.previousProcessorBlock.modifyErrorInformation(t)}setFirstInEventsFile(t){this.isFirstInEventsFile=t}getIsFirstInEventsFile(){return this.isFirstInEventsFile}setMappingSupported(t){this.mappingSupported=t}isMappingSupported(){return this.mappingSupported}isFileReadOnly(t){return"1"===t.getFlag()||this.previousProcessorBlock&&!this.getIsFirstInEventsFile()&&void 0!==this.previousProcessorBlock.getOutputFile()&&t.getFilename()===this.previousProcessorBlock.getOutputFile().getFilename()||void 0!==this.getOutputFile()&&t.getFilename()===this.getOutputFile().getFilename()}getAllProcessorErrors(){let t=[];return this.previousProcessorBlock&&(t=this.previousProcessorBlock.getAllProcessorErrors()),t.push(this.errors),t}resolveFileNamesForAllErrors(){this.previousProcessorBlock&&this.previousProcessorBlock.resolveFileNamesForAllErrors(),this.errors.forEach((t=>{this.resolveFileNameAndDetermineIfReadOnly(t)}))}resolveFileNameAndDetermineIfReadOnly(t){let e=!1;if(this.previousProcessorBlock&&!this.getIsFirstInEventsFile()&&this.isMappingSupported()&&t.getFileId()===this.INPUT_FILE_ID)this.previousProcessorBlock.modifyErrorInformation(t);else{const s=this.mappingTable.getFileLocationForFileID(t.getFileId());if(s){const i=this.mappingTable.getFileIDRecordForFileID(t.getFileId());e=!!i&&this.isFileReadOnly(i),t.setFileName(s)}else{const s=this.getInitialInputFile();e=!!s&&this.isFileReadOnly(s),t.setFileName(s?.getFilename()||""),t.setStmtLine("0"),t.setStartErrLine("0"),t.setTokenStart("000"),t.setEndErrLine("0"),t.setTokenEnd("000")}}return e}}},1:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ErrorInformationRecord=void 0;const i=s(768);e.ErrorInformationRecord=class{constructor(t,e,s,i,r,n,o,u,a,p,l,c,h){this.version=t,this.fileId=e,this.annotClass=s,this.stmtLine=i,this.startErrLine=r,this.tokenStart=n,this.endErrLine=o,this.tokenEnd=u,this.msgId=a,this.sevChar=p,this.sevNum=l,this.length=c,this.msg=h,this.fileName=""}getRecordType(){return i.IRecordT.ERROR_INFORMATION}getVersion(){return this.version}getFileId(){return this.fileId}setFileId(t){this.fileId=t}getFileName(){return this.fileName}setFileName(t){this.fileName=t}getAnnotClass(){return this.annotClass}setAnnotClass(t){this.annotClass=t}getStmtLine(){return this.stmtLine}setStmtLine(t){this.stmtLine=t}getStartErrLine(){return this.startErrLine}setStartErrLine(t){this.startErrLine=t}getTokenStart(){return this.tokenStart}setTokenStart(t){this.tokenStart=t}getEndErrLine(){return this.endErrLine}setEndErrLine(t){this.endErrLine=t}getTokenEnd(){return this.tokenEnd}setTokenEnd(t){this.tokenEnd=t}getMsgId(){return this.msgId}getSevChar(){return this.sevChar}getSevNum(){return this.sevNum}getLength(){return this.length}setLength(t){this.length=t}getMsg(){return this.msg}}},618:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExpansionRecord=void 0;const i=s(768);e.ExpansionRecord=class{constructor(t,e,s,i,r,n,o){this.version=t,this.inputFileID=e,this.inputLineStart=s,this.inputLineEnd=i,this.outputFileID=r,this.outputLineStart=n,this.outputLineEnd=o}getRecordType(){return i.IRecordT.EXPANSION}getVersion(){return this.version}setVersion(t){this.version=t}getInputFileID(){return this.inputFileID}setInputFileID(t){this.inputFileID=t}getInputLineStart(){return this.inputLineStart}setInputLineStart(t){this.inputLineStart=t}getInputLineEnd(){return this.inputLineEnd}setInputLineEnd(t){this.inputLineEnd=t}getOutputFileID(){return this.outputFileID}setOutputFileID(t){this.outputFileID=t}getOutputLineStart(){return this.outputLineStart}setOutputLineStart(t){this.outputLineStart=t}getOutputLineEnd(){return this.outputLineEnd}setOutputLineEnd(t){this.outputLineEnd=t}}},884:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.FileEndRecord=void 0;const i=s(768);e.FileEndRecord=class{constructor(t,e,s){this.version=t,this.fileId=e,this.expansion=s}getRecordType(){return i.IRecordT.FILE_END}getVersion(){return this.version}setVersion(t){this.version=t}getFileId(){return this.fileId}setFileId(t){this.fileId=t}getExpansion(){return this.expansion}setExpansion(t){this.expansion=t}}},253:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.FileIDRecord=void 0;const i=s(768);e.FileIDRecord=class{constructor(t,e,s,i,r,n,o){this.version=t,this.sourceId=e,this.line=s,this.length=i,this.filename=r,this.timestamp=n,this.flag=o}getRecordType(){return i.IRecordT.FILE_ID}getVersion(){return this.version}getSourceId(){return this.sourceId}getLine(){return this.line}getLength(){return this.length}getFilename(){return this.filename}getTimestamp(){return this.timestamp}getFlag(){return this.flag}}},768:(t,e)=>{var s;Object.defineProperty(e,"__esModule",{value:!0}),e.IRecordT=void 0,function(t){t.TIMESTAMP="TIMESTAMP",t.PROCESSOR="PROCESSOR",t.FILE_ID="FILEID",t.FILE_CONT="FILEIDCONT",t.FILE_END="FILEEND",t.ERROR_INFORMATION="ERROR",t.PROGRAM="PROGRAM",t.MAP_DEFINE="MAPDEFINE",t.MAP_START="MAPSTART",t.MAP_END="MAPEND",t.FEEDBACK_CODE="FEEDBACK",t.EXPANSION="EXPANSION"}(s||(e.IRecordT=s={}))},130:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ProcessorRecord=void 0;const i=s(768);e.ProcessorRecord=class{constructor(t,e,s){this.version=t,this.outputId=e,this.lineClass=s}getRecordType(){return i.IRecordT.PROCESSOR}getVersion(){return this.version}setVersion(t){this.version=t}getOutputId(){return this.outputId}setOutputId(t){this.outputId=t}getLineClass(){return this.lineClass}setLineClass(t){this.lineClass=t}}},477:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TimestampRecord=void 0;const i=s(768);e.TimestampRecord=class{constructor(t,e){this.version=t,this.timestamp=e}getRecordType(){return i.IRecordT.TIMESTAMP}getVersion(){return this.version}setVersion(t){this.version=t}getTimestamp(){return this.timestamp}setTimestamp(t){this.timestamp=t}}},147:t=>{t.exports=require("fs")},17:t=>{t.exports=require("path")}},e={};function s(i){var r=e[i];if(void 0!==r)return r.exports;var n=e[i]={exports:{}};return t[i].call(n.exports,n,n.exports,s),n.exports}var i={};(()=>{var t=i;Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorInformationRecord=t.Parser=void 0;var e=s(387);Object.defineProperty(t,"Parser",{enumerable:!0,get:function(){return e.Parser}});var r=s(1);Object.defineProperty(t,"ErrorInformationRecord",{enumerable:!0,get:function(){return r.ErrorInformationRecord}})})();var r=exports;for(var n in i)r[n]=i[n];i.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();
|
|
1
|
+
(()=>{"use strict";var t={322:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExpansionProcessor=void 0;const i=s(153);e.ExpansionProcessor=class{constructor(){this.PRE_COMPILE_PROCESSOR_ID=999,this.postProcessingNeeded=!0,this._noProcessorEventsYet=!0,this._containsPreCompileProcessorBlocks=!1}processErrorRecord(t){this.currentProcessor.addErrorInformation(t)}processExpansionRecord(t){this.currentProcessor.setContainsExpansionEvents(!0),this.currentProcessor.getMappingTable().addExpansionRecord(t)}processFeedbackCodeRecord(t){}processFileEndRecord(t){try{this.currentProcessor.closeFile(t)}catch(t){throw this.postProcessingNeeded=!1,new Error(t.message?t.message:t)}}processFileIDRecord(t){try{const e=t.getSourceId();if(this.currentProcessor.isProcessorIDZero())1!==e||this.currentProcessor.getInputFile()||this.currentProcessor.setInputFile(t),this.currentProcessor.getMappingTable().addFileToFileTable(t);else{if(e>1){if(!this.currentProcessor.getOutputFile())return void this.currentProcessor.setOutputFile(t)}else 1!==e||this.currentProcessor.getInputFile()||this.currentProcessor.setInputFile(t);this.currentProcessor.addFile(t)}}catch(t){throw this.postProcessingNeeded=!1,new Error(t.message?t.message:t)}}processMapDefineRecord(t){}processMapEndRecord(t){}processMapStartRecord(t){}processProcessorRecord(t){this._containsPreCompileProcessorBlocks||t.getOutputId()!==this.PRE_COMPILE_PROCESSOR_ID||(this._containsPreCompileProcessorBlocks=!0);try{this.currentProcessor&&this.currentProcessor.processorEnded()}catch(t){throw this.postProcessingNeeded=!1,new Error(t.message?t.message:t)}const e=this.constructEventsFileProcessorBlock(t);this._noProcessorEventsYet&&(e.setFirstInEventsFile(!0),this._noProcessorEventsYet=!1),e.setPreviousProcessor(this.currentProcessor),this.currentProcessor=e}constructEventsFileProcessorBlock(t){return new i.ProcessorBlock(t)}processProgramRecord(t){}processTimestampRecord(t){this._noProcessorEventsYet=!0}doPreProcessing(){return!1}doPostProcessing(){return!(this.postProcessingNeeded&&this._containsPreCompileProcessorBlocks&&this.determineAndSetMappingSupport(this.currentProcessor)&&(this.currentProcessor.resolveFileNamesForAllErrors(),1))}determineAndSetMappingSupport(t){let e=!1,s=t;for(;s;){const t=this.isMappingSupportedByCurrentEventsFile(s);for(this.setMappingSupportForCurrentEventsFile(s,t),!e&&t&&(e=!0);s&&!s.getIsFirstInEventsFile();)s=s.getPreviousProcessorBlock();s&&(s=s.getPreviousProcessorBlock())}return e}setMappingSupportForCurrentEventsFile(t,e){let s=t;for(;s;)s.setMappingSupported(e),s=s.getIsFirstInEventsFile()?void 0:s.getPreviousProcessorBlock()}isMappingSupportedByCurrentEventsFile(t){let e;e=t.getOutputFile()?!!t.getContainsExpansionEvents()||0!==t.getTotalNumberOfLinesInOutputFile()&&t.getTotalNumberOfLinesInOutputFile()===t.getTotalNumberOfLinesInInputFiles():!(!t.getPreviousProcessorBlock()||t.getIsFirstInEventsFile());const s=t.getPreviousProcessorBlock();return s&&!t.getIsFirstInEventsFile()&&(e=e&&this.isMappingSupportedByCurrentEventsFile(s)),e}getAllErrors(){return this.currentProcessor?this.currentProcessor.getAllProcessorErrors():[]}getAllFileIDRecords(){return this.currentProcessor?this.currentProcessor.getMappingTable().getAllFileIDRecords():[]}}},232:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.MapTable=void 0;class s{constructor(t){this.inputStartLine=0,this.inputEndLine=-1,this.outputStartLine=0,this.outputEndLine=-1,"number"==typeof t?this.inputFileID=t:(this.inputStartLine=t.getInputStartLine(),this.inputEndLine=t.getInputEndLine(),this.inputFileID=t.getInputFileID(),this.outputStartLine=t.getOutputStartLine(),this.outputEndLine=t.getOutputEndLine())}getInputEndLine(){return this.inputEndLine}setInputEndLine(t){this.inputEndLine=t}getInputFileID(){return this.inputFileID}setInputFileID(t){this.inputFileID=t}getInputStartLine(){return this.inputStartLine}setInputStartLine(t){this.inputStartLine=t}getOutputEndLine(){return this.outputEndLine}setOutputEndLine(t){this.outputEndLine=t}getOutputStartLine(){return this.outputStartLine}setOutputStartLine(t){this.outputStartLine=t}shiftOutputLines(t){this.outputStartLine+=t,this.outputEndLine>0&&(this.outputEndLine+=t)}containsOutputLine(t){return-1===this.outputEndLine?t>=this.outputStartLine:t>=this.outputStartLine&&t<=this.outputEndLine}containsInputLine(t,e){return-1===this.inputEndLine?t>=this.inputStartLine&&e===this.inputFileID:t>=this.inputStartLine&&t<=this.inputEndLine&&e===this.inputFileID}fixInputRangeBasedOnOutputRange(){this.inputEndLine=this.outputEndLine-this.outputStartLine+this.inputStartLine}fixOutputRangeBasedOnInputRange(){this.outputEndLine=this.inputEndLine-this.inputStartLine+this.outputStartLine}}class i{constructor(t){this.ID=t,this.lines=0}getID(){return this.ID}getLinesProcessed(){return this.lines}increaseLinesProcessed(t){this.lines+=t}}e.MapTable=class{constructor(){this.map=[],this.queueExpansion=[],this.files=new r,this.lookupIndex=0,this.fileTable=new Map}addFileInformation(t){const e=this.createOpenEndedSourceLineRange(t),s=new i(t.getSourceId());if(!this.files.isEmpty()){const t=this.files.peek(),s=this.map[this.map.length-1];s.getOutputStartLine()===e.getOutputStartLine()?this.map.pop():(s.setOutputEndLine(e.getOutputStartLine()-1),s.setInputEndLine(s.getOutputEndLine()-s.getOutputStartLine()+s.getInputStartLine()),t?.increaseLinesProcessed(s.getInputEndLine()-s.getInputStartLine()+1))}this.map.push(e),this.files.push(s),this.fileTable.set(t.getSourceId(),t)}addFileToFileTable(t){this.fileTable.set(t.getSourceId(),t)}closeFile(t){if(this.files.isEmpty())throw new Error(`A FILEEND event does not have a matching FILEID.\nFaulty event: ${t.toString()}`);const e=this.files.pop();if(e?.getID()!==t.getFileId())throw new Error(`The ID field of the FILEEND event does not match the ID field of the last FILEID event.\nMismatched IDs: \t FILEID: ${e?.getID()}\t FILEEND: ${t.toString()}`);const i=this.map[this.map.length-1];if(i.getInputFileID()!==t.getFileId())throw new Error(`The ID field of the FILEEND event does not match the ID field of the last SourceLineRange.\nMismatched IDs: \t FILEID: ${i.getInputFileID()}\t FILEEND: ${t.toString()}`);let r=0;try{r=t.getExpansion()}catch(e){throw new Error(`Unable to parse the expansion field of the FILEEND record to an integer\nFaulty record: ${t.toString()}`)}if(0!==r){if(i.setInputEndLine(i.getInputStartLine()+r-e.getLinesProcessed()-1),i.setOutputEndLine(i.getOutputStartLine()+r-e.getLinesProcessed()-1),this.files.isEmpty())return;const t=this.files.peek(),n=new s(t.getID());n.setInputStartLine(t.getLinesProcessed()+1),n.setOutputStartLine(i.getOutputEndLine()+1),this.map.push(n)}else{if(i.setInputEndLine(i.getInputStartLine()),i.setOutputStartLine(i.getOutputStartLine()-1),i.setOutputEndLine(i.getOutputStartLine()),this.files.isEmpty())return;const t=this.files.peek(),e=new s(t.getID());e.setInputStartLine(t.getLinesProcessed()+1),e.setOutputStartLine(i.getOutputStartLine()+1),this.map.push(e)}}createOpenEndedSourceLineRange(t){let e=1;try{e=t.getLine()}catch(e){throw new Error(`Unable to parse the line field of the FILEID record to an integer\nFaulty record: ${t.toString()}`)}const i=new s(t.getSourceId());if(i.setInputStartLine(1),this.files.isEmpty())i.setOutputStartLine(1);else{const t=this.map[this.map.length-1],s=this.files.peek();s&&i.setOutputStartLine(t.getOutputStartLine()+e-s.getLinesProcessed())}return i}addExpansionRecord(t){this.queueExpansion.push(t)}getSourceLineRangeForOutputLine(t){for(const e of this.map)if(e.containsOutputLine(t))return e}optimizedSourceLineRangeLookup(t){for(let e=this.lookupIndex;e<this.map.length;e++){const s=this.map[e];if(s.containsOutputLine(t))return this.lookupIndex=e,s}for(let e=0;e<this.lookupIndex&&e<this.map.length;e++){const s=this.map[e];if(s.containsOutputLine(t))return this.lookupIndex=e,s}}getSourceLineRangeForInputLine(t,e){for(const s of this.map)if(s.containsInputLine(t,e))return s}shiftRangesBy(t,e){for(let s=e;s<this.map.length;s++)this.map[s].shiftOutputLines(t)}handleExpansion(t){const e=this.createSourceLineRange(t);let s;if(e.getOutputStartLine()-this.map[this.map.length-1].getOutputEndLine()==1){if(e.getInputStartLine()===e.getInputEndLine())return void this.map.push(e)}else s=e.getInputStartLine()!==e.getInputEndLine()||0===e.getOutputStartLine()&&0===e.getOutputEndLine()?this.getSourceLineRangeForInputLine(e.getInputStartLine(),e.getInputFileID()):this.getSourceLineRangeForOutputLine(e.getOutputStartLine());this.splitExpandedSourceLineRange(e,s)}splitExpandedSourceLineRange(t,e){const i=this.map.indexOf(e),r=0===t.getOutputStartLine()&&0===t.getOutputEndLine(),n=r?t.getInputStartLine()-t.getInputEndLine()-1:t.getOutputEndLine()-t.getOutputStartLine()+1;if(r)if(t.getInputStartLine()===e.getInputStartLine()&&t.getInputEndLine()===e.getInputEndLine())this.map.splice(i,1),this.shiftRangesBy(n,i);else if(t.getInputStartLine()===e.getInputStartLine())e.setInputStartLine(t.getInputEndLine()+1),e.setOutputStartLine(e.getOutputStartLine()+Math.abs(n)),this.shiftRangesBy(n,i);else if(t.getInputEndLine()===e.getInputEndLine())e.setInputEndLine(t.getInputStartLine()-1),e.setOutputEndLine(e.getOutputEndLine()-Math.abs(n)),this.shiftRangesBy(n,i+1);else{const r=new s(e);e.setInputEndLine(t.getInputStartLine()-1),e.fixOutputRangeBasedOnInputRange(),r.setInputStartLine(t.getInputEndLine()+1),r.setOutputStartLine(e.getOutputEndLine()+Math.abs(n)+1),this.map.splice(i+1,0,r),this.shiftRangesBy(n,i+1)}else if(e.getOutputStartLine()===t.getOutputStartLine())t.getInputStartLine()===t.getInputEndLine()&&(this.map.splice(i,0,t),this.shiftRangesBy(n,i+1));else{const r=new s(e);e.setOutputEndLine(t.getOutputStartLine()-1),e.fixInputRangeBasedOnOutputRange(),this.map.splice(i+1,0,t),r.setInputStartLine(e.getInputEndLine()+1),r.setOutputStartLine(e.getOutputEndLine()+1),this.map.splice(i+2,0,r),this.shiftRangesBy(n,i+2)}}createSourceLineRange(t){const e=new s(t.getInputFileID());let i=0,r=0,n=0,o=0;try{i=t.getInputLineStart(),r=t.getInputLineEnd(),n=t.getOutputLineStart(),o=t.getOutputLineEnd()}catch(e){throw new Error(`Unable to parse the fields of the EXPANSION record to integers\nFaulty record: ${t.toString()}`)}return e.setInputStartLine(i),e.setInputEndLine(r),e.setOutputStartLine(n),e.setOutputEndLine(o),e}getFileIDRecordForFileID(t){return this.fileTable.get(t)}getFileLocationForFileID(t){const e=this.getFileIDRecordForFileID(t);if(e)return e.getFileName()}modifyErrorInformation(t){const e=t.getStmtLine(),s=this.optimizedSourceLineRangeLookup(e);if(!s)throw new Error(`The line number on which ERROR occurs could not be found in the map.\nFaulty event: ${t.toString()}`);try{t.setStmtLine(this.getLineFromSourceLineRange(s,e)),t.setFileId(s.getInputFileID());const i=t.getStartErrLine();t.setStartErrLine(this.getLineFromSourceLineRange(s,i));const r=t.getEndErrLine();t.setEndErrLine(this.getLineFromSourceLineRange(s,r)),t.setFileName(this.fileTable.get(s.getInputFileID()).getFileName())}catch(e){throw new Error(`Unable to parse the line fields of the ERROR record to integers\nFaulty record: ${t.toString()}`)}}getLineFromSourceLineRange(t,e){return t?t.getInputEndLine()-t.getInputStartLine()==t.getOutputEndLine()-t.getOutputStartLine()||-1===t.getInputEndLine()&&-1===t.getOutputEndLine()?e-t.getOutputStartLine()+t.getInputStartLine():t.getInputStartLine():e}finalizeMap(){if(!this.files.isEmpty())throw new Error(`One or more FILEID records do not have matching FILEEND records\nList of outstanding FILEID records: ${JSON.stringify(this.files)}`);this.queueExpansion.forEach((t=>{this.handleExpansion(t)}));const t=new s(1);t.setInputStartLine(0),t.setInputEndLine(0),t.setOutputStartLine(0),t.setOutputEndLine(0),this.map.unshift(t)}toString(){let t="";return this.map.forEach((e=>{t+=`${e.getInputFileID()}: [${e.getInputStartLine()},${e.getInputEndLine()}]--\x3e[${e.getOutputStartLine()},${e.getOutputEndLine()}]\n`})),t}getAllFileIDRecords(){if(!this.fileTable||0===this.fileTable.size)return[];const t=new Set;for(let e of this.fileTable.keys()){const s=this.fileTable.get(e);t.add(s)}return Array.from(t.values())}};class r{constructor(){this.stack=[]}push(t){this.stack.push(t)}pop(){return this.stack.pop()}peek(){return this.stack[this.stack.length-1]}isEmpty(){return 0===this.stack.length}size(){return this.stack.length}}},387:function(t,e,s){var i=this&&this.__createBinding||(Object.create?function(t,e,s,i){void 0===i&&(i=s);var r=Object.getOwnPropertyDescriptor(e,s);r&&!("get"in r?!e.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return e[s]}}),Object.defineProperty(t,i,r)}:function(t,e,s,i){void 0===i&&(i=s),t[i]=e[s]}),r=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),n=this&&this.__importStar||function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var s in t)"default"!==s&&Object.prototype.hasOwnProperty.call(t,s)&&i(e,t,s);return r(e,t),e};Object.defineProperty(e,"__esModule",{value:!0}),e.Parser=void 0;const o=n(s(17)),u=s(768),a=s(477),p=s(130),c=s(253),l=s(1),h=s(884),d=s(618),g=s(322),I=s(147);class E{constructor(t,e){this.location=t,this.browseMode=e}getLocation(){return this.location}isReadOnly(){return this.browseMode.toString()}setReadOnly(t){this.browseMode=t}}class L{constructor(t){this.iSequentialFileReader=t}readNextLine(){if(this.peakLine){const t=this.peakLine;return this.peakLine=void 0,t}return this.iSequentialFileReader.readNextLine()}peakNextRecordType(){return this.peakLine=this.iSequentialFileReader.readNextLine(),this.peakLine?.split(/\s+/).filter((t=>""!==t))[0]}}e.Parser=class{constructor(){this.sourceTable=new Map}getUntilTheEndOfTheLine(t,e){let s=e[t++];for(;t<e.length;){s=s.concat(" ");let i=e[t++];s=s.concat(i)}return s}log(t){process.env.DEBUG&&console.log(t)}parseFile(t,e){this.parse(new F(t),e)}parse(t,e){let s,i;this.processor||(this.processor=new g.ExpansionProcessor),this.processor?.doPreProcessing();const r=new L(t);let n=r.readNextLine();for(;n;){let t=n.split(/\s+/).filter((t=>""!==t)),e=0;for(;e<t.length;){if(s=t[e++],s===u.IRecordT.ERROR_INFORMATION){const s=parseInt(t[e++]);i=parseInt(t[e++]);let r=this.sourceTable.get(i);if(!r)if(0===i){r=this.sourceTable.get(1)||new E("",!1)}else r=new E("",!1);const n=parseInt(t[e++]),o=parseInt(t[e++]),u=parseInt(t[e++]),a=parseInt(t[e++]),p=parseInt(t[e++]),c=parseInt(t[e++]),h=t[e++],d=t[e++],g=parseInt(t[e++]),I=parseInt(t[e++]),L=this.getUntilTheEndOfTheLine(e,t),F=new l.ErrorInformationRecord(s,i,n,o,u,a,p,c,h,d,g,I,L);F.setFileName(r.getLocation()),this.processor&&this.processor.processErrorRecord(F);break}if(s===u.IRecordT.FILE_ID){let s=!1;const o=parseInt(t[e++]);i=parseInt(t[e++]);const a=parseInt(t[e++]),p=parseInt(t[e++]);let l=n.substring(28);this.log(`EventsFileParser: location from line 1 = ${l}`);let h=r.peakNextRecordType();for(;h===u.IRecordT.FILE_CONT;){if(n=r.readNextLine(),!n)throw new Error("Events file has incorrect format. End of file encountered before location length satisfied.");t=n.split(" "),l+=n.substring(28),this.log(`EventsFileParser: location from line 1 = ${l}`),h=r.peakNextRecordType()}let d=l.substring(l.length-16,l.length-2);try{parseInt(d)}catch(t){d=""}const g=parseInt(l.charAt(l.length-1)),I=" "===l.charAt(l.length-2);s=!(1!==g||!I),l=l.substring(0,l.length-17),l=this.resolveRelativePath(l);const L=new E(l,s);if((this.lastOutputFile&&l===this.lastOutputFile.getLocation()||this.currentOutputFile&&l===this.currentOutputFile.getLocation())&&L.setReadOnly(!0),999===i&&(this.lastOutputFile?(this.lastOutputFile=this.currentOutputFile,this.currentOutputFile=L):this.lastOutputFile=this.currentOutputFile=L),this.sourceTable.set(i,L),this.processor){const t=new c.FileIDRecord(o,i,a,p,l,d.toString(),g);try{this.processor.processFileIDRecord(t)}catch(t){const e=t.message?t.message:t;this.log(e),this.exception=new Error(e)}}break}if(s===u.IRecordT.FILE_END){if(this.processor){const s=parseInt(t[e++]),i=parseInt(t[e++]),r=parseInt(t[e++]),n=new h.FileEndRecord(s,i,r);try{this.processor?.processFileEndRecord(n)}catch(t){const e=t.message?t.message:t;this.log(e),this.exception=new Error(e)}}break}if(s===u.IRecordT.EXPANSION){if(this.processor){const s=parseInt(t[e++]),i=parseInt(t[e++]),r=parseInt(t[e++]),n=parseInt(t[e++]),o=parseInt(t[e++]),u=parseInt(t[e++]),a=parseInt(t[e++]),p=new d.ExpansionRecord(s,i,r,n,o,u,a);this.processor?.processExpansionRecord(p)}break}if(s===u.IRecordT.TIMESTAMP){if(this.processor){const s=parseInt(t[e++]),i=t[e++];let r=new a.TimestampRecord(s,i);this.processor?.processTimestampRecord(r)}break}if(s===u.IRecordT.PROCESSOR){if(this.processor){const s=parseInt(t[e++]),i=parseInt(t[e++]),r=parseInt(t[e++]);let n=new p.ProcessorRecord(s,i,r);try{this.processor?.processProcessorRecord(n)}catch(t){const e=t.message?t.message:t;this.log(e),this.exception=new Error(e)}}break}if(s===u.IRecordT.PROGRAM||s===u.IRecordT.MAP_DEFINE||s===u.IRecordT.MAP_END||s===u.IRecordT.MAP_START||s===u.IRecordT.FEEDBACK_CODE||0===s.trim().length)break;throw new Error(`Events file has incorrect format. Unexpected line type. LT=${n}`)}n&&(n=r.readNextLine())}if(this.processor)try{this.processor?.doPostProcessing()}catch(t){this.exception=new Error(t.message?t.message:t)}e&&this.getAllErrors().forEach((t=>{const s=this.sourceTable.get(t.getFileId());s&&e.createMarker(t,t.getFileName(),s.isReadOnly())}))}resolveRelativePath(t){return(t=o.normalize(t).toString()).replace(/\\/g,"/")}getException(){return this.exception}setProcessor(t){this.processor=t}getAllErrors(){if(this.processor){const t=this.processor?.getAllErrors();let e=[];return e=e.concat(...t),e}return[]}getAllFileIDRecords(){return this.processor?this.processor.getAllFileIDRecords():[]}};class F{constructor(t){this.currLineNum=0,this.file=(0,I.readFileSync)(t,"utf-8"),this.linesArray=this.file.split(/\r?\n/)}readNextLine(){let t;return this.currLineNum<this.linesArray.length?(t=this.linesArray[this.currLineNum],this.currLineNum++):t=void 0,t}}e.default=F},153:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ProcessorBlock=void 0;const i=s(232);e.ProcessorBlock=class{constructor(t){this.INPUT_FILE_ID=1,this.containsExpansionEvents=!1,this.isFirstInEventsFile=!1,this.mappingSupported=!1,this.totalNumberOfLinesInOutputFile=0,this.totalNumberOfLinesInInputFiles=0,this.currentProcessor=t,this.mappingTable=new i.MapTable,this.errors=[]}getInputFile(){return this.inputFile}getInitialInputFile(){return this.previousProcessorBlock&&!this.getIsFirstInEventsFile()?this.previousProcessorBlock.getInitialInputFile():this.getInputFile()}setInputFile(t){this.inputFile=t}addFile(t){this.mappingTable.addFileInformation(t)}closeFile(t){if(this.outputFile){if(t.getFileId()===this.outputFile.getSourceId())return void this.setTotalNumberOfLinesInOutputFile(t.getExpansion());this.increaseTotalNumberOfLinesInInputFiles(t.getExpansion()),this.mappingTable.closeFile(t)}}getOutputFile(){return this.outputFile}setOutputFile(t){this.outputFile=t}getMappingTable(){return this.mappingTable}isProcessorIDZero(){return 0===this.currentProcessor.getOutputId()}addErrorInformation(t){this.errors.push(t)}processorEnded(){this.mappingTable.finalizeMap()}setPreviousProcessor(t){this.previousProcessorBlock=t}setContainsExpansionEvents(t){this.containsExpansionEvents=t}getContainsExpansionEvents(){return this.containsExpansionEvents}increaseTotalNumberOfLinesInInputFiles(t){this.totalNumberOfLinesInInputFiles+=t}getTotalNumberOfLinesInInputFiles(){return this.totalNumberOfLinesInInputFiles}setTotalNumberOfLinesInOutputFile(t){this.totalNumberOfLinesInOutputFile=t}getTotalNumberOfLinesInOutputFile(){return this.totalNumberOfLinesInOutputFile}getPreviousProcessorBlock(){return this.previousProcessorBlock}modifyErrorInformation(t){this.mappingTable.modifyErrorInformation(t);let e="",s=-1;const i=this.getInputFile();i&&(e=i.getFileName(),s=i.getSourceId()),!this.previousProcessorBlock||this.getIsFirstInEventsFile()||!this.isMappingSupported()||t.getFileId()!==s&&t.getFileName()!==e||this.previousProcessorBlock.modifyErrorInformation(t)}setFirstInEventsFile(t){this.isFirstInEventsFile=t}getIsFirstInEventsFile(){return this.isFirstInEventsFile}setMappingSupported(t){this.mappingSupported=t}isMappingSupported(){return this.mappingSupported}isFileReadOnly(t){return 1===t.getFlag()||this.previousProcessorBlock&&!this.getIsFirstInEventsFile()&&void 0!==this.previousProcessorBlock.getOutputFile()&&t.getFileName()===this.previousProcessorBlock.getOutputFile().getFileName()||void 0!==this.getOutputFile()&&t.getFileName()===this.getOutputFile().getFileName()}getAllProcessorErrors(){let t=[];return this.previousProcessorBlock&&(t=this.previousProcessorBlock.getAllProcessorErrors()),t.push(this.errors),t}resolveFileNamesForAllErrors(){this.previousProcessorBlock&&this.previousProcessorBlock.resolveFileNamesForAllErrors(),this.errors.forEach((t=>{this.resolveFileNameAndDetermineIfReadOnly(t)}))}resolveFileNameAndDetermineIfReadOnly(t){let e=!1;if(this.previousProcessorBlock&&!this.getIsFirstInEventsFile()&&this.isMappingSupported()&&t.getFileId()===this.INPUT_FILE_ID)this.previousProcessorBlock.modifyErrorInformation(t);else{const s=this.mappingTable.getFileLocationForFileID(t.getFileId());if(s){const i=this.mappingTable.getFileIDRecordForFileID(t.getFileId());e=!!i&&this.isFileReadOnly(i),t.setFileName(s)}else{const s=this.getInitialInputFile();e=!!s&&this.isFileReadOnly(s),t.setFileName(s?.getFileName()||""),t.setStmtLine(0),t.setStartErrLine(0),t.setTokenStart(0),t.setEndErrLine(0),t.setTokenEnd(0)}}return e}}},1:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ErrorInformationRecord=void 0;const i=s(768);e.ErrorInformationRecord=class{constructor(t,e,s,i,r,n,o,u,a,p,c,l,h){this.version=t,this.fileId=e,this.annotClass=s,this.stmtLine=i,this.startErrLine=r,this.tokenStart=n,this.endErrLine=o,this.tokenEnd=u,this.msgId=a,this.sevChar=p,this.sevNum=c,this.length=l,this.msg=h,this.fileName=""}getRecordType(){return i.IRecordT.ERROR_INFORMATION}getVersion(){return this.version}getFileId(){return this.fileId}setFileId(t){this.fileId=t}getFileName(){return this.fileName}setFileName(t){this.fileName=t}getAnnotClass(){return this.annotClass}getStmtLine(){return this.stmtLine}setStmtLine(t){this.stmtLine=t}getStartErrLine(){return this.startErrLine}setStartErrLine(t){this.startErrLine=t}getTokenStart(){return this.tokenStart}setTokenStart(t){this.tokenStart=t}getEndErrLine(){return this.endErrLine}setEndErrLine(t){this.endErrLine=t}getTokenEnd(){return this.tokenEnd}setTokenEnd(t){this.tokenEnd=t}getMsgId(){return this.msgId}getSevChar(){return this.sevChar}getSevNum(){return this.sevNum}getLength(){return this.length}getMsg(){return this.msg}toString(){return`${i.IRecordT.ERROR_INFORMATION}\t${this.version} ${this.fileId} ${this.annotClass} ${this.stmtLine} ${this.startErrLine} ${this.tokenStart} ${this.endErrLine} ${this.tokenEnd} ${this.msgId} ${this.sevChar} ${this.sevNum} ${this.length} ${this.msg}`}}},618:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ExpansionRecord=void 0;const i=s(768);e.ExpansionRecord=class{constructor(t,e,s,i,r,n,o){this.version=t,this.inputFileID=e,this.inputLineStart=s,this.inputLineEnd=i,this.outputFileID=r,this.outputLineStart=n,this.outputLineEnd=o}getRecordType(){return i.IRecordT.EXPANSION}getVersion(){return this.version}getInputFileID(){return this.inputFileID}getInputLineStart(){return this.inputLineStart}getInputLineEnd(){return this.inputLineEnd}getOutputFileID(){return this.outputFileID}getOutputLineStart(){return this.outputLineStart}getOutputLineEnd(){return this.outputLineEnd}toString(){return`${i.IRecordT.EXPANSION}\t${this.version} ${this.inputFileID} ${this.inputLineStart} ${this.inputLineEnd} ${this.outputFileID} ${this.outputLineStart} ${this.outputLineEnd}`}}},884:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.FileEndRecord=void 0;const i=s(768);e.FileEndRecord=class{constructor(t,e,s){this.version=t,this.fileId=e,this.expansion=s}getRecordType(){return i.IRecordT.FILE_END}getVersion(){return this.version}getFileId(){return this.fileId}getExpansion(){return this.expansion}toString(){return`${i.IRecordT.FILE_END}\t${this.version} ${this.fileId} ${this.expansion}`}}},253:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.FileIDRecord=void 0;const i=s(768);e.FileIDRecord=class{constructor(t,e,s,i,r,n,o){this.version=t,this.sourceId=e,this.line=s,this.length=i,this.fileName=r,this.timestamp=n,this.flag=o}getRecordType(){return i.IRecordT.FILE_ID}getVersion(){return this.version}getSourceId(){return this.sourceId}getLine(){return this.line}getLength(){return this.length}getFileName(){return this.fileName}getTimestamp(){return this.timestamp}getFlag(){return this.flag}toString(){return`${i.IRecordT.FILE_ID}\t${this.version} ${this.sourceId} ${this.line} ${this.length} ${this.fileName} ${this.timestamp} ${this.flag}`}}},768:(t,e)=>{var s;Object.defineProperty(e,"__esModule",{value:!0}),e.IRecordT=void 0,function(t){t.TIMESTAMP="TIMESTAMP",t.PROCESSOR="PROCESSOR",t.FILE_ID="FILEID",t.FILE_CONT="FILEIDCONT",t.FILE_END="FILEEND",t.ERROR_INFORMATION="ERROR",t.PROGRAM="PROGRAM",t.MAP_DEFINE="MAPDEFINE",t.MAP_START="MAPSTART",t.MAP_END="MAPEND",t.FEEDBACK_CODE="FEEDBACK",t.EXPANSION="EXPANSION"}(s||(e.IRecordT=s={}))},130:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ProcessorRecord=void 0;const i=s(768);e.ProcessorRecord=class{constructor(t,e,s){this.version=t,this.outputId=e,this.lineClass=s}getRecordType(){return i.IRecordT.PROCESSOR}getVersion(){return this.version}getOutputId(){return this.outputId}getLineClass(){return this.lineClass}toString(){return`${i.IRecordT.PROCESSOR}\t${this.version} ${this.outputId} ${this.lineClass}`}}},477:(t,e,s)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TimestampRecord=void 0;const i=s(768);e.TimestampRecord=class{constructor(t,e){this.version=t,this.timestamp=e}getRecordType(){return i.IRecordT.TIMESTAMP}getVersion(){return this.version}getTimestamp(){return this.timestamp}toString(){return`${i.IRecordT.TIMESTAMP}\t${this.version} ${this.timestamp}`}}},147:t=>{t.exports=require("fs")},17:t=>{t.exports=require("path")}},e={};function s(i){var r=e[i];if(void 0!==r)return r.exports;var n=e[i]={exports:{}};return t[i].call(n.exports,n,n.exports,s),n.exports}var i={};(()=>{var t=i;Object.defineProperty(t,"__esModule",{value:!0}),t.ErrorInformationRecord=t.Parser=void 0;var e=s(387);Object.defineProperty(t,"Parser",{enumerable:!0,get:function(){return e.Parser}});var r=s(1);Object.defineProperty(t,"ErrorInformationRecord",{enumerable:!0,get:function(){return r.ErrorInformationRecord}})})();var r=exports;for(var n in i)r[n]=i[n];i.__esModule&&Object.defineProperty(r,"__esModule",{value:!0})})();
|
|
2
2
|
//# sourceMappingURL=index.js.map
|