yini-parser 1.0.1-beta → 1.0.2-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 CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.0.2-beta - 2025 Aug
4
+ - Fixed issues with floats, including negative and exponential numbers with new test files here: `tests/fixed-issues/issue-32/*`
5
+ - Fixed an issue where parseFile(..) did not output a warning when parsing a file missing a newline at EOF. Plus added test cases to check that it is fixed (in `tests/fixed-issues/issue-30`).
6
+ - Fixed and improved number parsing to fully support negative values and edge cases for integers, floats, hex, bin, octal, duodecimal, and exponential numbers. Based on updated lexer and parser grammar files, and added extensive tests to ensure correct and robust handling. Here: `tests/integration/6-number-literals/*`
7
+
3
8
  ## 1.0.1-beta - 2025 Aug
4
9
  - Fixed catching lexer related errors correctly.
5
10
  - Improves error and test handling for invalid YINI syntax.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # YINI Parser for Node.js
2
2
 
3
- YINI is a clean, minimal, and human-readable config format for structured configuration. This parser implements the YINI spec in TypeScript for Node.js, with support for nested sections, strict/lenient modes, and typed values.
3
+ A TypeScript/Node.js parser for YINI A type-safe, structured, and human-readable config format with nested sections, types, comments, and support for strict validation.
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/yini-parser.svg)](https://www.npmjs.com/package/yini-parser) [![All Tests](https://github.com/YINI-lang/yini-parser-typescript/actions/workflows/run-all-tests.yml/badge.svg)](https://github.com/YINI-lang/yini-parser-typescript/actions/workflows/run-all-tests.yml)
6
6
 
@@ -13,7 +13,7 @@ import YINI from 'yini-parser'
13
13
  const config = YINI.parseFile('./config.yini')
14
14
  ```
15
15
 
16
- A clean, minimal, human-readable config formatdesigned as an alternative to INI, YAML, and JSON.
16
+ YINI (Yet another INI): YINI is a configuration format designed for readability and structure, inspired by INI and YAML.
17
17
 
18
18
  ➡️ See full [documentation or YINI format specification](https://github.com/YINI-lang/YINI-spec)
19
19
 
@@ -34,6 +34,28 @@ YINI is a simple, human-friendly configuration format inspired by INI and JSON.
34
34
 
35
35
  ---
36
36
 
37
+ ## 🙋‍♀️ Why YINI?
38
+ - **YINI is an alternative** to other great config formats like INI, JSON, YAML, XML, and TOML — Supports section nesting and explicit syntax for configuration files.
39
+ - **Started as a personal project and a research challenge:** Provides structure similar to INI, with features inspired by JSON and YAML.
40
+ - **Built for clarity:**
41
+ * Uses a concise syntax to minimize unnecessary characters.
42
+ * Supports commonly used configuration structures.
43
+ - *Developed to meet practical needs, driven by curiosity and a desire **for configuration clarity, simplicity, minimalism, and flexibility**.
44
+
45
+ ---
46
+
47
+ ## 💡 What is YINI?
48
+ - **Simple like INI** — but with strong typing, comments, and nested sections.
49
+ - **Provides concise, structured syntax** for configuration.
50
+ - Supports section nesting **without requiring indentation or dot-delimited keys**.
51
+ - This repo/parser is built for both **JavaScript and TypeScript**.
52
+ - **Supports strict and lenient modes**, and all major data types.
53
+ - Can be **edited manually** or **processed programmatically**.
54
+ - 👉 See [how YINI compares with JSON, YAML, INI, and TOML](https://github.com/YINI-lang/yini-parser-typescript/tree/main/examples/compare-formats.md).
55
+ - Want the full syntax reference? See the [YINI Specification](https://github.com/YINI-lang/YINI-spec).
56
+
57
+ ---
58
+
37
59
  ## Quick Start
38
60
 
39
61
  A minimal example using YINI in TypeScript:
@@ -81,232 +103,15 @@ false
81
103
 
82
104
  That's it!
83
105
 
84
- ▶️ Link to [examples/](https://github.com/YINI-lang/yini-parser-typescript/tree/main/examples) files.
106
+ - ▶️ Link to [examples/](https://github.com/YINI-lang/yini-parser-typescript/tree/main/examples) files.
107
+ - ▶️ Link to [Demo Apps](https://github.com/YINI-lang/yini-demo-apps/tree/main) with complete basic usage.
85
108
 
86
- ## 💡 Why YINI?
87
- - **Easy to read and write**, minimal syntax noise, maximum clarity.
88
- - **Clear and minimal section nesting** without painful indentation rules or long dot nested strings, etc.
89
- - A perfect alternative to messy JSON, legacy INI, or complex YAML.
90
- - Built for both **JavaScript and TypeScript**.
91
- - **Supports strict/lenient modes**, and all major data types.
92
- - Both **human-friendly**, and **machine-friendly**.
93
- - 👉 See [how YINI compares to JSON, YAML, INI, and TOML](https://github.com/YINI-lang/yini-parser-typescript/tree/main/examples/compare-formats.md).
94
- - Want the full syntax reference? See the [YINI Specification](https://github.com/YINI-lang/YINI-spec).
95
-
96
109
  ---
97
110
 
98
111
  ## Intro to YINI Config Format
112
+ **YINI** is a simple and readable configuration format. Sections are defined with `^ SectionName`, and values are assigned using `key = value`. The format supports common data types (same as those found in JSON), including strings, numbers, booleans, nulls, and lists.
99
113
 
100
- ### 1. Sections
101
- Group settings under a named header. A section header name starts with `^`.
102
-
103
- Start a section with `^`, e.g.:
104
- ```yini
105
- ^ App
106
- title = "AppName"
107
- ```
108
-
109
- > Alternative section markers to `^` are also supported: `<`, `§`, `€` (e.g. `< Section`).
110
-
111
- > See section 9 for more advanced marker and naming options.
112
-
113
- ### 2. Key = Value
114
- Each line inside a section is a **key** (name) and **value**, separated by `=`.
115
-
116
- Write settings as `key = value`:
117
- ```yini
118
- maxConnections = 100
119
- enableLogging = true
120
- ```
121
-
122
- > See section 9 for more advanced marker and naming options.
123
-
124
- #### 💡Tip
125
- Use backticks (\`) to quote section or key names that contain spaces or special characters.
126
-
127
- Key names with spaces/special characters can be backticked:
128
-
129
- ```yini
130
- user id = 1 # Invalid ❌
131
- `user id` = 1 # Valid ✅
132
- ```
133
-
134
- ### 3. Values
135
- Values can be:
136
- - **Strings** (always quoted): `'hello'` or `"world"` (either single or double quoted)
137
- - **Numbers:** `42`, `3.14` or `-10`
138
- - **Booleans:** `true`, `false`, `on`, `off`, `yes`, `no` (all case-insensitive)
139
- - **Nulls:** Use `null` or leave the value blank after `=` (in lenient mode)
140
- - **Lists:**
141
- * JSON‑style: `["red", "green", "blue"]`
142
- * Colon‑style: *(Planned – not yet implemented in parser)*
143
-
144
- ### 4. Comments
145
- Various commenting styles are supported:
146
- ```yini
147
- // This is a line comment
148
- timeout = 30 // inline comment
149
- # This is also a line comment (must have a space after #)
150
- interval = 30 # inline comment (must have a space after #)
151
- /* Block comment spanning
152
- multiple lines */
153
- ; Full line comment (must be whole line).
154
- ```
155
-
156
- > **Tip:** You can add comments anywhere—above, beside, or below any setting or section.
157
- >
158
- 👆 **Caveat 1:** If you use `#` for comments, always put a space after the `#`.
159
- (Otherwise, the parser might misinterpret it as part of a value.)
160
-
161
- 👆 **Caveat 2:** `;` is used only for full-line comments. The `;` must be the first non-whitespace character on a line (only spaces or tabs are allowed before it).
162
- (If `;` appears later in the line, the parser may treat it as part of a value or as a line delimiter, not as a comment.)
163
-
164
- 💡**Tip:** You can use any comment style in your file.
165
- For best readability, try to stick to one style per file.
166
-
167
- ### 5. Nested Sections
168
- Use extra carets `^` for sub‑sections:
169
- ```yini
170
- ^ Parent
171
- ^^ Child
172
-
173
- // Add another caret `^` and you get a sub-section
174
- // of the previous section, and so...
175
- ^^^ SubChild
176
- ```
177
-
178
- If you prefer, you can indent the nested section for visibility:
179
- ```yini
180
- ^ Main
181
- ^^ Sub
182
- host = "db.example.com"
183
- ```
184
-
185
- One can nest multiple sections:
186
- ```yini
187
- ^ Root
188
- ^^ Sub
189
- ^^^ SubSub
190
- ^ BackToRoot
191
- ```
192
-
193
- Example with indented sections:
194
- ```yini
195
- ^ Root
196
- value = 'At level 1'
197
- ^^ Sub
198
- value = 'At level 2'
199
- ^^^ SubSub
200
- value = 'At level 3'
201
-
202
- ^ BackToRoot
203
- value = 'Back at level 1'
204
- ```
205
-
206
- The above Yini code will produce the following JavaScript object:
207
- ```js
208
- // JS object
209
- {
210
- Root: {
211
- value: 'At level 1',
212
- Sub: { value: 'At level 2', SubSub: { value: 'At level 3' } }
213
- },
214
- BackToRoot: { value: 'Back at level 1' }
215
- }
216
- ```
217
-
218
- > See section 9 for more advanced marker and naming options.
219
-
220
- ### 6. Lists
221
- ```yini
222
- // JSON‑style lists
223
- colors = ["red", "green", "blue"]
224
-
225
- numberList = [
226
- 10,
227
- 20,
228
- 30
229
- ]
230
-
231
-
232
- // Colon‑style list
233
- // 👆 Colon‑style list support is planned for an upcoming release.
234
- fruits:
235
- "Pear",
236
- "Cherry",
237
- "Banana"
238
- ```
239
-
240
- > You can use either single or double quotes for string values in YINI.
241
-
242
- ### 7. Document Terminator (strict mode)
243
- The `/END` marker is required only in strict mode, and optional in lenient (default) mode.
244
-
245
- End a file explicitly with:
246
- ```yini
247
- ^ App
248
- title = "MyTitle"
249
-
250
- /END // Must be included in strict mode.
251
- ```
252
-
253
- ### 8. Disabled Lines
254
- Prefix any valid line with `--` to skip it entirely:
255
- ```yini
256
- --maxRetries = 5
257
- ```
258
-
259
- ### 9. Advanced: Alternative Section Markers & Naming
260
- In addition to the standard syntax, YINI supports several advanced options:
261
-
262
- - (a.) **Alternative section markers:**
263
- Besides `^`, you can use `<`, `§`, or `€` as section header markers.
264
-
265
- ```yini
266
- < MySection
267
- § Settings
268
- € MyApp
269
- ```
270
-
271
- - (b.) **Backticked section names and key names:**
272
- Use backticks (`) to allow spaces or special characters in section or key names:
273
-
274
- ```yini
275
- ^ `Section name with spaces`
276
- `user id` = 42
277
- ```
278
-
279
- - (c.) **Numeric shorthand section markers:**
280
- To create deeply nested sections (beyond 6 levels), use numeric shorthand:
281
-
282
- ```yini
283
- ^7 DeepSection # Equivalent to 7 carets: ^^^^^^^ DeepSection
284
- <10 VeryDeep # Equivalent to <<<<<<<<<<< VeryDeep
285
- ```
286
-
287
- 👆 Though, can not mix standard/classic and numeric shorthand markers in the same section header.
288
-
289
- - (d.) **More features:**
290
- The YINI format supports even more features than listed here, such as additional number notations, string types, and advanced escaping. For full details, see the [latest release of the YINI specification](https://github.com/YINI-lang/YINI-spec/blob/release/YINI-Specification.md).
291
-
292
- ### 10. Complete Example
293
-
294
- ```yini
295
- @yini # Optional marker to identify YINI format.
296
-
297
- ^ App
298
- name = "MyApp"
299
- version = "1.0.0"
300
- debug = off // Turn on for debugging.
301
-
302
- ^^ Database
303
- host = "db.local"
304
- port = 5432
305
- --user = "secret" # This line is disabled due to --.
306
- userList = ["alice", "bob", "carol"]
307
-
308
- /END
309
- ```
114
+ To learn more, see the [Getting Started: Intro to YINI Config Format](https://github.com/YINI-lang/YINI-spec/blob/develop/Docs/Intro-to-YINI-Config-Format.md) tutorial.
310
115
 
311
116
  ---
312
117
 
@@ -544,13 +349,26 @@ We welcome feedback, bug reports, feature requests, and code contributions!
544
349
  ---
545
350
 
546
351
  ## Links
547
- - ➡️ [Why YINI? Why another format!?](./RATIONALE.md) (rationale)
548
- - ➡️ [Intro to YINI Config Format](https://github.com/YINI-lang/yini-parser-typescript?tab=readme-ov-file#intro-to-yini-config-format) (learn YINI)
549
- - ➡️ [Read the YINI Specification](./YINI-Specification.md#table-of-contents) (spec)
550
- - ➡️ [Official YINI Parser on npm](https://www.npmjs.com/package/yini-parser) (npm)
551
- - ➡️ [YINI Parser GitHub Repo](https://github.com/YINI-lang/yini-parser-typescript) (GitHub)
552
- - ➡️ [YINI vs Other Formats](https://github.com/YINI-lang/YINI-spec/blob/develop/Docs/Examples%20of%20YINI%20vs%20Other%20Formats.md)
553
- - ➡️ [YINI Project](https://github.com/YINI-lang) (home)
352
+ - ➡️ [Getting Started: Intro to YINI Config Format](https://github.com/YINI-lang/YINI-spec/blob/develop/Docs/Intro-to-YINI-Config-Format.md)
353
+ *Beginner-friendly walkthrough and basic usage examples.*
354
+
355
+ - ➡️ [YINI Parser on npm](https://www.npmjs.com/package/yini-parser)
356
+ *Install and view package details.*
357
+
358
+ - ➡️ [Read the YINI Specification](https://github.com/YINI-lang/YINI-spec/blob/release/YINI-Specification.md#table-of-contents)
359
+ *Full formal spec for the YINI format, including syntax and features.*
360
+
361
+ - ➡️ [YINI CLI on GitHub](https://github.com/YINI-lang/yini-cli)
362
+ *TypeScript source code, issue tracker, and contributing guide.*
363
+
364
+ - ➡️ [YINI vs Other Formats](https://github.com/YINI-lang/YINI-spec/tree/release#-summary-difference-with-other-formats)
365
+ *How does YINI differ: comparison with INI, YAML, and JSON.*
366
+
367
+ - ➡️ [Why YINI? (Project Rationale)](https://github.com/YINI-lang/YINI-spec/blob/release/RATIONALE.md)
368
+ *Learn about the motivations and design decisions behind YINI.*
369
+
370
+ - ➡️ [YINI Project](https://github.com/YINI-lang)
371
+ *YINI home.*
554
372
 
555
373
  ---
556
374
 
package/dist/YINI.js CHANGED
@@ -2,6 +2,7 @@
2
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
+ var _a;
5
6
  Object.defineProperty(exports, "__esModule", { value: true });
6
7
  const fs_1 = __importDefault(require("fs"));
7
8
  const env_1 = require("./config/env");
@@ -15,6 +16,7 @@ const print_1 = require("./utils/print");
15
16
  */
16
17
  class YINI {
17
18
  }
19
+ _a = YINI;
18
20
  YINI.filePath = ''; // Used in error reporting.
19
21
  /**
20
22
  * Parse YINI content into a JavaScript object.
@@ -43,14 +45,11 @@ YINI.parse = (yiniContent, strictMode = false, bailSensitivity = 'auto', include
43
45
  yiniContent += '\n';
44
46
  }
45
47
  let level = 0;
46
- // if (bailSensitivity === 'auto' && !strictMode) level = 0
47
- // if (bailSensitivity === 'auto' && strictMode) level = 1
48
48
  if (bailSensitivity === 'auto') {
49
49
  if (!strictMode)
50
50
  level = 0;
51
51
  if (strictMode)
52
52
  level = 1;
53
- // if (process.env.NODE_ENV === 'test') level = 1
54
53
  }
55
54
  else {
56
55
  level = bailSensitivity;
@@ -105,37 +104,10 @@ YINI.parseFile = (filePath, strictMode = false, bailSensitivity = 'auto', includ
105
104
  content += '\n';
106
105
  hasNoNewlineAtEOF = true;
107
106
  }
108
- YINI.filePath = filePath;
109
- let level = 0;
110
- // if (bailSensitivity === 'auto' && !strictMode) level = 0
111
- // if (bailSensitivity === 'auto' && strictMode) level = 1
112
- if (bailSensitivity === 'auto') {
113
- if (!strictMode)
114
- level = 0;
115
- if (strictMode)
116
- level = 1;
117
- // if (process.env.NODE_ENV === 'test') level = 1
118
- }
119
- else {
120
- level = bailSensitivity;
121
- }
122
- const options = {
123
- isStrict: strictMode,
124
- bailSensitivityLevel: level,
125
- isIncludeMeta: includeMetaData,
126
- isWithDiagnostics: (0, env_1.isDev)() || (0, env_1.isDebug)(),
127
- isWithTiming: (0, env_1.isDebug)(),
128
- };
129
- (0, print_1.debugPrint)();
130
- (0, print_1.debugPrint)('==== Call parse ==========================');
131
- const result = (0, parseEntry_1.parseMain)(content, options);
132
- (0, print_1.debugPrint)('==== End call parse ==========================\n');
133
- if ((0, env_1.isDev)()) {
134
- console.log();
135
- (0, print_1.devPrint)('YINI.parse(..): result:');
136
- console.log(result);
137
- (0, print_1.devPrint)('Complete result:');
138
- (0, print_1.printObject)(result);
107
+ _a.filePath = filePath;
108
+ const result = _a.parse(content, strictMode, bailSensitivity, includeMetaData);
109
+ if (hasNoNewlineAtEOF) {
110
+ console.warn(`No newline at end of file, it's recommended to end a file with a newline. File:\n"${filePath}"`);
139
111
  }
140
112
  return result;
141
113
  };
@@ -776,8 +776,6 @@ class YINIVisitor extends YiniParserVisitor_1.default {
776
776
  this.visitValue = (ctx) => {
777
777
  (0, env_1.isDebug)() && console.log();
778
778
  (0, print_1.debugPrint)('-> Entered visitValue(..)');
779
- (0, print_1.debugPrint)('ctx.number_literal(): ' + ctx.number_literal());
780
- (0, print_1.debugPrint)('ctx.boolean_literal(): ' + ctx.boolean_literal());
781
779
  if (ctx.string_literal())
782
780
  return this.visit(ctx.string_literal());
783
781
  if (ctx.number_literal())