@sie-js/vkp 1.0.5 → 1.0.6
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/.github/dependabot.yml +11 -0
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/src/parser.js +27 -9
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
|
3
|
+
# Please see the documentation for all configuration options:
|
|
4
|
+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
|
|
5
|
+
|
|
6
|
+
version: 2
|
|
7
|
+
updates:
|
|
8
|
+
- package-ecosystem: "npm" # See documentation for possible values
|
|
9
|
+
directory: "/" # Location of package manifests
|
|
10
|
+
schedule:
|
|
11
|
+
interval: "weekly"
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -168,4 +168,4 @@ function vkpCanonicalize(text) {
|
|
|
168
168
|
return iconv.encode(text.replace(/(\r\n|\n|\r)/g, "\r\n"), 'windows-1251');
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
export { vkpParse, vkpRawParser, vkpNormalize, vkpNormalizeWithRTF, vkpCanonicalize, vkpDetectContent };
|
|
171
|
+
export { vkpParse, vkpRawParser, vkpNormalize, vkpNormalizeWithRTF, vkpCanonicalize, vkpDetectContent, VkpParseError };
|
package/src/parser.js
CHANGED
|
@@ -97,6 +97,9 @@ function vkpRawParser(text, options = {}) {
|
|
|
97
97
|
throw new VkpParseError("Syntax error", getLocation());
|
|
98
98
|
}
|
|
99
99
|
} catch (e) {
|
|
100
|
+
if (!(e instanceof VkpParseError))
|
|
101
|
+
throw e;
|
|
102
|
+
|
|
100
103
|
let loc = getLocation();
|
|
101
104
|
let token;
|
|
102
105
|
while ((token = nextToken())) {
|
|
@@ -122,7 +125,8 @@ function parseComments() {
|
|
|
122
125
|
} else if (token.type == TOKEN.COMMENT || token.type == TOKEN.MULTILINE_COMMENT || token.type == TOKEN.UNFINISHED_COMMENT) {
|
|
123
126
|
if (token.type == TOKEN.UNFINISHED_COMMENT)
|
|
124
127
|
state.onWarning(new VkpParseError(`Unfinished multiline comment`, getLocation()));
|
|
125
|
-
comments.push(
|
|
128
|
+
comments.push(parseCommentValue(token.value));
|
|
129
|
+
nextToken();
|
|
126
130
|
} else {
|
|
127
131
|
break;
|
|
128
132
|
}
|
|
@@ -133,16 +137,16 @@ function parseComments() {
|
|
|
133
137
|
function parsePatchPragma() {
|
|
134
138
|
let pragma = parsePragmaValue(peekToken().value);
|
|
135
139
|
nextToken();
|
|
136
|
-
let
|
|
137
|
-
return { pragma,
|
|
140
|
+
let comment = parseCommentsAfterExpr();
|
|
141
|
+
return { pragma, comment };
|
|
138
142
|
}
|
|
139
143
|
|
|
140
144
|
function parsePatchOffsetCorrector() {
|
|
141
145
|
let text = peekToken().value;
|
|
142
146
|
let offset = parseOffsetValue(text);
|
|
143
147
|
nextToken();
|
|
144
|
-
let
|
|
145
|
-
return { text, offset,
|
|
148
|
+
let comment = parseCommentsAfterExpr();
|
|
149
|
+
return { text, offset, comment };
|
|
146
150
|
}
|
|
147
151
|
|
|
148
152
|
function parsePatchRecord() {
|
|
@@ -160,10 +164,10 @@ function parsePatchRecord() {
|
|
|
160
164
|
if (!data.length)
|
|
161
165
|
throw new VkpParseError(`Empty patch data record!`, getLocation());
|
|
162
166
|
|
|
163
|
-
let
|
|
167
|
+
let comment = parseCommentsAfterExpr();
|
|
164
168
|
return {
|
|
165
169
|
address,
|
|
166
|
-
|
|
170
|
+
comment,
|
|
167
171
|
old: data.length == 2 ? data[0] : null,
|
|
168
172
|
new: data.length == 2 ? data[1] : data[0],
|
|
169
173
|
};
|
|
@@ -244,12 +248,13 @@ function parseCommentsAfterExpr() {
|
|
|
244
248
|
} else if (token.type == TOKEN.COMMENT || token.type == TOKEN.MULTILINE_COMMENT || token.type == TOKEN.UNFINISHED_COMMENT) {
|
|
245
249
|
if (token.type == TOKEN.UNFINISHED_COMMENT)
|
|
246
250
|
state.onWarning(new VkpParseError(`Unfinished multiline comment`, getLocation()));
|
|
247
|
-
comments.push(
|
|
251
|
+
comments.push(parseCommentValue(token.value));
|
|
252
|
+
nextToken();
|
|
248
253
|
} else {
|
|
249
254
|
throw new VkpParseError("Syntax error", getLocation());
|
|
250
255
|
}
|
|
251
256
|
}
|
|
252
|
-
return comments;
|
|
257
|
+
return comments.join(" ");
|
|
253
258
|
}
|
|
254
259
|
|
|
255
260
|
function nextToken() {
|
|
@@ -272,6 +277,19 @@ function prevToken() {
|
|
|
272
277
|
/**
|
|
273
278
|
* Token value parsers
|
|
274
279
|
* */
|
|
280
|
+
function parseCommentValue(v) {
|
|
281
|
+
if (v.startsWith(';')) {
|
|
282
|
+
return v.substr(1);
|
|
283
|
+
} else if (v.startsWith('#')) {
|
|
284
|
+
return v.substr(1);
|
|
285
|
+
} else if (v.startsWith('//')) {
|
|
286
|
+
return v.substr(2);
|
|
287
|
+
} else if (v.startsWith('/*')) {
|
|
288
|
+
return v.slice(2, -2);
|
|
289
|
+
}
|
|
290
|
+
throw new VkpParseError(`Invalid comment type`, getLocation());
|
|
291
|
+
}
|
|
292
|
+
|
|
275
293
|
function parseAnyNumberValue(v) {
|
|
276
294
|
let m;
|
|
277
295
|
let tmpBuffer = Buffer.allocUnsafe(8);
|