@sap/eslint-plugin-cds 2.5.0 → 2.6.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.
- package/CHANGELOG.md +24 -0
- package/README.md +2 -1
- package/lib/api/index.js +9 -9
- package/lib/conf/all.js +20 -19
- package/lib/conf/index.js +10 -10
- package/lib/conf/recommended.js +17 -16
- package/lib/constants.js +16 -14
- package/lib/index.js +17 -11
- package/lib/parser.js +90 -82
- package/lib/rules/assoc2many-ambiguous-key.js +71 -70
- package/lib/rules/auth-no-empty-restrictions.js +16 -15
- package/lib/rules/auth-use-requires.js +19 -18
- package/lib/rules/auth-valid-restrict-grant.js +49 -46
- package/lib/rules/auth-valid-restrict-keys.js +19 -18
- package/lib/rules/auth-valid-restrict-to.js +68 -64
- package/lib/rules/auth-valid-restrict-where.js +44 -43
- package/lib/rules/extension-restrictions.js +69 -0
- package/lib/rules/index.js +23 -22
- package/lib/rules/latest-cds-version.js +21 -20
- package/lib/rules/min-node-version.js +22 -22
- package/lib/rules/no-db-keywords.js +21 -27
- package/lib/rules/no-dollar-prefixed-names.js +12 -11
- package/lib/rules/no-join-on-draft.js +27 -0
- package/lib/rules/require-2many-oncond.js +8 -8
- package/lib/rules/sql-cast-suggestion.js +13 -12
- package/lib/rules/start-elements-lowercase.js +42 -41
- package/lib/rules/start-entities-uppercase.js +26 -25
- package/lib/rules/valid-csv-header.js +58 -57
- package/lib/types.d.ts +1 -0
- package/lib/utils/Cache.js +17 -17
- package/lib/utils/Colors.js +8 -8
- package/lib/utils/createRule.js +172 -153
- package/lib/utils/findFuzzy.js +37 -38
- package/lib/utils/genDocs.js +224 -242
- package/lib/utils/getConfigPath.js +27 -27
- package/lib/utils/getConfiguredFileTypes.js +4 -4
- package/lib/utils/getFileExtensions.js +3 -3
- package/lib/utils/getProjectRootPath.js +25 -0
- package/lib/utils/isConfiguredFileType.js +11 -11
- package/lib/utils/rules.js +59 -59
- package/lib/utils/runRuleTester.js +76 -71
- package/package.json +7 -1
- package/lib/rules/no-join-on-draft-enabled-entities.js +0 -25
- package/lib/utils/createRuleDocs.js +0 -361
- package/lib/utils/jsonc.js +0 -1
- package/lib/utils/jsoncParser.js +0 -1
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates custom rules documentation (markdown files)
|
|
3
|
-
* for user according to contents of:
|
|
4
|
-
* - Rule files
|
|
5
|
-
* - Test files (with valid/invalid/fixed examples)
|
|
6
|
-
* @param {string} projectPath
|
|
7
|
-
* @param {string} customRulesDir
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
const os = require("os");
|
|
11
|
-
const fs = require("fs");
|
|
12
|
-
const path = require("path");
|
|
13
|
-
const { exit } = require("process");
|
|
14
|
-
const cp = require("child_process");
|
|
15
|
-
const semver = require("semver");
|
|
16
|
-
|
|
17
|
-
const { mkdirp } = require("@sap/cds/lib/utils");
|
|
18
|
-
const JSONC = require("./jsoncParser");
|
|
19
|
-
const IS_WIN = os.platform() === "win32";
|
|
20
|
-
|
|
21
|
-
module.exports = async (projectPath, customRulesDir, registry, prepareRelease = false) => {
|
|
22
|
-
let docsPath, rulePath, testPath, release;
|
|
23
|
-
|
|
24
|
-
if (!projectPath) {
|
|
25
|
-
docsPath = path.join(__dirname, "../../docs");
|
|
26
|
-
rulePath = path.join(__dirname, "../rules");
|
|
27
|
-
testPath = path.join(__dirname, "../../test/rules");
|
|
28
|
-
release = JSON.parse(fs.readFileSync(path.join(__dirname, "../../package.json"))).version;
|
|
29
|
-
} else {
|
|
30
|
-
docsPath = path.join(projectPath, `${customRulesDir}/docs`);
|
|
31
|
-
rulePath = path.join(projectPath, `${customRulesDir}/rules`);
|
|
32
|
-
testPath = path.join(projectPath, `${customRulesDir}/tests`);
|
|
33
|
-
await Promise.all(
|
|
34
|
-
[docsPath, rulePath, testPath].filter((path) => !fs.existsSync(path)).map((path) => mkdirp(path))
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
if (registry) {
|
|
38
|
-
// Get rules (internal on artifactory)
|
|
39
|
-
const versionInternal = prepareRelease
|
|
40
|
-
? JSON.parse(fs.readFileSync(path.join(__dirname, "../../package.json"))).version
|
|
41
|
-
: _getPackageVersion(registry);
|
|
42
|
-
if (versionInternal) {
|
|
43
|
-
console.log(`Updating internal rules from v>=${versionInternal}:\n${registry}\n`);
|
|
44
|
-
const ruleDictInternal = _getRuleDict(docsPath, rulePath, testPath, versionInternal);
|
|
45
|
-
_genDocFiles(ruleDictInternal, docsPath);
|
|
46
|
-
}
|
|
47
|
-
// Get rules released (external on npm)
|
|
48
|
-
const npmRegistry = "https://registry.npmjs.org";
|
|
49
|
-
const versionExternal = prepareRelease
|
|
50
|
-
? JSON.parse(fs.readFileSync(path.join(__dirname, "../../package.json"))).version
|
|
51
|
-
: _getPackageVersion(npmRegistry);
|
|
52
|
-
if (versionExternal) {
|
|
53
|
-
console.log(`Updating external rules from v>=${versionExternal}:\n${npmRegistry}\n`);
|
|
54
|
-
const ruleDictExternal = _getRuleDict(docsPath, rulePath, testPath, versionExternal, release);
|
|
55
|
-
_genDocFiles(ruleDictExternal, docsPath, release);
|
|
56
|
-
}
|
|
57
|
-
} else {
|
|
58
|
-
// Get "custom" rules
|
|
59
|
-
const ruleDict = _getRuleDict(docsPath, rulePath, testPath);
|
|
60
|
-
_genDocFiles(ruleDict, docsPath);
|
|
61
|
-
}
|
|
62
|
-
console.log("Done!");
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Generates markdown documentation files for:
|
|
67
|
-
* - Overview of all rules in form of markdown table (RuleList)
|
|
68
|
-
* - List of all rules details in form of markdown page (Rules)
|
|
69
|
-
* If used internally within the @sap/eslint-plugin-cds, this
|
|
70
|
-
* also generates 'released' files, which only contain information
|
|
71
|
-
* on rules published until the currently released version.
|
|
72
|
-
* @param ruleDict
|
|
73
|
-
* @param docsPath
|
|
74
|
-
* @param release
|
|
75
|
-
*/
|
|
76
|
-
function _genDocFiles(ruleDict, docsPath, release = false) {
|
|
77
|
-
let suffix = "";
|
|
78
|
-
if (release) {
|
|
79
|
-
suffix = "-released";
|
|
80
|
-
}
|
|
81
|
-
const ruleDocsPath = path.join(docsPath, `Rules${suffix}.md`);
|
|
82
|
-
const ruleListDocsPath = path.join(docsPath, `RuleList${suffix}.md`);
|
|
83
|
-
|
|
84
|
-
if (!fs.existsSync(ruleDocsPath)) {
|
|
85
|
-
fs.writeFileSync(ruleDocsPath, "", "utf8");
|
|
86
|
-
}
|
|
87
|
-
if (!fs.existsSync(ruleListDocsPath)) {
|
|
88
|
-
fs.writeFileSync(ruleListDocsPath, "", "utf8");
|
|
89
|
-
}
|
|
90
|
-
const mdRulesCur = fs.readFileSync(ruleDocsPath, "utf8");
|
|
91
|
-
const mdRuleListCur = fs.readFileSync(ruleListDocsPath, "utf8");
|
|
92
|
-
|
|
93
|
-
// Get rules table
|
|
94
|
-
const mdRuleList = _genMdRules(ruleDict, release, true);
|
|
95
|
-
|
|
96
|
-
// Get rule details
|
|
97
|
-
let mdRules = _genMdRules(ruleDict, release, false);
|
|
98
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
99
|
-
Object.entries(ruleDict).forEach(([category, rules]) => {
|
|
100
|
-
rules.forEach(function (rule) {
|
|
101
|
-
mdRules += `${rule.contents}\n\n${rule.sources}\n\n---\n\n`;
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
if (mdRuleListCur !== mdRuleList || mdRulesCur !== mdRules) {
|
|
106
|
-
fs.writeFileSync(ruleDocsPath, mdRules, "utf8");
|
|
107
|
-
fs.writeFileSync(ruleListDocsPath, mdRuleList, "utf8");
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function _getPackageVersion(registry) {
|
|
112
|
-
let version;
|
|
113
|
-
let result;
|
|
114
|
-
try {
|
|
115
|
-
result = cp
|
|
116
|
-
.execSync(`npm show @sap/eslint-plugin-cds --@sap:registry=${registry} --json`, {
|
|
117
|
-
cwd: process.cwd(),
|
|
118
|
-
shell: IS_WIN,
|
|
119
|
-
stdio: "pipe",
|
|
120
|
-
})
|
|
121
|
-
.toString();
|
|
122
|
-
} catch (err) {
|
|
123
|
-
console.err(`Failed to connect to ${registry} - check your connection and try again.`);
|
|
124
|
-
exit(0);
|
|
125
|
-
}
|
|
126
|
-
version = JSON.parse(result)["version"];
|
|
127
|
-
if (!version) {
|
|
128
|
-
console.err(`Failed to get latest plugin version from ${registry} - check your connection and try again.`);
|
|
129
|
-
exit(0);
|
|
130
|
-
}
|
|
131
|
-
return version;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Generates overview table of all rules based on rule dictionary.
|
|
136
|
-
* @param ruleDict
|
|
137
|
-
* @param release
|
|
138
|
-
* @param table
|
|
139
|
-
* @returns Markdown table
|
|
140
|
-
*/
|
|
141
|
-
function _genMdRules(ruleDict, release, table = true) {
|
|
142
|
-
let mdRules = `# @sap/eslint-plugin-cds [latest]\n\n`;
|
|
143
|
-
if (table) {
|
|
144
|
-
mdRules += `Rules in ESLint are grouped by type to help you understand their purpose. Each rule has emojis denoting:\n\n`;
|
|
145
|
-
mdRules += `✔️ if the plugin's "recommended" configuration enables the rule\n\n`;
|
|
146
|
-
mdRules += `🔧 if problems reported by the rule are automatically fixable (\`--fix\`)\n\n`;
|
|
147
|
-
mdRules += `💡 if problems reported by the rule are manually fixable (editor)\n\n`;
|
|
148
|
-
if (!release) {
|
|
149
|
-
mdRules += `🚧 if rule exists in plugin (main branch) but is not yet released (artifactory)\n\n`;
|
|
150
|
-
mdRules += "| | | | | | | |\n";
|
|
151
|
-
mdRules += "|:-:|:-:|:-:|:-:|-:|:-|:-|\n";
|
|
152
|
-
} else {
|
|
153
|
-
mdRules += "| | | | | | | |\n";
|
|
154
|
-
mdRules += "|:-:|:-:|:-:|:-:|-:|:-|:-|\n";
|
|
155
|
-
}
|
|
156
|
-
/* eslint-disable-next-line no-unused-vars */
|
|
157
|
-
Object.entries(ruleDict).forEach(([, rules]) => {
|
|
158
|
-
rules.forEach(function (rule) {
|
|
159
|
-
mdRules += release
|
|
160
|
-
? `| ${rule.recommended} | ${rule.fixable} | ${rule.hasSuggestions} | | | [${rule.name}](Rules-released.md#${rule.name}) | ${rule.details}|\n`
|
|
161
|
-
: `| ${rule.recommended} | ${rule.fixable} | ${rule.hasSuggestions} | ${rule.construction} | | [${rule.name}](Rules.md#${rule.name}) | ${rule.details}|\n`;
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
mdRules += "\n";
|
|
165
|
-
}
|
|
166
|
-
return mdRules;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
function _getRuleDict(docsPath, rulePath, testPath, versionRequired = "0.0.0", release = false) {
|
|
170
|
-
let mdRule, mdRuleSources, mdRuleContents;
|
|
171
|
-
const ruleDict = {};
|
|
172
|
-
fs.readdirSync(rulePath).filter((file) => {
|
|
173
|
-
if (path.extname(file).toLowerCase() === ".js" && file !== "index.js") {
|
|
174
|
-
const rule = path.basename(file).replace(path.extname(file), "");
|
|
175
|
-
const ruleTestPath = path.join(testPath, rule, "rule.test.js");
|
|
176
|
-
|
|
177
|
-
// Get rule meta information
|
|
178
|
-
const ruleMeta = require(path.join(rulePath, file)).meta;
|
|
179
|
-
const version = ruleMeta.docs.version;
|
|
180
|
-
|
|
181
|
-
if ((release && semver.satisfies(version, `<=${versionRequired}`)) || !release) {
|
|
182
|
-
const details = ruleMeta.docs.description;
|
|
183
|
-
const category = ruleMeta.docs.category;
|
|
184
|
-
const fixable = ruleMeta.fixable;
|
|
185
|
-
const messages = ruleMeta.messages;
|
|
186
|
-
const recommended = ruleMeta.docs.recommended;
|
|
187
|
-
const suggestions = ruleMeta.hasSuggestions;
|
|
188
|
-
|
|
189
|
-
let underConstruction = "";
|
|
190
|
-
if (!release && (version === "TBD" || semver.satisfies(version, `>${versionRequired}`))) {
|
|
191
|
-
underConstruction = "🚧";
|
|
192
|
-
console.log(` > 🚧 Rule '${rule}' still under construction.\n`);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
const isFixable = ["code", "whitespace"].includes(fixable) ? "🔧" : "";
|
|
196
|
-
const isRecommended = recommended === true ? "✔️" : "";
|
|
197
|
-
const hasSuggestions = suggestions === true ? "💡" : "";
|
|
198
|
-
|
|
199
|
-
const ruleDictEntry = {
|
|
200
|
-
name: rule,
|
|
201
|
-
details,
|
|
202
|
-
recommended: isRecommended,
|
|
203
|
-
fixable: isFixable,
|
|
204
|
-
hasSuggestions,
|
|
205
|
-
construction: underConstruction,
|
|
206
|
-
messages,
|
|
207
|
-
version: version,
|
|
208
|
-
};
|
|
209
|
-
mdRule = _getRuleExamples(ruleTestPath, testPath, ruleDictEntry);
|
|
210
|
-
mdRuleContents = "";
|
|
211
|
-
|
|
212
|
-
mdRuleContents +=
|
|
213
|
-
!release && underConstruction
|
|
214
|
-
? `## ${rule}\n<span class='shifted'>${underConstruction} <span class='label'>${category}</span></span>\n\n`
|
|
215
|
-
: `## ${rule}\n<span class='shifted label'>${category}</span>\n\n`;
|
|
216
|
-
|
|
217
|
-
mdRuleContents += `### Rule Details\n${details}\n\n`;
|
|
218
|
-
if (mdRule) {
|
|
219
|
-
mdRuleContents += `### Examples\n${mdRule}\n\n`;
|
|
220
|
-
}
|
|
221
|
-
mdRuleContents += `### Version\nThis rule was introduced in \`@sap/eslint-plugin-cds ${version}\`.\n\n`;
|
|
222
|
-
mdRuleSources = `### Resources\n[Rule & Documentation source](${path
|
|
223
|
-
.relative(docsPath, path.join(rulePath, `${rule}.js`))
|
|
224
|
-
.replace(/\\/g, "/")})\n\n`;
|
|
225
|
-
|
|
226
|
-
ruleDictEntry.contents = mdRuleContents;
|
|
227
|
-
ruleDictEntry.sources = mdRuleSources;
|
|
228
|
-
if (Object.keys(ruleDict).includes(category)) {
|
|
229
|
-
ruleDict[category].push(ruleDictEntry);
|
|
230
|
-
} else {
|
|
231
|
-
ruleDict[category] = [
|
|
232
|
-
{
|
|
233
|
-
name: rule,
|
|
234
|
-
details,
|
|
235
|
-
recommended: isRecommended,
|
|
236
|
-
fixable: isFixable,
|
|
237
|
-
hasSuggestions,
|
|
238
|
-
version: version,
|
|
239
|
-
contents: mdRuleContents,
|
|
240
|
-
sources: mdRuleSources,
|
|
241
|
-
construction: underConstruction,
|
|
242
|
-
},
|
|
243
|
-
];
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
return ruleDict;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Gets value for a given key in allowed keys for input of runRuleTester api
|
|
253
|
-
* @param {string} text test input for ruleTester
|
|
254
|
-
* @param {string} key key to get value for
|
|
255
|
-
* @returns Value for given key
|
|
256
|
-
*/
|
|
257
|
-
function _getKeyFromTest(text, key) {
|
|
258
|
-
let result = "";
|
|
259
|
-
if (["root", "rule", "filename", "parser"].includes(key)) {
|
|
260
|
-
const regexTestKey = new RegExp(`${key}:.*$`, "gm");
|
|
261
|
-
const matchTestKey = regexTestKey.exec(text);
|
|
262
|
-
if (matchTestKey) {
|
|
263
|
-
const quote = matchTestKey[0].replace(",", "").slice(-1);
|
|
264
|
-
const regexTestValue = new RegExp(`${quote}[\\s\\S]*?(\\${quote},?)`, "gm");
|
|
265
|
-
const matchValue = regexTestValue.exec(matchTestKey[0]);
|
|
266
|
-
if (matchValue) {
|
|
267
|
-
const regex = new RegExp(`${quote},`, "gm");
|
|
268
|
-
const regex2 = new RegExp(`${quote}`, "gm");
|
|
269
|
-
result = matchValue[0].replace(regex, "").replace(regex2, "");
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
} else if (key === "errors") {
|
|
273
|
-
const regexTestKey = new RegExp(`${key}:.*$(([\\s]+.+)+])?`, "gm");
|
|
274
|
-
const matchTestKey = regexTestKey.exec(text);
|
|
275
|
-
if (matchTestKey) {
|
|
276
|
-
result = matchTestKey[0];
|
|
277
|
-
}
|
|
278
|
-
} else if (key === "data") {
|
|
279
|
-
const regexTestKey = new RegExp(`${key}:.*}`, "gm");
|
|
280
|
-
const matchTestKey = regexTestKey.exec(text);
|
|
281
|
-
if (matchTestKey) {
|
|
282
|
-
result = matchTestKey[0];
|
|
283
|
-
}
|
|
284
|
-
} else {
|
|
285
|
-
result = `No parameter \\'${key}\\' found in ruleTest`;
|
|
286
|
-
}
|
|
287
|
-
return result;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function _getRuleExamples(ruleTestPath, testPath, ruleDictEntry) {
|
|
291
|
-
// Get rule valid/invalid tests
|
|
292
|
-
let mdRule = "";
|
|
293
|
-
if (fs.existsSync(ruleTestPath)) {
|
|
294
|
-
const ruleTest = fs.readFileSync(ruleTestPath, "utf8");
|
|
295
|
-
const filename = _getKeyFromTest(ruleTest, "filename");
|
|
296
|
-
let errorsString = _getKeyFromTest(ruleTest, "errors");
|
|
297
|
-
const re = /(\S+):/gm;
|
|
298
|
-
errorsString = errorsString.replace(re, `"$&`).replace(/:/gm, '":').replace(/`/gm, '"');
|
|
299
|
-
const errors = JSONC.parse(`{${errorsString}}`).errors;
|
|
300
|
-
const valid = fs.readFileSync(path.join(testPath, ruleDictEntry.name, "valid", filename), "utf8");
|
|
301
|
-
let invalid = fs.readFileSync(path.join(testPath, ruleDictEntry.name, "invalid", filename), "utf8");
|
|
302
|
-
const insertAt = (str, sub, pos) => `${str.slice(0, pos)}${sub}${str.slice(pos)}`;
|
|
303
|
-
let errorsSorted = [];
|
|
304
|
-
errors.forEach((err) => {
|
|
305
|
-
if (errorsSorted.length === 0) {
|
|
306
|
-
errorsSorted = [err];
|
|
307
|
-
} else {
|
|
308
|
-
const errLast = errorsSorted[errorsSorted.length - 1];
|
|
309
|
-
if (err.line > errLast.line) {
|
|
310
|
-
errorsSorted.push(err);
|
|
311
|
-
} else if (err.line < errLast.line) {
|
|
312
|
-
errorsSorted.unshift(err);
|
|
313
|
-
} else {
|
|
314
|
-
if (err.column > errLast.column) {
|
|
315
|
-
errorsSorted.push(err);
|
|
316
|
-
} else if (err.line < errLast.line) {
|
|
317
|
-
errorsSorted.unshift(err);
|
|
318
|
-
} else {
|
|
319
|
-
errorsSorted.push(err);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
errorsSorted.reverse().forEach((err, i) => {
|
|
325
|
-
if (err.messageId) {
|
|
326
|
-
let msg = ruleDictEntry.messages[err.messageId];
|
|
327
|
-
let data;
|
|
328
|
-
if (errorsSorted[i].suggestions && errorsSorted[i].suggestions[0]) {
|
|
329
|
-
data = errorsSorted[i].suggestions[0].data;
|
|
330
|
-
}
|
|
331
|
-
if (data) {
|
|
332
|
-
Object.keys(data).forEach((d) => {
|
|
333
|
-
msg = msg.replace(`{{${d}}}`, data[d]);
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
err.message = msg;
|
|
337
|
-
}
|
|
338
|
-
const msg = err.message.replace(/"/gm, "`");
|
|
339
|
-
if (err.line) {
|
|
340
|
-
const code = invalid.split("\n");
|
|
341
|
-
code[err.line - 1] = insertAt(code[err.line - 1], "</i></b></span>", err.endColumn - 1);
|
|
342
|
-
code[err.line - 1] = insertAt(
|
|
343
|
-
code[err.line - 1],
|
|
344
|
-
`<span style="display:inline-block; position:relative; color:red; border-bottom:2pt dotted red" title="${msg}"><b><i>`,
|
|
345
|
-
err.column - 1
|
|
346
|
-
);
|
|
347
|
-
invalid = code.join("\n");
|
|
348
|
-
}
|
|
349
|
-
});
|
|
350
|
-
|
|
351
|
-
mdRule +=
|
|
352
|
-
`<span>✔️ Example of ` +
|
|
353
|
-
`<span style="color:green">correct</span> ` +
|
|
354
|
-
`code for this rule:</span>\n\n<pre><code>\n${valid}\n</code></pre>\n\n`;
|
|
355
|
-
mdRule +=
|
|
356
|
-
`<span>❌ Example of ` +
|
|
357
|
-
`<span style="color:red">incorrect</span> ` +
|
|
358
|
-
`code for this rule:</span>\n\n<pre><code>\n${invalid}\n</code></pre>`;
|
|
359
|
-
}
|
|
360
|
-
return mdRule;
|
|
361
|
-
}
|
package/lib/utils/jsonc.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function peg$subclass(t,r){function e(){this.constructor=t}e.prototype=r.prototype,t.prototype=new e}function peg$SyntaxError(t,r,e,n){this.message=t,this.expected=r,this.found=e,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,peg$SyntaxError)}function peg$parse(t,r){r=void 0!==r?r:{};var e,n={},a={JSON:it},c=it,u=nt("{",!1),o=function(t,r,e){t[r]=e},s=nt("}",!1),h=nt("[",!1),i=function(t,r){t.push(r)},l=nt("]",!1),f=/^[+\-]/,A=at(["+","-"],!1,!1),p=/^[0-9]/,g=at([["0","9"]],!1,!1),d=nt(".",!1),C=nt("e",!1),v=ct("string"),x='"',b=nt('"',!1),y="\\",m=nt("\\",!1),E=nt("/",!1),S=nt("n",!1),$=nt("r",!1),F=nt("t",!1),w=nt("b",!1),R=nt("f",!1),j=nt("u",!1),k=/^[0-9a-f]/,M=at([["0","9"],["a","f"]],!1,!1),N=function(t){return String.fromCharCode(parseInt(t,16))},T=/^[^"]/,I=at(['"'],!0,!1),J="null",O=nt("null",!1),U="true",q=nt("true",!1),z="false",B=nt("false",!1),D=nt(":",!1),G=nt(",",!1),H=/^[ \t\n\r]/,K=at([" ","\t","\n","\r"],!1,!1),L=nt("//",!1),P=/^[\n\r\u2028\u2029]/,Q=at(["\n","\r","\u2028","\u2029"],!1,!1),V={type:"any"},W=nt("/*",!1),X="*/",Y=nt("*/",!1),Z=0,_=[{line:1,column:1}],tt=0,rt=[],et=0;if("startRule"in r){if(!(r.startRule in a))throw new Error("Can't start parsing from rule \""+r.startRule+'".');c=a[r.startRule]}function nt(t,r){return{type:"literal",text:t,ignoreCase:r}}function at(t,r,e){return{type:"class",parts:t,inverted:r,ignoreCase:e}}function ct(t){return{type:"other",description:t}}function ut(r){var e,n=_[r];if(n)return n;for(e=r-1;!_[e];)e--;for(n={line:(n=_[e]).line,column:n.column};e<r;)10===t.charCodeAt(e)?(n.line++,n.column=1):n.column++,e++;return _[r]=n,n}function ot(t,r){var e=ut(t),n=ut(r);return{start:{offset:t,line:e.line,column:e.column},end:{offset:r,line:n.line,column:n.column}}}function st(t){Z<tt||(Z>tt&&(tt=Z,rt=[]),rt.push(t))}function ht(t,r,e){return new peg$SyntaxError(peg$SyntaxError.buildMessage(t,r),t,r,e)}function it(){var t,r;return t=Z,gt()!==n&&(r=lt())!==n&>()!==n?(t,t=r):(Z=t,t=n),t}function lt(){var r;return(r=function(){var r,e,a,c,h,i,l,f,A;r=Z,e=Z,(a=gt())!==n?(123===t.charCodeAt(Z)?(c="{",Z++):(c=n,0===et&&st(u)),c!==n&&(h=gt())!==n?(e,e=a={}):(Z=e,e=n)):(Z=e,e=n);if(e!==n){if(a=Z,c=Z,(h=ft())!==n&&(i=At())!==n&&(l=lt())!==n?(c,c=h=o(e,h,l)):(Z=c,c=n),c!==n){for(h=[],i=Z,(l=pt())!==n&&(f=ft())!==n&&At()!==n&&(A=lt())!==n?(i,i=l=o(e,f,A)):(Z=i,i=n);i!==n;)h.push(i),i=Z,(l=pt())!==n&&(f=ft())!==n&&At()!==n&&(A=lt())!==n?(i,i=l=o(e,f,A)):(Z=i,i=n);h!==n?((i=pt())===n&&(i=null),i!==n?a=c=[c,h,i]:(Z=a,a=n)):(Z=a,a=n)}else Z=a,a=n;a===n&&(a=null),a!==n&&(c=gt())!==n?(125===t.charCodeAt(Z)?(h="}",Z++):(h=n,0===et&&st(s)),h!==n&&(i=gt())!==n?(r,r=e=e):(Z=r,r=n)):(Z=r,r=n)}else Z=r,r=n;return r}())===n&&(r=function(){var r,e,a,c,u,o,s;r=Z,e=Z,(a=gt())!==n?(91===t.charCodeAt(Z)?(c="[",Z++):(c=n,0===et&&st(h)),c!==n&&(u=gt())!==n?(e,e=a=[]):(Z=e,e=n)):(Z=e,e=n);if(e!==n){if(a=Z,c=Z,(u=lt())!==n&&(c,u=i(e,u)),(c=u)!==n){for(u=[],o=Z,pt()!==n&&(s=lt())!==n?(o,o=i(e,s)):(Z=o,o=n);o!==n;)u.push(o),o=Z,pt()!==n&&(s=lt())!==n?(o,o=i(e,s)):(Z=o,o=n);u!==n?((o=pt())===n&&(o=null),o!==n?a=c=[c,u,o]:(Z=a,a=n)):(Z=a,a=n)}else Z=a,a=n;a===n&&(a=null),a!==n&&(c=gt())!==n?(93===t.charCodeAt(Z)?(u="]",Z++):(u=n,0===et&&st(l)),u!==n&&(o=gt())!==n?(r,r=e=e):(Z=r,r=n)):(Z=r,r=n)}else Z=r,r=n;return r}())===n&&(r=function(){var r,e;r=Z,t.substr(Z,4)===J?(e=J,Z+=4):(e=n,0===et&&st(O));e!==n&&(r,e=null);return r=e}())===n&&(r=function(){var r,e;r=Z,t.substr(Z,4)===U?(e=U,Z+=4):(e=n,0===et&&st(q));e!==n&&(r,e=!0);return r=e}())===n&&(r=function(){var r,e;r=Z,t.substr(Z,5)===z?(e=z,Z+=5):(e=n,0===et&&st(B));e!==n&&(r,e=!1);return r=e}())===n&&(r=function(){var r,e,a,c,u,o,s,h,i,l,v;r=Z,e=Z,a=Z,f.test(t.charAt(Z))?(c=t.charAt(Z),Z++):(c=n,0===et&&st(A));c===n&&(c=null);if(c!==n){if(u=[],p.test(t.charAt(Z))?(o=t.charAt(Z),Z++):(o=n,0===et&&st(g)),o!==n)for(;o!==n;)u.push(o),p.test(t.charAt(Z))?(o=t.charAt(Z),Z++):(o=n,0===et&&st(g));else u=n;if(u!==n){if(o=Z,46===t.charCodeAt(Z)?(s=".",Z++):(s=n,0===et&&st(d)),s!==n){if(h=[],p.test(t.charAt(Z))?(i=t.charAt(Z),Z++):(i=n,0===et&&st(g)),i!==n)for(;i!==n;)h.push(i),p.test(t.charAt(Z))?(i=t.charAt(Z),Z++):(i=n,0===et&&st(g));else h=n;h!==n?o=s=[s,h]:(Z=o,o=n)}else Z=o,o=n;if(o===n&&(o=null),o!==n){if(s=Z,101===t.charCodeAt(Z)?(h="e",Z++):(h=n,0===et&&st(C)),h!==n)if(f.test(t.charAt(Z))?(i=t.charAt(Z),Z++):(i=n,0===et&&st(A)),i===n&&(i=null),i!==n){if(l=[],p.test(t.charAt(Z))?(v=t.charAt(Z),Z++):(v=n,0===et&&st(g)),v!==n)for(;v!==n;)l.push(v),p.test(t.charAt(Z))?(v=t.charAt(Z),Z++):(v=n,0===et&&st(g));else l=n;l!==n?s=h=[h,i,l]:(Z=s,s=n)}else Z=s,s=n;else Z=s,s=n;s===n&&(s=null),s!==n?a=c=[c,u,o,s]:(Z=a,a=n)}else Z=a,a=n}else Z=a,a=n}else Z=a,a=n;e=a!==n?t.substring(e,Z):a;e!==n&&(r,e=Number(e));return r=e}())===n&&(r=ft()),r}function ft(){var r,e,a,c,u,o,s,h,i,l,f,A,p;if(et++,r=Z,34===t.charCodeAt(Z)?(e=x,Z++):(e=n,0===et&&st(b)),e!==n){for(a=[],c=Z,92===t.charCodeAt(Z)?(u=y,Z++):(u=n,0===et&&st(m)),u!==n?(34===t.charCodeAt(Z)?(o=x,Z++):(o=n,0===et&&st(b)),o===n&&(92===t.charCodeAt(Z)?(o=y,Z++):(o=n,0===et&&st(m)),o===n&&(47===t.charCodeAt(Z)?(o="/",Z++):(o=n,0===et&&st(E)),o===n&&(o=Z,110===t.charCodeAt(Z)?(s="n",Z++):(s=n,0===et&&st(S)),s!==n&&(o,s="\n"),(o=s)===n&&(o=Z,114===t.charCodeAt(Z)?(s="r",Z++):(s=n,0===et&&st($)),s!==n&&(o,s="\r"),(o=s)===n&&(o=Z,116===t.charCodeAt(Z)?(s="t",Z++):(s=n,0===et&&st(F)),s!==n&&(o,s="\t"),(o=s)===n&&(o=Z,98===t.charCodeAt(Z)?(s="b",Z++):(s=n,0===et&&st(w)),s!==n&&(o,s="\b"),(o=s)===n&&(o=Z,102===t.charCodeAt(Z)?(s="f",Z++):(s=n,0===et&&st(R)),s!==n&&(o,s="\f"),(o=s)===n&&(o=Z,117===t.charCodeAt(Z)?(s="u",Z++):(s=n,0===et&&st(j)),s!==n?(h=Z,i=Z,k.test(t.charAt(Z))?(l=t.charAt(Z),Z++):(l=n,0===et&&st(M)),l!==n?(k.test(t.charAt(Z))?(f=t.charAt(Z),Z++):(f=n,0===et&&st(M)),f!==n?(k.test(t.charAt(Z))?(A=t.charAt(Z),Z++):(A=n,0===et&&st(M)),A!==n?(k.test(t.charAt(Z))?(p=t.charAt(Z),Z++):(p=n,0===et&&st(M)),p!==n?i=l=[l,f,A,p]:(Z=i,i=n)):(Z=i,i=n)):(Z=i,i=n)):(Z=i,i=n),(h=i!==n?t.substring(h,Z):i)!==n?(o,o=s=N(h)):(Z=o,o=n)):(Z=o,o=n))))))))),o!==n?(c,c=u=o):(Z=c,c=n)):(Z=c,c=n),c===n&&(T.test(t.charAt(Z))?(c=t.charAt(Z),Z++):(c=n,0===et&&st(I)));c!==n;)a.push(c),c=Z,92===t.charCodeAt(Z)?(u=y,Z++):(u=n,0===et&&st(m)),u!==n?(34===t.charCodeAt(Z)?(o=x,Z++):(o=n,0===et&&st(b)),o===n&&(92===t.charCodeAt(Z)?(o=y,Z++):(o=n,0===et&&st(m)),o===n&&(47===t.charCodeAt(Z)?(o="/",Z++):(o=n,0===et&&st(E)),o===n&&(o=Z,110===t.charCodeAt(Z)?(s="n",Z++):(s=n,0===et&&st(S)),s!==n&&(o,s="\n"),(o=s)===n&&(o=Z,114===t.charCodeAt(Z)?(s="r",Z++):(s=n,0===et&&st($)),s!==n&&(o,s="\r"),(o=s)===n&&(o=Z,116===t.charCodeAt(Z)?(s="t",Z++):(s=n,0===et&&st(F)),s!==n&&(o,s="\t"),(o=s)===n&&(o=Z,98===t.charCodeAt(Z)?(s="b",Z++):(s=n,0===et&&st(w)),s!==n&&(o,s="\b"),(o=s)===n&&(o=Z,102===t.charCodeAt(Z)?(s="f",Z++):(s=n,0===et&&st(R)),s!==n&&(o,s="\f"),(o=s)===n&&(o=Z,117===t.charCodeAt(Z)?(s="u",Z++):(s=n,0===et&&st(j)),s!==n?(h=Z,i=Z,k.test(t.charAt(Z))?(l=t.charAt(Z),Z++):(l=n,0===et&&st(M)),l!==n?(k.test(t.charAt(Z))?(f=t.charAt(Z),Z++):(f=n,0===et&&st(M)),f!==n?(k.test(t.charAt(Z))?(A=t.charAt(Z),Z++):(A=n,0===et&&st(M)),A!==n?(k.test(t.charAt(Z))?(p=t.charAt(Z),Z++):(p=n,0===et&&st(M)),p!==n?i=l=[l,f,A,p]:(Z=i,i=n)):(Z=i,i=n)):(Z=i,i=n)):(Z=i,i=n),(h=i!==n?t.substring(h,Z):i)!==n?(o,o=s=N(h)):(Z=o,o=n)):(Z=o,o=n))))))))),o!==n?(c,c=u=o):(Z=c,c=n)):(Z=c,c=n),c===n&&(T.test(t.charAt(Z))?(c=t.charAt(Z),Z++):(c=n,0===et&&st(I)));a!==n?(34===t.charCodeAt(Z)?(c=x,Z++):(c=n,0===et&&st(b)),c!==n?(r,r=e=a.join("")):(Z=r,r=n)):(Z=r,r=n)}else Z=r,r=n;return et--,r===n&&(e=n,0===et&&st(v)),r}function At(){var r,e;return r=Z,gt()!==n?(58===t.charCodeAt(Z)?(e=":",Z++):(e=n,0===et&&st(D)),e!==n&>()!==n?(r,r=void 0):(Z=r,r=n)):(Z=r,r=n),r}function pt(){var r,e;return r=Z,gt()!==n?(44===t.charCodeAt(Z)?(e=",",Z++):(e=n,0===et&&st(G)),e!==n&>()!==n?(r,r=void 0):(Z=r,r=n)):(Z=r,r=n),r}function gt(){var r,e,a;for(r=Z,e=[],H.test(t.charAt(Z))?(a=t.charAt(Z),Z++):(a=n,0===et&&st(K)),a===n&&(a=dt())===n&&(a=Ct());a!==n;)e.push(a),H.test(t.charAt(Z))?(a=t.charAt(Z),Z++):(a=n,0===et&&st(K)),a===n&&(a=dt())===n&&(a=Ct());return e!==n&&(r,e=void 0),r=e}function dt(){var r,e,a,c,u,o,s;if(r=Z,e=Z,"//"===t.substr(Z,2)?(a="//",Z+=2):(a=n,0===et&&st(L)),a!==n){for(c=[],u=Z,o=Z,et++,P.test(t.charAt(Z))?(s=t.charAt(Z),Z++):(s=n,0===et&&st(Q)),et--,s===n?o=void 0:(Z=o,o=n),o!==n?(t.length>Z?(s=t.charAt(Z),Z++):(s=n,0===et&&st(V)),s!==n?u=o=[o,s]:(Z=u,u=n)):(Z=u,u=n);u!==n;)c.push(u),u=Z,o=Z,et++,P.test(t.charAt(Z))?(s=t.charAt(Z),Z++):(s=n,0===et&&st(Q)),et--,s===n?o=void 0:(Z=o,o=n),o!==n?(t.length>Z?(s=t.charAt(Z),Z++):(s=n,0===et&&st(V)),s!==n?u=o=[o,s]:(Z=u,u=n)):(Z=u,u=n);c!==n?e=a=[a,c]:(Z=e,e=n)}else Z=e,e=n;return r=e!==n?t.substring(r,Z):e}function Ct(){var r,e,a,c,u,o,s;if(r=Z,e=Z,"/*"===t.substr(Z,2)?(a="/*",Z+=2):(a=n,0===et&&st(W)),a!==n){for(c=[],u=Z,o=Z,et++,t.substr(Z,2)===X?(s=X,Z+=2):(s=n,0===et&&st(Y)),et--,s===n?o=void 0:(Z=o,o=n),o!==n?(t.length>Z?(s=t.charAt(Z),Z++):(s=n,0===et&&st(V)),s!==n?u=o=[o,s]:(Z=u,u=n)):(Z=u,u=n);u!==n;)c.push(u),u=Z,o=Z,et++,t.substr(Z,2)===X?(s=X,Z+=2):(s=n,0===et&&st(Y)),et--,s===n?o=void 0:(Z=o,o=n),o!==n?(t.length>Z?(s=t.charAt(Z),Z++):(s=n,0===et&&st(V)),s!==n?u=o=[o,s]:(Z=u,u=n)):(Z=u,u=n);c!==n?(t.substr(Z,2)===X?(u=X,Z+=2):(u=n,0===et&&st(Y)),u!==n?e=a=[a,c,u]:(Z=e,e=n)):(Z=e,e=n)}else Z=e,e=n;return r=e!==n?t.substring(r,Z):e}if((e=c())!==n&&Z===t.length)return e;throw e!==n&&Z<t.length&&st({type:"end"}),ht(rt,tt<t.length?t.charAt(tt):null,tt<t.length?ot(tt,tt+1):ot(tt,tt))}peg$subclass(peg$SyntaxError,Error),peg$SyntaxError.buildMessage=function(t,r){var e={literal:function(t){return'"'+a(t.text)+'"'},class:function(t){var r,e="";for(r=0;r<t.parts.length;r++)e+=t.parts[r]instanceof Array?c(t.parts[r][0])+"-"+c(t.parts[r][1]):c(t.parts[r]);return"["+(t.inverted?"^":"")+e+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function n(t){return t.charCodeAt(0).toString(16).toUpperCase()}function a(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}function c(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}return"Expected "+function(t){var r,n,a,c=new Array(t.length);for(r=0;r<t.length;r++)c[r]=(a=t[r],e[a.type](a));if(c.sort(),c.length>0){for(r=1,n=1;r<c.length;r++)c[r-1]!==c[r]&&(c[n]=c[r],n++);c.length=n}switch(c.length){case 1:return c[0];case 2:return c[0]+" or "+c[1];default:return c.slice(0,-1).join(", ")+", or "+c[c.length-1]}}(t)+" but "+function(t){return t?'"'+a(t)+'"':"end of input"}(r)+" found."},module.exports={SyntaxError:peg$SyntaxError,parse:peg$parse};
|
package/lib/utils/jsoncParser.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function peg$subclass(t,r){function e(){this.constructor=t}e.prototype=r.prototype,t.prototype=new e}function peg$SyntaxError(t,r,e,n){this.message=t,this.expected=r,this.found=e,this.location=n,this.name="SyntaxError","function"==typeof Error.captureStackTrace&&Error.captureStackTrace(this,peg$SyntaxError)}function peg$parse(t,r){r=void 0!==r?r:{};var e,n={},a={JSON:it},c=it,u=nt("{",!1),o=function(t,r,e){t[r]=e},s=nt("}",!1),h=nt("[",!1),i=function(t,r){t.push(r)},l=nt("]",!1),f=/^[+\-]/,A=at(["+","-"],!1,!1),p=/^[0-9]/,g=at([["0","9"]],!1,!1),d=nt(".",!1),C=nt("e",!1),v=ct("string"),x='"',b=nt('"',!1),y="\\",m=nt("\\",!1),E=nt("/",!1),S=nt("n",!1),$=nt("r",!1),F=nt("t",!1),w=nt("b",!1),R=nt("f",!1),j=nt("u",!1),k=/^[0-9a-f]/,M=at([["0","9"],["a","f"]],!1,!1),N=function(t){return String.fromCharCode(parseInt(t,16))},T=/^[^"]/,I=at(['"'],!0,!1),J="null",O=nt("null",!1),U="true",q=nt("true",!1),z="false",B=nt("false",!1),D=nt(":",!1),G=nt(",",!1),H=/^[ \t\n\r]/,K=at([" ","\t","\n","\r"],!1,!1),L=nt("//",!1),P=/^[\n\r\u2028\u2029]/,Q=at(["\n","\r","\u2028","\u2029"],!1,!1),V={type:"any"},W=nt("/*",!1),X="*/",Y=nt("*/",!1),Z=0,_=[{line:1,column:1}],tt=0,rt=[],et=0;if("startRule"in r){if(!(r.startRule in a))throw new Error("Can't start parsing from rule \""+r.startRule+'".');c=a[r.startRule]}function nt(t,r){return{type:"literal",text:t,ignoreCase:r}}function at(t,r,e){return{type:"class",parts:t,inverted:r,ignoreCase:e}}function ct(t){return{type:"other",description:t}}function ut(r){var e,n=_[r];if(n)return n;for(e=r-1;!_[e];)e--;for(n={line:(n=_[e]).line,column:n.column};e<r;)10===t.charCodeAt(e)?(n.line++,n.column=1):n.column++,e++;return _[r]=n,n}function ot(t,r){var e=ut(t),n=ut(r);return{start:{offset:t,line:e.line,column:e.column},end:{offset:r,line:n.line,column:n.column}}}function st(t){Z<tt||(Z>tt&&(tt=Z,rt=[]),rt.push(t))}function ht(t,r,e){return new peg$SyntaxError(peg$SyntaxError.buildMessage(t,r),t,r,e)}function it(){var t,r;return t=Z,gt()!==n&&(r=lt())!==n&>()!==n?(t,t=r):(Z=t,t=n),t}function lt(){var r;return(r=function(){var r,e,a,c,h,i,l,f,A;r=Z,e=Z,(a=gt())!==n?(123===t.charCodeAt(Z)?(c="{",Z++):(c=n,0===et&&st(u)),c!==n&&(h=gt())!==n?(e,e=a={}):(Z=e,e=n)):(Z=e,e=n);if(e!==n){if(a=Z,c=Z,(h=ft())!==n&&(i=At())!==n&&(l=lt())!==n?(c,c=h=o(e,h,l)):(Z=c,c=n),c!==n){for(h=[],i=Z,(l=pt())!==n&&(f=ft())!==n&&At()!==n&&(A=lt())!==n?(i,i=l=o(e,f,A)):(Z=i,i=n);i!==n;)h.push(i),i=Z,(l=pt())!==n&&(f=ft())!==n&&At()!==n&&(A=lt())!==n?(i,i=l=o(e,f,A)):(Z=i,i=n);h!==n?((i=pt())===n&&(i=null),i!==n?a=c=[c,h,i]:(Z=a,a=n)):(Z=a,a=n)}else Z=a,a=n;a===n&&(a=null),a!==n&&(c=gt())!==n?(125===t.charCodeAt(Z)?(h="}",Z++):(h=n,0===et&&st(s)),h!==n&&(i=gt())!==n?(r,r=e=e):(Z=r,r=n)):(Z=r,r=n)}else Z=r,r=n;return r}())===n&&(r=function(){var r,e,a,c,u,o,s;r=Z,e=Z,(a=gt())!==n?(91===t.charCodeAt(Z)?(c="[",Z++):(c=n,0===et&&st(h)),c!==n&&(u=gt())!==n?(e,e=a=[]):(Z=e,e=n)):(Z=e,e=n);if(e!==n){if(a=Z,c=Z,(u=lt())!==n&&(c,u=i(e,u)),(c=u)!==n){for(u=[],o=Z,pt()!==n&&(s=lt())!==n?(o,o=i(e,s)):(Z=o,o=n);o!==n;)u.push(o),o=Z,pt()!==n&&(s=lt())!==n?(o,o=i(e,s)):(Z=o,o=n);u!==n?((o=pt())===n&&(o=null),o!==n?a=c=[c,u,o]:(Z=a,a=n)):(Z=a,a=n)}else Z=a,a=n;a===n&&(a=null),a!==n&&(c=gt())!==n?(93===t.charCodeAt(Z)?(u="]",Z++):(u=n,0===et&&st(l)),u!==n&&(o=gt())!==n?(r,r=e=e):(Z=r,r=n)):(Z=r,r=n)}else Z=r,r=n;return r}())===n&&(r=function(){var r,e;r=Z,t.substr(Z,4)===J?(e=J,Z+=4):(e=n,0===et&&st(O));e!==n&&(r,e=null);return r=e}())===n&&(r=function(){var r,e;r=Z,t.substr(Z,4)===U?(e=U,Z+=4):(e=n,0===et&&st(q));e!==n&&(r,e=!0);return r=e}())===n&&(r=function(){var r,e;r=Z,t.substr(Z,5)===z?(e=z,Z+=5):(e=n,0===et&&st(B));e!==n&&(r,e=!1);return r=e}())===n&&(r=function(){var r,e,a,c,u,o,s,h,i,l,v;r=Z,e=Z,a=Z,f.test(t.charAt(Z))?(c=t.charAt(Z),Z++):(c=n,0===et&&st(A));c===n&&(c=null);if(c!==n){if(u=[],p.test(t.charAt(Z))?(o=t.charAt(Z),Z++):(o=n,0===et&&st(g)),o!==n)for(;o!==n;)u.push(o),p.test(t.charAt(Z))?(o=t.charAt(Z),Z++):(o=n,0===et&&st(g));else u=n;if(u!==n){if(o=Z,46===t.charCodeAt(Z)?(s=".",Z++):(s=n,0===et&&st(d)),s!==n){if(h=[],p.test(t.charAt(Z))?(i=t.charAt(Z),Z++):(i=n,0===et&&st(g)),i!==n)for(;i!==n;)h.push(i),p.test(t.charAt(Z))?(i=t.charAt(Z),Z++):(i=n,0===et&&st(g));else h=n;h!==n?o=s=[s,h]:(Z=o,o=n)}else Z=o,o=n;if(o===n&&(o=null),o!==n){if(s=Z,101===t.charCodeAt(Z)?(h="e",Z++):(h=n,0===et&&st(C)),h!==n)if(f.test(t.charAt(Z))?(i=t.charAt(Z),Z++):(i=n,0===et&&st(A)),i===n&&(i=null),i!==n){if(l=[],p.test(t.charAt(Z))?(v=t.charAt(Z),Z++):(v=n,0===et&&st(g)),v!==n)for(;v!==n;)l.push(v),p.test(t.charAt(Z))?(v=t.charAt(Z),Z++):(v=n,0===et&&st(g));else l=n;l!==n?s=h=[h,i,l]:(Z=s,s=n)}else Z=s,s=n;else Z=s,s=n;s===n&&(s=null),s!==n?a=c=[c,u,o,s]:(Z=a,a=n)}else Z=a,a=n}else Z=a,a=n}else Z=a,a=n;e=a!==n?t.substring(e,Z):a;e!==n&&(r,e=Number(e));return r=e}())===n&&(r=ft()),r}function ft(){var r,e,a,c,u,o,s,h,i,l,f,A,p;if(et++,r=Z,34===t.charCodeAt(Z)?(e=x,Z++):(e=n,0===et&&st(b)),e!==n){for(a=[],c=Z,92===t.charCodeAt(Z)?(u=y,Z++):(u=n,0===et&&st(m)),u!==n?(34===t.charCodeAt(Z)?(o=x,Z++):(o=n,0===et&&st(b)),o===n&&(92===t.charCodeAt(Z)?(o=y,Z++):(o=n,0===et&&st(m)),o===n&&(47===t.charCodeAt(Z)?(o="/",Z++):(o=n,0===et&&st(E)),o===n&&(o=Z,110===t.charCodeAt(Z)?(s="n",Z++):(s=n,0===et&&st(S)),s!==n&&(o,s="\n"),(o=s)===n&&(o=Z,114===t.charCodeAt(Z)?(s="r",Z++):(s=n,0===et&&st($)),s!==n&&(o,s="\r"),(o=s)===n&&(o=Z,116===t.charCodeAt(Z)?(s="t",Z++):(s=n,0===et&&st(F)),s!==n&&(o,s="\t"),(o=s)===n&&(o=Z,98===t.charCodeAt(Z)?(s="b",Z++):(s=n,0===et&&st(w)),s!==n&&(o,s="\b"),(o=s)===n&&(o=Z,102===t.charCodeAt(Z)?(s="f",Z++):(s=n,0===et&&st(R)),s!==n&&(o,s="\f"),(o=s)===n&&(o=Z,117===t.charCodeAt(Z)?(s="u",Z++):(s=n,0===et&&st(j)),s!==n?(h=Z,i=Z,k.test(t.charAt(Z))?(l=t.charAt(Z),Z++):(l=n,0===et&&st(M)),l!==n?(k.test(t.charAt(Z))?(f=t.charAt(Z),Z++):(f=n,0===et&&st(M)),f!==n?(k.test(t.charAt(Z))?(A=t.charAt(Z),Z++):(A=n,0===et&&st(M)),A!==n?(k.test(t.charAt(Z))?(p=t.charAt(Z),Z++):(p=n,0===et&&st(M)),p!==n?i=l=[l,f,A,p]:(Z=i,i=n)):(Z=i,i=n)):(Z=i,i=n)):(Z=i,i=n),(h=i!==n?t.substring(h,Z):i)!==n?(o,o=s=N(h)):(Z=o,o=n)):(Z=o,o=n))))))))),o!==n?(c,c=u=o):(Z=c,c=n)):(Z=c,c=n),c===n&&(T.test(t.charAt(Z))?(c=t.charAt(Z),Z++):(c=n,0===et&&st(I)));c!==n;)a.push(c),c=Z,92===t.charCodeAt(Z)?(u=y,Z++):(u=n,0===et&&st(m)),u!==n?(34===t.charCodeAt(Z)?(o=x,Z++):(o=n,0===et&&st(b)),o===n&&(92===t.charCodeAt(Z)?(o=y,Z++):(o=n,0===et&&st(m)),o===n&&(47===t.charCodeAt(Z)?(o="/",Z++):(o=n,0===et&&st(E)),o===n&&(o=Z,110===t.charCodeAt(Z)?(s="n",Z++):(s=n,0===et&&st(S)),s!==n&&(o,s="\n"),(o=s)===n&&(o=Z,114===t.charCodeAt(Z)?(s="r",Z++):(s=n,0===et&&st($)),s!==n&&(o,s="\r"),(o=s)===n&&(o=Z,116===t.charCodeAt(Z)?(s="t",Z++):(s=n,0===et&&st(F)),s!==n&&(o,s="\t"),(o=s)===n&&(o=Z,98===t.charCodeAt(Z)?(s="b",Z++):(s=n,0===et&&st(w)),s!==n&&(o,s="\b"),(o=s)===n&&(o=Z,102===t.charCodeAt(Z)?(s="f",Z++):(s=n,0===et&&st(R)),s!==n&&(o,s="\f"),(o=s)===n&&(o=Z,117===t.charCodeAt(Z)?(s="u",Z++):(s=n,0===et&&st(j)),s!==n?(h=Z,i=Z,k.test(t.charAt(Z))?(l=t.charAt(Z),Z++):(l=n,0===et&&st(M)),l!==n?(k.test(t.charAt(Z))?(f=t.charAt(Z),Z++):(f=n,0===et&&st(M)),f!==n?(k.test(t.charAt(Z))?(A=t.charAt(Z),Z++):(A=n,0===et&&st(M)),A!==n?(k.test(t.charAt(Z))?(p=t.charAt(Z),Z++):(p=n,0===et&&st(M)),p!==n?i=l=[l,f,A,p]:(Z=i,i=n)):(Z=i,i=n)):(Z=i,i=n)):(Z=i,i=n),(h=i!==n?t.substring(h,Z):i)!==n?(o,o=s=N(h)):(Z=o,o=n)):(Z=o,o=n))))))))),o!==n?(c,c=u=o):(Z=c,c=n)):(Z=c,c=n),c===n&&(T.test(t.charAt(Z))?(c=t.charAt(Z),Z++):(c=n,0===et&&st(I)));a!==n?(34===t.charCodeAt(Z)?(c=x,Z++):(c=n,0===et&&st(b)),c!==n?(r,r=e=a.join("")):(Z=r,r=n)):(Z=r,r=n)}else Z=r,r=n;return et--,r===n&&(e=n,0===et&&st(v)),r}function At(){var r,e;return r=Z,gt()!==n?(58===t.charCodeAt(Z)?(e=":",Z++):(e=n,0===et&&st(D)),e!==n&>()!==n?(r,r=void 0):(Z=r,r=n)):(Z=r,r=n),r}function pt(){var r,e;return r=Z,gt()!==n?(44===t.charCodeAt(Z)?(e=",",Z++):(e=n,0===et&&st(G)),e!==n&>()!==n?(r,r=void 0):(Z=r,r=n)):(Z=r,r=n),r}function gt(){var r,e,a;for(r=Z,e=[],H.test(t.charAt(Z))?(a=t.charAt(Z),Z++):(a=n,0===et&&st(K)),a===n&&(a=dt())===n&&(a=Ct());a!==n;)e.push(a),H.test(t.charAt(Z))?(a=t.charAt(Z),Z++):(a=n,0===et&&st(K)),a===n&&(a=dt())===n&&(a=Ct());return e!==n&&(r,e=void 0),r=e}function dt(){var r,e,a,c,u,o,s;if(r=Z,e=Z,"//"===t.substr(Z,2)?(a="//",Z+=2):(a=n,0===et&&st(L)),a!==n){for(c=[],u=Z,o=Z,et++,P.test(t.charAt(Z))?(s=t.charAt(Z),Z++):(s=n,0===et&&st(Q)),et--,s===n?o=void 0:(Z=o,o=n),o!==n?(t.length>Z?(s=t.charAt(Z),Z++):(s=n,0===et&&st(V)),s!==n?u=o=[o,s]:(Z=u,u=n)):(Z=u,u=n);u!==n;)c.push(u),u=Z,o=Z,et++,P.test(t.charAt(Z))?(s=t.charAt(Z),Z++):(s=n,0===et&&st(Q)),et--,s===n?o=void 0:(Z=o,o=n),o!==n?(t.length>Z?(s=t.charAt(Z),Z++):(s=n,0===et&&st(V)),s!==n?u=o=[o,s]:(Z=u,u=n)):(Z=u,u=n);c!==n?e=a=[a,c]:(Z=e,e=n)}else Z=e,e=n;return r=e!==n?t.substring(r,Z):e}function Ct(){var r,e,a,c,u,o,s;if(r=Z,e=Z,"/*"===t.substr(Z,2)?(a="/*",Z+=2):(a=n,0===et&&st(W)),a!==n){for(c=[],u=Z,o=Z,et++,t.substr(Z,2)===X?(s=X,Z+=2):(s=n,0===et&&st(Y)),et--,s===n?o=void 0:(Z=o,o=n),o!==n?(t.length>Z?(s=t.charAt(Z),Z++):(s=n,0===et&&st(V)),s!==n?u=o=[o,s]:(Z=u,u=n)):(Z=u,u=n);u!==n;)c.push(u),u=Z,o=Z,et++,t.substr(Z,2)===X?(s=X,Z+=2):(s=n,0===et&&st(Y)),et--,s===n?o=void 0:(Z=o,o=n),o!==n?(t.length>Z?(s=t.charAt(Z),Z++):(s=n,0===et&&st(V)),s!==n?u=o=[o,s]:(Z=u,u=n)):(Z=u,u=n);c!==n?(t.substr(Z,2)===X?(u=X,Z+=2):(u=n,0===et&&st(Y)),u!==n?e=a=[a,c,u]:(Z=e,e=n)):(Z=e,e=n)}else Z=e,e=n;return r=e!==n?t.substring(r,Z):e}if((e=c())!==n&&Z===t.length)return e;throw e!==n&&Z<t.length&&st({type:"end"}),ht(rt,tt<t.length?t.charAt(tt):null,tt<t.length?ot(tt,tt+1):ot(tt,tt))}peg$subclass(peg$SyntaxError,Error),peg$SyntaxError.buildMessage=function(t,r){var e={literal:function(t){return'"'+a(t.text)+'"'},class:function(t){var r,e="";for(r=0;r<t.parts.length;r++)e+=t.parts[r]instanceof Array?c(t.parts[r][0])+"-"+c(t.parts[r][1]):c(t.parts[r]);return"["+(t.inverted?"^":"")+e+"]"},any:function(t){return"any character"},end:function(t){return"end of input"},other:function(t){return t.description}};function n(t){return t.charCodeAt(0).toString(16).toUpperCase()}function a(t){return t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}function c(t){return t.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,(function(t){return"\\x0"+n(t)})).replace(/[\x10-\x1F\x7F-\x9F]/g,(function(t){return"\\x"+n(t)}))}return"Expected "+function(t){var r,n,a,c=new Array(t.length);for(r=0;r<t.length;r++)c[r]=(a=t[r],e[a.type](a));if(c.sort(),c.length>0){for(r=1,n=1;r<c.length;r++)c[r-1]!==c[r]&&(c[n]=c[r],n++);c.length=n}switch(c.length){case 1:return c[0];case 2:return c[0]+" or "+c[1];default:return c.slice(0,-1).join(", ")+", or "+c[c.length-1]}}(t)+" but "+function(t){return t?'"'+a(t)+'"':"end of input"}(r)+" found."},module.exports={SyntaxError:peg$SyntaxError,parse:peg$parse};
|