Project Init

This commit is contained in:
Muluhabt
2026-05-29 15:23:46 +03:00
commit 2fbc557aac
67387 changed files with 6063341 additions and 0 deletions

View File

@@ -0,0 +1 @@
export declare const parse: (code: string) => Object;

View File

@@ -0,0 +1,530 @@
/*
* Generated by PEG.js 0.10.0.
*
* http://pegjs.org/
*/
"use strict";
function peg$subclass(child, parent) {
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
}
function peg$SyntaxError(message, expected, found, location) {
this.message = message;
this.expected = expected;
this.found = found;
this.location = location;
this.name = "SyntaxError";
if (typeof Error.captureStackTrace === "function") {
Error.captureStackTrace(this, peg$SyntaxError);
}
}
peg$subclass(peg$SyntaxError, Error);
peg$SyntaxError.buildMessage = function(expected, found) {
var DESCRIBE_EXPECTATION_FNS = {
literal: function(expectation) {
return "\"" + literalEscape(expectation.text) + "\"";
},
"class": function(expectation) {
var escapedParts = "",
i;
for (i = 0; i < expectation.parts.length; i++) {
escapedParts += expectation.parts[i] instanceof Array
? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1])
: classEscape(expectation.parts[i]);
}
return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
},
any: function(expectation) {
return "any character";
},
end: function(expectation) {
return "end of input";
},
other: function(expectation) {
return expectation.description;
}
};
function hex(ch) {
return ch.charCodeAt(0).toString(16).toUpperCase();
}
function literalEscape(s) {
return s
.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(ch) { return '\\x0' + hex(ch); })
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
}
function classEscape(s) {
return s
.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(ch) { return '\\x0' + hex(ch); })
.replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return '\\x' + hex(ch); });
}
function describeExpectation(expectation) {
return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
}
function describeExpected(expected) {
var descriptions = new Array(expected.length),
i, j;
for (i = 0; i < expected.length; i++) {
descriptions[i] = describeExpectation(expected[i]);
}
descriptions.sort();
if (descriptions.length > 0) {
for (i = 1, j = 1; i < descriptions.length; i++) {
if (descriptions[i - 1] !== descriptions[i]) {
descriptions[j] = descriptions[i];
j++;
}
}
descriptions.length = j;
}
switch (descriptions.length) {
case 1:
return descriptions[0];
case 2:
return descriptions[0] + " or " + descriptions[1];
default:
return descriptions.slice(0, -1).join(", ")
+ ", or "
+ descriptions[descriptions.length - 1];
}
}
function describeFound(found) {
return found ? "\"" + literalEscape(found) + "\"" : "end of input";
}
return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
};
function peg$parse(input, options) {
options = options !== void 0 ? options : {};
var peg$FAILED = {},
peg$startRuleFunctions = { resolution: peg$parseresolution },
peg$startRuleFunction = peg$parseresolution,
peg$c0 = "/",
peg$c1 = peg$literalExpectation("/", false),
peg$c2 = function(from, descriptor) { return { from, descriptor } },
peg$c3 = function(descriptor) { return { descriptor } },
peg$c4 = "@",
peg$c5 = peg$literalExpectation("@", false),
peg$c6 = function(fullName, description) { return { fullName, description } },
peg$c7 = function(fullName) { return { fullName } },
peg$c8 = function() { return text() },
peg$c9 = /^[^\/@]/,
peg$c10 = peg$classExpectation(["/", "@"], true, false),
peg$c11 = /^[^\/]/,
peg$c12 = peg$classExpectation(["/"], true, false),
peg$currPos = 0,
peg$savedPos = 0,
peg$posDetailsCache = [{ line: 1, column: 1 }],
peg$maxFailPos = 0,
peg$maxFailExpected = [],
peg$silentFails = 0,
peg$result;
if ("startRule" in options) {
if (!(options.startRule in peg$startRuleFunctions)) {
throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
}
peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
}
function text() {
return input.substring(peg$savedPos, peg$currPos);
}
function location() {
return peg$computeLocation(peg$savedPos, peg$currPos);
}
function expected(description, location) {
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
throw peg$buildStructuredError(
[peg$otherExpectation(description)],
input.substring(peg$savedPos, peg$currPos),
location
);
}
function error(message, location) {
location = location !== void 0 ? location : peg$computeLocation(peg$savedPos, peg$currPos)
throw peg$buildSimpleError(message, location);
}
function peg$literalExpectation(text, ignoreCase) {
return { type: "literal", text: text, ignoreCase: ignoreCase };
}
function peg$classExpectation(parts, inverted, ignoreCase) {
return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };
}
function peg$anyExpectation() {
return { type: "any" };
}
function peg$endExpectation() {
return { type: "end" };
}
function peg$otherExpectation(description) {
return { type: "other", description: description };
}
function peg$computePosDetails(pos) {
var details = peg$posDetailsCache[pos], p;
if (details) {
return details;
} else {
p = pos - 1;
while (!peg$posDetailsCache[p]) {
p--;
}
details = peg$posDetailsCache[p];
details = {
line: details.line,
column: details.column
};
while (p < pos) {
if (input.charCodeAt(p) === 10) {
details.line++;
details.column = 1;
} else {
details.column++;
}
p++;
}
peg$posDetailsCache[pos] = details;
return details;
}
}
function peg$computeLocation(startPos, endPos) {
var startPosDetails = peg$computePosDetails(startPos),
endPosDetails = peg$computePosDetails(endPos);
return {
start: {
offset: startPos,
line: startPosDetails.line,
column: startPosDetails.column
},
end: {
offset: endPos,
line: endPosDetails.line,
column: endPosDetails.column
}
};
}
function peg$fail(expected) {
if (peg$currPos < peg$maxFailPos) { return; }
if (peg$currPos > peg$maxFailPos) {
peg$maxFailPos = peg$currPos;
peg$maxFailExpected = [];
}
peg$maxFailExpected.push(expected);
}
function peg$buildSimpleError(message, location) {
return new peg$SyntaxError(message, null, null, location);
}
function peg$buildStructuredError(expected, found, location) {
return new peg$SyntaxError(
peg$SyntaxError.buildMessage(expected, found),
expected,
found,
location
);
}
function peg$parseresolution() {
var s0, s1, s2, s3;
s0 = peg$currPos;
s1 = peg$parsespecifier();
if (s1 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 47) {
s2 = peg$c0;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c1); }
}
if (s2 !== peg$FAILED) {
s3 = peg$parsespecifier();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c2(s1, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parsespecifier();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c3(s1);
}
s0 = s1;
}
return s0;
}
function peg$parsespecifier() {
var s0, s1, s2, s3;
s0 = peg$currPos;
s1 = peg$parsefullName();
if (s1 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 64) {
s2 = peg$c4;
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
}
if (s2 !== peg$FAILED) {
s3 = peg$parsedescription();
if (s3 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c6(s1, s3);
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parsefullName();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c7(s1);
}
s0 = s1;
}
return s0;
}
function peg$parsefullName() {
var s0, s1, s2, s3, s4;
s0 = peg$currPos;
if (input.charCodeAt(peg$currPos) === 64) {
s1 = peg$c4;
peg$currPos++;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c5); }
}
if (s1 !== peg$FAILED) {
s2 = peg$parseident();
if (s2 !== peg$FAILED) {
if (input.charCodeAt(peg$currPos) === 47) {
s3 = peg$c0;
peg$currPos++;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c1); }
}
if (s3 !== peg$FAILED) {
s4 = peg$parseident();
if (s4 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c8();
s0 = s1;
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
} else {
peg$currPos = s0;
s0 = peg$FAILED;
}
if (s0 === peg$FAILED) {
s0 = peg$currPos;
s1 = peg$parseident();
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c8();
}
s0 = s1;
}
return s0;
}
function peg$parseident() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = [];
if (peg$c9.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
}
if (s2 !== peg$FAILED) {
while (s2 !== peg$FAILED) {
s1.push(s2);
if (peg$c9.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c10); }
}
}
} else {
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c8();
}
s0 = s1;
return s0;
}
function peg$parsedescription() {
var s0, s1, s2;
s0 = peg$currPos;
s1 = [];
if (peg$c11.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c12); }
}
if (s2 !== peg$FAILED) {
while (s2 !== peg$FAILED) {
s1.push(s2);
if (peg$c11.test(input.charAt(peg$currPos))) {
s2 = input.charAt(peg$currPos);
peg$currPos++;
} else {
s2 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$c12); }
}
}
} else {
s1 = peg$FAILED;
}
if (s1 !== peg$FAILED) {
peg$savedPos = s0;
s1 = peg$c8();
}
s0 = s1;
return s0;
}
peg$result = peg$startRuleFunction();
if (peg$result !== peg$FAILED && peg$currPos === input.length) {
return peg$result;
} else {
if (peg$result !== peg$FAILED && peg$currPos < input.length) {
peg$fail(peg$endExpectation());
}
throw peg$buildStructuredError(
peg$maxFailExpected,
peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,
peg$maxFailPos < input.length
? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)
: peg$computeLocation(peg$maxFailPos, peg$maxFailPos)
);
}
}
module.exports = {
SyntaxError: peg$SyntaxError,
parse: peg$parse
};

View File

@@ -0,0 +1,17 @@
resolution =
from:specifier "/" descriptor:specifier { return { from, descriptor } }
/ descriptor:specifier { return { descriptor } }
specifier =
fullName:fullName "@" description:description { return { fullName, description } }
/ fullName:fullName { return { fullName } }
fullName =
"@" ident "/" ident { return text() }
/ ident { return text() }
ident =
[^/@]+ { return text() }
description =
[^/]+ { return text() }

92
node_modules/@yarnpkg/parsers/lib/grammars/shell.d.ts generated vendored Normal file
View File

@@ -0,0 +1,92 @@
// From the top to the bottom:
//
// - A shell line is composed of multiple command lines, first separated by ";" and then chained by "&&" / "||"
// - A command line is composed of multiple commands chained by "|" / "|&"
// - A command is composed of multiple arguments separated by spaces
// - An argument can be a value argument (sent to the underlying program), or a redirection
// - A value argument is a combination of argument segments
export type ArgumentSegment =
| {type: `text`, text: string}
| {type: `glob`, pattern: string}
| {type: `shell`, shell: ShellLine, quoted: boolean}
| {type: `variable`, name: string, defaultValue?: Array<ValueArgument>, alternativeValue?: Array<ValueArgument>, quoted: boolean}
| {type: `arithmetic`, arithmetic: ArithmeticExpression};
export type Argument =
| RedirectArgument
| ValueArgument;
export type RedirectArgument = {
type: `redirection`;
subtype: `>` | `<` | '>&' | '<&' | `>>` | `<<<`;
fd: number | null;
args: Array<ValueArgument>;
};
export type ValueArgument =
| {type: `argument`, segments: Array<ArgumentSegment>};
export type EnvSegment = {
name: string;
args: [] | [ValueArgument];
};
export type Command = {
type: `command`;
args: Array<Argument>;
envs: Array<EnvSegment>;
} | {
type: `subshell`;
subshell: ShellLine;
args: Array<RedirectArgument>;
} | {
type: `group`;
group: ShellLine;
args: Array<RedirectArgument>;
} | {
type: `envs`;
envs: Array<EnvSegment>;
};
export type CommandChain = Command & {
then?: CommandChainThen;
};
export type CommandChainThen = {
type: `|&` | `|`;
chain: CommandChain;
};
export type CommandLine = {
chain: CommandChain;
then?: CommandLineThen;
};
export type CommandLineThen = {
type: `&&` | `||`;
line: CommandLine;
};
export type ShellLine = Array<{
type: ';' | '&';
command: CommandLine;
}>;
export type ArithmeticPrimary = {
type: `number`;
value: number;
} | {
type: `variable`;
name: string;
};
export type ArithmeticOperatorExpression = {
type: `multiplication` | `division` | `addition` | `subtraction`;
left: ArithmeticExpression;
right: ArithmeticExpression;
};
export type ArithmeticExpression = ArithmeticPrimary | ArithmeticOperatorExpression;
export declare const parse: (code: string, options: {isGlobPattern: (arg: string) => boolean}) => ShellLine;

3653
node_modules/@yarnpkg/parsers/lib/grammars/shell.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

189
node_modules/@yarnpkg/parsers/lib/grammars/shell.pegjs generated vendored Normal file
View File

@@ -0,0 +1,189 @@
Start
= S* line:ShellLine? { return line ? line : [] }
ShellLine
= command:CommandLine S* type:ShellLineType then:ShellLineThen? { return [ { command, type } ].concat(then || []) }
/ command:CommandLine S* type:ShellLineType? { return [ { command, type: type || ';' } ] }
ShellLineThen
= S* then:ShellLine S* { return then }
ShellLineType
= ';'
/ '&'
CommandLine
= chain:CommandChain then:CommandLineThen? { return then ? { chain, then } : { chain } }
CommandLineThen
= S* type:CommandLineType S* then:CommandLine S* { return { type, line: then } }
CommandLineType
= '&&'
/ '||'
CommandChain
= main:Command then:CommandChainThen? { return then ? { ...main, then } : main }
CommandChainThen
= S* type:CommandChainType S* then:CommandChain S* { return { type, chain: then } }
CommandChainType
= '|&'
/ '|'
VariableAssignment
= name:EnvVariable '=' arg:StrictValueArgument S* { return { name, args: [arg] } }
/ name:EnvVariable '=' S* { return { name, args: [] } }
Command
= S* "(" S* subshell:ShellLine S* ")" S* args:RedirectArgument* S* { return { type: `subshell`, subshell, args } }
/ S* "{" S* group:ShellLine S* "}" S* args:RedirectArgument* S* { return { type: `group`, group, args } }
/ S* envs:VariableAssignment* S* args:Argument+ S* { return { type: `command`, args, envs } }
/ S* envs:VariableAssignment+ S* { return { type: `envs`, envs } }
CommandString
= S* args:ValueArgument+ S* { return args }
Argument
= S* arg:RedirectArgument { return arg }
/ S* arg:ValueArgument { return arg }
RedirectArgument
= S* fd:[0-9]? redirect:RedirectType arg:ValueArgument { return { type: `redirection`, subtype: redirect, fd: fd !== null ? parseInt(fd) : null, args: [arg] } }
RedirectType
= '>>'
/ '>&'
/ '>'
/ '<<<'
/ '<&'
/ '<'
ValueArgument
= S* arg:StrictValueArgument { return arg }
StrictValueArgument
= segments:ArgumentSegment+ { return { type: `argument`, segments: [].concat(... segments) } }
ArgumentSegment
= string:CQuoteString { return string }
/ string:SglQuoteString { return string }
/ string:DblQuoteString { return string }
/ string:PlainString { return string }
CQuoteString
= "$'" text:CQuoteStringText "'" { return [ { type: `text`, text } ] }
SglQuoteString
= "'" text:SglQuoteStringText "'" { return [ { type: `text`, text } ] }
DblQuoteString
= '""' { return { type: `text`, text: `` } } / '"' segments:DblQuoteStringSegment* '"' { return segments }
PlainString
= segments:PlainStringSegment+ { return segments }
DblQuoteStringSegment
= arithmetic:Arithmetic { return { type: `arithmetic`, arithmetic, quoted: true} }
/ shell:Subshell { return { type: `shell`, shell, quoted: true } }
/ variable:Variable { return { type: `variable`, ...variable, quoted: true } }
/ text:DblQuoteStringText { return { type: `text`, text } }
PlainStringSegment
= arithmetic:Arithmetic { return { type: `arithmetic`, arithmetic, quoted: false} }
/ shell:Subshell { return { type: `shell`, shell, quoted: false } }
/ variable:Variable { return { type: `variable`, ...variable, quoted: false } }
/ pattern:Glob { return { type: `glob`, pattern } }
/ text:PlainStringText { return { type: `text`, text } }
SglQuoteStringText
= chars:[^']* { return chars.join(``) }
DblQuoteStringText
= chars:( DblQuoteEscapedChar / [^$"])+ { return chars.join(``) }
DblQuoteEscapedChar
= '\\\n' { return `` }
/ '\\' c:[\\$"`] { return c }
CQuoteStringText
= chars:(CQuoteEscapedChar / [^'])* { return chars.join(``) }
CQuoteEscapedChar
= '\\a' { return '\a' }
/ '\\b' { return '\b' }
/ '\\' [Ee] { return '\x1b' }
/ '\\f' { return '\f' }
/ '\\n' { return '\n' }
/ '\\r' { return '\r' }
/ '\\t' { return '\t' }
/ '\\v' { return '\v' }
/ '\\' c:[\\'"?] { return c }
/ HexCodeString
HexCodeString
= '\\' c:HexCodeChar0 { return String.fromCharCode(parseInt(c, 16)) }
/ char:('\\x' c:$(HexCodeChar0 HexCodeChar / HexCodeChar0) { return String.fromCharCode(parseInt(c, 16)) })
/ utf8:('\\u' c:$(HexCodeChar HexCodeChar HexCodeChar HexCodeChar) { return String.fromCharCode(parseInt(c, 16)) })
/ utf16:('\\U' c:$(HexCodeChar HexCodeChar HexCodeChar HexCodeChar HexCodeChar HexCodeChar HexCodeChar HexCodeChar) { return String.fromCodePoint(parseInt(c, 16)) })
HexCodeChar0
= [0-7]
HexCodeChar
= [0-9a-fA-f]
PlainStringText
= chars:('\\' c:. { return c } / '{}' { return '{}' } / !SpecialShellChars c:. { return c })+ { return chars.join(``) }
ArithmeticPrimary
= sign:('-' / '+')? left:[0-9]+ '.' right:[0-9]+ { return { type: `number`, value: (sign === '-' ? -1 : 1) * parseFloat(left.join(``) + `.` + right.join(``)) } }
/ sign:('-' / '+')? value:[0-9]+ { return { type: `number`, value: (sign === '-' ? -1 : 1) * parseInt(value.join(``)) } }
/ variable:Variable { return { type: `variable`, ...variable } }
/ name:Identifier { return { type: `variable`, name } }
/ '(' S* value:ArithmeticExpression S* ')' { return value }
ArithmeticTimesExpression
= left:ArithmeticPrimary rest:(S* op:('*' / '/') S* right:ArithmeticPrimary { return { type: op === `*` ? `multiplication` : `division`, right } })* {
return rest.reduce((left, right) => ({ left, ...right }), left)
}
ArithmeticExpression
= left:ArithmeticTimesExpression rest:(S* op:('+' / '-') S* right:ArithmeticTimesExpression { return { type: op === `+` ? `addition` : `subtraction`, right } })* {
return rest.reduce((left, right) => ({ left, ...right }), left)
}
Arithmetic
= '$((' S* arithmetic:ArithmeticExpression S* '))' { return arithmetic }
Subshell
= '$(' command:ShellLine ')' { return command }
Variable
= '${' name:Identifier ':-' arg:CommandString '}' { return { name, defaultValue: arg } }
/ '${' name:Identifier ':-}' { return { name, defaultValue: [] } }
/ '${' name:Identifier ':+' arg:CommandString '}' { return { name, alternativeValue: arg } }
/ '${' name:Identifier ':+}' { return { name, alternativeValue: [] } }
/ '${' name:Identifier '}' { return { name } }
/ '$' name:Identifier { return { name } }
Glob
= pattern:GlobText & { return options.isGlobPattern(pattern) } { return pattern }
GlobText
= chars:(!GlobSpecialShellChars c:. { return c })+ { return chars.join(``) }
EnvVariable
= [a-zA-Z0-9_]+ { return text() }
Identifier
= [$@*?#a-zA-Z0-9_-]+ { return text() }
SpecialShellChars
= [()}<>$|&; \t"']
GlobSpecialShellChars
= [<>&; \t"']
S = [ \t]+

1
node_modules/@yarnpkg/parsers/lib/grammars/syml.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export declare const parse: (code: string) => {[key: string]: any};

1911
node_modules/@yarnpkg/parsers/lib/grammars/syml.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

125
node_modules/@yarnpkg/parsers/lib/grammars/syml.pegjs generated vendored Normal file
View File

@@ -0,0 +1,125 @@
{
const INDENT_STEP = 2;
let indentLevel = 0;
}
Start
= PropertyStatements
ItemStatements
= statements:ItemStatement* { return [].concat(... statements) }
ItemStatement
= Samedent "-" B value:Expression { return value }
PropertyStatements
= statements:PropertyStatement* { return Object.assign({}, ... statements) }
PropertyStatement
= B? ("#" (!EOL .)+)? EOL_ANY+ { return {} }
/ Samedent property:Name B? ":" B? value:Expression { return {[property]: value} }
// Compatibility with the old lockfile format (key-values without a ":")
/ Samedent property:LegacyName B? ":" B? value:Expression { return {[property]: value} }
// Compatibility with the old lockfile format (key-values without a ":")
/ Samedent property:LegacyName B value:LegacyLiteral EOL_ANY+ { return {[property]: value} }
// Compatibility with the old lockfile format (multiple keys for a same value)
/ Samedent property:LegacyName others:(B? "," B? other:LegacyName { return other })+ B? ":" B? value:Expression { return Object.assign({}, ... [property].concat(others).map(property => ({[property]: value}))) }
Expression
= &(EOL Extradent "-" B) EOL_ANY Indent statements:ItemStatements Dedent { return statements }
/ EOL Indent statements:PropertyStatements Dedent { return statements }
/ expression:Literal EOL_ANY+ { return expression }
Samedent "correct indentation"
= spaces:" "* &{ return spaces.length === indentLevel * INDENT_STEP }
Extradent
= spaces:" "* &{ return spaces.length === (indentLevel + 1) * INDENT_STEP }
Indent
= &{ indentLevel++; return true }
Dedent
= &{ indentLevel--; return true }
Name
= string
/ pseudostring
LegacyName
= string
/ pseudostringLegacy+ { return text() }
Literal
= null
/ boolean
/ string
/ pseudostring
LegacyLiteral
= null
/ string
/ pseudostringLegacy
/**
*/
pseudostring "pseudostring"
= [^\r\n\t ?:,\][{}#&*!|>'"%@`-] (B? [^\r\n\t ,\][{}:#"'])* { return text().replace(/^ *| *$/g, '') }
pseudostringLegacy
= "--"? [a-zA-Z\/0-9] [^\r\n\t :,]* { return text().replace(/^ *| *$/g, '') }
/**
* String parsing
*/
null
= "null" { return null }
boolean
= "true" { return true }
/ "false" { return false }
string "string"
= '"' '"' { return "" }
/ '"' chars:chars '"' { return chars }
chars
= chars:char+ { return chars.join(``) }
char
= [^"\\\0-\x1F\x7f]
/ '\\"' { return `"` }
/ "\\\\" { return `\\` }
/ "\\/" { return `/` }
/ "\\b" { return `\b` }
/ "\\f" { return `\f` }
/ "\\n" { return `\n` }
/ "\\r" { return `\r` }
/ "\\t" { return `\t` }
/ "\\u" h1:hexDigit h2:hexDigit h3:hexDigit h4:hexDigit {
return String.fromCharCode(parseInt(`0x${h1}${h2}${h3}${h4}`));
}
hexDigit
= [0-9a-fA-F]
/**
* Spaces
*/
B "blank space"
= [ \t]+
S "white space"
= [ \t\n\r]+
EOL_ANY
= EOL (B? EOL)*
EOL
= "\r\n"
/ "\n"
/ "\r"