|
|
|
@ -13,15 +13,14 @@ const escapedStrSQ = nonEscapedValuePartSQ.or(escapedChar.map((v: string) => v.r
|
|
|
|
|
const nonEscapedValuePartDQ = Parsimmon.regexp(/[^"\\]+/);
|
|
|
|
|
const escapedStrDQ = nonEscapedValuePartDQ.or(escapedChar.map((v: string) => v.replace('\\"', '"').replace('\\\\', '\\'))).many();
|
|
|
|
|
|
|
|
|
|
// to alow spaces in simple values: [^"'\s][^\s]*([^\S\r\n]+\S+)* -- but that wont work in BASH so we do not allowed unescaped spaces!
|
|
|
|
|
const simpleValueWithoutSpacesAndQuotes = Parsimmon.regexp(/[^"'\s][^\s]*/);
|
|
|
|
|
const simpleValueNotQuoted = Parsimmon.regexp(/[^"'\s][^\s]*([^\S\r\n]+[^\s#][^\s]*)*/);
|
|
|
|
|
|
|
|
|
|
const valueWithSpacesDoubleQuoted = Parsimmon.seqObj<string, any>(['quote', doubleQuote], ['value', escapedStrDQ.map((v) => v.join(''))], doubleQuote);
|
|
|
|
|
const valueWithSpacesSingleQuoted = Parsimmon.seqObj<string, any>(['quote', singleQuote], ['value', escapedStrSQ.map((v) => v.join(''))], singleQuote);
|
|
|
|
|
const value = Parsimmon.alt(
|
|
|
|
|
valueWithSpacesSingleQuoted,
|
|
|
|
|
valueWithSpacesDoubleQuoted,
|
|
|
|
|
simpleValueWithoutSpacesAndQuotes.map((v) => ({ quote: '', value: v })),
|
|
|
|
|
simpleValueNotQuoted.map((v) => ({ quote: '', value: v })),
|
|
|
|
|
).desc('property value');
|
|
|
|
|
const commentOpt = Parsimmon.regexp(/[^\S\r\n]+#[^\r\n]*/);
|
|
|
|
|
const comment = Parsimmon.regexp(/[\n\r]*[^\S\r\n]*#[^\r\n]*/);
|
|
|
|
|