@sap/eslint-plugin-cds 2.0.5 → 2.2.2
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 +111 -1
- package/README.md +2 -3
- package/lib/api/formatter.js +182 -132
- package/lib/api/index.js +27 -9
- package/lib/impl/constants.js +38 -44
- package/lib/impl/index.js +57 -34
- package/lib/impl/parser.js +37 -25
- package/lib/impl/processor.js +23 -0
- package/lib/impl/ruleFactory.js +301 -149
- package/lib/impl/rules/assoc2many-ambiguous-key.js +171 -0
- package/lib/impl/rules/cds-compile-error.js +35 -0
- package/lib/impl/rules/latest-cds-version.js +39 -33
- package/lib/impl/rules/min-node-version.js +36 -36
- package/lib/impl/rules/no-db-keywords.js +35 -0
- package/lib/impl/rules/no-join-on-draft-enabled-entities.js +35 -0
- package/lib/impl/rules/require-2many-oncond.js +29 -0
- package/lib/impl/rules/rule.hbs +20 -0
- package/lib/impl/rules/sql-cast-suggestion.js +45 -39
- package/lib/impl/rules/start-elements-lowercase.js +74 -0
- package/lib/impl/rules/start-entities-uppercase.js +65 -0
- package/lib/impl/types.d.ts +48 -0
- package/lib/impl/utils/helpers.js +68 -0
- package/lib/impl/utils/jsonc.js +1 -0
- package/lib/impl/utils/model.js +528 -0
- package/lib/impl/utils/rules.js +550 -0
- package/lib/impl/utils/validate.js +49 -0
- package/package.json +3 -3
- package/lib/impl/rules/assocs-card-flaw.js +0 -215
- package/lib/impl/rules/csn-compile-error.js +0 -37
- package/lib/impl/rules/lower-camelcase-elements.js +0 -42
- package/lib/impl/rules/upper-camelcase-entities.js +0 -50
- package/lib/impl/utils.js +0 -395
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
module.exports = require("../../api").createRule({
|
|
2
|
+
meta: {
|
|
3
|
+
docs: {
|
|
4
|
+
description: "Regular entity names should start with uppercase letters.",
|
|
5
|
+
category: "Model Validation",
|
|
6
|
+
version: "1.0.4",
|
|
7
|
+
},
|
|
8
|
+
type: "suggestion",
|
|
9
|
+
hasSuggestions: true,
|
|
10
|
+
messages: {
|
|
11
|
+
startUppercase:
|
|
12
|
+
"Entity name '{{entityName}}' should start with an uppercase letter.",
|
|
13
|
+
},
|
|
14
|
+
fixable: "code",
|
|
15
|
+
},
|
|
16
|
+
create: function (context) {
|
|
17
|
+
const m = context.cds.model;
|
|
18
|
+
if (m) {
|
|
19
|
+
m.foreach("entity", (e) => {
|
|
20
|
+
let entityName = e.name;
|
|
21
|
+
const names = entityName.split(".");
|
|
22
|
+
entityName = names[names.length - 1];
|
|
23
|
+
if (
|
|
24
|
+
entityName &&
|
|
25
|
+
!(entityName.startsWith("localized") || entityName.endsWith("texts"))
|
|
26
|
+
) {
|
|
27
|
+
if (entityName.charAt(0) !== entityName.charAt(0).toUpperCase()) {
|
|
28
|
+
if (e.$location && e.$location.file) {
|
|
29
|
+
const file = e.$location.file;
|
|
30
|
+
const loc = context.cds.getLocation(entityName, e);
|
|
31
|
+
const fix = (fixer) => {
|
|
32
|
+
const entityNameSanitized =
|
|
33
|
+
entityName.charAt(0).toUpperCase() + entityName.slice(1);
|
|
34
|
+
const rangeEnd = context.sourcecode.getIndexFromLoc({
|
|
35
|
+
line: loc.end.line,
|
|
36
|
+
column: loc.end.column,
|
|
37
|
+
});
|
|
38
|
+
const rangeBeg = rangeEnd
|
|
39
|
+
? rangeEnd - entityNameSanitized.length
|
|
40
|
+
: 0;
|
|
41
|
+
return fixer.replaceTextRange(
|
|
42
|
+
[rangeBeg, rangeEnd],
|
|
43
|
+
entityNameSanitized
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
context.report({
|
|
47
|
+
messageId: "startUppercase",
|
|
48
|
+
loc,
|
|
49
|
+
file,
|
|
50
|
+
fix,
|
|
51
|
+
data: { entityName },
|
|
52
|
+
suggest: [
|
|
53
|
+
{
|
|
54
|
+
messageId: "startUppercase",
|
|
55
|
+
fix,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Rule, RuleTester, SourceCode } from "eslint";
|
|
2
|
+
|
|
3
|
+
export interface CDSRuleMetaData extends Rule.RuleMetaData {
|
|
4
|
+
docs: {
|
|
5
|
+
/** provides the short description of the rule in the [rules index](https://eslint.org/docs/rules/) */
|
|
6
|
+
description: Rule.RuleMetaData['docs']['description'];
|
|
7
|
+
/** specifies version of @sap/eslint-plugin-cds at which the rule was first implemented */
|
|
8
|
+
version: string;
|
|
9
|
+
};
|
|
10
|
+
messages?: Rule.RuleMetaData['messages'];
|
|
11
|
+
fixable?: Rule.RuleMetaData['fixable'];
|
|
12
|
+
schema?: Rule.RuleMetaData['schema'];
|
|
13
|
+
deprecated?: Rule.RuleMetaData['deprecated'];
|
|
14
|
+
type?: Rule.RuleMetaData['type'];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type CDSReport = Rule.ReportDescriptor & { file?: string };
|
|
18
|
+
|
|
19
|
+
export interface CDSRuleContext extends Rule.RuleContext {
|
|
20
|
+
cds: any;
|
|
21
|
+
configPath: string;
|
|
22
|
+
code: string;
|
|
23
|
+
filePath: string;
|
|
24
|
+
options: [];
|
|
25
|
+
ruleID: string;
|
|
26
|
+
sourcecode: SourceCode
|
|
27
|
+
}
|
|
28
|
+
export interface CDSRuleSpec {
|
|
29
|
+
meta: CDSRuleMetaData,
|
|
30
|
+
create: (arg0: CDSRuleContext) => Rule.ReportDescriptor;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface CDSTestCaseError extends RuleTester.TestCaseError {
|
|
34
|
+
message: string | RegExp;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface CDSRuleTestOpts {
|
|
38
|
+
/** specifies __dirname */
|
|
39
|
+
root: string;
|
|
40
|
+
/** requires your rule .js here */
|
|
41
|
+
rule?: string;
|
|
42
|
+
/** filename ('schema.cds' for model, 'package.json' for env) */
|
|
43
|
+
filename: string;
|
|
44
|
+
/** resolves cds parser path */
|
|
45
|
+
parser?: string;
|
|
46
|
+
/** List of warnings/errors from ESLint's [ruleTester](https://eslint.org/docs/developer-guide/nodejs-api#ruletester) */
|
|
47
|
+
errors: CDSTestCaseError[]
|
|
48
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
const { files, envFiles, modelFiles } = require("../constants");
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Checks whether the given file path contains a file extension allowed by
|
|
7
|
+
* the plugin
|
|
8
|
+
* @param {string} filePath
|
|
9
|
+
* @returns boolean
|
|
10
|
+
*/
|
|
11
|
+
isValidFile: function (filePath, key = "") {
|
|
12
|
+
function genRegex(key) {
|
|
13
|
+
return new RegExp(
|
|
14
|
+
`${key
|
|
15
|
+
.map((file) => {
|
|
16
|
+
return file.replace("*", "");
|
|
17
|
+
})
|
|
18
|
+
.join("$|")}$`
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
if (key === "model") {
|
|
22
|
+
return genRegex(modelFiles).test(filePath);
|
|
23
|
+
} else if (key === "env") {
|
|
24
|
+
return genRegex(envFiles).test(filePath);
|
|
25
|
+
} else {
|
|
26
|
+
return genRegex(files).test(filePath);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Checks whether the plugin is run via the VS Code ESLint extension (editor)
|
|
32
|
+
* @returns boolean
|
|
33
|
+
*/
|
|
34
|
+
isEditor() {
|
|
35
|
+
return process.argv.join(" ").includes("dbaeumer.vscode-eslint");
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Returns an array of allowed file extensions
|
|
40
|
+
* the plugin can parse of the form "*.ext"
|
|
41
|
+
* @returns {ConfigOverrideFiles} Array of file extensions
|
|
42
|
+
*/
|
|
43
|
+
getFileExtensions: function () {
|
|
44
|
+
return files;
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Prints a formatted message string according to the styles provided
|
|
49
|
+
* @param msg message to print
|
|
50
|
+
* @param styles array of styles for apply
|
|
51
|
+
* @returns
|
|
52
|
+
*/
|
|
53
|
+
styleText: function (msg, styles) {
|
|
54
|
+
const types = {
|
|
55
|
+
reset: "\x1b[0m", // Default
|
|
56
|
+
bold: "\x1b[1m", // Bold/Bright
|
|
57
|
+
link: "\x1b[4m", // underline
|
|
58
|
+
red: "\x1b[31m", // Foreground Red
|
|
59
|
+
green: "\x1b[32m", // Foreground Green
|
|
60
|
+
yellow: "\x1b[33m", // Foreground Yellow
|
|
61
|
+
};
|
|
62
|
+
let msgStyle = "";
|
|
63
|
+
styles.forEach((style) => {
|
|
64
|
+
msgStyle += types[style];
|
|
65
|
+
});
|
|
66
|
+
return `${msgStyle}${msg}${types.reset}`;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
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};
|