yini-parser 1.2.0-beta → 1.3.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 +27 -1
- package/README.md +2 -2
- package/dist/YINI.d.ts +35 -23
- package/dist/YINI.js +6 -6
- package/dist/YINI.js.map +1 -1
- package/dist/core/astBuilder.js +9 -9
- package/dist/core/astBuilder.js.map +1 -1
- package/dist/core/errorDataHandler.d.ts +9 -5
- package/dist/core/errorDataHandler.js +99 -53
- package/dist/core/errorDataHandler.js.map +1 -1
- package/dist/core/internalTypes.d.ts +12 -6
- package/dist/core/options/defaultParserOptions.d.ts +17 -0
- package/dist/core/options/defaultParserOptions.js +46 -0
- package/dist/core/options/defaultParserOptions.js.map +1 -0
- package/dist/core/options/optionsFunctions.d.ts +8 -0
- package/dist/core/options/{normalizeOptions.js → optionsFunctions.js} +21 -12
- package/dist/core/options/optionsFunctions.js.map +1 -0
- package/dist/core/parsingRules/modeFromRulesMatcher.d.ts +8 -0
- package/dist/core/parsingRules/modeFromRulesMatcher.js +114 -0
- package/dist/core/parsingRules/modeFromRulesMatcher.js.map +1 -0
- package/dist/core/parsingRules/rulesConstAndGuards.d.ts +7 -0
- package/dist/core/parsingRules/rulesConstAndGuards.js +35 -0
- package/dist/core/parsingRules/rulesConstAndGuards.js.map +1 -0
- package/dist/core/pipeline/errorListeners.d.ts +18 -0
- package/dist/core/pipeline/errorListeners.js +107 -0
- package/dist/core/pipeline/errorListeners.js.map +1 -0
- package/dist/core/{pipeline.d.ts → pipeline/pipeline.d.ts} +3 -3
- package/dist/core/{pipeline.js → pipeline/pipeline.js} +70 -149
- package/dist/core/pipeline/pipeline.js.map +1 -0
- package/dist/core/resultMetadataBuilder.d.ts +2 -2
- package/dist/core/resultMetadataBuilder.js +29 -8
- package/dist/core/resultMetadataBuilder.js.map +1 -1
- package/dist/core/runtime.d.ts +7 -3
- package/dist/core/runtime.js +32 -20
- package/dist/core/runtime.js.map +1 -1
- package/dist/dev/main.js +49 -118
- package/dist/dev/main.js.map +1 -1
- package/dist/grammar/generated/YiniLexer.js +1 -1
- package/dist/grammar/generated/YiniLexer.js.map +1 -1
- package/dist/grammar/generated/YiniParser.js +1 -1
- package/dist/grammar/generated/YiniParser.js.map +1 -1
- package/dist/grammar/generated/YiniParserVisitor.js +1 -1
- package/dist/grammar/generated/YiniParserVisitor.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +46 -25
- package/examples/basic-output.js +12 -12
- package/package.json +6 -3
- package/dist/core/options/normalizeOptions.d.ts +0 -5
- package/dist/core/options/normalizeOptions.js.map +0 -1
- package/dist/core/options/parserOptionsConstants.d.ts +0 -7
- package/dist/core/options/parserOptionsConstants.js +0 -37
- package/dist/core/options/parserOptionsConstants.js.map +0 -1
- package/dist/core/pipeline.js.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// --- Parsing Rule Values -------------------------------------------------
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.isEmptyValueRule = exports.isDocumentTerminatorRule = exports.isDuplicateKeyPolicy = exports.EmptyValueRules = exports.DocumentTerminatorRules = exports.DuplicateKeyPolicies = void 0;
|
|
5
|
+
/*
|
|
6
|
+
NOTE: These rule values are re-exported as **types** (derived from these consants) in types/index.ts.
|
|
7
|
+
NOTE: These constant gives runtime access as they are also used in error messages.
|
|
8
|
+
*/
|
|
9
|
+
exports.DuplicateKeyPolicies = [
|
|
10
|
+
'error',
|
|
11
|
+
'warn-and-keep-first', // Keep first with a warning.
|
|
12
|
+
'warn-and-overwrite', // 'warn-and-overwrite' = 'warn-and-keep-last'
|
|
13
|
+
'keep-first', // Silent, first wins.
|
|
14
|
+
'overwrite', // Silent, last wins.
|
|
15
|
+
];
|
|
16
|
+
exports.DocumentTerminatorRules = [
|
|
17
|
+
'optional',
|
|
18
|
+
'warn-if-missing',
|
|
19
|
+
'required',
|
|
20
|
+
];
|
|
21
|
+
exports.EmptyValueRules = [
|
|
22
|
+
'allow',
|
|
23
|
+
'allow-with-warning',
|
|
24
|
+
'disallow',
|
|
25
|
+
];
|
|
26
|
+
// --- Runtime Guards ------------------------------------------------------
|
|
27
|
+
const isDuplicateKeyPolicy = (v) => typeof v === 'string' &&
|
|
28
|
+
exports.DuplicateKeyPolicies.includes(v);
|
|
29
|
+
exports.isDuplicateKeyPolicy = isDuplicateKeyPolicy;
|
|
30
|
+
const isDocumentTerminatorRule = (v) => typeof v === 'string' &&
|
|
31
|
+
exports.DocumentTerminatorRules.includes(v);
|
|
32
|
+
exports.isDocumentTerminatorRule = isDocumentTerminatorRule;
|
|
33
|
+
const isEmptyValueRule = (v) => typeof v === 'string' && exports.EmptyValueRules.includes(v);
|
|
34
|
+
exports.isEmptyValueRule = isEmptyValueRule;
|
|
35
|
+
//# sourceMappingURL=rulesConstAndGuards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rulesConstAndGuards.js","sourceRoot":"","sources":["../../../src/core/parsingRules/rulesConstAndGuards.ts"],"names":[],"mappings":";AAAA,4EAA4E;;;AAQ5E;;;EAGE;AAEW,QAAA,oBAAoB,GAAG;IAChC,OAAO;IACP,qBAAqB,EAAE,6BAA6B;IACpD,oBAAoB,EAAE,8CAA8C;IACpE,YAAY,EAAE,sBAAsB;IACpC,WAAW,EAAE,qBAAqB;CAC5B,CAAA;AAEG,QAAA,uBAAuB,GAAG;IACnC,UAAU;IACV,iBAAiB;IACjB,UAAU;CACJ,CAAA;AAEG,QAAA,eAAe,GAAG;IAC3B,OAAO;IACP,oBAAoB;IACpB,UAAU;CACJ,CAAA;AAEV,4EAA4E;AAErE,MAAM,oBAAoB,GAAG,CAAC,CAAU,EAA2B,EAAE,CACxE,OAAO,CAAC,KAAK,QAAQ;IACpB,4BAA0C,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AAF9C,QAAA,oBAAoB,wBAE0B;AAEpD,MAAM,wBAAwB,GAAG,CACpC,CAAU,EACiB,EAAE,CAC7B,OAAO,CAAC,KAAK,QAAQ;IACpB,+BAA6C,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AAJjD,QAAA,wBAAwB,4BAIyB;AAEvD,MAAM,gBAAgB,GAAG,CAAC,CAAU,EAAuB,EAAE,CAChE,OAAO,CAAC,KAAK,QAAQ,IAAK,uBAAqC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AADlE,QAAA,gBAAgB,oBACkD"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ErrorListener, RecognitionException } from 'antlr4';
|
|
2
|
+
import { ErrorDataHandler } from '../errorDataHandler';
|
|
3
|
+
export declare const createLexerErrorListener: (errorHandler: ErrorDataHandler) => MyLexerErrorListener;
|
|
4
|
+
export declare const createParserErrorListener: (errorHandler: ErrorDataHandler) => MyParserErrorListener;
|
|
5
|
+
declare class MyLexerErrorListener implements ErrorListener<any> {
|
|
6
|
+
private errorHandler;
|
|
7
|
+
constructor(errorHandler: ErrorDataHandler);
|
|
8
|
+
syntaxError(recognizer: any, offendingSymbol: any, line: number, charPositionInLine: number, msg: string, e: RecognitionException | undefined): void;
|
|
9
|
+
}
|
|
10
|
+
declare class MyParserErrorListener implements ErrorListener<any> {
|
|
11
|
+
private errorHandler;
|
|
12
|
+
constructor(errorHandler: ErrorDataHandler);
|
|
13
|
+
syntaxError(recognizer: any, offendingSymbol: any, line: number, charPositionInLine: number, msg: string, e: RecognitionException | undefined): void;
|
|
14
|
+
reportAmbiguity(...args: any[]): void;
|
|
15
|
+
reportAttemptingFullContext(...args: any[]): void;
|
|
16
|
+
reportContextSensitivity(...args: any[]): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createParserErrorListener = exports.createLexerErrorListener = void 0;
|
|
4
|
+
const util_1 = require("util");
|
|
5
|
+
const antlr4_1 = require("antlr4");
|
|
6
|
+
const env_1 = require("../../config/env");
|
|
7
|
+
const YiniParser_1 = require("../../grammar/generated/YiniParser");
|
|
8
|
+
const print_1 = require("../../utils/print");
|
|
9
|
+
const createLexerErrorListener = (errorHandler) => {
|
|
10
|
+
return new MyLexerErrorListener(errorHandler);
|
|
11
|
+
};
|
|
12
|
+
exports.createLexerErrorListener = createLexerErrorListener;
|
|
13
|
+
const createParserErrorListener = (errorHandler) => {
|
|
14
|
+
return new MyParserErrorListener(errorHandler);
|
|
15
|
+
};
|
|
16
|
+
exports.createParserErrorListener = createParserErrorListener;
|
|
17
|
+
/**
|
|
18
|
+
* @param line Line number as 1-based.
|
|
19
|
+
* @param col Column number as 0-based.
|
|
20
|
+
*
|
|
21
|
+
* @note Refactor away this function if possible, due to this context ad-hoc
|
|
22
|
+
* is brittle, it relies on runtime internals of ANTLR generated code.
|
|
23
|
+
*/
|
|
24
|
+
const createGeneralCtx = (line, endColumn, startColumn = undefined) => {
|
|
25
|
+
const startToken = new antlr4_1.Token();
|
|
26
|
+
const stopToken = new antlr4_1.Token();
|
|
27
|
+
const ctx = new YiniParser_1.YiniContext();
|
|
28
|
+
ctx.start = startToken;
|
|
29
|
+
ctx.stop = stopToken;
|
|
30
|
+
ctx.start.line = line; // Note: Line num is 1-based.
|
|
31
|
+
// if (startColumn && startColumn >= 0) {
|
|
32
|
+
if (startColumn !== undefined) {
|
|
33
|
+
ctx.start.column = startColumn; // Note: Column num is 0-based.
|
|
34
|
+
ctx.stop.line = line;
|
|
35
|
+
}
|
|
36
|
+
ctx.stop.column = endColumn; // Note: Column num is 0-based.
|
|
37
|
+
return ctx;
|
|
38
|
+
};
|
|
39
|
+
const parsePossibleStartCol = (errorHandler, recognizer) => {
|
|
40
|
+
let possibleStartCol = undefined;
|
|
41
|
+
try {
|
|
42
|
+
possibleStartCol = recognizer?._ctx.start?.column
|
|
43
|
+
? recognizer?._ctx.start?.column + 1
|
|
44
|
+
: undefined;
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
let msgHint = '';
|
|
48
|
+
if ((0, util_1.isError)(err)) {
|
|
49
|
+
msgHint = 'Error: ' + err.message;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
msgHint = 'Thrown value:' + JSON.stringify(err);
|
|
53
|
+
}
|
|
54
|
+
if ((0, env_1.isProdEnv)()) {
|
|
55
|
+
// return 0
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
errorHandler.pushOrBail(null, 'Internal-Error', 'Catched error of possibleStartCol in parser grammar listener.', msgHint);
|
|
59
|
+
}
|
|
60
|
+
return possibleStartCol;
|
|
61
|
+
};
|
|
62
|
+
class MyLexerErrorListener {
|
|
63
|
+
constructor(errorHandler) {
|
|
64
|
+
this.errorHandler = errorHandler;
|
|
65
|
+
}
|
|
66
|
+
syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) {
|
|
67
|
+
// Handle the error as you want:
|
|
68
|
+
(0, print_1.debugPrint)('ANTLR lexer cached an error');
|
|
69
|
+
const col = charPositionInLine + 1;
|
|
70
|
+
const possibleStartCol = parsePossibleStartCol(this.errorHandler, recognizer);
|
|
71
|
+
// const msgWhat = `Syntax error at line ${line}, column ${col}:`
|
|
72
|
+
const msgWhat = `Syntax error`;
|
|
73
|
+
// Try to map message:
|
|
74
|
+
// From: "mismatched input '/END' expecting <EOF>"
|
|
75
|
+
// To: "Found '/END', but expected the end of the document."
|
|
76
|
+
// const msgWhy = `${capitalizeFirst(msg)}`
|
|
77
|
+
const msgWhy = `Details: ${msg}`;
|
|
78
|
+
// const msgHint = ``
|
|
79
|
+
const ctx = createGeneralCtx(line, charPositionInLine, possibleStartCol); // So we can show line/col in error message.
|
|
80
|
+
// Note, after pushing processing may continue or exit, depending on the error and/or the bail threshold.
|
|
81
|
+
this.errorHandler.pushOrBail(ctx, 'Syntax-Error', msgWhat, msgWhy);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
class MyParserErrorListener {
|
|
85
|
+
constructor(errorHandler) {
|
|
86
|
+
this.errorHandler = errorHandler;
|
|
87
|
+
}
|
|
88
|
+
syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) {
|
|
89
|
+
(0, print_1.debugPrint)('ANTLR parser cached an error');
|
|
90
|
+
const col = charPositionInLine + 1;
|
|
91
|
+
const possibleStartCol = parsePossibleStartCol(this.errorHandler, recognizer);
|
|
92
|
+
const msgWhat = `Syntax error`;
|
|
93
|
+
// Try to map message:
|
|
94
|
+
// From: "mismatched input '/END' expecting <EOF>"
|
|
95
|
+
// To: "Found '/END', but expected the end of the document."
|
|
96
|
+
// const msgWhy = `${capitalizeFirst(msg)}`
|
|
97
|
+
const msgWhy = `Details: ${msg}`;
|
|
98
|
+
const ctx = createGeneralCtx(line, charPositionInLine, possibleStartCol); // So we can show line/col in error message.
|
|
99
|
+
// Note, after pushing processing may continue or exit, depending on the error and/or the bail threshold.
|
|
100
|
+
this.errorHandler.pushOrBail(ctx, 'Syntax-Error', msgWhat, msgWhy);
|
|
101
|
+
}
|
|
102
|
+
// The following are required for the interface, but can be left empty.
|
|
103
|
+
reportAmbiguity(...args) { }
|
|
104
|
+
reportAttemptingFullContext(...args) { }
|
|
105
|
+
reportContextSensitivity(...args) { }
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=errorListeners.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errorListeners.js","sourceRoot":"","sources":["../../../src/core/pipeline/errorListeners.ts"],"names":[],"mappings":";;;AAAA,+BAA8B;AAC9B,mCAAmE;AACnE,0CAA4C;AAC5C,mEAAgE;AAChE,6CAA8C;AAGvC,MAAM,wBAAwB,GAAG,CACpC,YAA8B,EACV,EAAE;IACtB,OAAO,IAAI,oBAAoB,CAAC,YAAY,CAAC,CAAA;AACjD,CAAC,CAAA;AAJY,QAAA,wBAAwB,4BAIpC;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,YAAY,YAA8B;QACtC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAA;IACpC,CAAC;IAED,WAAW,CACP,UAAe,EACf,eAAoB,EACpB,IAAY,EACZ,kBAA0B,EAC1B,GAAW,EACX,CAAmC;QAEnC,IAAA,kBAAU,EAAC,8BAA8B,CAAC,CAAA;QAE1C,MAAM,GAAG,GAAG,kBAAkB,GAAG,CAAC,CAAA;QAClC,MAAM,gBAAgB,GAAuB,qBAAqB,CAC9D,IAAI,CAAC,YAAY,EACjB,UAAU,CACb,CAAA;QAED,MAAM,OAAO,GAAG,cAAc,CAAA;QAE9B,sBAAsB;QACtB,kDAAkD;QAClD,8DAA8D;QAC9D,2CAA2C;QAC3C,MAAM,MAAM,GAAG,YAAY,GAAG,EAAE,CAAA;QAEhC,MAAM,GAAG,GAAG,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,CAAA,CAAC,4CAA4C;QACrH,yGAAyG;QACzG,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,GAAG,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IACtE,CAAC;IAED,uEAAuE;IACvE,eAAe,CAAC,GAAG,IAAW,IAAS,CAAC;IACxC,2BAA2B,CAAC,GAAG,IAAW,IAAS,CAAC;IACpD,wBAAwB,CAAC,GAAG,IAAW,IAAS,CAAC;CACpD"}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* This file is the orchestrator that wires up the pipeline (lexer → parser →
|
|
3
3
|
* astBuilder → objectBuilder, etc.)
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
6
|
-
import { IParseCoreOptions, IRuntimeInfo } from '
|
|
5
|
+
import { ParsedObject, ParseOptions, YiniParseResult } from '../../types';
|
|
6
|
+
import { IParseCoreOptions, IRuntimeInfo } from '../internalTypes';
|
|
7
7
|
/**
|
|
8
8
|
* @internal Single source of truth.
|
|
9
9
|
*
|
|
@@ -15,4 +15,4 @@ import { IParseCoreOptions, IRuntimeInfo } from './internalTypes';
|
|
|
15
15
|
* and metadata purposes and should not be relied upon in
|
|
16
16
|
* application logic.
|
|
17
17
|
*/
|
|
18
|
-
export declare const runPipeline: (yiniContent: string, coreOptions: IParseCoreOptions, runtimeInfo: IRuntimeInfo, _meta_userOpts:
|
|
18
|
+
export declare const runPipeline: (yiniContent: string, coreOptions: IParseCoreOptions, runtimeInfo: IRuntimeInfo, _meta_userOpts: ParseOptions) => ParsedObject | YiniParseResult;
|
|
@@ -3,139 +3,23 @@
|
|
|
3
3
|
* This file is the orchestrator that wires up the pipeline (lexer → parser →
|
|
4
4
|
* astBuilder → objectBuilder, etc.)
|
|
5
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
6
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
7
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
8
|
};
|
|
42
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
10
|
exports.runPipeline = void 0;
|
|
44
11
|
const perf_hooks_1 = require("perf_hooks");
|
|
45
|
-
const util_1 = require("util");
|
|
46
12
|
const antlr4_1 = require("antlr4");
|
|
47
|
-
const env_1 = require("
|
|
48
|
-
const YiniLexer_1 = __importDefault(require("
|
|
49
|
-
const YiniParser_1 =
|
|
50
|
-
const object_1 = require("
|
|
51
|
-
const print_1 = require("
|
|
52
|
-
const astBuilder_1 = __importDefault(require("
|
|
53
|
-
const errorDataHandler_1 = require("
|
|
54
|
-
const objectBuilder_1 = require("
|
|
55
|
-
const resultMetadataBuilder_1 = require("
|
|
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
|
-
}
|
|
13
|
+
const env_1 = require("../../config/env");
|
|
14
|
+
const YiniLexer_1 = __importDefault(require("../../grammar/generated/YiniLexer"));
|
|
15
|
+
const YiniParser_1 = __importDefault(require("../../grammar/generated/YiniParser"));
|
|
16
|
+
const object_1 = require("../../utils/object");
|
|
17
|
+
const print_1 = require("../../utils/print");
|
|
18
|
+
const astBuilder_1 = __importDefault(require("../astBuilder"));
|
|
19
|
+
const errorDataHandler_1 = require("../errorDataHandler");
|
|
20
|
+
const objectBuilder_1 = require("../objectBuilder");
|
|
21
|
+
const resultMetadataBuilder_1 = require("../resultMetadataBuilder");
|
|
22
|
+
const errorListeners_1 = require("./errorListeners");
|
|
139
23
|
/**
|
|
140
24
|
* @internal Single source of truth.
|
|
141
25
|
*
|
|
@@ -149,17 +33,17 @@ class MyLexerErrorListener {
|
|
|
149
33
|
*/
|
|
150
34
|
const runPipeline = (yiniContent, coreOptions, runtimeInfo, _meta_userOpts) => {
|
|
151
35
|
(0, print_1.debugPrint)();
|
|
152
|
-
(0, print_1.debugPrint)('-> Entered
|
|
153
|
-
(0, print_1.debugPrint)('
|
|
36
|
+
(0, print_1.debugPrint)('-> Entered runPipeline(..) in pipeline.ts');
|
|
37
|
+
(0, print_1.debugPrint)(' isStrict initialMode = ' + coreOptions.rules.initialMode);
|
|
154
38
|
(0, print_1.debugPrint)(' bailSensitivity = ' + coreOptions.bailSensitivity);
|
|
155
39
|
(0, print_1.debugPrint)(' isIncludeMeta = ' + coreOptions.isIncludeMeta);
|
|
156
40
|
(0, print_1.debugPrint)(' isWithDiagnostics = ' + coreOptions.isWithDiagnostics);
|
|
157
41
|
(0, print_1.debugPrint)(' isWithTiming = ' + coreOptions.isWithTiming);
|
|
158
42
|
(0, print_1.debugPrint)(' isKeepUndefinedInMeta = ' + coreOptions.isKeepUndefinedInMeta);
|
|
159
|
-
(0, print_1.debugPrint)('
|
|
160
|
-
(0, print_1.debugPrint)('
|
|
161
|
-
(0, print_1.debugPrint)('
|
|
162
|
-
(0, print_1.debugPrint)('
|
|
43
|
+
(0, print_1.debugPrint)('isQuiet = ' + coreOptions.isQuiet);
|
|
44
|
+
(0, print_1.debugPrint)(' onDuplicateKey = ' + coreOptions.rules.onDuplicateKey);
|
|
45
|
+
(0, print_1.debugPrint)(' requireDocTerminator = ' + coreOptions.rules.requireDocTerminator);
|
|
46
|
+
(0, print_1.debugPrint)(' treatEmptyValueAsNull = ' + coreOptions.rules.treatEmptyValueAsNull);
|
|
163
47
|
(0, print_1.debugPrint)();
|
|
164
48
|
(0, print_1.debugPrint)(' runtimeInfo.sourceType = ' + runtimeInfo.sourceType);
|
|
165
49
|
(0, print_1.debugPrint)(' runtimeInfo.fileName = ' + runtimeInfo.fileName);
|
|
@@ -174,7 +58,7 @@ const runPipeline = (yiniContent, coreOptions, runtimeInfo, _meta_userOpts) => {
|
|
|
174
58
|
// default:
|
|
175
59
|
// persistThreshold = '2-Abort-Even-on-Warnings'
|
|
176
60
|
// }
|
|
177
|
-
const errorHandler = new errorDataHandler_1.ErrorDataHandler(runtimeInfo.sourceType, runtimeInfo.fileName, coreOptions.bailSensitivity, coreOptions.
|
|
61
|
+
const errorHandler = new errorDataHandler_1.ErrorDataHandler(runtimeInfo.sourceType, runtimeInfo.fileName, coreOptions.bailSensitivity, coreOptions.isQuiet, coreOptions.isSilent, coreOptions.isThrowOnError);
|
|
178
62
|
if (yiniContent.trim() === '') {
|
|
179
63
|
const isFileSourceType = runtimeInfo?.sourceType === 'File';
|
|
180
64
|
// Note, after pushing processing may continue or exit, depending on the error and/or the bail threshold.
|
|
@@ -208,7 +92,8 @@ const runPipeline = (yiniContent, coreOptions, runtimeInfo, _meta_userOpts) => {
|
|
|
208
92
|
const lexer = new YiniLexer_1.default(inputStream);
|
|
209
93
|
// Remove the default ConsoleErrorListener
|
|
210
94
|
lexer.removeErrorListeners(); // Removes the default lexer console error output.
|
|
211
|
-
const lexerErrorListener = new MyLexerErrorListener(errorHandler)
|
|
95
|
+
// const lexerErrorListener = new MyLexerErrorListener(errorHandler)
|
|
96
|
+
const lexerErrorListener = (0, errorListeners_1.createLexerErrorListener)(errorHandler);
|
|
212
97
|
lexer.addErrorListener(lexerErrorListener);
|
|
213
98
|
const tokenStream = new antlr4_1.CommonTokenStream(lexer);
|
|
214
99
|
// Important: force tokenization here so lexing is measured separately.
|
|
@@ -223,17 +108,24 @@ const runPipeline = (yiniContent, coreOptions, runtimeInfo, _meta_userOpts) => {
|
|
|
223
108
|
const parser = new YiniParser_1.default(tokenStream);
|
|
224
109
|
// const errorListener = new MyParserErrorListener(errorHandler)
|
|
225
110
|
parser.removeErrorListeners(); // Removes the default parser console error output.
|
|
226
|
-
const parserErrorListener = new MyParserErrorListener(errorHandler)
|
|
111
|
+
// const parserErrorListener = new MyParserErrorListener(errorHandler)
|
|
112
|
+
const parserErrorListener = (0, errorListeners_1.createParserErrorListener)(errorHandler);
|
|
227
113
|
parser.addErrorListener(parserErrorListener);
|
|
228
114
|
const parseTree = parser.yini(); // The function yini() is the start rule.
|
|
229
|
-
if (
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
115
|
+
// if (
|
|
116
|
+
// parserErrorListener.errors.length > 0 ||
|
|
117
|
+
// lexerErrorListener.errors.length > 0
|
|
118
|
+
// ) {
|
|
119
|
+
// debugPrint('*** ERROR detected ***')
|
|
120
|
+
// if (isDebug()) {
|
|
121
|
+
// // Handle or display syntax errors
|
|
122
|
+
// console.error(
|
|
123
|
+
// 'Syntax errors detected:',
|
|
124
|
+
// parserErrorListener.errors,
|
|
125
|
+
// lexerErrorListener.errors,
|
|
126
|
+
// )
|
|
127
|
+
// }
|
|
128
|
+
// }
|
|
237
129
|
(0, print_1.debugPrint)('=== Ended phase 2 =============================================');
|
|
238
130
|
(0, env_1.isDebug)() && console.log();
|
|
239
131
|
(0, print_1.debugPrint)('=== Phase 3 - AST Model build & validation ===================================================');
|
|
@@ -279,9 +171,15 @@ const runPipeline = (yiniContent, coreOptions, runtimeInfo, _meta_userOpts) => {
|
|
|
279
171
|
(0, print_1.debugPrint)('visitor.visit(..): finalJSResult:');
|
|
280
172
|
(0, env_1.isDebug)() && console.debug(finalJSResult);
|
|
281
173
|
(0, print_1.debugPrint)();
|
|
282
|
-
if (coreOptions.
|
|
174
|
+
if (coreOptions.rules.initialMode === 'strict') {
|
|
283
175
|
// 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
|
|
176
|
+
errorHandler.pushOrBail(null, 'Syntax-Warning', 'Warning: Strict initialMode is not yet fully implemented.', 'Some validation rules may still be missing or incomplete.');
|
|
177
|
+
if (coreOptions.bailSensitivity === '0-Ignore-Errors') {
|
|
178
|
+
// IMPORTANT: If "silent" option is set, do not log anything to console!
|
|
179
|
+
if (!coreOptions.isQuiet && !coreOptions.isSilent) {
|
|
180
|
+
console.warn(`Warning: The initial mode was set to strict mode, but fail level is set to 'ignore-errors'. This combination is contradictory and might be a mistake.`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
285
183
|
}
|
|
286
184
|
else {
|
|
287
185
|
(0, print_1.debugPrint)('visitor.visit(..): finalJSResult:');
|
|
@@ -304,10 +202,33 @@ const runPipeline = (yiniContent, coreOptions, runtimeInfo, _meta_userOpts) => {
|
|
|
304
202
|
};
|
|
305
203
|
const constructedMetadata = (0, resultMetadataBuilder_1.buildResultMetadata)(params);
|
|
306
204
|
(0, print_1.debugPrint)('getNumOfErrors(): ' + errorHandler.getNumOfErrors());
|
|
307
|
-
if
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
205
|
+
// Print a summary line at the end if any errors or warnings.
|
|
206
|
+
if (!coreOptions.isQuiet && !coreOptions.isSilent) {
|
|
207
|
+
const errors = errorHandler.getNumOfErrors();
|
|
208
|
+
const warnings = errorHandler.getNumOfWarnings();
|
|
209
|
+
// Notes:
|
|
210
|
+
// - if any errors, print to console **ERROR**.
|
|
211
|
+
// - if no errors but warnings, print to console **WARN**.
|
|
212
|
+
// Otherwise, adds a lot more complexity to auto testing (especially options testing), etc.
|
|
213
|
+
//
|
|
214
|
+
// Also, output one concise summary line (according to "best practices").
|
|
215
|
+
if (coreOptions.bailSensitivity !== '0-Ignore-Errors') {
|
|
216
|
+
/*
|
|
217
|
+
'1-Abort-on-Errors':
|
|
218
|
+
Show summary if: errors >= 1 or warnings >= 3.
|
|
219
|
+
|
|
220
|
+
'2-Abort-Even-on-Warnings':
|
|
221
|
+
Show summary if: errors >= 1 or warnings >= 1
|
|
222
|
+
*/
|
|
223
|
+
const numOfWarningsToTrigger = coreOptions.bailSensitivity === '1-Abort-on-Errors' ? 3 : 1;
|
|
224
|
+
if (errors) {
|
|
225
|
+
console.error(`Parsing completed with ${errors} error(s), ${warnings} warning(s). Please see details above.`);
|
|
226
|
+
}
|
|
227
|
+
else if (warnings >= numOfWarningsToTrigger &&
|
|
228
|
+
!coreOptions.isQuiet) {
|
|
229
|
+
console.warn(`Parsing completed with ${errors} error(s), ${warnings} warning(s).`);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
311
232
|
}
|
|
312
233
|
if (coreOptions.isIncludeMeta) {
|
|
313
234
|
return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pipeline.js","sourceRoot":"","sources":["../../../src/core/pipeline/pipeline.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,2CAAwC;AACxC,mCAAuD;AACvD,0CAA0C;AAC1C,kFAAyD;AACzD,oFAA4E;AAO5E,+CAAwD;AACxD,6CAA2D;AAC3D,+DAAsC;AACtC,0DAAsD;AAEtD,oDAA8C;AAC9C,oEAGiC;AACjC,qDAGyB;AAEzB;;;;;;;;;;GAUG;AACI,MAAM,WAAW,GAAG,CACvB,WAAmB,EACnB,WAA8B,EAC9B,WAAyB,EACzB,cAA4B,EACE,EAAE;IAChC,IAAA,kBAAU,GAAE,CAAA;IACZ,IAAA,kBAAU,EAAC,2CAA2C,CAAC,CAAA;IACvD,IAAA,kBAAU,EAAC,6BAA6B,GAAG,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAA;IACzE,IAAA,kBAAU,EAAC,6BAA6B,GAAG,WAAW,CAAC,eAAe,CAAC,CAAA;IACvE,IAAA,kBAAU,EAAC,6BAA6B,GAA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
|
1
|
+
import { ParseOptions, ResultMetadata } from '../types';
|
|
2
2
|
import { ErrorDataHandler } from './errorDataHandler';
|
|
3
3
|
import { IParseCoreOptions, IRuntimeInfo, IYiniAST } from './internalTypes';
|
|
4
4
|
export interface IBuildResultMetadataParams {
|
|
5
5
|
ast: IYiniAST;
|
|
6
6
|
coreOptions: IParseCoreOptions;
|
|
7
7
|
runtimeInfo: IRuntimeInfo;
|
|
8
|
-
_meta_userOpts:
|
|
8
|
+
_meta_userOpts: ParseOptions;
|
|
9
9
|
errorHandler: ErrorDataHandler;
|
|
10
10
|
runStartedAt: string;
|
|
11
11
|
runFinishedAt: string;
|
|
@@ -8,14 +8,33 @@ exports.buildResultMetadata = void 0;
|
|
|
8
8
|
const package_json_1 = __importDefault(require("../../package.json")); // NOTE: Requires "resolveJsonModule": true (or "esModuleInterop": true).
|
|
9
9
|
const env_1 = require("../config/env");
|
|
10
10
|
const object_1 = require("../utils/object");
|
|
11
|
+
const print_1 = require("../utils/print");
|
|
11
12
|
const string_1 = require("../utils/string");
|
|
13
|
+
const modeFromRulesMatcher_1 = require("./parsingRules/modeFromRulesMatcher");
|
|
12
14
|
const buildResultMetadata = (p) => {
|
|
13
15
|
// --- Construct meta information -------------------------------------
|
|
14
|
-
const to3 = (n) =>
|
|
16
|
+
const to3 = (n) => {
|
|
17
|
+
if (!n) {
|
|
18
|
+
if ((0, env_1.isProdEnv)()) {
|
|
19
|
+
return 0;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
(0, print_1.debugPrint)('In buildResultMetadata(..): p.runtimeInfo:');
|
|
23
|
+
(0, print_1.printObject)(p.runtimeInfo);
|
|
24
|
+
(0, print_1.debugPrint)('In buildResultMetadata(..): p.coreOptions:');
|
|
25
|
+
(0, print_1.printObject)(p.coreOptions);
|
|
26
|
+
(0, print_1.debugPrint)('In buildResultMetadata(..): p.durationMs:');
|
|
27
|
+
(0, print_1.printObject)(p.durationMs);
|
|
28
|
+
// p.errorHandler.pushOrBail(null,'Internal-Error', 'to3 received undefined')
|
|
29
|
+
throw Error('to3(..) received undefined');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return Number.parseFloat(n.toFixed(3));
|
|
33
|
+
};
|
|
15
34
|
// Construct meta data.
|
|
16
35
|
const metadata = {
|
|
17
36
|
parserVersion: package_json_1.default.version,
|
|
18
|
-
mode: p.coreOptions.
|
|
37
|
+
mode: p.coreOptions.rules.initialMode,
|
|
19
38
|
totalErrors: p.errorHandler.getNumOfErrors(),
|
|
20
39
|
totalWarnings: p.errorHandler.getNumOfWarnings(),
|
|
21
40
|
totalMessages: p.errorHandler.getNumOfAllMessages(),
|
|
@@ -43,7 +62,7 @@ const buildResultMetadata = (p) => {
|
|
|
43
62
|
// listCount: null,
|
|
44
63
|
sectionNamePaths: p.ast.sectionNamePaths,
|
|
45
64
|
},
|
|
46
|
-
metaSchemaVersion: '1.1.
|
|
65
|
+
metaSchemaVersion: '1.1.1',
|
|
47
66
|
};
|
|
48
67
|
// Attach optional diagnostics.
|
|
49
68
|
if (p.coreOptions.isWithDiagnostics) {
|
|
@@ -68,6 +87,7 @@ const buildResultMetadata = (p) => {
|
|
|
68
87
|
}
|
|
69
88
|
return null;
|
|
70
89
|
};
|
|
90
|
+
const effectiveMode = (0, modeFromRulesMatcher_1.matchModeFromCoreOptions)(p.coreOptions);
|
|
71
91
|
metadata.diagnostics = {
|
|
72
92
|
failLevel: {
|
|
73
93
|
preferredLevel: p.runtimeInfo.preferredBailSensitivity,
|
|
@@ -101,17 +121,18 @@ const buildResultMetadata = (p) => {
|
|
|
101
121
|
},
|
|
102
122
|
},
|
|
103
123
|
effectiveOptions: (0, object_1.sortObjectKeys)({
|
|
124
|
+
effectiveMode: effectiveMode, // Appended.
|
|
104
125
|
// IMPORTANT: (!) These user options MUST be mapped from coreOptions (to user options).
|
|
105
|
-
strictMode:
|
|
126
|
+
strictMode: effectiveMode === 'strict' ? true : false,
|
|
106
127
|
failLevel: mapLevelKey(p.coreOptions.bailSensitivity),
|
|
107
128
|
includeMetadata: p.coreOptions.isIncludeMeta,
|
|
108
129
|
includeDiagnostics: p.coreOptions.isWithDiagnostics,
|
|
109
130
|
includeTiming: p.coreOptions.isWithTiming,
|
|
110
131
|
preserveUndefinedInMeta: p.coreOptions.isKeepUndefinedInMeta,
|
|
111
|
-
|
|
112
|
-
requireDocTerminator: p.coreOptions.requireDocTerminator,
|
|
113
|
-
treatEmptyValueAsNull: p.coreOptions.treatEmptyValueAsNull,
|
|
114
|
-
onDuplicateKey: p.coreOptions.onDuplicateKey,
|
|
132
|
+
quiet: p.coreOptions.isQuiet,
|
|
133
|
+
requireDocTerminator: p.coreOptions.rules.requireDocTerminator,
|
|
134
|
+
treatEmptyValueAsNull: p.coreOptions.rules.treatEmptyValueAsNull,
|
|
135
|
+
onDuplicateKey: p.coreOptions.rules.onDuplicateKey,
|
|
115
136
|
}),
|
|
116
137
|
options: (0, object_1.sortObjectKeys)(p._meta_userOpts),
|
|
117
138
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resultMetadataBuilder.js","sourceRoot":"","sources":["../../src/core/resultMetadataBuilder.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA4C;AAC5C,sEAAoC,CAAC,yEAAyE;AAC9G,
|
|
1
|
+
{"version":3,"file":"resultMetadataBuilder.js","sourceRoot":"","sources":["../../src/core/resultMetadataBuilder.ts"],"names":[],"mappings":";;;;;;AAAA,4CAA4C;AAC5C,sEAAoC,CAAC,yEAAyE;AAC9G,uCAMsB;AAEtB,4CAAgD;AAChD,0CAAwD;AACxD,4CAAkD;AASlD,8EAA8E;AAmBvE,MAAM,mBAAmB,GAAG,CAC/B,CAA6B,EACf,EAAE;IAChB,uEAAuE;IACvE,MAAM,GAAG,GAAG,CAAC,CAAS,EAAU,EAAE;QAC9B,IAAI,CAAC,CAAC,EAAE,CAAC;YACL,IAAI,IAAA,eAAS,GAAE,EAAE,CAAC;gBACd,OAAO,CAAC,CAAA;Y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,CAAC,CAAC,CAAC,WAAW,CAAC,QAAS,CAAC;oBAEpC,IAAI,EAAE,KAAK;iBACd;YACX,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,WAAW,CAAC;oBAEzC,IAAI,EAAE,QAAQ;iBACjB;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,SAAS;iBAClB;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,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;AA7LY,QAAA,mBAAmB,uBA6L/B"}
|
package/dist/core/runtime.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ParsedObject, ParseOptions, PreferredFailLevel } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Private class representing a runtime context for a single parse call.
|
|
4
4
|
*
|
|
5
5
|
* @note This design prevents race conditions: each call gets its own
|
|
6
6
|
* runtimeInfo and related state. Without this, multiple calls
|
|
7
7
|
* (especially in parallel) could overwrite each other's data.
|
|
8
|
+
*
|
|
9
|
+
* @note The following options MUST be respected!
|
|
10
|
+
* quiet?: boolean // Reduce output (show only errors, does not effect warnings and etc. in meta data).
|
|
11
|
+
* silent?: boolean // Suppress all output (even errors, exit code only).
|
|
8
12
|
*/
|
|
9
13
|
export declare class YiniRuntime {
|
|
10
14
|
#private;
|
|
11
15
|
constructor(sourceType: 'Inline' | 'File');
|
|
12
16
|
private makeRuntimeInfo;
|
|
13
17
|
doParse(yiniContent: string, strictMode?: boolean, failLevel?: PreferredFailLevel, includeMetadata?: boolean): ParsedObject;
|
|
14
|
-
doParse(yiniContent: string, options?:
|
|
18
|
+
doParse(yiniContent: string, options?: ParseOptions): ParsedObject;
|
|
15
19
|
doParseFile(filePath: string, strictMode?: boolean, failLevel?: PreferredFailLevel, includeMetadata?: boolean): ParsedObject;
|
|
16
|
-
doParseFile(filePath: string, options?:
|
|
20
|
+
doParseFile(filePath: string, options?: ParseOptions): ParsedObject;
|
|
17
21
|
}
|