yini-parser 1.0.2-beta → 1.2.0-beta
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/CHANGELOG.md +50 -0
- package/README.md +83 -98
- package/dist/YINI.d.ts +162 -23
- package/dist/YINI.js +183 -99
- package/dist/YINI.js.map +1 -0
- package/dist/config/env.js +1 -0
- package/dist/config/env.js.map +1 -0
- package/dist/core/astBuilder.d.ts +191 -0
- package/dist/core/astBuilder.js +840 -0
- package/dist/core/astBuilder.js.map +1 -0
- package/dist/core/{ErrorDataHandler.d.ts → errorDataHandler.d.ts} +21 -19
- package/dist/core/errorDataHandler.js +271 -0
- package/dist/core/errorDataHandler.js.map +1 -0
- package/dist/core/internalTypes.d.ts +121 -0
- package/dist/core/internalTypes.js +16 -0
- package/dist/core/internalTypes.js.map +1 -0
- package/dist/core/objectBuilder.d.ts +10 -4
- package/dist/core/objectBuilder.js +127 -163
- package/dist/core/objectBuilder.js.map +1 -0
- package/dist/core/options/failLevel.d.ts +3 -0
- package/dist/core/options/failLevel.js +27 -0
- package/dist/core/options/failLevel.js.map +1 -0
- package/dist/core/options/normalizeOptions.d.ts +5 -0
- package/dist/core/options/normalizeOptions.js +53 -0
- package/dist/core/options/normalizeOptions.js.map +1 -0
- package/dist/core/options/parserOptionsConstants.d.ts +7 -0
- package/dist/core/options/parserOptionsConstants.js +37 -0
- package/dist/core/options/parserOptionsConstants.js.map +1 -0
- package/dist/core/pipeline.d.ts +18 -0
- package/dist/core/pipeline.js +323 -0
- package/dist/core/pipeline.js.map +1 -0
- package/dist/core/resultMetadataBuilder.d.ts +19 -0
- package/dist/core/resultMetadataBuilder.js +166 -0
- package/dist/core/resultMetadataBuilder.js.map +1 -0
- package/dist/core/runtime.d.ts +17 -0
- package/dist/core/runtime.js +189 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/dev/main.d.ts +1 -0
- package/dist/dev/main.js +374 -0
- package/dist/dev/main.js.map +1 -0
- package/dist/grammar/generated/YiniLexer.d.ts +74 -0
- package/dist/grammar/generated/YiniLexer.js +415 -0
- package/dist/grammar/generated/YiniLexer.js.map +1 -0
- package/dist/grammar/{YiniParser.d.ts → generated/YiniParser.d.ts} +167 -150
- package/dist/grammar/{YiniParser.js → generated/YiniParser.js} +1242 -1202
- package/dist/grammar/generated/YiniParser.js.map +1 -0
- package/dist/grammar/{YiniParserVisitor.d.ts → generated/YiniParserVisitor.d.ts} +59 -45
- package/dist/grammar/{YiniParserVisitor.js → generated/YiniParserVisitor.js} +2 -1
- package/dist/grammar/generated/YiniParserVisitor.js.map +1 -0
- package/dist/index.d.ts +43 -2
- package/dist/index.js +62 -101
- package/dist/index.js.map +1 -0
- package/dist/parsers/extractHeaderParts.d.ts +4 -3
- package/dist/parsers/extractHeaderParts.js +3 -1
- package/dist/parsers/extractHeaderParts.js.map +1 -0
- package/dist/parsers/extractSignificantYiniLine.js +2 -1
- package/dist/parsers/extractSignificantYiniLine.js.map +1 -0
- package/dist/parsers/parseBoolean.d.ts +1 -1
- package/dist/parsers/parseBoolean.js +3 -1
- package/dist/parsers/parseBoolean.js.map +1 -0
- package/dist/parsers/parseNull.js +1 -0
- package/dist/parsers/parseNull.js.map +1 -0
- package/dist/parsers/parseNumber.d.ts +8 -3
- package/dist/parsers/parseNumber.js +22 -7
- package/dist/parsers/parseNumber.js.map +1 -0
- package/dist/parsers/parseSectionHeader.d.ts +5 -4
- package/dist/parsers/parseSectionHeader.js +3 -1
- package/dist/parsers/parseSectionHeader.js.map +1 -0
- package/dist/parsers/parseString.js +3 -3
- package/dist/parsers/parseString.js.map +1 -0
- package/dist/types/index.d.ts +198 -0
- package/dist/types/index.js +4 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utils/number.d.ts +3 -0
- package/dist/utils/number.js +19 -0
- package/dist/utils/number.js.map +1 -0
- package/dist/utils/object.d.ts +67 -0
- package/dist/utils/object.js +125 -0
- package/dist/utils/object.js.map +1 -0
- package/dist/utils/pathAndFileName.js +1 -0
- package/dist/utils/pathAndFileName.js.map +1 -0
- package/dist/utils/print.d.ts +2 -2
- package/dist/utils/print.js +11 -6
- package/dist/utils/print.js.map +1 -0
- package/dist/utils/string.d.ts +26 -1
- package/dist/utils/string.js +48 -4
- package/dist/utils/string.js.map +1 -0
- package/dist/utils/system.d.ts +15 -0
- package/dist/utils/system.js +22 -0
- package/dist/utils/system.js.map +1 -0
- package/dist/{yiniHelpers.d.ts → utils/yiniHelpers.d.ts} +3 -0
- package/dist/{yiniHelpers.js → utils/yiniHelpers.js} +46 -9
- package/dist/utils/yiniHelpers.js.map +1 -0
- package/package.json +7 -5
- package/dist/core/ErrorDataHandler.js +0 -203
- package/dist/core/YINIVisitor.d.ts +0 -158
- package/dist/core/YINIVisitor.js +0 -1008
- package/dist/core/types.d.ts +0 -59
- package/dist/core/types.js +0 -36
- package/dist/grammar/YiniLexer.d.ts +0 -68
- package/dist/grammar/YiniLexer.js +0 -379
- package/dist/parseEntry.d.ts +0 -2
- package/dist/parseEntry.js +0 -185
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* This file is the orchestrator that wires up the pipeline (lexer → parser →
|
|
4
|
+
* astBuilder → objectBuilder, etc.)
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.runPipeline = void 0;
|
|
44
|
+
const perf_hooks_1 = require("perf_hooks");
|
|
45
|
+
const util_1 = require("util");
|
|
46
|
+
const antlr4_1 = require("antlr4");
|
|
47
|
+
const env_1 = require("../config/env");
|
|
48
|
+
const YiniLexer_1 = __importDefault(require("../grammar/generated/YiniLexer"));
|
|
49
|
+
const YiniParser_1 = __importStar(require("../grammar/generated/YiniParser"));
|
|
50
|
+
const object_1 = require("../utils/object");
|
|
51
|
+
const print_1 = require("../utils/print");
|
|
52
|
+
const astBuilder_1 = __importDefault(require("./astBuilder"));
|
|
53
|
+
const errorDataHandler_1 = require("./errorDataHandler");
|
|
54
|
+
const objectBuilder_1 = require("./objectBuilder");
|
|
55
|
+
const resultMetadataBuilder_1 = require("./resultMetadataBuilder");
|
|
56
|
+
/**
|
|
57
|
+
* @param line Line number as 1-based.
|
|
58
|
+
* @param col Column number as 0-based.
|
|
59
|
+
*/
|
|
60
|
+
const createGeneralCtx = (line, endColumn, startColumn = undefined) => {
|
|
61
|
+
const startToken = new antlr4_1.Token();
|
|
62
|
+
const stopToken = new antlr4_1.Token();
|
|
63
|
+
const ctx = new YiniParser_1.YiniContext();
|
|
64
|
+
ctx.start = startToken;
|
|
65
|
+
ctx.stop = stopToken;
|
|
66
|
+
ctx.start.line = line; // Note: Line num is 1-based.
|
|
67
|
+
if (startColumn && startColumn >= 0) {
|
|
68
|
+
ctx.start.column = startColumn; // Note: Column num is 0-based.
|
|
69
|
+
}
|
|
70
|
+
ctx.stop.column = endColumn; // Note: Column num is 0-based.
|
|
71
|
+
return ctx;
|
|
72
|
+
};
|
|
73
|
+
const parsePossibleStartCol = (errorHandler, recognizer) => {
|
|
74
|
+
let possibleStartCol = undefined;
|
|
75
|
+
try {
|
|
76
|
+
possibleStartCol = recognizer?._ctx.start?.column
|
|
77
|
+
? recognizer?._ctx.start?.column + 1
|
|
78
|
+
: undefined;
|
|
79
|
+
}
|
|
80
|
+
catch (err) {
|
|
81
|
+
let msgHint = '';
|
|
82
|
+
if ((0, util_1.isError)(err)) {
|
|
83
|
+
msgHint = 'Error: ' + err.message;
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
msgHint = 'Thrown value:' + JSON.stringify(err);
|
|
87
|
+
}
|
|
88
|
+
errorHandler.pushOrBail(null, 'Internal-Error', 'Catched error of possibleStartCol in parser grammar listener.', msgHint);
|
|
89
|
+
}
|
|
90
|
+
return possibleStartCol;
|
|
91
|
+
};
|
|
92
|
+
class MyParserErrorListener {
|
|
93
|
+
constructor(errorHandler) {
|
|
94
|
+
this.errors = [];
|
|
95
|
+
this.errorHandler = errorHandler;
|
|
96
|
+
}
|
|
97
|
+
syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) {
|
|
98
|
+
(0, print_1.debugPrint)('ANTLR parser cached an error');
|
|
99
|
+
const col = charPositionInLine + 1;
|
|
100
|
+
const possibleStartCol = parsePossibleStartCol(this.errorHandler, recognizer);
|
|
101
|
+
const msgWhat = `Syntax error`;
|
|
102
|
+
// Try to map message:
|
|
103
|
+
// From: "mismatched input '/END' expecting <EOF>"
|
|
104
|
+
// To: "Found '/END', but expected the end of the document."
|
|
105
|
+
// const msgWhy = `${capitalizeFirst(msg)}`
|
|
106
|
+
const msgWhy = `Details: ${msg}`;
|
|
107
|
+
const ctx = createGeneralCtx(line, charPositionInLine, possibleStartCol); // So we can show line/col in error message.
|
|
108
|
+
// Note, after pushing processing may continue or exit, depending on the error and/or the bail threshold.
|
|
109
|
+
this.errorHandler.pushOrBail(ctx, 'Syntax-Error', msgWhat, msgWhy);
|
|
110
|
+
}
|
|
111
|
+
// The following are required for the interface, but can be left empty.
|
|
112
|
+
reportAmbiguity(...args) { }
|
|
113
|
+
reportAttemptingFullContext(...args) { }
|
|
114
|
+
reportContextSensitivity(...args) { }
|
|
115
|
+
}
|
|
116
|
+
class MyLexerErrorListener {
|
|
117
|
+
constructor(errorHandler) {
|
|
118
|
+
this.errors = [];
|
|
119
|
+
this.errorHandler = errorHandler;
|
|
120
|
+
}
|
|
121
|
+
syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) {
|
|
122
|
+
// Handle the error as you want:
|
|
123
|
+
(0, print_1.debugPrint)('ANTLR lexer cached an error');
|
|
124
|
+
const col = charPositionInLine + 1;
|
|
125
|
+
const possibleStartCol = parsePossibleStartCol(this.errorHandler, recognizer);
|
|
126
|
+
// const msgWhat = `Syntax error at line ${line}, column ${col}:`
|
|
127
|
+
const msgWhat = `Syntax error`;
|
|
128
|
+
// Try to map message:
|
|
129
|
+
// From: "mismatched input '/END' expecting <EOF>"
|
|
130
|
+
// To: "Found '/END', but expected the end of the document."
|
|
131
|
+
// const msgWhy = `${capitalizeFirst(msg)}`
|
|
132
|
+
const msgWhy = `Details: ${msg}`;
|
|
133
|
+
// const msgHint = ``
|
|
134
|
+
const ctx = createGeneralCtx(line, charPositionInLine, possibleStartCol); // So we can show line/col in error message.
|
|
135
|
+
// Note, after pushing processing may continue or exit, depending on the error and/or the bail threshold.
|
|
136
|
+
this.errorHandler.pushOrBail(ctx, 'Syntax-Error', msgWhat, msgWhy);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* @internal Single source of truth.
|
|
141
|
+
*
|
|
142
|
+
* Entrypoint for the YINI parsing pipeline:
|
|
143
|
+
* tokenization → grammar parse → AST build → object build → result.
|
|
144
|
+
*
|
|
145
|
+
* @param _meta_userOpts The user options from which the core options were
|
|
146
|
+
* derived/resolved from. This object is provided only for debugging
|
|
147
|
+
* and metadata purposes and should not be relied upon in
|
|
148
|
+
* application logic.
|
|
149
|
+
*/
|
|
150
|
+
const runPipeline = (yiniContent, coreOptions, runtimeInfo, _meta_userOpts) => {
|
|
151
|
+
(0, print_1.debugPrint)();
|
|
152
|
+
(0, print_1.debugPrint)('-> Entered parseMain(..) in parseEntry');
|
|
153
|
+
(0, print_1.debugPrint)(' isStrict mode = ' + coreOptions.isStrict);
|
|
154
|
+
(0, print_1.debugPrint)(' bailSensitivity = ' + coreOptions.bailSensitivity);
|
|
155
|
+
(0, print_1.debugPrint)(' isIncludeMeta = ' + coreOptions.isIncludeMeta);
|
|
156
|
+
(0, print_1.debugPrint)(' isWithDiagnostics = ' + coreOptions.isWithDiagnostics);
|
|
157
|
+
(0, print_1.debugPrint)(' isWithTiming = ' + coreOptions.isWithTiming);
|
|
158
|
+
(0, print_1.debugPrint)(' isKeepUndefinedInMeta = ' + coreOptions.isKeepUndefinedInMeta);
|
|
159
|
+
(0, print_1.debugPrint)('isAvoidWarningsInConsole = ' + coreOptions.isAvoidWarningsInConsole);
|
|
160
|
+
(0, print_1.debugPrint)(' requireDocTerminator = ' + coreOptions.requireDocTerminator);
|
|
161
|
+
(0, print_1.debugPrint)(' treatEmptyValueAsNull = ' + coreOptions.treatEmptyValueAsNull);
|
|
162
|
+
(0, print_1.debugPrint)(' onDuplicateKey = ' + coreOptions.onDuplicateKey);
|
|
163
|
+
(0, print_1.debugPrint)();
|
|
164
|
+
(0, print_1.debugPrint)(' runtimeInfo.sourceType = ' + runtimeInfo.sourceType);
|
|
165
|
+
(0, print_1.debugPrint)(' runtimeInfo.fileName = ' + runtimeInfo.fileName);
|
|
166
|
+
// let persistThreshold: TBailSensitivityLevel
|
|
167
|
+
// switch (coreOptions.bailSensitivity) {
|
|
168
|
+
// case '0-Ignore-Errors':
|
|
169
|
+
// persistThreshold = '0-Ignore-Errors'
|
|
170
|
+
// break
|
|
171
|
+
// case 1:
|
|
172
|
+
// persistThreshold = '1-Abort-on-Errors'
|
|
173
|
+
// break
|
|
174
|
+
// default:
|
|
175
|
+
// persistThreshold = '2-Abort-Even-on-Warnings'
|
|
176
|
+
// }
|
|
177
|
+
const errorHandler = new errorDataHandler_1.ErrorDataHandler(runtimeInfo.sourceType, runtimeInfo.fileName, coreOptions.bailSensitivity, coreOptions.isAvoidWarningsInConsole);
|
|
178
|
+
if (yiniContent.trim() === '') {
|
|
179
|
+
const isFileSourceType = runtimeInfo?.sourceType === 'File';
|
|
180
|
+
// Note, after pushing processing may continue or exit, depending on the error and/or the bail threshold.
|
|
181
|
+
errorHandler.pushOrBail(null, 'Syntax-Error', 'Empty YINI document.', `The input is blank or contains only whitespace in the ${isFileSourceType ? 'YINI file' : 'YINI inline content'}.`, `Tip: Add at least one section '^ SectionName' or a key-value pair 'key = value' to make it a valid YINI file.`);
|
|
182
|
+
}
|
|
183
|
+
//---------------------------------------------
|
|
184
|
+
// Note: Only computed when isWithTiming.
|
|
185
|
+
let timeStartMs = 0;
|
|
186
|
+
let timeEnd1Ms = 0;
|
|
187
|
+
let timeEnd2Ms = 0;
|
|
188
|
+
let timeEnd3Ms = 0;
|
|
189
|
+
let timeEnd4Ms = 0;
|
|
190
|
+
//---------------------------------------------
|
|
191
|
+
//---------------------------------------------
|
|
192
|
+
// Note: Should ALWAYS be computed.
|
|
193
|
+
let runStartedAt = '';
|
|
194
|
+
let runFinishedAt = '';
|
|
195
|
+
let durationMs = 0;
|
|
196
|
+
//---------------------------------------------
|
|
197
|
+
(0, env_1.isDebug)() && console.log();
|
|
198
|
+
(0, print_1.debugPrint)('=== Phase 1 - Lexing ===================================================');
|
|
199
|
+
// -----------------------------
|
|
200
|
+
// Below block should always be done despite isWithTiming to compute
|
|
201
|
+
// total time and runStartedAt that should always be computed.
|
|
202
|
+
{
|
|
203
|
+
timeStartMs = perf_hooks_1.performance.now();
|
|
204
|
+
runStartedAt = new Date().toISOString();
|
|
205
|
+
}
|
|
206
|
+
// -----------------------------
|
|
207
|
+
const inputStream = antlr4_1.CharStreams.fromString(yiniContent);
|
|
208
|
+
const lexer = new YiniLexer_1.default(inputStream);
|
|
209
|
+
// Remove the default ConsoleErrorListener
|
|
210
|
+
lexer.removeErrorListeners(); // Removes the default lexer console error output.
|
|
211
|
+
const lexerErrorListener = new MyLexerErrorListener(errorHandler);
|
|
212
|
+
lexer.addErrorListener(lexerErrorListener);
|
|
213
|
+
const tokenStream = new antlr4_1.CommonTokenStream(lexer);
|
|
214
|
+
// Important: force tokenization here so lexing is measured separately.
|
|
215
|
+
tokenStream.fill();
|
|
216
|
+
(0, print_1.debugPrint)('--- Parsing done. ---');
|
|
217
|
+
(0, print_1.debugPrint)('=== Ended phase 1 =============================================');
|
|
218
|
+
(0, env_1.isDebug)() && console.log();
|
|
219
|
+
(0, print_1.debugPrint)('=== Phase 2 - Parsing ===================================================');
|
|
220
|
+
if (coreOptions.isWithTiming) {
|
|
221
|
+
timeEnd1Ms = perf_hooks_1.performance.now();
|
|
222
|
+
}
|
|
223
|
+
const parser = new YiniParser_1.default(tokenStream);
|
|
224
|
+
// const errorListener = new MyParserErrorListener(errorHandler)
|
|
225
|
+
parser.removeErrorListeners(); // Removes the default parser console error output.
|
|
226
|
+
const parserErrorListener = new MyParserErrorListener(errorHandler);
|
|
227
|
+
parser.addErrorListener(parserErrorListener);
|
|
228
|
+
const parseTree = parser.yini(); // The function yini() is the start rule.
|
|
229
|
+
if (parserErrorListener.errors.length > 0 ||
|
|
230
|
+
lexerErrorListener.errors.length > 0) {
|
|
231
|
+
(0, print_1.debugPrint)('*** ERROR detected ***');
|
|
232
|
+
if ((0, env_1.isDebug)()) {
|
|
233
|
+
// Handle or display syntax errors
|
|
234
|
+
console.error('Syntax errors detected:', parserErrorListener.errors, lexerErrorListener.errors);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
(0, print_1.debugPrint)('=== Ended phase 2 =============================================');
|
|
238
|
+
(0, env_1.isDebug)() && console.log();
|
|
239
|
+
(0, print_1.debugPrint)('=== Phase 3 - AST Model build & validation ===================================================');
|
|
240
|
+
if (coreOptions.isWithTiming) {
|
|
241
|
+
timeEnd2Ms = perf_hooks_1.performance.now();
|
|
242
|
+
}
|
|
243
|
+
const builder = new astBuilder_1.default(errorHandler, coreOptions, runtimeInfo.sourceType, runtimeInfo.fileName || null);
|
|
244
|
+
const ast = builder.buildAST(parseTree);
|
|
245
|
+
if (ast.numOfMembers === 0 && ast.numOfSections === 0) {
|
|
246
|
+
// Note, after pushing processing may continue or exit, depending on the error and/or the bail threshold.
|
|
247
|
+
errorHandler.pushOrBail(null, 'Syntax-Error', 'No meaningful content.', `No sections or members found in the ${ast.sourceType === 'File' ? 'YINI file' : 'YINI inline content'}.`, `${ast.sourceType === 'File' ? 'A valid YINI file' : 'Any valid YINI inline content'} must contain at least one section '^ SectionName' or a key–value pair 'key = value' to make it a valid YINI file.`);
|
|
248
|
+
}
|
|
249
|
+
if ((0, env_1.isDebug)()) {
|
|
250
|
+
console.log();
|
|
251
|
+
console.log('**************************************************************************');
|
|
252
|
+
console.log('*** AST *************************************************');
|
|
253
|
+
(0, print_1.printObject)(ast);
|
|
254
|
+
console.log('**************************************************************************');
|
|
255
|
+
console.log('**************************************************************************');
|
|
256
|
+
console.log();
|
|
257
|
+
}
|
|
258
|
+
(0, print_1.debugPrint)('=== Ended phase 3 =============================================');
|
|
259
|
+
(0, env_1.isDebug)() && console.log();
|
|
260
|
+
(0, print_1.debugPrint)('=== Phase 4 - Object Building Construction / Binding / Evaluation) ===================================================');
|
|
261
|
+
if (coreOptions.isWithTiming) {
|
|
262
|
+
timeEnd3Ms = perf_hooks_1.performance.now();
|
|
263
|
+
}
|
|
264
|
+
// Construct.
|
|
265
|
+
// const finalJSResult = constructFinalObject(syntaxTreeC, errorHandler)
|
|
266
|
+
// const finalJSResult = builder.build(parseTree)
|
|
267
|
+
// const finalJSResult = ast //NOTE: ONLY TEMP so code runs
|
|
268
|
+
const finalJSResult = (0, objectBuilder_1.astToObject)(ast, errorHandler);
|
|
269
|
+
(0, print_1.debugPrint)('=== Ended phase 4 =============================================');
|
|
270
|
+
// -----------------------------
|
|
271
|
+
// Below block should always be done despite isWithTiming to compute
|
|
272
|
+
// total time and runStartedAt that should always be computed.
|
|
273
|
+
{
|
|
274
|
+
timeEnd4Ms = perf_hooks_1.performance.now();
|
|
275
|
+
durationMs = timeEnd4Ms - timeStartMs;
|
|
276
|
+
runFinishedAt = new Date().toISOString();
|
|
277
|
+
}
|
|
278
|
+
// -----------------------------
|
|
279
|
+
(0, print_1.debugPrint)('visitor.visit(..): finalJSResult:');
|
|
280
|
+
(0, env_1.isDebug)() && console.debug(finalJSResult);
|
|
281
|
+
(0, print_1.debugPrint)();
|
|
282
|
+
if (coreOptions.isStrict) {
|
|
283
|
+
// Note, after pushing processing may continue or exit, depending on the error and/or the bail threshold.
|
|
284
|
+
errorHandler.pushOrBail(null, 'Syntax-Warning', 'Warning: Strict mode is not yet fully implemented.', 'Some validation rules may still be missing or incomplete.');
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
(0, print_1.debugPrint)('visitor.visit(..): finalJSResult:');
|
|
288
|
+
(0, env_1.isDebug)() && console.debug(finalJSResult);
|
|
289
|
+
}
|
|
290
|
+
const params = {
|
|
291
|
+
ast,
|
|
292
|
+
coreOptions,
|
|
293
|
+
runtimeInfo,
|
|
294
|
+
_meta_userOpts,
|
|
295
|
+
errorHandler,
|
|
296
|
+
runStartedAt,
|
|
297
|
+
runFinishedAt,
|
|
298
|
+
durationMs,
|
|
299
|
+
timeStartMs,
|
|
300
|
+
timeEnd1Ms,
|
|
301
|
+
timeEnd2Ms,
|
|
302
|
+
timeEnd3Ms,
|
|
303
|
+
timeEnd4Ms,
|
|
304
|
+
};
|
|
305
|
+
const constructedMetadata = (0, resultMetadataBuilder_1.buildResultMetadata)(params);
|
|
306
|
+
(0, print_1.debugPrint)('getNumOfErrors(): ' + errorHandler.getNumOfErrors());
|
|
307
|
+
if (errorHandler.getNumOfErrors()) {
|
|
308
|
+
console.log();
|
|
309
|
+
console.log('Parsing is complete, but some problems were detected. Please see the errors above for details.');
|
|
310
|
+
console.log('Number of errors found: ' + errorHandler.getNumOfErrors());
|
|
311
|
+
}
|
|
312
|
+
if (coreOptions.isIncludeMeta) {
|
|
313
|
+
return {
|
|
314
|
+
result: finalJSResult,
|
|
315
|
+
meta: !coreOptions.isKeepUndefinedInMeta
|
|
316
|
+
? (0, object_1.removeUndefinedDeep)(constructedMetadata)
|
|
317
|
+
: constructedMetadata,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
return finalJSResult;
|
|
321
|
+
};
|
|
322
|
+
exports.runPipeline = runPipeline;
|
|
323
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../src/core/pipeline.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAAwC;AACxC,+BAA8B;AAC9B,mCAOe;AACf,uCAAyE;AACzE,+EAAsD;AACtD,8EAAyE;AAQzE,4CAAqE;AACrE,0CAAwD;AAExD,8DAAqC;AACrC,yDA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AI,EAAE,CAAC,WAAW,CAAC,qBAAqB;gBACpC,CAAC,CAAC,IAAA,4BAAmB,EAAC,mBAAmB,CAAC;gBAC1C,CAAC,CAAC,mBAAmB;SACT,CAAA;IACxB,CAAC;IAED,OAAO,aAA6B,CAAA;AACxC,CAAC,CAAA;AA3QY,QAAA,WAAW,eA2QvB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AllUserOptions, ResultMetadata } from '../types';
|
|
2
|
+
import { ErrorDataHandler } from './errorDataHandler';
|
|
3
|
+
import { IParseCoreOptions, IRuntimeInfo, IYiniAST } from './internalTypes';
|
|
4
|
+
export interface IBuildResultMetadataParams {
|
|
5
|
+
ast: IYiniAST;
|
|
6
|
+
coreOptions: IParseCoreOptions;
|
|
7
|
+
runtimeInfo: IRuntimeInfo;
|
|
8
|
+
_meta_userOpts: AllUserOptions;
|
|
9
|
+
errorHandler: ErrorDataHandler;
|
|
10
|
+
runStartedAt: string;
|
|
11
|
+
runFinishedAt: string;
|
|
12
|
+
durationMs: number;
|
|
13
|
+
timeStartMs: number;
|
|
14
|
+
timeEnd1Ms: number;
|
|
15
|
+
timeEnd2Ms: number;
|
|
16
|
+
timeEnd3Ms: number;
|
|
17
|
+
timeEnd4Ms: number;
|
|
18
|
+
}
|
|
19
|
+
export declare const buildResultMetadata: (p: IBuildResultMetadataParams) => ResultMetadata;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.buildResultMetadata = void 0;
|
|
7
|
+
// const pkg = require('../../package.json')
|
|
8
|
+
const package_json_1 = __importDefault(require("../../package.json")); // NOTE: Requires "resolveJsonModule": true (or "esModuleInterop": true).
|
|
9
|
+
const env_1 = require("../config/env");
|
|
10
|
+
const object_1 = require("../utils/object");
|
|
11
|
+
const string_1 = require("../utils/string");
|
|
12
|
+
const buildResultMetadata = (p) => {
|
|
13
|
+
// --- Construct meta information -------------------------------------
|
|
14
|
+
const to3 = (n) => Number.parseFloat(n.toFixed(3));
|
|
15
|
+
// Construct meta data.
|
|
16
|
+
const metadata = {
|
|
17
|
+
parserVersion: package_json_1.default.version,
|
|
18
|
+
mode: p.coreOptions.isStrict ? 'strict' : 'lenient',
|
|
19
|
+
totalErrors: p.errorHandler.getNumOfErrors(),
|
|
20
|
+
totalWarnings: p.errorHandler.getNumOfWarnings(),
|
|
21
|
+
totalMessages: p.errorHandler.getNumOfAllMessages(),
|
|
22
|
+
runStartedAt: p.runStartedAt,
|
|
23
|
+
runFinishedAt: p.runFinishedAt,
|
|
24
|
+
durationMs: to3(p.durationMs),
|
|
25
|
+
preservesOrder: true,
|
|
26
|
+
orderGuarantee: 'implementation-defined',
|
|
27
|
+
source: {
|
|
28
|
+
// sourceType: toLowerSnakeCase(ast.sourceType),
|
|
29
|
+
sourceType: (0, string_1.toLowerKebabCase)(p.ast.sourceType),
|
|
30
|
+
fileName: p.ast.fileName,
|
|
31
|
+
hasDocumentTerminator: p.ast.terminatorSeen,
|
|
32
|
+
hasYiniMarker: p.ast.yiniMarkerSeen,
|
|
33
|
+
lineCount: p.runtimeInfo.lineCount,
|
|
34
|
+
byteSize: p.runtimeInfo.fileByteSize,
|
|
35
|
+
sha256: p.runtimeInfo.sha256,
|
|
36
|
+
},
|
|
37
|
+
structure: {
|
|
38
|
+
maxDepth: p.ast.maxDepth,
|
|
39
|
+
sectionCount: p.ast.numOfSections,
|
|
40
|
+
memberCount: p.ast.numOfMembers,
|
|
41
|
+
keysParsedCount: null,
|
|
42
|
+
// objectCount: null,
|
|
43
|
+
// listCount: null,
|
|
44
|
+
sectionNamePaths: p.ast.sectionNamePaths,
|
|
45
|
+
},
|
|
46
|
+
metaSchemaVersion: '1.1.0',
|
|
47
|
+
};
|
|
48
|
+
// Attach optional diagnostics.
|
|
49
|
+
if (p.coreOptions.isWithDiagnostics) {
|
|
50
|
+
const mapLevelKey = (level) => {
|
|
51
|
+
switch (level) {
|
|
52
|
+
case '0-Ignore-Errors':
|
|
53
|
+
return 'ignore-errors';
|
|
54
|
+
case '1-Abort-on-Errors':
|
|
55
|
+
return 'errors';
|
|
56
|
+
case '2-Abort-Even-on-Warnings':
|
|
57
|
+
return 'warnings-and-errors';
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const mapLevelDescription = (level) => {
|
|
61
|
+
switch (level) {
|
|
62
|
+
case '0-Ignore-Errors':
|
|
63
|
+
return 'Continue despite errors.';
|
|
64
|
+
case '1-Abort-on-Errors':
|
|
65
|
+
return 'Abort when errors occur.';
|
|
66
|
+
case '2-Abort-Even-on-Warnings':
|
|
67
|
+
return 'Abort when errors or warnings occur.';
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
};
|
|
71
|
+
metadata.diagnostics = {
|
|
72
|
+
failLevel: {
|
|
73
|
+
preferredLevel: p.runtimeInfo.preferredBailSensitivity,
|
|
74
|
+
usedLevelType: p.coreOptions.bailSensitivity,
|
|
75
|
+
usedLevelKey: mapLevelKey(p.coreOptions.bailSensitivity),
|
|
76
|
+
levelDescription: (mapLevelDescription(p.coreOptions.bailSensitivity)),
|
|
77
|
+
},
|
|
78
|
+
errors: {
|
|
79
|
+
errorCount: p.errorHandler.getNumOfErrors(),
|
|
80
|
+
payload: p.errorHandler.getErrors(),
|
|
81
|
+
},
|
|
82
|
+
warnings: {
|
|
83
|
+
warningCount: p.errorHandler.getNumOfWarnings(),
|
|
84
|
+
payload: p.errorHandler.getWarnings(),
|
|
85
|
+
},
|
|
86
|
+
notices: {
|
|
87
|
+
noticeCount: p.errorHandler.getNumOfNotices(),
|
|
88
|
+
payload: p.errorHandler.getNotices(),
|
|
89
|
+
},
|
|
90
|
+
infos: {
|
|
91
|
+
infoCount: p.errorHandler.getNumOfInfos(),
|
|
92
|
+
payload: p.errorHandler.getInfos(),
|
|
93
|
+
},
|
|
94
|
+
environment: {
|
|
95
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
96
|
+
APP_ENV: process.env.APP_ENV,
|
|
97
|
+
lib: {
|
|
98
|
+
nodeEnv: env_1.localNodeEnv,
|
|
99
|
+
appEnv: env_1.localAppEnv,
|
|
100
|
+
flags: { isDev: (0, env_1.isDev)(), isDebug: (0, env_1.isDebug)() },
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
effectiveOptions: (0, object_1.sortObjectKeys)({
|
|
104
|
+
// IMPORTANT: (!) These user options MUST be mapped from coreOptions (to user options).
|
|
105
|
+
strictMode: p.coreOptions.isStrict,
|
|
106
|
+
failLevel: mapLevelKey(p.coreOptions.bailSensitivity),
|
|
107
|
+
includeMetadata: p.coreOptions.isIncludeMeta,
|
|
108
|
+
includeDiagnostics: p.coreOptions.isWithDiagnostics,
|
|
109
|
+
includeTiming: p.coreOptions.isWithTiming,
|
|
110
|
+
preserveUndefinedInMeta: p.coreOptions.isKeepUndefinedInMeta,
|
|
111
|
+
suppressWarnings: p.coreOptions.isAvoidWarningsInConsole,
|
|
112
|
+
requireDocTerminator: p.coreOptions.requireDocTerminator,
|
|
113
|
+
treatEmptyValueAsNull: p.coreOptions.treatEmptyValueAsNull,
|
|
114
|
+
onDuplicateKey: p.coreOptions.onDuplicateKey,
|
|
115
|
+
}),
|
|
116
|
+
options: (0, object_1.sortObjectKeys)(p._meta_userOpts),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
// Attach optional durations timing data.
|
|
120
|
+
if (p.coreOptions.isWithTiming) {
|
|
121
|
+
metadata.timing = {
|
|
122
|
+
total: !p.coreOptions.isWithTiming
|
|
123
|
+
? null
|
|
124
|
+
: {
|
|
125
|
+
timeMs: to3(p.durationMs), // durationMs = timeEnd4Ms - timeStartMs
|
|
126
|
+
name: p.runtimeInfo.sourceType === 'Inline'
|
|
127
|
+
? 'Total'
|
|
128
|
+
: 'Total (excluding phase0 (I/O))',
|
|
129
|
+
},
|
|
130
|
+
phase0: !p.coreOptions.isWithTiming ||
|
|
131
|
+
p.runtimeInfo.sourceType === 'Inline'
|
|
132
|
+
? undefined
|
|
133
|
+
: {
|
|
134
|
+
timeMs: to3(p.runtimeInfo.timeIoMs),
|
|
135
|
+
name: 'I/O',
|
|
136
|
+
},
|
|
137
|
+
phase1: !p.coreOptions.isWithTiming
|
|
138
|
+
? null
|
|
139
|
+
: {
|
|
140
|
+
timeMs: to3(p.timeEnd1Ms - p.timeStartMs),
|
|
141
|
+
name: 'Lexing',
|
|
142
|
+
},
|
|
143
|
+
phase2: !p.coreOptions.isWithTiming
|
|
144
|
+
? null
|
|
145
|
+
: {
|
|
146
|
+
timeMs: to3(p.timeEnd2Ms - p.timeEnd1Ms),
|
|
147
|
+
name: 'Parsing',
|
|
148
|
+
},
|
|
149
|
+
phase3: !p.coreOptions.isWithTiming
|
|
150
|
+
? null
|
|
151
|
+
: {
|
|
152
|
+
timeMs: to3(p.timeEnd3Ms - p.timeEnd2Ms),
|
|
153
|
+
name: 'AST Building',
|
|
154
|
+
},
|
|
155
|
+
phase4: !p.coreOptions.isWithTiming
|
|
156
|
+
? null
|
|
157
|
+
: {
|
|
158
|
+
timeMs: to3(p.timeEnd4Ms - p.timeEnd3Ms),
|
|
159
|
+
name: 'Object Building',
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
return metadata;
|
|
164
|
+
};
|
|
165
|
+
exports.buildResultMetadata = buildResultMetadata;
|
|
166
|
+
//# sourceMappingURL=resultMetadataBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resultMetadataBuilder.js","sourceRoot":"","sources":["../../src/core/resultMetadataBuilder.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA4C;AAC5C,sEAAoC,CAAC,yEAAyE;AAC9G,uCAAyE;AAEzE,4CAAgD;AAChD,4CAAkD;AA0B3C,MAAM,mBAAmB,GAAG,CAC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,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,YAAY;gBAC/B,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC;oBACI,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;oBACxC,IAAI,EAAE,cAAc;iBACvB;YACP,MAAM,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,YAAY;gBAC/B,CAAC,CAAC,IAAI;gBACN,CAAC,CAAC;oBACI,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;oBACxC,IAAI,EAAE,iBAAiB;iBAC1B;SACV,CAAA;IACL,CAAC;IAED,OAAO,QAAQ,CAAA;AACnB,CAAC,CAAA;AAvKY,QAAA,mBAAmB,uBAuK/B"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AllUserOptions, ParsedObject, PreferredFailLevel } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Private class representing a runtime context for a single parse call.
|
|
4
|
+
*
|
|
5
|
+
* @note This design prevents race conditions: each call gets its own
|
|
6
|
+
* runtimeInfo and related state. Without this, multiple calls
|
|
7
|
+
* (especially in parallel) could overwrite each other's data.
|
|
8
|
+
*/
|
|
9
|
+
export declare class YiniRuntime {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(sourceType: 'Inline' | 'File');
|
|
12
|
+
private makeRuntimeInfo;
|
|
13
|
+
doParse(yiniContent: string, strictMode?: boolean, failLevel?: PreferredFailLevel, includeMetadata?: boolean): ParsedObject;
|
|
14
|
+
doParse(yiniContent: string, options?: AllUserOptions): ParsedObject;
|
|
15
|
+
doParseFile(filePath: string, strictMode?: boolean, failLevel?: PreferredFailLevel, includeMetadata?: boolean): ParsedObject;
|
|
16
|
+
doParseFile(filePath: string, options?: AllUserOptions): ParsedObject;
|
|
17
|
+
}
|