yini-parser 1.2.0-beta → 1.3.1-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 +40 -2
- package/README.md +17 -6
- package/dist/YINI.d.ts +35 -23
- package/dist/YINI.js +9 -9
- 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 +8 -4
- package/dist/core/runtime.js +51 -24
- package/dist/core/runtime.js.map +1 -1
- package/dist/dev/main.js +70 -125
- 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 +0 -25
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +46 -25
- package/dist/utils/string.js +4 -0
- package/dist/utils/string.js.map +1 -1
- package/examples/basic-output.js +12 -12
- package/package.json +23 -18
- 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
package/dist/core/runtime.js
CHANGED
|
@@ -21,25 +21,27 @@ const env_1 = require("../config/env");
|
|
|
21
21
|
const pathAndFileName_1 = require("../utils/pathAndFileName");
|
|
22
22
|
const print_1 = require("../utils/print");
|
|
23
23
|
const string_1 = require("../utils/string");
|
|
24
|
+
const defaultParserOptions_1 = require("./options/defaultParserOptions");
|
|
24
25
|
const failLevel_1 = require("./options/failLevel");
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
const pipeline_1 = require("./pipeline");
|
|
26
|
+
const optionsFunctions_1 = require("./options/optionsFunctions");
|
|
27
|
+
const pipeline_1 = require("./pipeline/pipeline");
|
|
28
28
|
/**
|
|
29
29
|
* Private class representing a runtime context for a single parse call.
|
|
30
30
|
*
|
|
31
31
|
* @note This design prevents race conditions: each call gets its own
|
|
32
32
|
* runtimeInfo and related state. Without this, multiple calls
|
|
33
33
|
* (especially in parallel) could overwrite each other's data.
|
|
34
|
+
*
|
|
35
|
+
* @note The following options MUST be respected!
|
|
36
|
+
* quiet?: boolean // Reduce output (show only errors, does not effect warnings and etc. in meta data).
|
|
37
|
+
* silent?: boolean // Suppress all output (even errors, exit code only).
|
|
34
38
|
*/
|
|
35
39
|
class YiniRuntime {
|
|
36
|
-
// constructor(sourceType: 'Inline' | 'File', seed?: Partial<IRuntimeInfo>) {
|
|
37
40
|
constructor(sourceType) {
|
|
38
41
|
/**
|
|
39
42
|
* @note Leading # makes the property "truly private" at runtime.
|
|
40
43
|
*/
|
|
41
44
|
_YiniRuntime_runtime.set(this, void 0);
|
|
42
|
-
// this.#runtime = { sourceType, fileName: undefined, ...seed }
|
|
43
45
|
__classPrivateFieldSet(this, _YiniRuntime_runtime, this.makeRuntimeInfo(), "f");
|
|
44
46
|
__classPrivateFieldGet(this, _YiniRuntime_runtime, "f").sourceType = sourceType;
|
|
45
47
|
}
|
|
@@ -57,20 +59,35 @@ class YiniRuntime {
|
|
|
57
59
|
// --- Single implementation --------------------------------------------
|
|
58
60
|
// Implementation method (not declared with arrow function) for both method overload signatures.
|
|
59
61
|
// NOTE: Must be method declaration with NO =, arrow functions not (currently) supported for this type of method overloading.
|
|
60
|
-
|
|
62
|
+
runParse(yiniContent, arg2, // strictMode | options
|
|
61
63
|
failLevel = 'auto', includeMetadata = false) {
|
|
62
|
-
(0, print_1.debugPrint)('-> Entered
|
|
64
|
+
(0, print_1.debugPrint)('-> Entered runParse(..) in YiniRuntime class\n');
|
|
65
|
+
// Handle optional UTF-8 BOM content of file.
|
|
66
|
+
if (yiniContent.startsWith('\uFEFF')) {
|
|
67
|
+
// (!) NOTE: slice(1) only because UTF-8 BOM appears as one single Unicode code characte, even though it is 3 bytes (EF BB BF) on disk.
|
|
68
|
+
yiniContent = yiniContent.slice(1);
|
|
69
|
+
(0, print_1.devPrint)('runParse(..): BOM was detected and stripped BOM in UTF-8 content');
|
|
70
|
+
}
|
|
71
|
+
// Handle optional shebang line (if line starts with "#!").
|
|
72
|
+
if (yiniContent.startsWith('#!')) {
|
|
73
|
+
const newlineIndex = yiniContent.indexOf('\n');
|
|
74
|
+
(0, print_1.devPrint)('runParse(..): Shebang detected at first line, stripped line 1.');
|
|
75
|
+
if (newlineIndex < 2) {
|
|
76
|
+
throw new Error('Syntax-Error: Unexpected YINI input');
|
|
77
|
+
}
|
|
78
|
+
yiniContent = yiniContent.slice(newlineIndex + 1);
|
|
79
|
+
}
|
|
63
80
|
// Runtime guard to catch illegal/ambiguous calls coming from JS or any-cast code
|
|
64
|
-
if ((0,
|
|
81
|
+
if ((0, optionsFunctions_1.isOptionsObjectForm)(arg2) &&
|
|
65
82
|
(failLevel !== 'auto' || includeMetadata !== false)) {
|
|
66
83
|
throw new TypeError('Invalid call: when providing an options object, do not also pass positional parameters.');
|
|
67
84
|
}
|
|
68
|
-
const mode = (0,
|
|
69
|
-
const defaultOptions = (0,
|
|
85
|
+
const mode = (0, optionsFunctions_1.inferModeFromArgs)(arg2);
|
|
86
|
+
const defaultOptions = (0, defaultParserOptions_1.getDefaultUserOptions)(mode);
|
|
70
87
|
// Normalize to a fully-required options object.
|
|
71
88
|
let userOpts;
|
|
72
89
|
// Required, makes all properties in T required, no undefined.
|
|
73
|
-
if ((0,
|
|
90
|
+
if ((0, optionsFunctions_1.isOptionsObjectForm)(arg2)) {
|
|
74
91
|
userOpts = {
|
|
75
92
|
...defaultOptions, // Sets the default options.
|
|
76
93
|
...arg2,
|
|
@@ -101,14 +118,14 @@ class YiniRuntime {
|
|
|
101
118
|
yiniContent += '\n';
|
|
102
119
|
}
|
|
103
120
|
let level = (0, failLevel_1.mapFailLevelToBail)(userOpts.strictMode, userOpts.failLevel);
|
|
104
|
-
const coreOpts = (0,
|
|
121
|
+
const coreOpts = (0, optionsFunctions_1.toCoreOptions)(userOpts, level);
|
|
105
122
|
(0, print_1.debugPrint)();
|
|
106
123
|
(0, print_1.debugPrint)('==== Call runPipeline(..) ==========================');
|
|
107
124
|
const result = (0, pipeline_1.runPipeline)(yiniContent, coreOpts, __classPrivateFieldGet(this, _YiniRuntime_runtime, "f"), userOpts);
|
|
108
125
|
(0, print_1.debugPrint)('==== End call runPipeline ==========================\n');
|
|
109
126
|
if ((0, env_1.isDev)()) {
|
|
110
127
|
console.log();
|
|
111
|
-
(0, print_1.devPrint)('
|
|
128
|
+
(0, print_1.devPrint)('runParse(..): result:');
|
|
112
129
|
console.log(result);
|
|
113
130
|
(0, print_1.devPrint)('Complete result:');
|
|
114
131
|
(0, print_1.printObject)(result);
|
|
@@ -123,16 +140,16 @@ class YiniRuntime {
|
|
|
123
140
|
(0, print_1.debugPrint)('-> Entered doParseFile(..) in YiniRuntime class\n');
|
|
124
141
|
(0, print_1.debugPrint)('Current directory = ' + process.cwd());
|
|
125
142
|
// Runtime guard to catch illegal/ambiguous calls coming from JS or any-cast code
|
|
126
|
-
if ((0,
|
|
143
|
+
if ((0, optionsFunctions_1.isOptionsObjectForm)(arg2) &&
|
|
127
144
|
(failLevel !== 'auto' || includeMetadata !== false)) {
|
|
128
145
|
throw new TypeError('Invalid call: when providing an options object, do not also pass positional parameters.');
|
|
129
146
|
}
|
|
130
|
-
const mode = (0,
|
|
131
|
-
const defaultOptions = (0,
|
|
147
|
+
const mode = (0, optionsFunctions_1.inferModeFromArgs)(arg2);
|
|
148
|
+
const defaultOptions = (0, defaultParserOptions_1.getDefaultUserOptions)(mode);
|
|
132
149
|
// Normalize to a fully-required options object.
|
|
133
150
|
let userOpts;
|
|
134
151
|
// Required, makes all properties in T required, no undefined.
|
|
135
|
-
if ((0,
|
|
152
|
+
if ((0, optionsFunctions_1.isOptionsObjectForm)(arg2)) {
|
|
136
153
|
// Options-object Form.
|
|
137
154
|
userOpts = {
|
|
138
155
|
...defaultOptions, // Sets the default options.
|
|
@@ -149,9 +166,13 @@ class YiniRuntime {
|
|
|
149
166
|
};
|
|
150
167
|
}
|
|
151
168
|
if ((0, pathAndFileName_1.getFileNameExtension)(filePath).toLowerCase() !== '.yini') {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
169
|
+
// IMPORTANT: If "silent" option is set, do not log anything to console!
|
|
170
|
+
if (!userOpts.silent) {
|
|
171
|
+
// In quiet-mode we still show errors (these are fine).
|
|
172
|
+
console.error('Invalid file extension for YINI file:');
|
|
173
|
+
console.error(`"${filePath}"`);
|
|
174
|
+
console.error('File does not have a valid ".yini" extension (case-insensitive).');
|
|
175
|
+
}
|
|
155
176
|
throw new Error('Error: Unexpected file extension for YINI file');
|
|
156
177
|
}
|
|
157
178
|
// ---- Phase 0: I/O ----
|
|
@@ -163,10 +184,11 @@ class YiniRuntime {
|
|
|
163
184
|
const timeEndMs = performance.now();
|
|
164
185
|
// this.#runtime.sourceType = 'File'
|
|
165
186
|
__classPrivateFieldGet(this, _YiniRuntime_runtime, "f").fileName = filePath;
|
|
187
|
+
__classPrivateFieldGet(this, _YiniRuntime_runtime, "f").timeIoMs = +(timeEndMs - timeStartMs).toFixed(3); // NOTE: (!) Dependent of isWithTiming.
|
|
166
188
|
if (userOpts.includeMetadata) {
|
|
167
189
|
__classPrivateFieldGet(this, _YiniRuntime_runtime, "f").lineCount = content.split(/\r?\n/).length; // Counts the lines.
|
|
168
190
|
__classPrivateFieldGet(this, _YiniRuntime_runtime, "f").fileByteSize = fileByteSize;
|
|
169
|
-
|
|
191
|
+
// this.#runtime.timeIoMs = +(timeEndMs - timeStartMs).toFixed(3) // NOTE: (!) Dependent of isWithTiming.
|
|
170
192
|
__classPrivateFieldGet(this, _YiniRuntime_runtime, "f").preferredBailSensitivity = userOpts.failLevel;
|
|
171
193
|
__classPrivateFieldGet(this, _YiniRuntime_runtime, "f").sha256 = (0, string_1.computeSha256)(content); // NOTE: Compute BEFORE any possible tampering of content.
|
|
172
194
|
}
|
|
@@ -175,11 +197,16 @@ class YiniRuntime {
|
|
|
175
197
|
content += '\n';
|
|
176
198
|
hasNoNewlineAtEOF = true;
|
|
177
199
|
}
|
|
178
|
-
const result = this.
|
|
200
|
+
const result = this.runParse(content, {
|
|
179
201
|
...userOpts,
|
|
180
202
|
});
|
|
181
|
-
if (hasNoNewlineAtEOF && !userOpts.
|
|
182
|
-
|
|
203
|
+
// if (hasNoNewlineAtEOF && !userOpts.quiet && !userOpts.silent) {
|
|
204
|
+
if (hasNoNewlineAtEOF && !userOpts.quiet) {
|
|
205
|
+
// IMPORTANT: If "silent" option is set, do not log anything to console!
|
|
206
|
+
if (!userOpts.silent) {
|
|
207
|
+
//@todo: (or maybe not, 20250917) Maybe let errorHandler emit message
|
|
208
|
+
console.warn(`No newline at end of file, it's recommended to end a file with a newline. File:\n"${filePath}"`);
|
|
209
|
+
}
|
|
183
210
|
}
|
|
184
211
|
return result;
|
|
185
212
|
}
|
package/dist/core/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/core/runtime.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,4CAAmB;AACnB,uCAAqC;AAErC,8DAA+D;AAC/D,0CAAkE;AAClE,4CAA+C;AAO/C,mDAAwD;AACxD,iEAImC;AACnC,
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/core/runtime.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,4CAAmB;AACnB,uCAAqC;AAErC,8DAA+D;AAC/D,0CAAkE;AAClE,4CAA+C;AAO/C,yEAAsE;AACtE,mDAAwD;AACxD,iEAImC;AACnC,kDAAiD;AAEjD;;;;;;;;;;GAUG;AACH,MAAa,WAAW;IAMpB,YAAY,UAA6B;QALzC;;WAEG;QACH,uCAAsB;QAGlB,uBAAA,IAAI,wBAAY,IAAI,CAAC,eAAe,EAAE,MAAA,CAAA;QACtC,uBAAA,IAAI,4BAAS,CAAC,UAAU,GAAG,UAAU,CAAA;IACzC,CAAC;IAEO,eAAe;QACnB,OAAO;YACH,UAAU,EAAE,QAAQ;YACpB,QAAQ,EAAE,SAAS;YACnB,YAAY,EAAE,IAAI;YAClB,SAAS,EAAE,IAAI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AuC;QAEtG,IAAI,QAAQ,CAAC,eAAe,EAAE,CAAC;YAC3B,uBAAA,IAAI,4BAAS,CAAC,SAAS,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,MAAM,CAAA,CAAC,oBAAoB;YAC5E,uBAAA,IAAI,4BAAS,CAAC,YAAY,GAAG,YAAY,CAAA;YACzC,yGAAyG;YACzG,uBAAA,IAAI,4BAAS,CAAC,wBAAwB,GAAG,QAAQ,CAAC,SAAS,CAAA;YAC3D,uBAAA,IAAI,4BAAS,CAAC,MAAM,GAAG,IAAA,sBAAa,EAAC,OAAO,CAAC,CAAA,CAAC,0DAA0D;QAC5G,CAAC;QAED,IAAI,iBAAiB,GAAG,KAAK,CAAA;QAC7B,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,IAAI,CAAA;YACf,iBAAiB,GAAG,IAAI,CAAA;QAC5B,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YAClC,GAAG,QAAQ;SACd,CAAC,CAAA;QACF,kEAAkE;QAClE,IAAI,iBAAiB,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;YACvC,wEAAwE;YACxE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;gBACnB,qEAAqE;gBACrE,OAAO,CAAC,IAAI,CACR,qFAAqF,QAAQ,GAAG,CACnG,CAAA;YACL,CAAC;QACL,CAAC;QAED,OAAO,MAAM,CAAA;IACjB,CAAC;CACJ;AAnRD,kCAmRC"}
|
package/dist/dev/main.js
CHANGED
|
@@ -171,116 +171,41 @@ else {
|
|
|
171
171
|
// < SubTitle // NOT OK, SubTitle already exists
|
|
172
172
|
// theme2 = "special-dark"
|
|
173
173
|
// `
|
|
174
|
-
// Arrange.
|
|
175
174
|
/*
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
//
|
|
179
|
-
|
|
180
|
-
^ App
|
|
181
|
-
name = 'YINI Demo Service'
|
|
182
|
-
version = '1.4.0'
|
|
183
|
-
description = 'Demo service for showcasing the YINI format'
|
|
184
|
-
owners = ['dev-team', 'ops-team']
|
|
185
|
-
|
|
186
|
-
// String concatenation (the '+' joins adjacent STRING tokens)
|
|
187
|
-
-- longNote = 'This text is split across ' +
|
|
188
|
-
-- 'two strings and then concatenated.'
|
|
189
|
-
|
|
190
|
-
// Case-insensitive booleans
|
|
191
|
-
enabled = YES
|
|
192
|
-
experimentalMode = off
|
|
193
|
-
|
|
194
|
-
// Numbers (ints, floats, scientific)
|
|
195
|
-
retries = 3
|
|
196
|
-
requestTimeoutMs = 2500
|
|
197
|
-
backoffFactor = 1.25
|
|
198
|
-
maxPayloadMB = 1.0e2
|
|
199
|
-
|
|
200
|
-
^ Server
|
|
201
|
-
host = '127.0.0.1'
|
|
202
|
-
port = 8080
|
|
203
|
-
useTLS = false
|
|
204
|
-
|
|
205
|
-
^^ CORS
|
|
206
|
-
allowedOrigins: 'https://example.com', 'https://admin.example.com'
|
|
207
|
-
allowCredentials = true
|
|
208
|
-
|
|
209
|
-
^^ Headers
|
|
210
|
-
// Object literal with key:value pairs
|
|
211
|
-
defaults = {
|
|
212
|
-
\`X-Frame-Options\`: 'DENY',
|
|
213
|
-
\`X-Content-Type-Options\`: 'nosniff'
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
^ Database
|
|
217
|
-
engine = 'postgres'
|
|
218
|
-
host = 'db.internal'
|
|
219
|
-
port = 5432
|
|
220
|
-
username = 'app_user'
|
|
221
|
-
password = 'change_me'
|
|
222
|
-
pool = {
|
|
223
|
-
min: 2,
|
|
224
|
-
max: 16
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
^^ Replicas
|
|
228
|
-
// Colon-form list (values only)
|
|
229
|
-
endpoints: 'db-replica-1.internal', 'db-replica-2.internal'
|
|
230
|
-
readPreference = 'nearest'
|
|
231
|
-
|
|
232
|
-
^ Features
|
|
233
|
-
// Mixed data types
|
|
234
|
-
betaFlags = ['new-ui', 'fast-path']
|
|
235
|
-
darkLaunch = NO
|
|
236
|
-
uploadLimitMB = 128
|
|
237
|
-
|
|
238
|
-
^ Integrations
|
|
239
|
-
// List of objects
|
|
240
|
-
webhooks = [
|
|
241
|
-
{ name: 'audit', url: 'https://hooks.example.com/audit', active: true },
|
|
242
|
-
{ name: 'metrics', url: 'https://hooks.example.com/metric', active: true }
|
|
243
|
-
]
|
|
244
|
-
|
|
245
|
-
^ Users
|
|
246
|
-
// Simple table-ish list using colon form
|
|
247
|
-
admins: 'alice', 'bob', 'carol'
|
|
248
|
-
reviewers: 'dave', 'erin'
|
|
249
|
-
|
|
250
|
-
^^ Profiles
|
|
251
|
-
// Object-of-objects
|
|
252
|
-
alice = {
|
|
253
|
-
email: 'alice@example.com',
|
|
254
|
-
roles: ['admin', 'dev'],
|
|
255
|
-
mfa: true
|
|
256
|
-
}
|
|
257
|
-
bob = {
|
|
258
|
-
email: 'bob@example.com',
|
|
259
|
-
roles: ['admin'],
|
|
260
|
-
mfa: false
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
^ Paths
|
|
264
|
-
logs = '/var/log/yini-demo/'
|
|
265
|
-
data = '/srv/yini-demo/data'
|
|
266
|
-
|
|
267
|
-
^^ \`Backups\`
|
|
268
|
-
// Empty value -> null in lenient mode; in strict mode, supply explicit null:
|
|
269
|
-
lastFull = null
|
|
270
|
-
targets: '/mnt/backup1', '/mnt/backup2'
|
|
271
|
-
^^^ Backups2
|
|
272
|
-
value = 23
|
|
273
|
-
|
|
274
|
-
^ Security
|
|
275
|
-
allowedIPs: '10.0.0.0/24', '10.1.0.0/24'
|
|
175
|
+
const errorYini = `
|
|
176
|
+
^ Section1
|
|
177
|
+
333="oops" // invalid key => error
|
|
178
|
+
`
|
|
276
179
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
180
|
+
const warnYini = `
|
|
181
|
+
^ Section2
|
|
182
|
+
// => warning, if requireDocTerminator: 'warn-if-missing'
|
|
183
|
+
`
|
|
184
|
+
console.log(
|
|
185
|
+
toPrettyJSON(
|
|
186
|
+
YINI.parse(
|
|
187
|
+
`
|
|
188
|
+
^ App
|
|
189
|
+
title = 'My App'
|
|
190
|
+
items = 25
|
|
191
|
+
darkMode = true // "ON"/"YES" also work
|
|
281
192
|
|
|
282
|
-
|
|
283
|
-
|
|
193
|
+
^^ Special
|
|
194
|
+
primaryColor = #336699
|
|
195
|
+
keywords = [ "alpha", "beta", "release" ]
|
|
196
|
+
`,
|
|
197
|
+
{
|
|
198
|
+
// failLevel: 'errors',
|
|
199
|
+
throwOnError: false,
|
|
200
|
+
// requireDocTerminator: 'warn-if-missing',
|
|
201
|
+
strictMode: true,
|
|
202
|
+
silent: false,
|
|
203
|
+
includeMetadata: true,
|
|
204
|
+
},
|
|
205
|
+
),
|
|
206
|
+
),
|
|
207
|
+
)
|
|
208
|
+
*/
|
|
284
209
|
// const yini = `
|
|
285
210
|
// /*sdfsdf*/
|
|
286
211
|
// @yini
|
|
@@ -325,16 +250,18 @@ else {
|
|
|
325
250
|
// bool5 = yes
|
|
326
251
|
// bool6 = no
|
|
327
252
|
// `
|
|
328
|
-
//
|
|
329
|
-
//
|
|
330
|
-
//
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
253
|
+
// const yiniContent = `#!/usr/bin/env yini
|
|
254
|
+
// ^ App
|
|
255
|
+
// name = "Shebang-demo"`
|
|
256
|
+
const yiniContent = ` #!/usr/bin/env yini
|
|
257
|
+
^ App
|
|
258
|
+
name = "Shebang-demo"`;
|
|
259
|
+
console.log((0, print_1.toPrettyJSON)(YINI_1.default.parse(yiniContent, {
|
|
260
|
+
strictMode: true,
|
|
261
|
+
failLevel: 'auto',
|
|
262
|
+
includeMetadata: false,
|
|
263
|
+
requireDocTerminator: 'optional',
|
|
264
|
+
})));
|
|
338
265
|
// console.log(
|
|
339
266
|
// toPrettyJSON(
|
|
340
267
|
// YINI.parseFile(
|
|
@@ -345,8 +272,11 @@ else {
|
|
|
345
272
|
// ),
|
|
346
273
|
// ),
|
|
347
274
|
// )
|
|
348
|
-
const result =
|
|
349
|
-
|
|
275
|
+
// const result: YiniParseResult = YINI.parseFile(
|
|
276
|
+
// 'comprehensive-example.yini',
|
|
277
|
+
// { includeMetadata: true },
|
|
278
|
+
// )
|
|
279
|
+
// console.log(toPrettyJSON('' + result.meta))
|
|
350
280
|
// console.log(
|
|
351
281
|
// toPrettyJSON(
|
|
352
282
|
// YINI.parseFile('comprehensive-example.yini', {
|
|
@@ -356,16 +286,31 @@ else {
|
|
|
356
286
|
// }),
|
|
357
287
|
// ),
|
|
358
288
|
// )
|
|
359
|
-
// const fileName = './tests/fixtures/
|
|
360
|
-
// YINI.parseFile(fileName, {
|
|
361
|
-
// strictMode:
|
|
362
|
-
// failLevel: '
|
|
363
|
-
// includeMetadata: true,
|
|
289
|
+
// const fileName = './tests/fixtures/invalid/corrupt-config-2.yini'
|
|
290
|
+
// const result = YINI.parseFile(fileName, {
|
|
291
|
+
// strictMode: true,
|
|
292
|
+
// failLevel: 'ignore-errors',
|
|
364
293
|
// })
|
|
294
|
+
// printObject(result)
|
|
295
|
+
// let parserOptions: any = getDefaultUserOptions('lenient')
|
|
296
|
+
// debugPrint('** parserOptions: (lenient)')
|
|
297
|
+
// isDebug() && printObject(parserOptions)
|
|
298
|
+
// isDebug() &&
|
|
299
|
+
// console.log(
|
|
300
|
+
// 'derived mode = ' + matchModeFromParseOptions(parserOptions),
|
|
301
|
+
// )
|
|
302
|
+
// parserOptions = getDefaultUserOptions('strict')
|
|
303
|
+
// debugPrint('** parserOptions: (strict)')
|
|
304
|
+
// isDebug() && printObject(parserOptions)
|
|
305
|
+
// isDebug() &&
|
|
306
|
+
// console.log(
|
|
307
|
+
// 'derived mode = ' +
|
|
308
|
+
// matchModeFromCoreOptions(toCoreOptions(parserOptions)),
|
|
309
|
+
// )
|
|
365
310
|
// const fileName =
|
|
366
311
|
// './tests/fixtures/invalid/bad-user-profile-config-2.yini'
|
|
367
312
|
// YINI.parseFile(fileName, {
|
|
368
|
-
// strictMode:
|
|
313
|
+
// strictMode: false,
|
|
369
314
|
// failLevel: 'auto',
|
|
370
315
|
// includeMetadata: true,
|
|
371
316
|
// })
|
package/dist/dev/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/dev/main.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;AAEH,uCAQsB;
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/dev/main.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;;;AAEH,uCAQsB;AAUtB,0CAAsE;AACtE,mDAA0B;AAE1B,IAAA,kBAAU,GAAE,CAAA;AACZ,IAAA,kBAAU,EAAC,wBAAwB,CAAC,CAAA;AACpC,IAAA,kBAAU,GAAE,CAAA;AAEZ,IAAI,IAAA,WAAK,GAAE,IAAI,IAAA,aAAO,GAAE,EAAE,CAAC;IACvB,OAAO,CAAC,GAAG,CAAC,4BAA4B,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,CAAC,CAAA;IACjE,OAAO,CAAC,GAAG,CAAC,4BAA4B,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,CAAC,CAAA;IAChE,OAAO,CAAC,GAAG,CAAC,4BAA4B,OAAO,CAAC,GAAG,EAAE,QAAQ,GAAG,CAAC,CAAA;IAEjE,IAAA,kBAAU,GAAE,CAAA;IACZ,OAAO,CAAC,GAAG,CAAC,mBAAmB,kBAAY,GAAG,CAAC,CAAA;IAC/C,OAAO,CAAC,GAAG,CAAC,mBAAmB,iBAAW,GAAG,CAAC,CAAA;IAC9C,OAAO,CAAC,GAAG,CAAC,iBAAiB,GAAG,IAAA,eAAS,GAAE,CAAC,CAAA;IAC5C,OAAO,CAAC,GAAG,CA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oBAAoB;QACpB,aAAa;QACb,SAAS;QACT,IAAI;QAEJ,kDAAkD;QAClD,oCAAoC;QACpC,iCAAiC;QACjC,IAAI;QACJ,8CAA8C;QAE9C,eAAe;QACf,oBAAoB;QACpB,yDAAyD;QACzD,iCAAiC;QACjC,iCAAiC;QACjC,qCAAqC;QACrC,cAAc;QACd,SAAS;QACT,IAAI;QAEJ,oEAAoE;QACpE,4CAA4C;QAC5C,wBAAwB;QACxB,kCAAkC;QAClC,KAAK;QACL,sBAAsB;QAEtB,4DAA4D;QAC5D,4CAA4C;QAC5C,0CAA0C;QAC1C,eAAe;QACf,mBAAmB;QACnB,wEAAwE;QACxE,QAAQ;QAER,kDAAkD;QAClD,2CAA2C;QAC3C,0CAA0C;QAC1C,eAAe;QACf,mBAAmB;QACnB,8BAA8B;QAC9B,sEAAsE;QACtE,QAAQ;QAER,mBAAmB;QACnB,gEAAgE;QAChE,6BAA6B;QAC7B,yBAAyB;QACzB,yBAAyB;QACzB,6BAA6B;QAC7B,KAAK;IACT,CAAC;AACL,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
// Generated from grammar/v1.0.0-rc.3/YiniLexer.g4 by ANTLR 4.13.2
|
|
3
|
+
// Generated from ./grammar/v1.0.0-rc.3/YiniLexer.g4 by ANTLR 4.13.2
|
|
4
4
|
// noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols
|
|
5
5
|
const antlr4_1 = require("antlr4");
|
|
6
6
|
class YiniLexer extends antlr4_1.Lexer {
|