yini-parser 1.0.0-alpha.7x → 1.0.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 CHANGED
@@ -1,10 +1,20 @@
1
1
  # CHANGELOG
2
2
 
3
- ## --Upcoming-- -beta
3
+ ## 1.0.1-beta - 2025 Aug
4
+ - Fixed catching lexer related errors correctly.
5
+ - Improves error and test handling for invalid YINI syntax.
6
+ - Grammar logic updated to catch bad systax specifically related to bad syntax for (key-value) members.
7
+ - Added another testing suite for reported and fixed tests.
8
+ - Added another testing suite for golden tests.
9
+ - Updated to the latest grammar (logic) version 1.0.0-rc.2.
10
+
11
+ ## 1.0.0-beta.1 - 2025-07-26
4
12
  - Package updated to **beta**. The core API is stabilizing, some more advanced features may still change.
13
+ - Bugfix, fixed exports cleanly (so this lib can be imported in CJS and in full ESM).
5
14
  - Implemented support for colon lists, both empty and with elements, including nested lists. Also updated to the latest grammar, which fixes handling of empty lists with or without spaces or tabs between the brackets.
6
15
  - Optimized the top part of readme for npmjs Short Page.
7
16
  - Added a dir `examples/` with a few example Yini files, `compare-formats.md` and TS file.
17
+ - Updated to the latest grammar (logic) version 1.0.0-rc.1.
8
18
 
9
19
  ## 1.0.0-alpha.7
10
20
  - Fixed serious bug that on error did exit process.
package/README.md CHANGED
@@ -71,7 +71,10 @@ false
71
71
  name: 'My Title',
72
72
  items: 25,
73
73
  darkMode: true,
74
- Special: { primaryColor: 3368601, isCaching: false }
74
+ Special: {
75
+ primaryColor: 3368601,
76
+ isCaching: false
77
+ }
75
78
  }
76
79
  }
77
80
  ```
@@ -540,6 +543,17 @@ We welcome feedback, bug reports, feature requests, and code contributions!
540
543
 
541
544
  ---
542
545
 
546
+ ## 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)
554
+
555
+ ---
556
+
543
557
  ## License
544
558
  This project is licensed under the Apache-2.0 license - see the [LICENSE](<./LICENSE>) file for details.
545
559
 
package/dist/YINI.js CHANGED
@@ -7,7 +7,7 @@ const fs_1 = __importDefault(require("fs"));
7
7
  const env_1 = require("./config/env");
8
8
  const parseEntry_1 = require("./parseEntry");
9
9
  const pathAndFileName_1 = require("./utils/pathAndFileName");
10
- const system_1 = require("./utils/system");
10
+ const print_1 = require("./utils/print");
11
11
  /**
12
12
  * This class is the public API, which exposes only parse(..) and
13
13
  * parseFile(..), rest of the implementation details are hidden.
@@ -33,7 +33,7 @@ YINI.filePath = ''; // Used in error reporting.
33
33
  * @returns A JavaScript object representing the parsed YINI content.
34
34
  */
35
35
  YINI.parse = (yiniContent, strictMode = false, bailSensitivity = 'auto', includeMetaData = false) => {
36
- (0, system_1.debugPrint)('-> Entered static parse(..) in class YINI\n');
36
+ (0, print_1.debugPrint)('-> Entered static parse(..) in class YINI\n');
37
37
  // Important: First, before anything, trim beginning and trailing whitespaces!
38
38
  yiniContent = yiniContent.trim();
39
39
  if (!yiniContent) {
@@ -50,8 +50,7 @@ YINI.parse = (yiniContent, strictMode = false, bailSensitivity = 'auto', include
50
50
  level = 0;
51
51
  if (strictMode)
52
52
  level = 1;
53
- if (process.env.NODE_ENV === 'test')
54
- level = 1;
53
+ // if (process.env.NODE_ENV === 'test') level = 1
55
54
  }
56
55
  else {
57
56
  level = bailSensitivity;
@@ -63,16 +62,16 @@ YINI.parse = (yiniContent, strictMode = false, bailSensitivity = 'auto', include
63
62
  isWithDiagnostics: (0, env_1.isDev)() || (0, env_1.isDebug)(),
64
63
  isWithTiming: (0, env_1.isDebug)(),
65
64
  };
66
- (0, system_1.debugPrint)();
67
- (0, system_1.debugPrint)('==== Call parse ==========================');
65
+ (0, print_1.debugPrint)();
66
+ (0, print_1.debugPrint)('==== Call parse ==========================');
68
67
  const result = (0, parseEntry_1.parseMain)(yiniContent, options);
69
- (0, system_1.debugPrint)('==== End call parse ==========================\n');
68
+ (0, print_1.debugPrint)('==== End call parse ==========================\n');
70
69
  if ((0, env_1.isDev)()) {
71
70
  console.log();
72
- (0, system_1.devPrint)('YINI.parse(..): result:');
71
+ (0, print_1.devPrint)('YINI.parse(..): result:');
73
72
  console.log(result);
74
- (0, system_1.devPrint)('Complete result:');
75
- (0, system_1.printObject)(result);
73
+ (0, print_1.devPrint)('Complete result:');
74
+ (0, print_1.printObject)(result);
76
75
  }
77
76
  return result;
78
77
  };
@@ -93,7 +92,7 @@ YINI.parse = (yiniContent, strictMode = false, bailSensitivity = 'auto', include
93
92
  * @returns A JavaScript object representing the parsed YINI content.
94
93
  */
95
94
  YINI.parseFile = (filePath, strictMode = false, bailSensitivity = 'auto', includeMetaData = false) => {
96
- (0, system_1.debugPrint)('Current directory = ' + process.cwd());
95
+ (0, print_1.debugPrint)('Current directory = ' + process.cwd());
97
96
  if ((0, pathAndFileName_1.getFileNameExtension)(filePath).toLowerCase() !== '.yini') {
98
97
  console.error('Invalid file extension for YINI file:');
99
98
  console.error(`"${filePath}"`);
@@ -115,8 +114,7 @@ YINI.parseFile = (filePath, strictMode = false, bailSensitivity = 'auto', includ
115
114
  level = 0;
116
115
  if (strictMode)
117
116
  level = 1;
118
- if (process.env.NODE_ENV === 'test')
119
- level = 1;
117
+ // if (process.env.NODE_ENV === 'test') level = 1
120
118
  }
121
119
  else {
122
120
  level = bailSensitivity;
@@ -128,16 +126,16 @@ YINI.parseFile = (filePath, strictMode = false, bailSensitivity = 'auto', includ
128
126
  isWithDiagnostics: (0, env_1.isDev)() || (0, env_1.isDebug)(),
129
127
  isWithTiming: (0, env_1.isDebug)(),
130
128
  };
131
- (0, system_1.debugPrint)();
132
- (0, system_1.debugPrint)('==== Call parse ==========================');
129
+ (0, print_1.debugPrint)();
130
+ (0, print_1.debugPrint)('==== Call parse ==========================');
133
131
  const result = (0, parseEntry_1.parseMain)(content, options);
134
- (0, system_1.debugPrint)('==== End call parse ==========================\n');
132
+ (0, print_1.debugPrint)('==== End call parse ==========================\n');
135
133
  if ((0, env_1.isDev)()) {
136
134
  console.log();
137
- (0, system_1.devPrint)('YINI.parse(..): result:');
135
+ (0, print_1.devPrint)('YINI.parse(..): result:');
138
136
  console.log(result);
139
- (0, system_1.devPrint)('Complete result:');
140
- (0, system_1.printObject)(result);
137
+ (0, print_1.devPrint)('Complete result:');
138
+ (0, print_1.printObject)(result);
141
139
  }
142
140
  return result;
143
141
  };
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ErrorDataHandler = void 0;
4
4
  const env_1 = require("../config/env");
5
- const system_1 = require("../utils/system");
5
+ const print_1 = require("../utils/print");
6
6
  // All the issue titles are defined here to get a quick overview of all
7
7
  // titles, and to easier check that all titles match with relation to
8
8
  // the other titles.
@@ -48,7 +48,7 @@ class ErrorDataHandler {
48
48
  column: endCol,
49
49
  },
50
50
  };
51
- (0, system_1.debugPrint)('issue:');
51
+ (0, print_1.debugPrint)('issue:');
52
52
  (0, env_1.isDebug)() && console.log(issue);
53
53
  return issue;
54
54
  };
@@ -67,16 +67,16 @@ class ErrorDataHandler {
67
67
  */
68
68
  this.pushOrBail = (ctx, type, msgWhat, msgWhy = '', msgHint = '') => {
69
69
  var _a, _b, _c, _d, _e, _f;
70
- (0, system_1.debugPrint)('-> pushOrBail(..)');
71
- (0, system_1.debugPrint)('ctx.exception?.name =' + ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.exception) === null || _a === void 0 ? void 0 : _a.name));
72
- (0, system_1.debugPrint)('ctx.exception?.message = ' + ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.exception) === null || _b === void 0 ? void 0 : _b.message));
73
- (0, system_1.debugPrint)('exception?.offendingToken = ' + ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.exception) === null || _c === void 0 ? void 0 : _c.offendingToken));
74
- (0, system_1.debugPrint)();
75
- (0, system_1.debugPrint)('ctx.ruleIndex = ' + (ctx === null || ctx === void 0 ? void 0 : ctx.start.channel));
76
- (0, system_1.debugPrint)('ctx.ruleIndex = ' + (ctx === null || ctx === void 0 ? void 0 : ctx.ruleIndex));
77
- (0, system_1.debugPrint)('ctx.ruleContext = ' + (ctx === null || ctx === void 0 ? void 0 : ctx.ruleContext));
78
- (0, system_1.debugPrint)('ctx.stop?.line = ' + ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.stop) === null || _d === void 0 ? void 0 : _d.line));
79
- (0, system_1.debugPrint)('ctx.stop?.column = ' + ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.stop) === null || _e === void 0 ? void 0 : _e.column));
70
+ (0, print_1.debugPrint)('-> pushOrBail(..)');
71
+ (0, print_1.debugPrint)('ctx.exception?.name =' + ((_a = ctx === null || ctx === void 0 ? void 0 : ctx.exception) === null || _a === void 0 ? void 0 : _a.name));
72
+ (0, print_1.debugPrint)('ctx.exception?.message = ' + ((_b = ctx === null || ctx === void 0 ? void 0 : ctx.exception) === null || _b === void 0 ? void 0 : _b.message));
73
+ (0, print_1.debugPrint)('exception?.offendingToken = ' + ((_c = ctx === null || ctx === void 0 ? void 0 : ctx.exception) === null || _c === void 0 ? void 0 : _c.offendingToken));
74
+ (0, print_1.debugPrint)();
75
+ (0, print_1.debugPrint)('ctx.ruleIndex = ' + (ctx === null || ctx === void 0 ? void 0 : ctx.start.channel));
76
+ (0, print_1.debugPrint)('ctx.ruleIndex = ' + (ctx === null || ctx === void 0 ? void 0 : ctx.ruleIndex));
77
+ (0, print_1.debugPrint)('ctx.ruleContext = ' + (ctx === null || ctx === void 0 ? void 0 : ctx.ruleContext));
78
+ (0, print_1.debugPrint)('ctx.stop?.line = ' + ((_d = ctx === null || ctx === void 0 ? void 0 : ctx.stop) === null || _d === void 0 ? void 0 : _d.line));
79
+ (0, print_1.debugPrint)('ctx.stop?.column = ' + ((_e = ctx === null || ctx === void 0 ? void 0 : ctx.stop) === null || _e === void 0 ? void 0 : _e.column));
80
80
  const lineNum = (ctx === null || ctx === void 0 ? void 0 : ctx.start.line) || 0; // Column (1-based).
81
81
  const startCol = !ctx ? 0 : ++ctx.start.column; // Column (0-based).
82
82
  const endCol = (((_f = ctx === null || ctx === void 0 ? void 0 : ctx.stop) === null || _f === void 0 ? void 0 : _f.column) || 0) + 1; // Column (0-based).
@@ -85,9 +85,9 @@ class ErrorDataHandler {
85
85
  if (process.env.NODE_ENV === 'test') {
86
86
  msgWhat += `\nAt line: ${lineNum}, column(s): ${startCol}-${endCol}`;
87
87
  }
88
- (0, system_1.debugPrint)('persistThreshold = ' + this.persistThreshold);
89
- (0, system_1.debugPrint)('lineNum = ' + lineNum);
90
- (0, system_1.debugPrint)();
88
+ (0, print_1.debugPrint)('persistThreshold = ' + this.persistThreshold);
89
+ (0, print_1.debugPrint)('lineNum = ' + lineNum);
90
+ (0, print_1.debugPrint)();
91
91
  const issue = this.makeIssuePayload(type, msgWhat, lineNum, startCol, endCol);
92
92
  switch (type) {
93
93
  case 'Internal-Error':
@@ -1,4 +1,4 @@
1
- import { Boolean_literalContext, ElementContext, ElementsContext, List_in_bracketsContext, ListContext, Member_colon_listContext, MemberContext, Null_literalContext, Number_literalContext, Object_literalContext, ObjectMemberContext, ObjectMemberListContext, Section_membersContext, SectionContext, String_concatContext, String_literalContext, Terminal_lineContext, ValueContext, YiniContext } from '../grammar/YiniParser.js';
1
+ import { Bad_memberContext, Boolean_literalContext, ElementContext, ElementsContext, List_in_bracketsContext, ListContext, Member_colon_listContext, MemberContext, Null_literalContext, Number_literalContext, Object_literalContext, ObjectMemberContext, ObjectMemberListContext, Section_membersContext, SectionContext, String_concatContext, String_literalContext, Terminal_lineContext, ValueContext, YiniContext } from '../grammar/YiniParser.js';
2
2
  import YiniParserVisitor from '../grammar/YiniParserVisitor';
3
3
  import { ErrorDataHandler } from './ErrorDataHandler';
4
4
  export type TDataType = undefined | 'String' | 'Number-Integer' | 'Number-Float' | 'Boolean' | 'Null' | 'Object' | 'List';
@@ -42,6 +42,12 @@ export default class YINIVisitor<IResult> extends YiniParserVisitor<IResult> {
42
42
  * @returns { [sectionName]: sectionObj }
43
43
  */
44
44
  visitSection: (ctx: SectionContext) => any;
45
+ /**
46
+ * Visit a parse tree produced by `YiniParser.bad_member`.
47
+ * @param ctx the parse tree
48
+ * @return the visitor result
49
+ */
50
+ visitBad_member: (ctx: Bad_memberContext) => any;
45
51
  /**
46
52
  * Visit a parse tree produced by `YiniParser.terminal_line`.
47
53
  * @param ctx the parse tree