yini-parser 1.0.0-alpha.7x → 1.0.0-beta.1

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.
@@ -2,34 +2,34 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.constructFinalObject = 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
  /**
7
7
  * Construct the final result of a JavaScript Object.
8
8
  */
9
9
  const constructFinalObject = (syntaxTreeC, errorHandler) => {
10
- (0, system_1.debugPrint)('-> constructFinalObject(..)');
10
+ (0, print_1.debugPrint)('-> constructFinalObject(..)');
11
11
  const bulder = new Builder(syntaxTreeC, errorHandler);
12
12
  if ((0, env_1.isDebug)()) {
13
13
  console.log('Argument, syntaxTreeC:');
14
- (0, system_1.printObject)(syntaxTreeC);
14
+ (0, print_1.printObject)(syntaxTreeC);
15
15
  }
16
16
  const jsObject = bulder.doCheckAndBuild();
17
- (0, system_1.debugPrint)('<- About to leave constructFinalObject(..)');
17
+ (0, print_1.debugPrint)('<- About to leave constructFinalObject(..)');
18
18
  if ((0, env_1.isDebug)()) {
19
19
  console.log('Returning, jsObject:');
20
- (0, system_1.printObject)(syntaxTreeC);
20
+ (0, print_1.printObject)(syntaxTreeC);
21
21
  }
22
22
  return jsObject;
23
23
  };
24
24
  exports.constructFinalObject = constructFinalObject;
25
25
  class Builder {
26
26
  constructor(syntaxTreeC, errorHandler) {
27
- (0, system_1.debugPrint)('-> Builder: constructor(..)');
27
+ (0, print_1.debugPrint)('-> Builder: constructor(..)');
28
28
  this.syntaxTreeC = syntaxTreeC;
29
29
  this.errorHandler = errorHandler;
30
30
  }
31
31
  doCheckAndBuild() {
32
- (0, system_1.debugPrint)('-> Builder: doCheckAndBuild(..)');
32
+ (0, print_1.debugPrint)('-> Builder: doCheckAndBuild(..)');
33
33
  if (!this.syntaxTreeC) {
34
34
  // Note, after pushing processing may continue or exit, depending on the error and/or the bail threshold.
35
35
  this.errorHandler.pushOrBail(null, 'Fatal-Error', 'SyntaxTreeC is undefined', 'This is most likely caused by an internal error somewhere. The process cannot recover fully from this, sorry.');
@@ -39,46 +39,46 @@ class Builder {
39
39
  return jsObject;
40
40
  }
41
41
  buildFullSubTrees(syntaxTreeC) {
42
- (0, system_1.debugPrint)('-> Builder: buildFullSubTrees(..)');
42
+ (0, print_1.debugPrint)('-> Builder: buildFullSubTrees(..)');
43
43
  (0, env_1.isDebug)() && console.log();
44
44
  const fullSubTreeList = []; // List of FULL sub-trees.
45
45
  // Current Working Full Sub-Tree (starting at level 1).
46
46
  let workingFullSubTree = syntaxTreeC._syntaxTree[0]; // (!) Any tree MUST START at level 1.
47
- (0, system_1.debugPrint)(`Setted new workingFullSubTree, from syntaxTreeC._syntaxTree[0]`);
47
+ (0, print_1.debugPrint)(`Setted new workingFullSubTree, from syntaxTreeC._syntaxTree[0]`);
48
48
  const len = syntaxTreeC._syntaxTree.length;
49
49
  for (let i = 1; i < len; i++) {
50
50
  const currentChainC = syntaxTreeC._syntaxTree[i];
51
51
  const level = currentChainC.originLevel;
52
52
  const nestingIndex = level - 1; // For debugging purposes.
53
53
  const chain = currentChainC.chain; // For debugging purposes.
54
- (0, system_1.debugPrint)(`Got new chain from syntaxTreeC._syntaxTree[${i}] to be mounted onto parent...`);
55
- (0, system_1.debugPrint)('* level: ' + level + ' (i=' + i + '), chain: ' + chain);
54
+ (0, print_1.debugPrint)(`Got new chain from syntaxTreeC._syntaxTree[${i}] to be mounted onto parent...`);
55
+ (0, print_1.debugPrint)('* level: ' + level + ' (i=' + i + '), chain: ' + chain);
56
56
  if (level === 1) {
57
- (0, system_1.debugPrint)('HIT - Detected that currentChain starts with level 1');
57
+ (0, print_1.debugPrint)('HIT - Detected that currentChain starts with level 1');
58
58
  fullSubTreeList.push(workingFullSubTree);
59
- (0, system_1.debugPrint)('The workingFullSubTree is finished, pushed it to the list.');
59
+ (0, print_1.debugPrint)('The workingFullSubTree is finished, pushed it to the list.');
60
60
  workingFullSubTree = syntaxTreeC._syntaxTree[i]; // (!) The tree MUST START at level 1.
61
- (0, system_1.debugPrint)(`Setted new workingFullSubTree, from syntaxTreeC._syntaxTree[${i}]`);
61
+ (0, print_1.debugPrint)(`Setted new workingFullSubTree, from syntaxTreeC._syntaxTree[${i}]`);
62
62
  }
63
63
  else {
64
- (0, system_1.debugPrint)('About to mount currentChain onto workingFullSubTree at correct level...');
64
+ (0, print_1.debugPrint)('About to mount currentChain onto workingFullSubTree at correct level...');
65
65
  workingFullSubTree = this.mountChainOntoLevel(currentChainC, workingFullSubTree);
66
66
  }
67
- (0, system_1.debugPrint)();
67
+ (0, print_1.debugPrint)();
68
68
  }
69
69
  fullSubTreeList.push(workingFullSubTree);
70
70
  if ((0, env_1.isDebug)()) {
71
71
  console.log();
72
72
  console.log('--- fullSubTreeList: (list of FULL sub-trees.) -------');
73
- (0, system_1.printObject)(fullSubTreeList);
73
+ (0, print_1.printObject)(fullSubTreeList);
74
74
  console.log();
75
75
  }
76
76
  return fullSubTreeList;
77
77
  }
78
78
  mountChainOntoLevel(chainC, workingSubTree) {
79
- (0, system_1.debugPrint)('-> Builder: mountChainOntoLevel(..)');
79
+ (0, print_1.debugPrint)('-> Builder: mountChainOntoLevel(..)');
80
80
  if ((0, env_1.isDebug)()) {
81
- (0, system_1.printObject)(chainC);
81
+ (0, print_1.printObject)(chainC);
82
82
  }
83
83
  if (chainC.originLevel > 1) {
84
84
  // NOP
@@ -86,36 +86,36 @@ class Builder {
86
86
  else {
87
87
  // Note, after pushing processing may continue or exit, depending on the error and/or the bail threshold.
88
88
  this.errorHandler.pushOrBail(null, 'Fatal-Error', 'Internal-Error: Detected incorrect chain in mountChainOntoLevel(..), start section has level: ' +
89
- chainC.originLevel, 'The (chain) must start with a section level higher than 1', '' + (0, system_1.printObject)(chainC));
89
+ chainC.originLevel, 'The (chain) must start with a section level higher than 1', '' + (0, print_1.printObject)(chainC));
90
90
  }
91
91
  if (workingSubTree.originLevel != 1) {
92
92
  // Note, after pushing processing may continue or exit, depending on the error and/or the bail threshold.
93
93
  this.errorHandler.pushOrBail(null, 'Fatal-Error', 'Internal-Error: Detected incorrect full sub-tree in mountChainOntoLevel(..), start section has level: ' +
94
- chainC.originLevel, 'A full sub-tree (chain) must start with a section at level 1', '' + (0, system_1.printObject)(chainC));
94
+ chainC.originLevel, 'A full sub-tree (chain) must start with a section at level 1', '' + (0, print_1.printObject)(chainC));
95
95
  }
96
96
  const chain = chainC.chain;
97
97
  const targetLevel = chainC.originLevel;
98
98
  if ((0, env_1.isDebug)()) {
99
- (0, system_1.debugPrint)('Target level = ' + targetLevel);
100
- (0, system_1.debugPrint)(`The chain to mount: (onto level: ${targetLevel})`);
101
- (0, system_1.printObject)(chain);
102
- (0, system_1.debugPrint)('--- workingFullSubTree: -------');
103
- (0, system_1.debugPrint)('Before mounting onto workingSubTree.chain:');
104
- (0, system_1.printObject)(workingSubTree.chain);
99
+ (0, print_1.debugPrint)('Target level = ' + targetLevel);
100
+ (0, print_1.debugPrint)(`The chain to mount: (onto level: ${targetLevel})`);
101
+ (0, print_1.printObject)(chain);
102
+ (0, print_1.debugPrint)('--- workingFullSubTree: -------');
103
+ (0, print_1.debugPrint)('Before mounting onto workingSubTree.chain:');
104
+ (0, print_1.printObject)(workingSubTree.chain);
105
105
  }
106
- (0, system_1.debugPrint)('Mount currentChain onto workingFullSubTree.');
106
+ (0, print_1.debugPrint)('Mount currentChain onto workingFullSubTree.');
107
107
  workingSubTree.chain = mountObjectAtLevel(workingSubTree.chain, chain, targetLevel, this.errorHandler);
108
108
  if ((0, env_1.isDebug)()) {
109
- (0, system_1.debugPrint)('After mounting onto workingSubTree.chain:');
110
- (0, system_1.printObject)(workingSubTree.chain);
111
- (0, system_1.debugPrint)('----------');
109
+ (0, print_1.debugPrint)('After mounting onto workingSubTree.chain:');
110
+ (0, print_1.printObject)(workingSubTree.chain);
111
+ (0, print_1.debugPrint)('----------');
112
112
  }
113
- (0, system_1.debugPrint)('<- Builder: mountChainOntoLevel(..)');
113
+ (0, print_1.debugPrint)('<- Builder: mountChainOntoLevel(..)');
114
114
  return workingSubTree;
115
115
  }
116
116
  // Contruct the final JS object from the list of full sub-trees.
117
117
  buildObjectFromList(fullSubTreeList) {
118
- (0, system_1.debugPrint)('-> Builder: buildObjectFromList(..)');
118
+ (0, print_1.debugPrint)('-> Builder: buildObjectFromList(..)');
119
119
  const jsObject = {};
120
120
  for (const chainC of fullSubTreeList) {
121
121
  if (chainC.originLevel === 1) {
@@ -132,7 +132,7 @@ class Builder {
132
132
  else {
133
133
  // Note, after pushing processing may continue or exit, depending on the error and/or the bail threshold.
134
134
  this.errorHandler.pushOrBail(null, 'Fatal-Error', 'Internal-Error: Detected incorrect full sub-tree in buildObjectFromList(..), start section has level: ' +
135
- chainC.originLevel, 'A full sub-tree (chain) must start with a section at level 1', '' + (0, system_1.printObject)(chainC));
135
+ chainC.originLevel, 'A full sub-tree (chain) must start with a section at level 1', '' + (0, print_1.printObject)(chainC));
136
136
  }
137
137
  }
138
138
  return jsObject;
@@ -163,14 +163,14 @@ const mountObjectAtLevel = (objectSrc, objectDest, level, errorHandler) => {
163
163
  current = current[nextKey];
164
164
  currentLevel++;
165
165
  }
166
- (0, system_1.debugPrint)('--------');
167
- (0, system_1.debugPrint)(' current = ' + (0, system_1.toPrettyJSON)(current));
166
+ (0, print_1.debugPrint)('--------');
167
+ (0, print_1.debugPrint)(' current = ' + (0, print_1.toPrettyJSON)(current));
168
168
  const [firstKey] = Object.keys(objectDest);
169
- (0, system_1.debugPrint)('objectDest = ' + firstKey);
169
+ (0, print_1.debugPrint)('objectDest = ' + firstKey);
170
170
  if (Object.prototype.hasOwnProperty.call(current, firstKey)) {
171
171
  //@todo Add metadata with line number, onto chainC, so can use line number in error reporting
172
- (0, system_1.debugPrint)(`(!) sectionName already exist, name: "${firstKey}", in: `);
173
- (0, system_1.debugPrint)((0, system_1.toPrettyJSON)(current));
172
+ (0, print_1.debugPrint)(`(!) sectionName already exist, name: "${firstKey}", in: `);
173
+ (0, print_1.debugPrint)((0, print_1.toPrettyJSON)(current));
174
174
  // Note, after pushing processing may continue or exit, depending on the error and/or the bail threshold.
175
175
  errorHandler.pushOrBail(null, 'Syntax-Error', 'Section name already exists', 'Cannot redefine section name: "' +
176
176
  firstKey +
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- // Generated from grammar/v1.0.0-beta.7x/YiniLexer.g4 by ANTLR 4.13.2
3
+ // Generated from grammar/v1.0.0-rc.1/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 {
@@ -206,7 +206,7 @@ export declare class ObjectMemberListContext extends ParserRuleContext {
206
206
  export declare class ObjectMemberContext extends ParserRuleContext {
207
207
  constructor(parser?: YiniParser, parent?: ParserRuleContext, invokingState?: number);
208
208
  KEY(): TerminalNode;
209
- EQ(): TerminalNode;
209
+ COLON(): TerminalNode;
210
210
  value(): ValueContext;
211
211
  WS(): TerminalNode;
212
212
  NL_list(): TerminalNode[];
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Generated from grammar/v1.0.0-beta.7x/YiniParser.g4 by ANTLR 4.13.2
2
+ // Generated from grammar/v1.0.0-rc.1/YiniParser.g4 by ANTLR 4.13.2
3
3
  // noinspection ES6UnusedImports,JSUnusedGlobalSymbols,JSUnusedLocalSymbols
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.Empty_listContext = exports.Empty_objectContext = exports.Boolean_literalContext = exports.String_concatContext = exports.String_literalContext = exports.Null_literalContext = exports.Number_literalContext = exports.ElementContext = exports.ElementsContext = exports.List_in_bracketsContext = exports.ListContext = exports.ObjectMemberContext = exports.ObjectMemberListContext = exports.Object_literalContext = exports.ValueContext = exports.Member_colon_listContext = exports.MemberContext = exports.Section_membersContext = exports.Terminal_lineContext = exports.SectionContext = exports.YiniContext = void 0;
@@ -799,7 +799,7 @@ class YiniParser extends antlr4_1.Parser {
799
799
  }
800
800
  }
801
801
  this.state = 220;
802
- this.match(YiniParser.EQ);
802
+ this.match(YiniParser.COLON);
803
803
  this.state = 224;
804
804
  this._errHandler.sync(this);
805
805
  _la = this._input.LA(1);
@@ -1628,7 +1628,7 @@ YiniParser._serializedATN = [4, 1, 46, 347, 2, 0, 7, 0, 2,
1628
1628
  3, 38, 19, 0, 208, 210, 5, 39, 0, 0, 209, 208, 1, 0, 0, 0, 210, 213, 1, 0, 0, 0, 211, 209, 1, 0,
1629
1629
  0, 0, 211, 212, 1, 0, 0, 0, 212, 215, 1, 0, 0, 0, 213, 211, 1, 0, 0, 0, 214, 190, 1, 0, 0, 0, 214,
1630
1630
  207, 1, 0, 0, 0, 215, 17, 1, 0, 0, 0, 216, 218, 5, 29, 0, 0, 217, 219, 5, 41, 0, 0, 218, 217, 1,
1631
- 0, 0, 0, 218, 219, 1, 0, 0, 0, 219, 220, 1, 0, 0, 0, 220, 224, 5, 9, 0, 0, 221, 223, 5, 39, 0, 0,
1631
+ 0, 0, 0, 218, 219, 1, 0, 0, 0, 219, 220, 1, 0, 0, 0, 220, 224, 5, 12, 0, 0, 221, 223, 5, 39, 0, 0,
1632
1632
  222, 221, 1, 0, 0, 0, 223, 226, 1, 0, 0, 0, 224, 222, 1, 0, 0, 0, 224, 225, 1, 0, 0, 0, 225, 227,
1633
1633
  1, 0, 0, 0, 226, 224, 1, 0, 0, 0, 227, 228, 3, 12, 6, 0, 228, 19, 1, 0, 0, 0, 229, 232, 3, 24, 12,
1634
1634
  0, 230, 232, 3, 22, 11, 0, 231, 229, 1, 0, 0, 0, 231, 230, 1, 0, 0, 0, 232, 21, 1, 0, 0, 0, 233,
@@ -2005,8 +2005,8 @@ class ObjectMemberContext extends antlr4_1.ParserRuleContext {
2005
2005
  KEY() {
2006
2006
  return this.getToken(YiniParser.KEY, 0);
2007
2007
  }
2008
- EQ() {
2009
- return this.getToken(YiniParser.EQ, 0);
2008
+ COLON() {
2009
+ return this.getToken(YiniParser.COLON, 0);
2010
2010
  }
2011
2011
  value() {
2012
2012
  return this.getTypedRuleContext(ValueContext, 0);
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- // Generated from grammar/v1.0.0-beta.7x/YiniParser.g4 by ANTLR 4.13.2
2
+ // Generated from grammar/v1.0.0-rc.1/YiniParser.g4 by ANTLR 4.13.2
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const antlr4_1 = require("antlr4");
5
5
  /**
package/dist/index.js CHANGED
@@ -17,20 +17,20 @@ exports.parseFile = exports.parse = void 0;
17
17
  /END
18
18
  */
19
19
  const env_1 = require("./config/env");
20
- const system_1 = require("./utils/system");
20
+ const print_1 = require("./utils/print");
21
21
  const YINI_1 = __importDefault(require("./YINI"));
22
22
  // export { default } from './YINI'
23
23
  exports.parse = YINI_1.default.parse;
24
24
  exports.parseFile = YINI_1.default.parseFile;
25
25
  exports.default = YINI_1.default;
26
- (0, system_1.debugPrint)();
27
- (0, system_1.debugPrint)('-> Entered index.ts');
28
- (0, system_1.debugPrint)();
26
+ (0, print_1.debugPrint)();
27
+ (0, print_1.debugPrint)('-> Entered index.ts');
28
+ (0, print_1.debugPrint)();
29
29
  if ((0, env_1.isDev)() || (0, env_1.isDebug)()) {
30
30
  console.log(`process.env?.NODE_ENV = '${(_a = process.env) === null || _a === void 0 ? void 0 : _a.NODE_ENV}'`);
31
31
  console.log(`process.env?.APP_ENV = '${(_b = process.env) === null || _b === void 0 ? void 0 : _b.APP_ENV}'`);
32
32
  console.log(`process.env?.IS_DEBUG = '${(_c = process.env) === null || _c === void 0 ? void 0 : _c.IS_DEBUG}'`);
33
- (0, system_1.debugPrint)();
33
+ (0, print_1.debugPrint)();
34
34
  console.log(`localNodeEnv = '${env_1.localNodeEnv}'`);
35
35
  console.log(` localAppEnv = '${env_1.localAppEnv}'`);
36
36
  console.log(' isProdEnv() = ' + (0, env_1.isProdEnv)());
@@ -45,9 +45,9 @@ const debugTestObj = {
45
45
  name: 'e_test',
46
46
  lang: 'TypeScript',
47
47
  };
48
- (0, system_1.debugPrint)('debugTestObj:');
49
- (0, system_1.debugPrint)(debugTestObj);
50
- (0, system_1.debugPrint)();
48
+ (0, print_1.debugPrint)('debugTestObj:');
49
+ (0, print_1.debugPrint)(debugTestObj);
50
+ (0, print_1.debugPrint)();
51
51
  if ((0, env_1.isProdEnv)()) {
52
52
  // Do nothing, and exit.
53
53
  }
@@ -176,33 +176,9 @@ Expected JS output:
176
176
  // title = "My Program"
177
177
  // `
178
178
  const yini = `
179
- /*
180
- nested.yini
181
- Demonstrates nested sections in YINI format.
182
- */
183
-
184
- @yini
185
-
186
- ^ App // Top-level section: App
187
- name = 'Nested Demo App'
188
- version = "1.2.3"
189
-
190
- ^^ Theme // Nested under App: App.Theme
191
- primaryColor = #336699
192
- darkMode = true
193
-
194
-
195
- ^^^ Overrides // Nested under Theme: App.Theme.Overrides
196
- darkMode = false
197
- fontSize = 14
198
-
199
- ^ Database // Another top-level section: Database
200
- host = "db.local"
201
- port = 5432
202
-
203
- ^^ Credentials // Nested under Database: Database.Credentials username = "admin"
204
- password = "secret"
205
- `;
179
+ ^ Database
180
+ pool = { max: 10, min: 2 }
181
+ `;
206
182
  YINI_1.default.parse(yini);
207
183
  // YINI.parse(`
208
184
  // ^ Section1
@@ -11,14 +11,14 @@ const objectBuilder_1 = require("./core/objectBuilder");
11
11
  const YINIVisitor_1 = __importDefault(require("./core/YINIVisitor"));
12
12
  const YiniLexer_1 = __importDefault(require("./grammar/YiniLexer"));
13
13
  const YiniParser_1 = __importDefault(require("./grammar/YiniParser"));
14
- const system_1 = require("./utils/system");
14
+ const print_1 = require("./utils/print");
15
15
  class MyErrorListener {
16
16
  constructor(errorHandler) {
17
17
  this.errors = [];
18
18
  this.errorHandler = errorHandler;
19
19
  }
20
20
  syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) {
21
- (0, system_1.debugPrint)('ANTLR grammar cached an error');
21
+ (0, print_1.debugPrint)('ANTLR grammar cached an error');
22
22
  this.errors.push(`Line ${line}:${charPositionInLine} ${msg}`);
23
23
  const msgWhat = `Syntax error, at line: ${line}`;
24
24
  const msgWhy = `At about column ${1 + charPositionInLine} ${msg}`;
@@ -36,10 +36,10 @@ const parseMain = (yiniContent, options = {
36
36
  isWithDiagnostics: false,
37
37
  isWithTiming: false,
38
38
  }) => {
39
- (0, system_1.debugPrint)();
40
- (0, system_1.debugPrint)('-> Entered parseMain(..) in parseEntry');
41
- (0, system_1.debugPrint)(' isStrict mode = ' + options.isStrict);
42
- (0, system_1.debugPrint)('bailSensitivityLevel = ' + options.bailSensitivityLevel);
39
+ (0, print_1.debugPrint)();
40
+ (0, print_1.debugPrint)('-> Entered parseMain(..) in parseEntry');
41
+ (0, print_1.debugPrint)(' isStrict mode = ' + options.isStrict);
42
+ (0, print_1.debugPrint)('bailSensitivityLevel = ' + options.bailSensitivityLevel);
43
43
  let persistThreshold;
44
44
  switch (options.bailSensitivityLevel) {
45
45
  case 0:
@@ -52,7 +52,7 @@ const parseMain = (yiniContent, options = {
52
52
  persistThreshold = '2-Abort-Even-on-Warnings';
53
53
  }
54
54
  (0, env_1.isDebug)() && console.log();
55
- (0, system_1.debugPrint)('=== Phase 1 ===================================================');
55
+ (0, print_1.debugPrint)('=== Phase 1 ===================================================');
56
56
  const inputStream = antlr4_1.CharStreams.fromString(yiniContent);
57
57
  const lexer = new YiniLexer_1.default(inputStream);
58
58
  const tokenStream = new antlr4_1.CommonTokenStream(lexer);
@@ -61,21 +61,21 @@ const parseMain = (yiniContent, options = {
61
61
  const errorListener = new MyErrorListener(errorHandler);
62
62
  parser.removeErrorListeners(); // Removes the default console error output.
63
63
  parser.addErrorListener(errorListener);
64
- (0, system_1.debugPrint)();
65
- (0, system_1.debugPrint)('--- Starting parsing... ---');
64
+ (0, print_1.debugPrint)();
65
+ (0, print_1.debugPrint)('--- Starting parsing... ---');
66
66
  const parseTree = parser.yini(); // The function yini() is the start rule.
67
67
  if (errorListener.errors.length > 0) {
68
- (0, system_1.debugPrint)('*** ERROR detected ***');
68
+ (0, print_1.debugPrint)('*** ERROR detected ***');
69
69
  if ((0, env_1.isDebug)()) {
70
70
  // Handle or display syntax errors
71
71
  console.error('Syntax errors detected:', errorListener.errors);
72
72
  //process.exit(1)
73
73
  }
74
74
  }
75
- (0, system_1.debugPrint)('--- Parsing done. ---');
76
- (0, system_1.debugPrint)('=== Ended phase 1 =============================================');
75
+ (0, print_1.debugPrint)('--- Parsing done. ---');
76
+ (0, print_1.debugPrint)('=== Ended phase 1 =============================================');
77
77
  (0, env_1.isDebug)() && console.log();
78
- (0, system_1.debugPrint)('=== Phase 2 ===================================================');
78
+ (0, print_1.debugPrint)('=== Phase 2 ===================================================');
79
79
  // const errorHandler = new ErrorDataHandler(persistThreshold)
80
80
  const visitor = new YINIVisitor_1.default(errorHandler, options.isStrict);
81
81
  const syntaxTreeC = visitor.visit(parseTree);
@@ -83,26 +83,26 @@ const parseMain = (yiniContent, options = {
83
83
  console.log();
84
84
  console.log('**************************************************************************');
85
85
  console.log('*** syntaxTreeContainer: *************************************************');
86
- (0, system_1.printObject)(syntaxTreeC);
86
+ (0, print_1.printObject)(syntaxTreeC);
87
87
  console.log('**************************************************************************');
88
88
  console.log('**************************************************************************');
89
89
  console.log();
90
90
  }
91
- (0, system_1.debugPrint)('=== Ended phase 2 =============================================');
91
+ (0, print_1.debugPrint)('=== Ended phase 2 =============================================');
92
92
  (0, env_1.isDebug)() && console.log();
93
- (0, system_1.debugPrint)('=== Phase 3 ===================================================');
93
+ (0, print_1.debugPrint)('=== Phase 3 ===================================================');
94
94
  // Construct.
95
95
  const finalJSResult = (0, objectBuilder_1.constructFinalObject)(syntaxTreeC, errorHandler);
96
- (0, system_1.debugPrint)('=== Ended phase 3 =============================================');
97
- (0, system_1.debugPrint)('visitor.visit(..): finalJSResult:');
96
+ (0, print_1.debugPrint)('=== Ended phase 3 =============================================');
97
+ (0, print_1.debugPrint)('visitor.visit(..): finalJSResult:');
98
98
  (0, env_1.isDebug)() && console.debug(finalJSResult);
99
- (0, system_1.debugPrint)();
99
+ (0, print_1.debugPrint)();
100
100
  if (options.isStrict) {
101
101
  //throw Error('ERROR: Strict-mode not yet implemented')
102
102
  errorHandler.pushOrBail(null, 'Syntax-Warning', 'WARNING: Strict-mode not yet fully implemented', '', '');
103
103
  }
104
104
  else {
105
- (0, system_1.debugPrint)('visitor.visit(..): finalJSResult:');
105
+ (0, print_1.debugPrint)('visitor.visit(..): finalJSResult:');
106
106
  (0, env_1.isDebug)() && console.debug(finalJSResult);
107
107
  }
108
108
  // Construct meta data.
@@ -148,7 +148,7 @@ const parseMain = (yiniContent, options = {
148
148
  phase3Ms: null,
149
149
  };
150
150
  }
151
- (0, system_1.debugPrint)('getNumOfErrors(): ' + errorHandler.getNumOfErrors());
151
+ (0, print_1.debugPrint)('getNumOfErrors(): ' + errorHandler.getNumOfErrors());
152
152
  if (errorHandler.getNumOfErrors()) {
153
153
  console.log();
154
154
  console.log('Parsing is complete, but some problems were detected. Please see the errors above for details.');
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const system_1 = require("../utils/system");
3
+ const print_1 = require("../utils/print");
4
4
  const yiniHelpers_1 = require("../yiniHelpers");
5
5
  const extractSignificantYiniLine_1 = require("./extractSignificantYiniLine");
6
6
  /**
@@ -26,11 +26,11 @@ const extractSignificantYiniLine_1 = require("./extractSignificantYiniLine");
26
26
  * @returns An object with the identified header parts: marker characters, parsed name, and parsed level string.
27
27
  */
28
28
  const extractHeaderParts = (rawLine, errorHandler = null, ctx = null) => {
29
- (0, system_1.debugPrint)('-> Entered extractHeaderParts(..)');
29
+ (0, print_1.debugPrint)('-> Entered extractHeaderParts(..)');
30
30
  rawLine = rawLine.trim();
31
31
  const str = (0, extractSignificantYiniLine_1.extractYiniLine)(rawLine);
32
- (0, system_1.debugPrint)('rawLine: >>>' + rawLine + '<<<');
33
- (0, system_1.debugPrint)(' str: >>>' + str + '<<<');
32
+ (0, print_1.debugPrint)('rawLine: >>>' + rawLine + '<<<');
33
+ (0, print_1.debugPrint)(' str: >>>' + str + '<<<');
34
34
  // Edge case: empty line.
35
35
  if (!str) {
36
36
  errorHandler.pushOrBail(ctx, 'Internal-Error', 'Received blank argument in extractHeaderParts(..)', 'Sorry, an unintended internal error happened.');
@@ -81,18 +81,18 @@ const extractHeaderParts = (rawLine, errorHandler = null, ctx = null) => {
81
81
  // Optionally, strip trailing comments or newlines here if needed.
82
82
  }
83
83
  if (isBacktickedName) {
84
- (0, system_1.debugPrint)('Backticed sectionNamePart: ' + sectionNamePart);
84
+ (0, print_1.debugPrint)('Backticed sectionNamePart: ' + sectionNamePart);
85
85
  // sectionNamePart = trimBackticks(sectionNamePart)
86
86
  }
87
- (0, system_1.debugPrint)();
88
- (0, system_1.debugPrint)('------');
89
- (0, system_1.debugPrint)('<- About to leave extractHeaderParts(..)');
90
- (0, system_1.debugPrint)();
91
- (0, system_1.debugPrint)(' markerCharsPart: >>>' + markerCharsPart + '<<<');
92
- (0, system_1.debugPrint)(' sectionNamePart: >>>' + sectionNamePart + '<<<');
93
- (0, system_1.debugPrint)(' numberPart: >>>' + numberPart + '<<<');
94
- (0, system_1.debugPrint)(' isBacktickedName: ' + isBacktickedName);
95
- (0, system_1.debugPrint)();
87
+ (0, print_1.debugPrint)();
88
+ (0, print_1.debugPrint)('------');
89
+ (0, print_1.debugPrint)('<- About to leave extractHeaderParts(..)');
90
+ (0, print_1.debugPrint)();
91
+ (0, print_1.debugPrint)(' markerCharsPart: >>>' + markerCharsPart + '<<<');
92
+ (0, print_1.debugPrint)(' sectionNamePart: >>>' + sectionNamePart + '<<<');
93
+ (0, print_1.debugPrint)(' numberPart: >>>' + numberPart + '<<<');
94
+ (0, print_1.debugPrint)(' isBacktickedName: ' + isBacktickedName);
95
+ (0, print_1.debugPrint)();
96
96
  return {
97
97
  strMarkerChars: markerCharsPart,
98
98
  strSectionName: sectionNamePart,
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.extractYiniLine = void 0;
4
4
  const env_1 = require("../config/env");
5
+ const print_1 = require("../utils/print");
5
6
  const string_1 = require("../utils/string");
6
- const system_1 = require("../utils/system");
7
7
  const yiniHelpers_1 = require("../yiniHelpers");
8
8
  /**
9
9
  * Extract significant YINI line from YINI content (that may be surrounded by comments.).
@@ -14,57 +14,57 @@ const yiniHelpers_1 = require("../yiniHelpers");
14
14
  * @returns Will filter out any comments (before or after) and return only one single significant YINI line.
15
15
  */
16
16
  const extractYiniLine = (rawYiniContent) => {
17
- (0, system_1.debugPrint)('-> Entered extractSignificantYiniCode(..)');
17
+ (0, print_1.debugPrint)('-> Entered extractSignificantYiniCode(..)');
18
18
  const significantLines = [];
19
19
  let resultLine = '';
20
- (0, system_1.debugPrint)('rawYiniContent: >>>' + rawYiniContent + '<<<');
20
+ (0, print_1.debugPrint)('rawYiniContent: >>>' + rawYiniContent + '<<<');
21
21
  const contentLines = (0, string_1.splitLines)(rawYiniContent);
22
22
  if ((0, env_1.isDebug)()) {
23
23
  console.log(`contentLines: (len: ${contentLines.length})`);
24
- (0, system_1.printObject)(contentLines);
24
+ (0, print_1.printObject)(contentLines);
25
25
  }
26
26
  // contentLines.forEach((row: string) => {
27
27
  for (const line of contentLines) {
28
28
  let row = line;
29
- (0, system_1.debugPrint)('---');
29
+ (0, print_1.debugPrint)('---');
30
30
  // debugPrint('row (a): >>>' + row + '<<<')
31
31
  // row = stripNLAndAfter(row)
32
- (0, system_1.debugPrint)('row (b): >>>' + row + '<<<');
32
+ (0, print_1.debugPrint)('row (b): >>>' + row + '<<<');
33
33
  row = (0, yiniHelpers_1.stripCommentsAndAfter)(row);
34
- (0, system_1.debugPrint)('row (c): >>>' + row + '<<<');
34
+ (0, print_1.debugPrint)('row (c): >>>' + row + '<<<');
35
35
  row = row.trim();
36
- (0, system_1.debugPrint)('row (d): >>>' + row + '<<<');
36
+ (0, print_1.debugPrint)('row (d): >>>' + row + '<<<');
37
37
  if (row) {
38
- (0, system_1.debugPrint)('Found some content in split row (non-comments).');
39
- (0, system_1.debugPrint)('Split row: >>>' + row + '<<<');
38
+ (0, print_1.debugPrint)('Found some content in split row (non-comments).');
39
+ (0, print_1.debugPrint)('Split row: >>>' + row + '<<<');
40
40
  // Use this as input in line.
41
41
  // line = row
42
42
  significantLines.push(row);
43
43
  // break
44
44
  }
45
45
  }
46
- (0, system_1.debugPrint)('--- End: parse line from section content-----------------');
47
- (0, system_1.debugPrint)();
46
+ (0, print_1.debugPrint)('--- End: parse line from section content-----------------');
47
+ (0, print_1.debugPrint)();
48
48
  switch (significantLines.length) {
49
49
  case 0:
50
50
  resultLine = '';
51
51
  break;
52
52
  case 1:
53
- (0, system_1.debugPrint)('Did only find one significant lines in rawYiniContent, OK');
53
+ (0, print_1.debugPrint)('Did only find one significant lines in rawYiniContent, OK');
54
54
  resultLine = significantLines[0];
55
55
  break;
56
56
  default:
57
- (0, system_1.debugPrint)('(!) Did find several significant lines in rawYiniContent! - Maybe internal error...');
58
- (0, system_1.debugPrint)('significantLines[0] = >>>' + significantLines[0] + '<<<');
59
- (0, system_1.debugPrint)('significantLines[1] = >>>' + significantLines[1] + '<<<');
57
+ (0, print_1.debugPrint)('(!) Did find several significant lines in rawYiniContent! - Maybe internal error...');
58
+ (0, print_1.debugPrint)('significantLines[0] = >>>' + significantLines[0] + '<<<');
59
+ (0, print_1.debugPrint)('significantLines[1] = >>>' + significantLines[1] + '<<<');
60
60
  // throw new Error(
61
61
  // 'Internal error: Detected several row lines in rawYiniContent: >>>' +
62
62
  // rawYiniContent +
63
63
  // '<<<',
64
64
  // )
65
65
  }
66
- (0, system_1.debugPrint)('<- About to leave extractSignificantYiniCode(..):');
67
- (0, system_1.debugPrint)('resultLine: >>>' + resultLine + '<<<');
66
+ (0, print_1.debugPrint)('<- About to leave extractSignificantYiniCode(..):');
67
+ (0, print_1.debugPrint)('resultLine: >>>' + resultLine + '<<<');
68
68
  return resultLine;
69
69
  };
70
70
  exports.extractYiniLine = extractYiniLine;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const system_1 = require("../utils/system");
3
+ const print_1 = require("../utils/print");
4
4
  /**
5
5
  * Extract boolean literal.
6
6
  */
7
7
  const parseBooleanLiteral = (txt) => {
8
- (0, system_1.debugPrint)('-> Entered parseBooleanLiteral(..)');
8
+ (0, print_1.debugPrint)('-> Entered parseBooleanLiteral(..)');
9
9
  const value = !!(txt === 'true' || txt === 'yes' || txt === 'on');
10
10
  return value;
11
11
  };
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const system_1 = require("../utils/system");
3
+ const print_1 = require("../utils/print");
4
4
  const parseNullLiteral = (txt) => {
5
- (0, system_1.debugPrint)('-> Entered parseNullLiteral(..)');
5
+ (0, print_1.debugPrint)('-> Entered parseNullLiteral(..)');
6
6
  if (txt.toLowerCase() !== 'null') {
7
7
  throw Error('Syntax Error: Unexpected token or character; expected `Null` literal (case-insensitive)');
8
8
  }