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.
@@ -20,6 +20,7 @@ import { String_concatContext } from "./YiniParser.js";
20
20
  import { Boolean_literalContext } from "./YiniParser.js";
21
21
  import { Empty_objectContext } from "./YiniParser.js";
22
22
  import { Empty_listContext } from "./YiniParser.js";
23
+ import { Bad_memberContext } from "./YiniParser.js";
23
24
  /**
24
25
  * This interface defines a complete generic visitor for a parse tree produced
25
26
  * by `YiniParser`.
@@ -154,4 +155,10 @@ export default class YiniParserVisitor<Result> extends ParseTreeVisitor<Result>
154
155
  * @return the visitor result
155
156
  */
156
157
  visitEmpty_list?: (ctx: Empty_listContext) => Result;
158
+ /**
159
+ * Visit a parse tree produced by `YiniParser.bad_member`.
160
+ * @param ctx the parse tree
161
+ * @return the visitor result
162
+ */
163
+ visitBad_member?: (ctx: Bad_memberContext) => Result;
157
164
  }
@@ -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.2/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
  }
@@ -93,15 +93,15 @@ listItems = ["a", "b", "c"]
93
93
  // if (isDebug()) {
94
94
  // console.debug(input2)
95
95
  // }
96
- // YINI.parse(input2)
96
+ // parseUntilError(input2)
97
97
  // debugPrint('invalidInput1:')
98
98
  // if (isDebug()) {
99
99
  // console.debug(invalidInput1)
100
100
  // }
101
- // YINI.parse(invalidInput1)
101
+ // parseUntilError(invalidInput1)
102
102
  if (env_1.localAppEnv === 'local' && env_1.localNodeEnv !== 'test') {
103
103
  /*
104
- YINI.parse(`
104
+ parseUntilError(`
105
105
  --^ Section0
106
106
  --value = 0
107
107
  ^ Section1
@@ -120,7 +120,7 @@ listItems = ["a", "b", "c"]
120
120
  `)
121
121
  }
122
122
  */
123
- // YINI.parse(`number = 42`)
123
+ // parseUntilError(`number = 42`)
124
124
  /*
125
125
  Expected JS output:
126
126
  {
@@ -130,7 +130,7 @@ Expected JS output:
130
130
 
131
131
  */
132
132
  /*
133
- YINI.parse(
133
+ parseUntilError(
134
134
  `
135
135
  // Using numeric shorthand section markers.
136
136
 
@@ -145,7 +145,7 @@ Expected JS output:
145
145
  2,
146
146
  )
147
147
  */
148
- // YINI.parse(`^1 SectionName`, false, 2)
148
+ // parseUntilError(`^1 SectionName`, false, 2)
149
149
  // const validYini = `
150
150
  // < user
151
151
  // username = 'tester two'
@@ -169,42 +169,22 @@ Expected JS output:
169
169
  // notifications = ON
170
170
  // `
171
171
  // // Act.
172
- // const result = YINI.parse(validYini)
172
+ // const result = parseUntilError(validYini)
173
173
  // debugPrint(result)
174
174
  // const validYini = `^ App
175
175
  // id = 32403 # The correct app id.
176
176
  // title = "My Program"
177
177
  // `
178
+ // const yini = ` // corrupt yini
179
+ // ^ Section
180
+ // = "missing_key_name" // In strict should throw error, while lenient should pass
181
+ // `
178
182
  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
- `;
206
- YINI_1.default.parse(yini);
207
- // YINI.parse(`
183
+ // NOTE: Raw string doesn't support escapes, escape sequences will appear as-is!
184
+ `;
185
+ // YINI.parse(yini, false)
186
+ console.log((0, print_1.toPrettyJSON)(YINI_1.default.parse(yini, false)));
187
+ // parseUntilError(`
208
188
  // ^ Section1
209
189
  // ^^ Section2
210
190
  // ^^^ Section3
@@ -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");
15
- class MyErrorListener {
14
+ const print_1 = require("./utils/print");
15
+ class MyParserErrorListener {
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 parser 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}`;
@@ -29,6 +29,20 @@ class MyErrorListener {
29
29
  reportAttemptingFullContext(...args) { }
30
30
  reportContextSensitivity(...args) { }
31
31
  }
32
+ class MyLexerErrorListener {
33
+ constructor(errorHandler) {
34
+ this.errors = [];
35
+ this.errorHandler = errorHandler;
36
+ }
37
+ syntaxError(recognizer, offendingSymbol, line, charPositionInLine, msg, e) {
38
+ // Handle the error as you want:
39
+ (0, print_1.debugPrint)('ANTLR parser cached an error');
40
+ this.errors.push(`Line ${line}:${charPositionInLine} ${msg}`);
41
+ const msgWhat = `Syntax error, at line: ${line}`;
42
+ const msgWhy = `At about column ${1 + charPositionInLine} ${msg}`;
43
+ this.errorHandler.pushOrBail(null, 'Syntax-Error', msgWhat, msgWhy);
44
+ }
45
+ }
32
46
  const parseMain = (yiniContent, options = {
33
47
  isStrict: false,
34
48
  bailSensitivityLevel: 0,
@@ -36,10 +50,10 @@ const parseMain = (yiniContent, options = {
36
50
  isWithDiagnostics: false,
37
51
  isWithTiming: false,
38
52
  }) => {
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);
53
+ (0, print_1.debugPrint)();
54
+ (0, print_1.debugPrint)('-> Entered parseMain(..) in parseEntry');
55
+ (0, print_1.debugPrint)(' isStrict mode = ' + options.isStrict);
56
+ (0, print_1.debugPrint)('bailSensitivityLevel = ' + options.bailSensitivityLevel);
43
57
  let persistThreshold;
44
58
  switch (options.bailSensitivityLevel) {
45
59
  case 0:
@@ -52,30 +66,36 @@ const parseMain = (yiniContent, options = {
52
66
  persistThreshold = '2-Abort-Even-on-Warnings';
53
67
  }
54
68
  (0, env_1.isDebug)() && console.log();
55
- (0, system_1.debugPrint)('=== Phase 1 ===================================================');
69
+ (0, print_1.debugPrint)('=== Phase 1 ===================================================');
56
70
  const inputStream = antlr4_1.CharStreams.fromString(yiniContent);
57
71
  const lexer = new YiniLexer_1.default(inputStream);
58
72
  const tokenStream = new antlr4_1.CommonTokenStream(lexer);
59
73
  const parser = new YiniParser_1.default(tokenStream);
60
74
  const errorHandler = new ErrorDataHandler_1.ErrorDataHandler(persistThreshold);
61
- const errorListener = new MyErrorListener(errorHandler);
62
- parser.removeErrorListeners(); // Removes the default console error output.
63
- parser.addErrorListener(errorListener);
64
- (0, system_1.debugPrint)();
65
- (0, system_1.debugPrint)('--- Starting parsing... ---');
75
+ // Remove the default ConsoleErrorListener
76
+ lexer.removeErrorListeners(); // Removes the default lexer console error output.
77
+ const lexerErrorListener = new MyLexerErrorListener(errorHandler);
78
+ lexer.addErrorListener(lexerErrorListener);
79
+ // const errorListener = new MyParserErrorListener(errorHandler)
80
+ parser.removeErrorListeners(); // Removes the default parser console error output.
81
+ const parserErrorListener = new MyParserErrorListener(errorHandler);
82
+ parser.addErrorListener(parserErrorListener);
83
+ (0, print_1.debugPrint)();
84
+ (0, print_1.debugPrint)('--- Starting parsing... ---');
66
85
  const parseTree = parser.yini(); // The function yini() is the start rule.
67
- if (errorListener.errors.length > 0) {
68
- (0, system_1.debugPrint)('*** ERROR detected ***');
86
+ if (parserErrorListener.errors.length > 0 ||
87
+ lexerErrorListener.errors.length > 0) {
88
+ (0, print_1.debugPrint)('*** ERROR detected ***');
69
89
  if ((0, env_1.isDebug)()) {
70
90
  // Handle or display syntax errors
71
- console.error('Syntax errors detected:', errorListener.errors);
91
+ console.error('Syntax errors detected:', parserErrorListener.errors, lexerErrorListener.errors);
72
92
  //process.exit(1)
73
93
  }
74
94
  }
75
- (0, system_1.debugPrint)('--- Parsing done. ---');
76
- (0, system_1.debugPrint)('=== Ended phase 1 =============================================');
95
+ (0, print_1.debugPrint)('--- Parsing done. ---');
96
+ (0, print_1.debugPrint)('=== Ended phase 1 =============================================');
77
97
  (0, env_1.isDebug)() && console.log();
78
- (0, system_1.debugPrint)('=== Phase 2 ===================================================');
98
+ (0, print_1.debugPrint)('=== Phase 2 ===================================================');
79
99
  // const errorHandler = new ErrorDataHandler(persistThreshold)
80
100
  const visitor = new YINIVisitor_1.default(errorHandler, options.isStrict);
81
101
  const syntaxTreeC = visitor.visit(parseTree);
@@ -83,26 +103,26 @@ const parseMain = (yiniContent, options = {
83
103
  console.log();
84
104
  console.log('**************************************************************************');
85
105
  console.log('*** syntaxTreeContainer: *************************************************');
86
- (0, system_1.printObject)(syntaxTreeC);
106
+ (0, print_1.printObject)(syntaxTreeC);
87
107
  console.log('**************************************************************************');
88
108
  console.log('**************************************************************************');
89
109
  console.log();
90
110
  }
91
- (0, system_1.debugPrint)('=== Ended phase 2 =============================================');
111
+ (0, print_1.debugPrint)('=== Ended phase 2 =============================================');
92
112
  (0, env_1.isDebug)() && console.log();
93
- (0, system_1.debugPrint)('=== Phase 3 ===================================================');
113
+ (0, print_1.debugPrint)('=== Phase 3 ===================================================');
94
114
  // Construct.
95
115
  const finalJSResult = (0, objectBuilder_1.constructFinalObject)(syntaxTreeC, errorHandler);
96
- (0, system_1.debugPrint)('=== Ended phase 3 =============================================');
97
- (0, system_1.debugPrint)('visitor.visit(..): finalJSResult:');
116
+ (0, print_1.debugPrint)('=== Ended phase 3 =============================================');
117
+ (0, print_1.debugPrint)('visitor.visit(..): finalJSResult:');
98
118
  (0, env_1.isDebug)() && console.debug(finalJSResult);
99
- (0, system_1.debugPrint)();
119
+ (0, print_1.debugPrint)();
100
120
  if (options.isStrict) {
101
121
  //throw Error('ERROR: Strict-mode not yet implemented')
102
122
  errorHandler.pushOrBail(null, 'Syntax-Warning', 'WARNING: Strict-mode not yet fully implemented', '', '');
103
123
  }
104
124
  else {
105
- (0, system_1.debugPrint)('visitor.visit(..): finalJSResult:');
125
+ (0, print_1.debugPrint)('visitor.visit(..): finalJSResult:');
106
126
  (0, env_1.isDebug)() && console.debug(finalJSResult);
107
127
  }
108
128
  // Construct meta data.
@@ -148,7 +168,7 @@ const parseMain = (yiniContent, options = {
148
168
  phase3Ms: null,
149
169
  };
150
170
  }
151
- (0, system_1.debugPrint)('getNumOfErrors(): ' + errorHandler.getNumOfErrors());
171
+ (0, print_1.debugPrint)('getNumOfErrors(): ' + errorHandler.getNumOfErrors());
152
172
  if (errorHandler.getNumOfErrors()) {
153
173
  console.log();
154
174
  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
  }
@@ -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
  const parseNumberLiteral = (txt) => {
5
- (0, system_1.debugPrint)('-> Entered parseNumberLiteral(..), txt: ' + txt);
5
+ (0, print_1.debugPrint)('-> Entered parseNumberLiteral(..), txt: ' + txt);
6
6
  if (/^0[xX]|#/.test(txt)) {
7
7
  // Prefix: 0x, 0X, #
8
- (0, system_1.debugPrint)('* Identified as a hex number');
8
+ (0, print_1.debugPrint)('* Identified as a hex number');
9
9
  return {
10
10
  type: 'Number-Integer',
11
11
  // value: parseInt(txt.replace('#', '0x'), 16),
@@ -14,7 +14,7 @@ const parseNumberLiteral = (txt) => {
14
14
  }
15
15
  if (/^0[bB]|%/.test(txt)) {
16
16
  // Prefix: 0b, 0B, %
17
- (0, system_1.debugPrint)('* Identified as a bin number');
17
+ (0, print_1.debugPrint)('* Identified as a bin number');
18
18
  return {
19
19
  type: 'Number-Integer',
20
20
  value: parseInt(txt.replace(/^0[bB]|%/, ''), 2),
@@ -22,7 +22,7 @@ const parseNumberLiteral = (txt) => {
22
22
  }
23
23
  if (/^0[oO]/.test(txt)) {
24
24
  // Prefix: 0o, 0O
25
- (0, system_1.debugPrint)('* Identified as a ord number');
25
+ (0, print_1.debugPrint)('* Identified as a ord number');
26
26
  return {
27
27
  type: 'Number-Integer',
28
28
  value: parseInt(txt.replace(/^0[oO]/, ''), 8),
@@ -30,7 +30,7 @@ const parseNumberLiteral = (txt) => {
30
30
  }
31
31
  if (/^0[zZ]/.test(txt)) {
32
32
  // Prefix: 0z, 0Z
33
- (0, system_1.debugPrint)('* Identified as a duodecimal number');
33
+ (0, print_1.debugPrint)('* Identified as a duodecimal number');
34
34
  return {
35
35
  type: 'Number-Integer',
36
36
  value: parseInt(txt.replace(/^0[zZ]/, ''), 12),
@@ -38,12 +38,12 @@ const parseNumberLiteral = (txt) => {
38
38
  }
39
39
  // In a regex literal the dot must be escaped (\.) to match a literal '.'
40
40
  if (/\./.test(txt)) {
41
- (0, system_1.debugPrint)('* Identified as a float number');
41
+ (0, print_1.debugPrint)('* Identified as a float number');
42
42
  return { type: 'Number-Float', value: parseFloat(txt) };
43
43
  }
44
44
  // TODO: Depending, on mode, below continue or break on error
45
45
  //console.error('Error: Failed to parse number value: ' + txt)
46
- (0, system_1.debugPrint)('* Identified as a int number');
46
+ (0, print_1.debugPrint)('* Identified as a int number');
47
47
  return { type: 'Number-Integer', value: parseInt(txt) };
48
48
  };
49
49
  exports.default = parseNumberLiteral;
@@ -5,25 +5,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const extractHeaderParts_1 = __importDefault(require("../parsers/extractHeaderParts"));
7
7
  const extractSignificantYiniLine_1 = require("../parsers/extractSignificantYiniLine");
8
+ const print_1 = require("../utils/print");
8
9
  const string_1 = require("../utils/string");
9
- const system_1 = require("../utils/system");
10
10
  const yiniHelpers_1 = require("../yiniHelpers");
11
11
  /**
12
12
  * Extract ...
13
13
  * @param rawLine Raw line with the section header.
14
14
  */
15
15
  const parseSectionHeader = (rawLine, errorHandler, ctx) => {
16
- (0, system_1.debugPrint)('-> Entered parseSectionHeader(..)');
16
+ (0, print_1.debugPrint)('-> Entered parseSectionHeader(..)');
17
17
  rawLine = rawLine.trim();
18
18
  const line = (0, extractSignificantYiniLine_1.extractYiniLine)(rawLine);
19
- (0, system_1.debugPrint)(' rawLine: >>>' + rawLine + '<<<');
20
- (0, system_1.debugPrint)('extractYiniLine(..), line: >>>' + line + '<<<');
19
+ (0, print_1.debugPrint)(' rawLine: >>>' + rawLine + '<<<');
20
+ (0, print_1.debugPrint)('extractYiniLine(..), line: >>>' + line + '<<<');
21
21
  let { strMarkerChars, strSectionName, strNumberPart, isBacktickedName } = (0, extractHeaderParts_1.default)(rawLine, errorHandler, ctx);
22
- (0, system_1.debugPrint)('In parseSectionHeader(..), after extractHeaderParts(..):');
23
- (0, system_1.debugPrint)(' strMarkerChars: ' + strMarkerChars);
24
- (0, system_1.debugPrint)(' strSectionName: ' + strSectionName);
25
- (0, system_1.debugPrint)(' strNumberPart: ' + strNumberPart);
26
- (0, system_1.debugPrint)('isBacktickedName: ' + isBacktickedName);
22
+ (0, print_1.debugPrint)('In parseSectionHeader(..), after extractHeaderParts(..):');
23
+ (0, print_1.debugPrint)(' strMarkerChars: ' + strMarkerChars);
24
+ (0, print_1.debugPrint)(' strSectionName: ' + strSectionName);
25
+ (0, print_1.debugPrint)(' strNumberPart: ' + strNumberPart);
26
+ (0, print_1.debugPrint)('isBacktickedName: ' + isBacktickedName);
27
27
  let headerMarkerType;
28
28
  let level = 0;
29
29
  if (strMarkerChars === '') {
@@ -76,7 +76,7 @@ const parseSectionHeader = (rawLine, errorHandler, ctx) => {
76
76
  }
77
77
  }
78
78
  else {
79
- (0, system_1.debugPrint)('Naming contraints: Is not a BacktickedName');
79
+ (0, print_1.debugPrint)('Naming contraints: Is not a BacktickedName');
80
80
  if (lenOfName <= 0) {
81
81
  errorHandler.pushOrBail(ctx, 'Syntax-Error', 'Invalid section name in repeating marker characters header, section name: "' +
82
82
  strSectionName +
@@ -93,15 +93,15 @@ const parseSectionHeader = (rawLine, errorHandler, ctx) => {
93
93
  }
94
94
  // ---------------------------------------------------------------
95
95
  // strSectionName = trimBackticks(strSectionName)
96
- (0, system_1.debugPrint)(' --------------');
97
- (0, system_1.debugPrint)('<- About to leave parseSectionHeader(..)');
98
- (0, system_1.debugPrint)(` rawLine = >>>${rawLine}<<<`);
99
- (0, system_1.debugPrint)(` line = >>>${line}<<<`);
100
- (0, system_1.debugPrint)();
101
- (0, system_1.debugPrint)('identified level: ' + level);
102
- (0, system_1.debugPrint)(' SectionName: ' + strSectionName);
103
- (0, system_1.debugPrint)('headerMarkerType: ' + headerMarkerType);
104
- (0, system_1.debugPrint)(' --------------');
96
+ (0, print_1.debugPrint)(' --------------');
97
+ (0, print_1.debugPrint)('<- About to leave parseSectionHeader(..)');
98
+ (0, print_1.debugPrint)(` rawLine = >>>${rawLine}<<<`);
99
+ (0, print_1.debugPrint)(` line = >>>${line}<<<`);
100
+ (0, print_1.debugPrint)();
101
+ (0, print_1.debugPrint)('identified level: ' + level);
102
+ (0, print_1.debugPrint)(' SectionName: ' + strSectionName);
103
+ (0, print_1.debugPrint)('headerMarkerType: ' + headerMarkerType);
104
+ (0, print_1.debugPrint)(' --------------');
105
105
  return {
106
106
  markerType: headerMarkerType,
107
107
  sectionName: strSectionName,