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
package/dist/YINI.js
CHANGED
|
@@ -1,114 +1,198 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
var _a;
|
|
6
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
3
|
const env_1 = require("./config/env");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
4
|
+
const errorDataHandler_1 = require("./core/errorDataHandler");
|
|
5
|
+
const normalizeOptions_1 = require("./core/options/normalizeOptions");
|
|
6
|
+
const runtime_1 = require("./core/runtime");
|
|
11
7
|
const print_1 = require("./utils/print");
|
|
8
|
+
const DEFAULT_TAB_SIZE = 4; // De facto "modern default" (even though traditionally/historically it's 8).
|
|
9
|
+
// let _runtimeInfo: IRuntimeInfo = {
|
|
10
|
+
// sourceType: 'Inline',
|
|
11
|
+
// fileName: undefined,
|
|
12
|
+
// fileByteSize: null,
|
|
13
|
+
// lineCount: null,
|
|
14
|
+
// timeIoMs: null,
|
|
15
|
+
// preferredBailSensitivity: null,
|
|
16
|
+
// sha256: null,
|
|
17
|
+
// }
|
|
12
18
|
/**
|
|
13
19
|
* This class is the public API, which exposes only parse(..) and
|
|
14
20
|
* parseFile(..), rest of the implementation details are hidden.
|
|
15
21
|
* @note Only parse and parseFile are public.
|
|
16
22
|
*/
|
|
17
23
|
class YINI {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*
|
|
24
|
-
* @param yiniContent YINI code as a string (multi‑line content supported).
|
|
25
|
-
* @param strictMode If `true`, enforce strict parsing rules (e.g. require `/END`, disallow trailing commas).
|
|
26
|
-
* @param bailSensitivity Controls how errors and warnings are handled:
|
|
27
|
-
* - `'auto'` : Auto‑select level (strict→1, lenient→0)
|
|
28
|
-
* - `0` / `'Ignore-Errors'` : Continue parsing despite errors; log them and attempt recovery.
|
|
29
|
-
* - `1` / `'Abort-on-Errors'` : Stop parsing on the first error.
|
|
30
|
-
* - `2` / `'Abort-Even-on-Warnings'`: Stop parsing on the first warning **or** error.
|
|
31
|
-
* @param includeMetaData If `true`, return additional metadata (e.g. warnings, statistics) alongside the parsed object.
|
|
32
|
-
*
|
|
33
|
-
* @note The order of properties in each output object may differ from their order in the YINI source.
|
|
34
|
-
*
|
|
35
|
-
* @returns A JavaScript object representing the parsed YINI content.
|
|
36
|
-
*/
|
|
37
|
-
YINI.parse = (yiniContent, strictMode = false, bailSensitivity = 'auto', includeMetaData = false) => {
|
|
38
|
-
(0, print_1.debugPrint)('-> Entered static parse(..) in class YINI\n');
|
|
39
|
-
// Important: First, before anything, trim beginning and trailing whitespaces!
|
|
40
|
-
yiniContent = yiniContent.trim();
|
|
41
|
-
if (!yiniContent) {
|
|
42
|
-
throw new Error('Syntax-Error: Unexpected blank YINI input');
|
|
43
|
-
}
|
|
44
|
-
if (!yiniContent.endsWith('\n')) {
|
|
45
|
-
yiniContent += '\n';
|
|
46
|
-
}
|
|
47
|
-
let level = 0;
|
|
48
|
-
if (bailSensitivity === 'auto') {
|
|
49
|
-
if (!strictMode)
|
|
50
|
-
level = 0;
|
|
51
|
-
if (strictMode)
|
|
52
|
-
level = 1;
|
|
24
|
+
/**
|
|
25
|
+
* @returns The number of spaces per tab character used in error messages.
|
|
26
|
+
*/
|
|
27
|
+
static getTabSize() {
|
|
28
|
+
return this.g_tabSize;
|
|
53
29
|
}
|
|
54
|
-
|
|
55
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Overrides the number of spaces per tab character used in error messages.
|
|
32
|
+
* Allowed range: 1-32.
|
|
33
|
+
*/
|
|
34
|
+
static setTabSize(spaces) {
|
|
35
|
+
if (spaces < 1 || spaces > 32) {
|
|
36
|
+
new errorDataHandler_1.ErrorDataHandler('None/Ignore').pushOrBail(null, 'Fatal-Error', `Invalid tab size ${spaces} is out of range.`, 'Tab size must be between 1 and 32 spaces.');
|
|
37
|
+
throw new RangeError(`Tab size ${spaces} is out of range (1–32).`);
|
|
38
|
+
}
|
|
39
|
+
this.g_tabSize = spaces;
|
|
56
40
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
41
|
+
// --- Single implementation --------------------------------------------
|
|
42
|
+
// Implementation method (not declared with arrow function) for both method overload signatures.
|
|
43
|
+
// NOTE: Must be method declaration with NO =, arrow functions not (currently) supported for this type of method overloading.
|
|
44
|
+
static parse(yiniContent, arg2, // strictMode | options
|
|
45
|
+
failLevel = 'auto', includeMetadata = false) {
|
|
46
|
+
(0, print_1.debugPrint)('-> Entered static parse(..) in class YINI\n');
|
|
47
|
+
// // Runtime guard to catch illegal/ambiguous calls coming from JS or any-cast code
|
|
48
|
+
// if (
|
|
49
|
+
// isOptionsObjectForm(arg2) &&
|
|
50
|
+
// (failLevel !== 'auto' || includeMetadata !== false)
|
|
51
|
+
// ) {
|
|
52
|
+
// throw new TypeError(
|
|
53
|
+
// 'Invalid call: when providing an options object, do not also pass positional parameters.',
|
|
54
|
+
// )
|
|
55
|
+
// }
|
|
56
|
+
// const mode: TParserMode = inferModeFromArgs(arg2)
|
|
57
|
+
// const defaultOptions = getDefaultOptions(mode)
|
|
58
|
+
// // Normalize to a fully-required options object.
|
|
59
|
+
// let userOpts: Required<IAllUserOptions>
|
|
60
|
+
// // Required, makes all properties in T required, no undefined.
|
|
61
|
+
// if (isOptionsObjectForm(arg2)) {
|
|
62
|
+
// userOpts = {
|
|
63
|
+
// ...defaultOptions, // Sets the default options.
|
|
64
|
+
// ...arg2,
|
|
65
|
+
// }
|
|
66
|
+
// } else {
|
|
67
|
+
// // Positional form.
|
|
68
|
+
// userOpts = {
|
|
69
|
+
// ...defaultOptions, // Sets the default options.
|
|
70
|
+
// strictMode:
|
|
71
|
+
// (arg2 as boolean | undefined) ?? defaultOptions.strictMode,
|
|
72
|
+
// failLevel,
|
|
73
|
+
// includeMetadata,
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
76
|
+
// if (userOpts.includeMetadata && _runtimeInfo.sourceType === 'Inline') {
|
|
77
|
+
// const lineCount = yiniContent.split(/\r?\n/).length // Counts the lines.
|
|
78
|
+
// const sha256 = computeSha256(yiniContent) // NOTE: Compute BEFORE any possible tampering of content.
|
|
79
|
+
// _runtimeInfo.lineCount = lineCount
|
|
80
|
+
// _runtimeInfo.preferredBailSensitivity = userOpts.failLevel
|
|
81
|
+
// _runtimeInfo.sha256 = sha256
|
|
82
|
+
// }
|
|
83
|
+
// // NOTE: Important: Do not trim or mutate the yiniContent here, due
|
|
84
|
+
// // to it will mess up the line numbers in error reporting.
|
|
85
|
+
// if (!yiniContent) {
|
|
86
|
+
// throw new Error('Syntax-Error: Unexpected blank YINI input')
|
|
87
|
+
// }
|
|
88
|
+
// if (!yiniContent.endsWith('\n')) {
|
|
89
|
+
// yiniContent += '\n'
|
|
90
|
+
// }
|
|
91
|
+
// let level: TBailSensitivityLevel = mapFailLevelToBail(
|
|
92
|
+
// userOpts.strictMode,
|
|
93
|
+
// userOpts.failLevel,
|
|
94
|
+
// )
|
|
95
|
+
////////////////
|
|
96
|
+
// const coreOpts: IParseCoreOptions = toCoreOptions(level, userOpts)
|
|
97
|
+
(0, print_1.debugPrint)();
|
|
98
|
+
(0, print_1.debugPrint)('==== Call doParse(..) in runtime ==========================');
|
|
99
|
+
// const result = _parseMain(yiniContent, coreOpts, _runtimeInfo)
|
|
100
|
+
const runtime = new runtime_1.YiniRuntime('Inline');
|
|
101
|
+
const result = (0, normalizeOptions_1.isOptionsObjectForm)(arg2)
|
|
102
|
+
? runtime.doParse(yiniContent, arg2) // Overload #2: (content, options)
|
|
103
|
+
: runtime.doParse(
|
|
104
|
+
// Overload #1: (content, strict?, failLevel?, includeMeta?)
|
|
105
|
+
yiniContent, arg2, failLevel, includeMetadata);
|
|
106
|
+
(0, print_1.debugPrint)('==== End call parse ==========================\n');
|
|
107
|
+
if ((0, env_1.isDev)()) {
|
|
108
|
+
console.log();
|
|
109
|
+
(0, print_1.devPrint)('YINI.parse(..): result:');
|
|
110
|
+
console.log(result);
|
|
111
|
+
(0, print_1.devPrint)('Complete result:');
|
|
112
|
+
(0, print_1.printObject)(result);
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
74
115
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
116
|
+
// --- Single implementation --------------------------------------------
|
|
117
|
+
// Implementation method (not declared with arrow function) for both method overload signatures.
|
|
118
|
+
// NOTE: Must be method declaration with NO =, arrow functions not (currently) supported for this type of method overloading.
|
|
119
|
+
static parseFile(filePath, arg2, // strictMode | options
|
|
120
|
+
failLevel = 'auto', includeMetadata = false) {
|
|
121
|
+
(0, print_1.debugPrint)('-> Entered static parseFile(..) in class YINI\n');
|
|
122
|
+
(0, print_1.debugPrint)('Current directory = ' + process.cwd());
|
|
123
|
+
// // Runtime guard to catch illegal/ambiguous calls coming from JS or any-cast code
|
|
124
|
+
// if (
|
|
125
|
+
// isOptionsObjectForm(arg2) &&
|
|
126
|
+
// (failLevel !== 'auto' || includeMetadata !== false)
|
|
127
|
+
// ) {
|
|
128
|
+
// throw new TypeError(
|
|
129
|
+
// 'Invalid call: when providing an options object, do not also pass positional parameters.',
|
|
130
|
+
// )
|
|
131
|
+
// }
|
|
132
|
+
// const mode: TParserMode = inferModeFromArgs(arg2)
|
|
133
|
+
// const defaultOptions = getDefaultOptions(mode)
|
|
134
|
+
// // Normalize to a fully-required options object.
|
|
135
|
+
// let userOpts: Required<IAllUserOptions>
|
|
136
|
+
// // Required, makes all properties in T required, no undefined.
|
|
137
|
+
// if (isOptionsObjectForm(arg2)) {
|
|
138
|
+
// // Options-object Form.
|
|
139
|
+
// userOpts = {
|
|
140
|
+
// ...defaultOptions, // Sets the default options.
|
|
141
|
+
// ...arg2,
|
|
142
|
+
// }
|
|
143
|
+
// } else {
|
|
144
|
+
// // Positional form.
|
|
145
|
+
// userOpts = {
|
|
146
|
+
// ...defaultOptions, // Sets the default options.
|
|
147
|
+
// strictMode:
|
|
148
|
+
// (arg2 as boolean | undefined) ?? defaultOptions.strictMode,
|
|
149
|
+
// failLevel,
|
|
150
|
+
// includeMetadata,
|
|
151
|
+
// }
|
|
152
|
+
// }
|
|
153
|
+
// if (getFileNameExtension(filePath).toLowerCase() !== '.yini') {
|
|
154
|
+
// console.error('Invalid file extension for YINI file:')
|
|
155
|
+
// console.error(`"${filePath}"`)
|
|
156
|
+
// console.log(
|
|
157
|
+
// 'File does not have a valid ".yini" extension (case-insensitive).',
|
|
158
|
+
// )
|
|
159
|
+
// throw new Error('Error: Unexpected file extension for YINI file')
|
|
160
|
+
// }
|
|
161
|
+
// // ---- Phase 0: I/O ----
|
|
162
|
+
// const timeStartMs = performance.now()
|
|
163
|
+
// // let content = fs.readFileSync(filePath, 'utf8')
|
|
164
|
+
// const rawBuffer = fs.readFileSync(filePath) // Raw buffer for size.
|
|
165
|
+
// const fileByteSize = rawBuffer.byteLength // Byte size in UTF-8.
|
|
166
|
+
// let content = rawBuffer.toString('utf8')
|
|
167
|
+
// const timeEndMs = performance.now()
|
|
168
|
+
// _runtimeInfo.sourceType = 'File'
|
|
169
|
+
// _runtimeInfo.fileName = filePath
|
|
170
|
+
// if (userOpts.includeMetadata) {
|
|
171
|
+
// _runtimeInfo.lineCount = content.split(/\r?\n/).length // Counts the lines.
|
|
172
|
+
// _runtimeInfo.fileByteSize = fileByteSize
|
|
173
|
+
// _runtimeInfo.timeIoMs = +(timeEndMs - timeStartMs).toFixed(3)
|
|
174
|
+
// _runtimeInfo.preferredBailSensitivity = userOpts.failLevel
|
|
175
|
+
// _runtimeInfo.sha256 = computeSha256(content) // NOTE: Compute BEFORE any possible tampering of content.
|
|
176
|
+
// }
|
|
177
|
+
// let hasNoNewlineAtEOF = false
|
|
178
|
+
// if (!content.endsWith('\n')) {
|
|
179
|
+
// content += '\n'
|
|
180
|
+
// hasNoNewlineAtEOF = true
|
|
181
|
+
// }
|
|
182
|
+
(0, print_1.debugPrint)();
|
|
183
|
+
(0, print_1.debugPrint)('==== Call doParseFile(..) in runtime ==========================');
|
|
184
|
+
// const result = _parseMain(yiniContent, coreOpts, _runtimeInfo)
|
|
185
|
+
const runtime = new runtime_1.YiniRuntime('File');
|
|
186
|
+
const result = (0, normalizeOptions_1.isOptionsObjectForm)(arg2)
|
|
187
|
+
? runtime.doParseFile(filePath, arg2) // Overload #2: (content, options)
|
|
188
|
+
: runtime.doParseFile(
|
|
189
|
+
// Overload #1: (content, strict?, failLevel?, includeMeta?)
|
|
190
|
+
filePath, arg2, failLevel, includeMetadata);
|
|
191
|
+
(0, print_1.debugPrint)('==== End call parse ==========================\n');
|
|
192
|
+
return result;
|
|
106
193
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
console.warn(`No newline at end of file, it's recommended to end a file with a newline. File:\n"${filePath}"`);
|
|
111
|
-
}
|
|
112
|
-
return result;
|
|
113
|
-
};
|
|
194
|
+
}
|
|
195
|
+
// @todo In future move/change this to not be a global and suffer from possible race conditions, possibly move this into YiniRuntime class.
|
|
196
|
+
YINI.g_tabSize = DEFAULT_TAB_SIZE; // Global tab size used in error messages.
|
|
114
197
|
exports.default = YINI;
|
|
198
|
+
//# sourceMappingURL=YINI.js.map
|
package/dist/YINI.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"YINI.js","sourceRoot":"","sources":["../src/YINI.ts"],"names":[],"mappings":";;AAAA,sCAA6C;AAC7C,8DAA0D;AAC1D,sEAAqE;AACrE,4CAA4C;AAO5C,yCAAiE;AAEjE,MAAM,gBAAgB,GAAG,CAAC,CAAA,CAAC,6EAA6E;AAExG,qCAAqC;AACrC,4BAA4B;AAC5B,2BAA2B;AAC3B,0BAA0B;AAC1B,uBAAuB;AACvB,sBAAsB;AACtB,sCAAsC;AACtC,oBAAoB;AACpB,IAAI;AAEJ;;;;GAIG;AACH,MAAqB,IAAI;IAIrB;;OAEG;IACI,MAAM,CAAC,UAAU;QACpB,OAAO,IAAI,CAAC,SAAS,CAAA;IACzB,CAAC;IAED;;;OAGG;IACI,MAAM,CA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AAO,KAAK,CAAA;AAChB,CAAC,CAAA;AAjBY,QAAA,KAAK,SAiBjB;AAED;;;;GAIG;AACI,MAAM,OAAO,GAAG,GAAY,EAAE;IACjC,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAA;IAE/B,oEAAoE;IACpE,uDAAuD;IACvD,kCAAkC;IAClC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAW,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;QACzC,IACI,GAAG,CAAC,WAAW,EAAE,KAAK,WAAW;YACjC,GAAG,CAAC,WAAW,EAAE,KAAK,cAAc,EACtC,CAAC;YACC,OAAO,IAAI,CAAA;QACf,CAAC;IACL,CAAC;IAED,OAAO,KAAK,CAAA;AAChB,CAAC,CAAA;AAjBY,QAAA,OAAO,WAiBnB"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { AnnotationContext, AssignmentContext, Bad_memberContext, Bad_meta_textContext, Boolean_literalContext, Colon_list_declContext, DirectiveContext, ElementsContext, EolContext, List_literalContext, MemberContext, Meta_stmtContext, Null_literalContext, Number_literalContext, Object_literalContext, Object_memberContext, Object_membersContext, PrologContext, StmtContext, String_concatContext, String_literalContext, Terminal_stmtContext, ValueContext, YiniContext } from '../grammar/generated/YiniParser.js';
|
|
2
|
+
import YiniParserVisitor from '../grammar/generated/YiniParserVisitor';
|
|
3
|
+
import { ErrorDataHandler } from './errorDataHandler';
|
|
4
|
+
import { IParseCoreOptions, IYiniAST, TSourceType } from './internalTypes';
|
|
5
|
+
/** Parse SECTION_HEAD token text → {level, name}.
|
|
6
|
+
* Supports repeated markers (^^^^) and shorthand (^7) (Spec 5.2–5.3.1). :contentReference[oaicite:5]{index=5}:contentReference[oaicite:6]{index=6}
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* This interface defines a complete generic visitor for a parse tree produced
|
|
10
|
+
* by `YiniParser`.
|
|
11
|
+
*
|
|
12
|
+
* @param <Result> The return type of the visit operation. Use `void` for
|
|
13
|
+
* operations with no return type.
|
|
14
|
+
*/
|
|
15
|
+
export default class ASTBuilder<Result> extends YiniParserVisitor<Result> {
|
|
16
|
+
private errorHandler;
|
|
17
|
+
private readonly options;
|
|
18
|
+
private readonly isStrict;
|
|
19
|
+
private readonly onDuplicateKey;
|
|
20
|
+
private ast;
|
|
21
|
+
private sectionStack;
|
|
22
|
+
private meta_hasYiniMarker;
|
|
23
|
+
private _numOfMembers;
|
|
24
|
+
private meta_maxLevel;
|
|
25
|
+
mapSectionNamePaths: Map<string, number>;
|
|
26
|
+
/**
|
|
27
|
+
* @param metaFileName If parsing from a file, provide the file name here so the meta information can be updated accordingly.
|
|
28
|
+
* @param metaLineCount Provide the line-count here so the meta information can be updated accordingly.
|
|
29
|
+
*/
|
|
30
|
+
constructor(errorHandler: ErrorDataHandler, options: IParseCoreOptions, sourceType: TSourceType, metaFileName: string | null);
|
|
31
|
+
private hasDefinedSectionTitle;
|
|
32
|
+
private setDefineSectionTitle;
|
|
33
|
+
/** Attach a section to the stack respecting up/down moves (Spec 5.3). :contentReference[oaicite:7]{index=7} */
|
|
34
|
+
private attachSection;
|
|
35
|
+
/** Insert a key/value into current section (duplicate handling per options). */
|
|
36
|
+
private putMember;
|
|
37
|
+
buildAST(ctx: YiniContext): IYiniAST;
|
|
38
|
+
/**
|
|
39
|
+
* Visit a parse tree produced by `YiniParser.yini`.
|
|
40
|
+
* @param ctx the parse tree
|
|
41
|
+
* @return the visitor result
|
|
42
|
+
*/
|
|
43
|
+
visitYini: (ctx: YiniContext) => any;
|
|
44
|
+
/**
|
|
45
|
+
* Visit a parse tree produced by `YiniParser.prolog`.
|
|
46
|
+
* @param ctx the parse tree
|
|
47
|
+
* @return the visitor result
|
|
48
|
+
*/
|
|
49
|
+
visitProlog: (ctx: PrologContext) => any;
|
|
50
|
+
/**
|
|
51
|
+
* Visit a parse tree produced by `YiniParser.terminal`.
|
|
52
|
+
* @param ctx the parse tree
|
|
53
|
+
* @return the visitor result
|
|
54
|
+
*/
|
|
55
|
+
visitTerminal_stmt: (ctx: Terminal_stmtContext) => any;
|
|
56
|
+
/**
|
|
57
|
+
* Visit a parse tree produced by `YiniParser.stmt`.
|
|
58
|
+
* @param ctx the parse tree
|
|
59
|
+
* @grammarRule eol | SECTION_HEAD | assignment | colon_list_decl | marker_stmt | bad_member
|
|
60
|
+
* @return the visitor result
|
|
61
|
+
*/
|
|
62
|
+
visitStmt: (ctx: StmtContext) => any;
|
|
63
|
+
/**
|
|
64
|
+
* Visit a parse tree produced by `YiniParser.meta_stmt`.
|
|
65
|
+
* @param ctx the parse tree
|
|
66
|
+
*/
|
|
67
|
+
visitMeta_stmt: (ctx: Meta_stmtContext) => any;
|
|
68
|
+
/**
|
|
69
|
+
* Visit a parse tree produced by `YiniParser.directive`.
|
|
70
|
+
* @param ctx the parse tree
|
|
71
|
+
* @note Directive statements in YINI are special top-level commands that
|
|
72
|
+
* appear only at the beginning of a document, before any sections
|
|
73
|
+
* or members. Each directive may occur at most once per file.
|
|
74
|
+
*/
|
|
75
|
+
visitDirective: (ctx: DirectiveContext) => any;
|
|
76
|
+
/**
|
|
77
|
+
* Visit a parse tree produced by `YiniParser.annotation`.
|
|
78
|
+
* @param ctx the parse tree
|
|
79
|
+
* @return the visitor result
|
|
80
|
+
*/
|
|
81
|
+
visitAnnotation: (ctx: AnnotationContext) => any;
|
|
82
|
+
/**
|
|
83
|
+
* Visit a parse tree produced by `YiniParser.eol`.
|
|
84
|
+
* @param ctx the parse tree
|
|
85
|
+
* @return the visitor result
|
|
86
|
+
*/
|
|
87
|
+
visitEol: (ctx: EolContext) => any;
|
|
88
|
+
/**
|
|
89
|
+
* Visit a parse tree produced by `YiniParser.assignment`.
|
|
90
|
+
* @param ctx the parse tree
|
|
91
|
+
* @return the visitor result
|
|
92
|
+
*/
|
|
93
|
+
visitAssignment: (ctx: AssignmentContext) => any;
|
|
94
|
+
/**
|
|
95
|
+
* Visit a parse tree produced by `YiniParser.member`.
|
|
96
|
+
* @param ctx the parse tree
|
|
97
|
+
* @grammarRule KEY WS? EQ WS? value?
|
|
98
|
+
* @return the visitor result
|
|
99
|
+
*/
|
|
100
|
+
visitMember: (ctx: MemberContext) => any;
|
|
101
|
+
/**
|
|
102
|
+
* Visit a parse tree produced by `YiniParser.value`.
|
|
103
|
+
* @param ctx the parse tree
|
|
104
|
+
* @return the visitor result
|
|
105
|
+
*/
|
|
106
|
+
visitValue: (ctx: ValueContext) => any;
|
|
107
|
+
/**
|
|
108
|
+
* Visit a parse tree produced by `YiniParser.string_literal`.
|
|
109
|
+
* @param ctx the parse tree
|
|
110
|
+
* @return the visitor result
|
|
111
|
+
*/
|
|
112
|
+
visitString_literal: (ctx: String_literalContext) => any;
|
|
113
|
+
/**
|
|
114
|
+
* Visit a parse tree produced by `YiniParser.number_literal`.
|
|
115
|
+
* @param ctx the parse tree
|
|
116
|
+
* @return the visitor result
|
|
117
|
+
*/
|
|
118
|
+
visitNumber_literal: (ctx: Number_literalContext) => any;
|
|
119
|
+
/**
|
|
120
|
+
* Visit a parse tree produced by `YiniParser.boolean_literal`.
|
|
121
|
+
* @param ctx the parse tree
|
|
122
|
+
* @return the visitor result
|
|
123
|
+
*/
|
|
124
|
+
visitBoolean_literal: (ctx: Boolean_literalContext) => any;
|
|
125
|
+
/**
|
|
126
|
+
* Visit a parse tree produced by `YiniParser.null_literal`.
|
|
127
|
+
* @param ctx the parse tree
|
|
128
|
+
* @return the visitor result
|
|
129
|
+
*/
|
|
130
|
+
visitNull_literal: (ctx: Null_literalContext) => any;
|
|
131
|
+
/**
|
|
132
|
+
* Visit a parse tree produced by `YiniParser.list_literal`.
|
|
133
|
+
* @param ctx the parse tree
|
|
134
|
+
* @grammarRule OB NL* elements? NL* CB NL* | EMPTY_LIST NL*
|
|
135
|
+
* @return the visitor result
|
|
136
|
+
*/
|
|
137
|
+
visitList_literal: (ctx: List_literalContext) => any;
|
|
138
|
+
/**
|
|
139
|
+
* Visit a parse tree produced by `YiniParser.elements`.
|
|
140
|
+
* @param ctx the parse tree
|
|
141
|
+
* @grammarRule value (NL* COMMA NL* value)* COMMA?
|
|
142
|
+
* @return the visitor result
|
|
143
|
+
*/
|
|
144
|
+
visitElements: (ctx: ElementsContext) => any;
|
|
145
|
+
/**
|
|
146
|
+
* Visit a parse tree produced by `YiniParser.object_literal`.
|
|
147
|
+
* @param ctx the parse tree
|
|
148
|
+
* @grammarRule OC NL* object_members? NL* CC NL* | EMPTY_OBJECT NL*
|
|
149
|
+
* @return the visitor result
|
|
150
|
+
*/
|
|
151
|
+
visitObject_literal: (ctx: Object_literalContext) => any;
|
|
152
|
+
/**
|
|
153
|
+
* Visit a parse tree produced by `YiniParser.object_members`.
|
|
154
|
+
* @param ctx the parse tree
|
|
155
|
+
* @grammarRule object_member (COMMA NL* object_member)* COMMA?
|
|
156
|
+
* @return the visitor result
|
|
157
|
+
*/
|
|
158
|
+
visitObject_members: (ctx: Object_membersContext) => any;
|
|
159
|
+
/**
|
|
160
|
+
* Visit a parse tree produced by `YiniParser.object_member`.
|
|
161
|
+
* @param ctx the parse tree
|
|
162
|
+
* @grammarRule KEY WS? COLON NL* value
|
|
163
|
+
* @return the visitor result
|
|
164
|
+
*/
|
|
165
|
+
visitObject_member: (ctx: Object_memberContext) => any;
|
|
166
|
+
/**
|
|
167
|
+
* Visit a parse tree produced by `YiniParser.colon_list_decl`.
|
|
168
|
+
* @param ctx the parse tree
|
|
169
|
+
* @grammarRule KEY WS? COLON (eol | WS+)* elements (eol | WS+)* eol
|
|
170
|
+
* @return the visitor result
|
|
171
|
+
*/
|
|
172
|
+
visitColon_list_decl: (ctx: Colon_list_declContext) => any;
|
|
173
|
+
/**
|
|
174
|
+
* Visit a parse tree produced by `YiniParser.string_concat`.
|
|
175
|
+
* @param ctx the parse tree
|
|
176
|
+
* @return the visitor result
|
|
177
|
+
*/
|
|
178
|
+
visitString_concat: (ctx: String_concatContext) => any;
|
|
179
|
+
/**
|
|
180
|
+
* Visit a parse tree produced by `YiniParser.bad_member`.
|
|
181
|
+
* @param ctx the parse tree
|
|
182
|
+
* @return the visitor result
|
|
183
|
+
*/
|
|
184
|
+
visitBad_member: (ctx: Bad_memberContext) => any;
|
|
185
|
+
/**
|
|
186
|
+
* Visit a parse tree produced by `YiniParser.bad_meta_text`.
|
|
187
|
+
* @param ctx the parse tree
|
|
188
|
+
* @return the visitor result
|
|
189
|
+
*/
|
|
190
|
+
visitBad_meta_text: (ctx: Bad_meta_textContext) => any;
|
|
191
|
+
}
|