Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
/*
Allow any of the following:
// Project: https://foo.com
// https://bar.com
// Project: https://foo.com,
// https://bar.com
// Project: https://foo.com, https://bar.com
Use `\s\s+` to ensure at least 2 spaces, to disambiguate from the next line being `// Definitions by:`.
*/
const separator = pm.regexp(/(, )|(,?\r?\n\/\/\s\s+)/);
const projectParser = pm.sepBy1(pm.regexp(/[^,\r\n]+/), separator);
function contributorsParser(strict) {
// Need to remove '^' and '$' from the regex, parsimmon does not expect those.
const contributor = strict
? pm.seqMap(pm.regexp(/([^<]+) /, 1), pm.regexp(/\/, 1), (name, username) => ({ name, url: "https://github.com/" + username }))
: pm.seqMap(pm.regexp(/([^<]+) /, 1), pm.regexp(/<([^>]+)>/, 1), (name, url) => ({ name, url }));
const contributors = pm.sepBy1(contributor, separator);
if (!strict) {
// Allow trailing whitespace.
return pm.seqMap(contributors, pm.regexp(/ */), a => a);
}
return contributors;
}
// TODO: Should we do something with the URL?
const definitionsParser = pm.regexp(/\r?\n\/\/ Definitions: [^\r\n]+/);
function parseLabel(strict) {
return pm.Parser((input, index) => {
function contributorsParser(strict) {
// Need to remove '^' and '$' from the regex, parsimmon does not expect those.
const contributor = strict
? pm.seqMap(pm.regexp(/([^<]+) /, 1), pm.regexp(/\/, 1), (name, username) => ({ name, url: "https://github.com/" + username }))
: pm.seqMap(pm.regexp(/([^<]+) /, 1), pm.regexp(/<([^>]+)>/, 1), (name, url) => ({ name, url }));
const contributors = pm.sepBy1(contributor, separator);
if (!strict) {
// Allow trailing whitespace.
return pm.seqMap(contributors, pm.regexp(/ */), a => a);
}
return contributors;
}
// TODO: Should we do something with the URL?
Term: L => P.sepBy1(L.Factor, L.AND).trim(P.optWhitespace)
.map(r => new node.Term(r)),
Factor: L => P.seq(L.Call, L.TypeAnnotation.times(0, 1)).trim(P.optWhitespace)
IntersectionType: L => P.sepBy1(L.ArrayType, L.AND)
.map(r => new node.IntersectionType(r)),
Expression: L => P.sepBy1(L.Term, L.OR).trim(P.optWhitespace)
.map(r => new node.Expression(r)),
TypeArgs: L => P.sepBy1(L.Type, L.COMMA).wrap(L.LT, L.GT),
Term: L => P.sepBy1(L.Factor, L.AND).trim(P.optWhitespace)
.map(r => new node.Term(r)),
UnionType: L => P.sepBy1(L.IntersectionType, L.OR)
.map(r => new node.UnionType(r)),
Expression: L => P.sepBy1(L.Term, L.OR).trim(P.optWhitespace)
.map(r => new node.Expression(r)),
Term: L => P.sepBy1(L.Factor, L.AND).trim(P.optWhitespace)